diff --git a/README.md b/README.md index 9057cb1..b64628f 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Custom Nintendo Switch bootloader, firmware patcher, and more. | bootloader | Main folder. | | \|__ bootlogo.bmp | It is used when custom is on and no logopath found. Can be skipped. | | \|__ hekate_ipl.ini | Main bootloader configuration and boot entries. | -| \|__ patches | Add external patches. Can be skipped | +| \|__ patches.ini | Add external patches. Can be skipped | | \|__ update.bin | If newer, it is loaded at boot. For modchips. Can be skipped. | | bootloader/ini/ | For individual inis. 'More configs...' menu. Autoboot is supported. | | bootloader/res/ | Nyx user resources. Icons and more. | diff --git a/bootloader/config/config.c b/bootloader/config/config.c index 810e2d3..2a65169 100644 --- a/bootloader/config/config.c +++ b/bootloader/config/config.c @@ -161,9 +161,6 @@ int create_config_entry() f_close(&fp); sd_unmount(); - if (mainIniFound) - ini_free(&ini_sections); - return 0; } @@ -269,7 +266,6 @@ out2:; free(ments); free(boot_values); free(boot_text); - ini_free(&ini_sections); sd_unmount(); } @@ -382,7 +378,6 @@ out2:; free(ments); free(boot_values); free(boot_text); - ini_free(&ini_sections); sd_unmount(); @@ -455,11 +450,11 @@ void config_verification() gfx_clear_grey(0x1B); gfx_con_setpos(0, 0); - ment_t *ments = (ment_t *)malloc(sizeof(ment_t) * 7); - u32 *vr_values = (u32 *)malloc(sizeof(u32) * 4); - char *vr_text = (char *)malloc(64 * 4); + ment_t *ments = (ment_t *)malloc(sizeof(ment_t) * 6); + u32 *vr_values = (u32 *)malloc(sizeof(u32) * 3); + char *vr_text = (char *)malloc(64 * 3); - for (u32 j = 0; j < 4; j++) + for (u32 j = 0; j < 3; j++) { vr_values[j] = j; ments[j + 2].type = MENT_DATA; @@ -474,9 +469,8 @@ void config_verification() memcpy(vr_text, " Disable (Fastest - Unsafe)", 28); memcpy(vr_text + 64, " Sparse (Fast - Safe)", 23); memcpy(vr_text + 128, " Full (Slow - Safe)", 23); - memcpy(vr_text + 192, " Full (w/ hashfile)", 23); - for (u32 i = 0; i < 4; i++) + for (u32 i = 0; i < 3; i++) { if (h_cfg.verification != i) vr_text[64 * i] = ' '; @@ -485,7 +479,7 @@ void config_verification() ments[2 + i].caption = vr_text + (i * 64); } - memset(&ments[6], 0, sizeof(ment_t)); + memset(&ments[5], 0, sizeof(ment_t)); menu_t menu = {ments, "Backup & Restore verification", 0, 0}; u32 *temp_verification = (u32 *)tui_do_menu(&menu); diff --git a/bootloader/config/ini.c b/bootloader/config/ini.c index a58d4ac..2dadfde 100644 --- a/bootloader/config/ini.c +++ b/bootloader/config/ini.c @@ -178,64 +178,6 @@ int ini_parse(link_t *dst, char *ini_path, bool is_dir) return 1; } -void ini_free(link_t *dst) -{ - if (!dst->prev || !dst->next) - return; - - LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, dst, link) - { - if (ini_sec->type == INI_CHOICE) - { - LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link) - { - free(kv->key); - free(kv->val); - //free(kv); - } - } - free(ini_sec->name); - //free(ini_sec); - } - - list_init(dst); -} - -ini_sec_t *ini_clone_section(ini_sec_t *cfg) -{ - if (cfg == NULL) - return NULL; - - ini_sec_t *csec = (ini_sec_t *)malloc(sizeof(ini_sec_t)); - list_init(&csec->kvs); - - LIST_FOREACH_ENTRY(ini_kv_t, kv, &cfg->kvs, link) - { - ini_kv_t *kvcfg = (ini_kv_t *)malloc(sizeof(ini_kv_t)); - kvcfg->key = _strdup(kv->key); - kvcfg->val = _strdup(kv->val); - list_append(&csec->kvs, &kvcfg->link); - } - - return csec; -} - -void ini_free_section(ini_sec_t *cfg) -{ - if (cfg == NULL) - return; - - LIST_FOREACH_ENTRY(ini_kv_t, kv, &cfg->kvs, link) - { - free(kv->key); - free(kv->val); - //free(kv); - } - //free(cfg); - - cfg = NULL; -} - char *ini_check_payload_section(ini_sec_t *cfg) { char *path = NULL; diff --git a/bootloader/config/ini.h b/bootloader/config/ini.h index 7f1d2c2..318adf0 100644 --- a/bootloader/config/ini.h +++ b/bootloader/config/ini.h @@ -44,9 +44,6 @@ typedef struct _ini_sec_t } ini_sec_t; int ini_parse(link_t *dst, char *ini_path, bool is_dir); -void ini_free(link_t *dst); -ini_sec_t *ini_clone_section(ini_sec_t *cfg); -void ini_free_section(ini_sec_t *cfg); char *ini_check_payload_section(ini_sec_t *cfg); #endif diff --git a/bootloader/gfx/gfx.h b/bootloader/gfx/gfx.h index ef37650..b1b6eba 100644 --- a/bootloader/gfx/gfx.h +++ b/bootloader/gfx/gfx.h @@ -21,8 +21,8 @@ #include "../../common/common_gfx.h" -#define EPRINTF(text) ({ gfx_con.mute = false; gfx_printf("%k"text"%k\n", 0xFFFF0000, 0xFFCCCCCC); }) -#define EPRINTFARGS(text, args...) ({ gfx_con.mute = false; gfx_printf("%k"text"%k\n", 0xFFFF0000, args, 0xFFCCCCCC); }) +#define EPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFF0000, 0xFFCCCCCC) +#define EPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFF0000, args, 0xFFCCCCCC) #define WPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFFDD00, 0xFFCCCCCC) #define WPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFFDD00, args, 0xFFCCCCCC) diff --git a/bootloader/hos/hos.c b/bootloader/hos/hos.c index aa39205..add3aac 100644 --- a/bootloader/hos/hos.c +++ b/bootloader/hos/hos.c @@ -52,6 +52,15 @@ extern bool sd_mount(); //#define DPRINTF(...) gfx_printf(__VA_ARGS__) #define DPRINTF(...) +#define EHPRINTF(text) \ + ({ display_backlight_brightness(h_cfg.backlight, 1000); \ + gfx_con.mute = false; \ + gfx_printf("%k"text"%k\n", 0xFFFF0000, 0xFFCCCCCC); }) +#define EHPRINTFARGS(text, args...) \ + ({ display_backlight_brightness(h_cfg.backlight, 1000); \ + gfx_con.mute = false; \ + gfx_printf("%k"text"%k\n", 0xFFFF0000, args, 0xFFCCCCCC); }) + #define PKG2_LOAD_ADDR 0xA9800000 // Secmon mailbox. @@ -210,7 +219,7 @@ int keygen(u8 *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt) // We rely on racing conditions, make sure we cover even the unluckiest cases. if (retries > 15) { - EPRINTF("\nFailed to get TSEC keys. Please try again.\n"); + EHPRINTF("\nFailed to get TSEC keys. Please try again.\n"); return 0; } } @@ -311,7 +320,7 @@ static int _read_emmc_pkg1(launch_ctxt_t *ctxt) ctxt->pkg1_id = pkg1_identify(ctxt->pkg1); if (!ctxt->pkg1_id) { - EPRINTF("Unknown pkg1 version."); + EHPRINTF("Unknown pkg1 version."); goto out; } gfx_printf("Identified pkg1 and Keyblob %d\n\n", ctxt->pkg1_id->kb); @@ -375,7 +384,6 @@ out:; static void _free_launch_components(launch_ctxt_t *ctxt) { - ini_free_section(ctxt->cfg); free(ctxt->keyblob); free(ctxt->pkg1); free(ctxt->pkg2); @@ -411,7 +419,7 @@ int hos_launch(ini_sec_t *cfg) // Try to parse config if present. if (ctxt.cfg && !parse_boot_config(&ctxt)) { - EPRINTF("Wrong ini cfg or missing files!"); + EHPRINTF("Wrong ini cfg or missing files!"); return 0; } @@ -452,14 +460,14 @@ int hos_launch(ini_sec_t *cfg) if (ctxt.pkg1_id->kb <= KB_FIRMWARE_VERSION_600) pkg1_decrypt(ctxt.pkg1_id, ctxt.pkg1); - if (ctxt.pkg1_id->kb <= KB_FIRMWARE_VERSION_620) + if (ctxt.pkg1_id->kb <= KB_FIRMWARE_VERSION_620 && !(emu_cfg.enabled && !h_cfg.emummc_force_disable)) { pkg1_unpack((void *)ctxt.pkg1_id->warmboot_base, (void *)ctxt.pkg1_id->secmon_base, NULL, ctxt.pkg1_id, ctxt.pkg1); gfx_printf("Decrypted & unpacked pkg1\n"); } else { - EPRINTF("No mandatory secmon or warmboot provided!"); + EHPRINTF("No mandatory secmon or warmboot provided!"); return 0; } } @@ -471,7 +479,7 @@ int hos_launch(ini_sec_t *cfg) { if (ctxt.pkg1_id->kb >= KB_FIRMWARE_VERSION_700) { - EPRINTF("No warmboot provided!"); + EHPRINTF("No warmboot provided!"); return 0; } // Else we patch it to allow downgrading. @@ -537,7 +545,7 @@ int hos_launch(ini_sec_t *cfg) ctxt.pkg2_kernel_id = pkg2_identify(kernel_hash); if (!ctxt.pkg2_kernel_id) { - EPRINTF("Failed to identify kernel!"); + EHPRINTF("Failed to identify kernel!"); return 0; } @@ -576,7 +584,7 @@ int hos_launch(ini_sec_t *cfg) const char* unappliedPatch = pkg2_patch_kips(&kip1_info, ctxt.kip1_patches); if (unappliedPatch != NULL) { - EPRINTFARGS("Failed to apply '%s'!", unappliedPatch); + EHPRINTFARGS("Failed to apply '%s'!", unappliedPatch); sd_unmount(); // Just exiting is not enough until pkg2_patch_kips stops modifying the string passed into it. _free_launch_components(&ctxt); diff --git a/bootloader/hos/secmon_exo.c b/bootloader/hos/secmon_exo.c index 5c082c7..6a8edfa 100644 --- a/bootloader/hos/secmon_exo.c +++ b/bootloader/hos/secmon_exo.c @@ -216,8 +216,10 @@ void config_exosphere(const char *id, u32 kb, void *warmboot, bool stock) else strcpy((char *)exo_cfg->emummc_cfg.file_cfg.path, emu_cfg.path); - if (emu_cfg.nintendo_path) + if (emu_cfg.nintendo_path && !stock) strcpy((char *)exo_cfg->emummc_cfg.nintendo_path, emu_cfg.nintendo_path); + else if (stock) + strcpy((char *)exo_cfg->emummc_cfg.nintendo_path, "Nintendo"); else exo_cfg->emummc_cfg.nintendo_path[0] = 0; } diff --git a/bootloader/hos/sept.c b/bootloader/hos/sept.c index d8d092d..b4df0a4 100644 --- a/bootloader/hos/sept.c +++ b/bootloader/hos/sept.c @@ -76,10 +76,14 @@ extern sdmmc_storage_t sd_storage; void check_sept() { // Check if non-hekate payload is used for sept and restore it. - if (h_cfg.sept_run && !f_stat("sept/payload.bak", NULL)) + if (h_cfg.sept_run) { - f_unlink("sept/payload.bin"); - f_rename("sept/payload.bak", "sept/payload.bin"); + if (!f_stat("sept/payload.bak", NULL)) + { + f_unlink("sept/payload.bin"); + f_rename("sept/payload.bak", "sept/payload.bin"); + } + return; } diff --git a/bootloader/main.c b/bootloader/main.c index 5bb96fe..96203f1 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -445,7 +445,6 @@ void ini_list_launcher() u8 max_entries = 61; char *payload_path = NULL; - ini_sec_t *cfg_tmp = NULL; ini_sec_t *cfg_sec = NULL; LIST_INIT(ini_list_sections); @@ -485,9 +484,9 @@ void ini_list_launcher() ments, "Launch ini configurations", 0, 0 }; - cfg_tmp = (ini_sec_t *)tui_do_menu(&menu); + cfg_sec = (ini_sec_t *)tui_do_menu(&menu); - if (cfg_tmp) + if (cfg_sec) { u32 non_cfg = 1; for (int j = 2; j < i; j++) @@ -495,7 +494,7 @@ void ini_list_launcher() if (ments[j].type != INI_CHOICE) non_cfg++; - if (ments[j].data == cfg_tmp) + if (ments[j].data == cfg_sec) { b_cfg.boot_cfg = BOOT_CFG_FROM_LAUNCH; b_cfg.autoboot = j - non_cfg; @@ -506,17 +505,14 @@ void ini_list_launcher() } } - payload_path = ini_check_payload_section(cfg_tmp); + payload_path = ini_check_payload_section(cfg_sec); - if (cfg_tmp && !payload_path) + if (cfg_sec && !payload_path) check_sept(); - cfg_sec = ini_clone_section(cfg_tmp); - if (!cfg_sec) { free(ments); - ini_free(&ini_list_sections); return; } @@ -524,7 +520,6 @@ void ini_list_launcher() else EPRINTF("No extra configs found."); free(ments); - ini_free(&ini_list_sections); } else EPRINTF("Could not find any ini\nin bootloader/ini!"); @@ -535,7 +530,6 @@ void ini_list_launcher() if (payload_path) { - ini_free_section(cfg_sec); if (launch_payload(payload_path, false)) { EPRINTF("Failed to launch payload."); @@ -549,7 +543,6 @@ void ini_list_launcher() } out: - ini_free_section(cfg_sec); btn_wait(); } @@ -559,7 +552,6 @@ void launch_firmware() u8 max_entries = 61; char *payload_path = NULL; - ini_sec_t *cfg_tmp = NULL; ini_sec_t *cfg_sec = NULL; LIST_INIT(ini_sections); @@ -613,16 +605,16 @@ void launch_firmware() ments, "Launch configurations", 0, 0 }; - cfg_tmp = (ini_sec_t *)tui_do_menu(&menu); + cfg_sec = (ini_sec_t *)tui_do_menu(&menu); - if (cfg_tmp) + if (cfg_sec) { u8 non_cfg = 4; for (int j = 5; j < i; j++) { if (ments[j].type != INI_CHOICE) non_cfg++; - if (ments[j].data == cfg_tmp) + if (ments[j].data == cfg_sec) { b_cfg.boot_cfg = BOOT_CFG_FROM_LAUNCH; b_cfg.autoboot = j - non_cfg; @@ -633,31 +625,28 @@ void launch_firmware() } } - payload_path = ini_check_payload_section(cfg_tmp); + payload_path = ini_check_payload_section(cfg_sec); - if (cfg_tmp) + if (cfg_sec) { - LIST_FOREACH_ENTRY(ini_kv_t, kv, &cfg_tmp->kvs, link) + LIST_FOREACH_ENTRY(ini_kv_t, kv, &cfg_sec->kvs, link) { if (!strcmp("emummc_force_disable", kv->key)) h_cfg.emummc_force_disable = atoi(kv->val); } } - if (cfg_tmp && !payload_path) + if (cfg_sec && !payload_path) check_sept(); - cfg_sec = ini_clone_section(cfg_tmp); if (!cfg_sec) { free(ments); - ini_free(&ini_sections); sd_unmount(); return; } free(ments); - ini_free(&ini_sections); } else EPRINTF("Could not open 'bootloader/hekate_ipl.ini'.\nMake sure it exists!"); @@ -675,7 +664,6 @@ void launch_firmware() if (payload_path) { - ini_free_section(cfg_sec); if (launch_payload(payload_path, false)) { EPRINTF("Failed to launch payload."); @@ -686,7 +674,6 @@ void launch_firmware() EPRINTF("Failed to launch firmware."); out: - ini_free_section(cfg_sec); sd_unmount(); h_cfg.emummc_force_disable = false; @@ -722,7 +709,7 @@ void nyx_load_run() nyx_str->version = ipl_ver.version - 0x303030; - memcpy((u8 *)nyx_str->irama, (void *)IRAM_BASE, 0x8000); + //memcpy((u8 *)nyx_str->irama, (void *)IRAM_BASE, 0x8000); volatile reloc_meta_t *reloc = (reloc_meta_t *)(IPL_LOAD_ADDR + RELOC_META_OFF); memcpy((u8 *)nyx_str->hekate, (u8 *)reloc->start, reloc->end - reloc->start); @@ -730,17 +717,22 @@ void nyx_load_run() bpmp_mmu_disable(); bpmp_clk_rate_set(BPMP_CLK_NORMAL); - msleep(100); minerva_periodic_training(); + // Some cards (Sandisk U1), do not like a fast power cycle. Wait min 100ms. + u32 sd_poweroff_time = (u32)get_tmr_ms() - h_cfg.sd_timeoff; + if (sd_poweroff_time < 100) + msleep(100 - sd_poweroff_time); + (*nyx_ptr)(); } void auto_launch_firmware() { - if(!h_cfg.sept_run && (b_cfg.extra_cfg & EXTRA_CFG_NYX_DUMP)) + if(b_cfg.extra_cfg & EXTRA_CFG_NYX_DUMP) { - EMC(EMC_SCRATCH0) |= EMC_HEKA_UPD; + if (!h_cfg.sept_run) + EMC(EMC_SCRATCH0) |= EMC_HEKA_UPD; check_sept(); } @@ -837,7 +829,7 @@ void auto_launch_firmware() if (h_cfg.autoboot == boot_entry_id && configEntry) { - cfg_sec = ini_clone_section(ini_sec); + cfg_sec = ini_sec; LIST_FOREACH_ENTRY(ini_kv_t, kv, &cfg_sec->kvs, link) { if (!strcmp("logopath", kv->key)) @@ -856,7 +848,6 @@ void auto_launch_firmware() if (h_cfg.autoboot_list) { - ini_free_section(cfg_sec); boot_entry_id = 1; bootlogoCustomEntry = NULL; @@ -872,7 +863,7 @@ void auto_launch_firmware() if (h_cfg.autoboot == boot_entry_id) { h_cfg.emummc_force_disable = false; - cfg_sec = ini_clone_section(ini_sec_list); + cfg_sec = ini_sec_list; LIST_FOREACH_ENTRY(ini_kv_t, kv, &cfg_sec->kvs, link) { if (!strcmp("logopath", kv->key)) @@ -970,10 +961,6 @@ void auto_launch_firmware() free(BOOTLOGO); } - ini_free(&ini_sections); - if (h_cfg.autoboot_list) - ini_free(&ini_list_sections); - if (!h_cfg.sept_run && h_cfg.bootwait) display_backlight_brightness(h_cfg.backlight, 1000); @@ -990,7 +977,6 @@ void auto_launch_firmware() if (payload_path) { - ini_free_section(cfg_sec); if (launch_payload(payload_path, false)) free(payload_path); } @@ -1001,11 +987,6 @@ void auto_launch_firmware() } out: - ini_free(&ini_sections); - if (h_cfg.autoboot_list) - ini_free(&ini_list_sections); - ini_free_section(cfg_sec); - gfx_con.mute = false; b_cfg.boot_cfg &= ~(BOOT_CFG_AUTOBOOT_EN | BOOT_CFG_FROM_LAUNCH); diff --git a/bootloader/soc/bpmp.c b/bootloader/soc/bpmp.c index 5fdc10e..4615c36 100644 --- a/bootloader/soc/bpmp.c +++ b/bootloader/soc/bpmp.c @@ -1,5 +1,5 @@ /* - * BPMP-Lite Cache/MMU driver for Tegra X1 + * BPMP-Lite Cache/MMU and Frequency driver for Tegra X1 * * Copyright (c) 2019 CTCaer * diff --git a/bootloader/soc/bpmp.h b/bootloader/soc/bpmp.h index bacb2d1..5c8f14b 100644 --- a/bootloader/soc/bpmp.h +++ b/bootloader/soc/bpmp.h @@ -1,5 +1,5 @@ /* - * BPMP-Lite Cache/MMU driver for Tegra X1 + * BPMP-Lite Cache/MMU and Frequency driver for Tegra X1 * * Copyright (c) 2019 CTCaer * diff --git a/nyx/nyx_gui/config/config.c b/nyx/nyx_gui/config/config.c index 882a3ab..9edafd9 100644 --- a/nyx/nyx_gui/config/config.c +++ b/nyx/nyx_gui/config/config.c @@ -31,6 +31,9 @@ extern hekate_config h_cfg; extern bool sd_mount(); extern void sd_unmount(bool deinit); +#pragma GCC push_options +#pragma GCC target ("thumb") + void set_default_configuration() { h_cfg.autoboot = 0; @@ -158,8 +161,7 @@ int create_config_entry() f_close(&fp); sd_unmount(false); - if (mainIniFound) - ini_free(&ini_sections); - return 0; } + +#pragma GCC pop_options diff --git a/nyx/nyx_gui/config/ini.c b/nyx/nyx_gui/config/ini.c index 4e5450b..ecb97f0 100644 --- a/nyx/nyx_gui/config/ini.c +++ b/nyx/nyx_gui/config/ini.c @@ -178,64 +178,6 @@ int ini_parse(link_t *dst, char *ini_path, bool is_dir) return 1; } -void ini_free(link_t *dst) -{ - if (!dst->prev || !dst->next) - return; - - LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, dst, link) - { - if (ini_sec->type == INI_CHOICE) - { - LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link) - { - free(kv->key); - free(kv->val); - //free(kv); - } - } - free(ini_sec->name); - //free(ini_sec); - } - - list_init(dst); -} - -ini_sec_t *ini_clone_section(ini_sec_t *cfg) -{ - if (cfg == NULL) - return NULL; - - ini_sec_t *csec = (ini_sec_t *)malloc(sizeof(ini_sec_t)); - list_init(&csec->kvs); - - LIST_FOREACH_ENTRY(ini_kv_t, kv, &cfg->kvs, link) - { - ini_kv_t *kvcfg = (ini_kv_t *)malloc(sizeof(ini_kv_t)); - kvcfg->key = _strdup(kv->key); - kvcfg->val = _strdup(kv->val); - list_append(&csec->kvs, &kvcfg->link); - } - - return csec; -} - -void ini_free_section(ini_sec_t *cfg) -{ - if (cfg == NULL) - return; - - LIST_FOREACH_ENTRY(ini_kv_t, kv, &cfg->kvs, link) - { - free(kv->key); - free(kv->val); - //free(kv); - } - //free(cfg); - - cfg = NULL; -} - char *ini_check_payload_section(ini_sec_t *cfg) { char *path = NULL; diff --git a/nyx/nyx_gui/config/ini.h b/nyx/nyx_gui/config/ini.h index 7f1d2c2..318adf0 100644 --- a/nyx/nyx_gui/config/ini.h +++ b/nyx/nyx_gui/config/ini.h @@ -44,9 +44,6 @@ typedef struct _ini_sec_t } ini_sec_t; int ini_parse(link_t *dst, char *ini_path, bool is_dir); -void ini_free(link_t *dst); -ini_sec_t *ini_clone_section(ini_sec_t *cfg); -void ini_free_section(ini_sec_t *cfg); char *ini_check_payload_section(ini_sec_t *cfg); #endif diff --git a/nyx/nyx_gui/frontend/fe_emmc_tools.c b/nyx/nyx_gui/frontend/fe_emmc_tools.c index 4020642..8a5a3ea 100644 --- a/nyx/nyx_gui/frontend/fe_emmc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emmc_tools.c @@ -132,6 +132,19 @@ static lv_obj_t *create_mbox_text(char *text, bool button_ok) return dark_bg; } +static void _update_filename(char *outFilename, u32 sdPathLen, u32 numSplitParts, u32 currPartIdx) +{ + if (numSplitParts >= 10 && currPartIdx < 10) + { + outFilename[sdPathLen] = '0'; + itoa(currPartIdx, &outFilename[sdPathLen + 1], 10); + } + else + itoa(currPartIdx, &outFilename[sdPathLen], 10); +} + +#pragma GCC pop_options + static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32 lba_curr, char *outFilename, emmc_part_t *part) { FIL fp; @@ -188,7 +201,7 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32 lv_bar_set_style(gui->bar, LV_BAR_STYLE_BG, gui->bar_teal_bg); lv_bar_set_style(gui->bar, LV_BAR_STYLE_INDIC, lv_theme_get_current()->bar.indic); s_printf(gui->txt_buf, " "SYMBOL_DOT" %d%%", pct); - lv_label_set_text(gui->label_pct, gui->txt_buf); + lv_label_set_array_text(gui->label_pct, gui->txt_buf, 32); manual_system_maintenance(true); clmt = f_expand_cltbl(&fp, 0x400000, 0); @@ -280,7 +293,7 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32 { lv_bar_set_value(gui->bar, pct); s_printf(gui->txt_buf, " "SYMBOL_DOT" %d%%", pct); - lv_label_set_text(gui->label_pct, gui->txt_buf); + lv_label_set_array_text(gui->label_pct, gui->txt_buf, 32); manual_system_maintenance(true); prevPct = pct; } @@ -312,7 +325,7 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32 lv_bar_set_value(gui->bar, pct); s_printf(gui->txt_buf, " "SYMBOL_DOT" %d%%", pct); - lv_label_set_text(gui->label_pct, gui->txt_buf); + lv_label_set_array_text(gui->label_pct, gui->txt_buf, 32); manual_system_maintenance(true); return 0; @@ -327,19 +340,6 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32 } } -static void _update_filename(char *outFilename, u32 sdPathLen, u32 numSplitParts, u32 currPartIdx) -{ - if (numSplitParts >= 10 && currPartIdx < 10) - { - outFilename[sdPathLen] = '0'; - itoa(currPartIdx, &outFilename[sdPathLen + 1], 10); - } - else - itoa(currPartIdx, &outFilename[sdPathLen], 10); -} - -#pragma GCC pop_options - bool partial_sd_full_unmount = false; static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part) @@ -417,7 +417,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t if (!maxSplitParts) { - s_printf(gui->txt_buf, "#FFDD00 Not enough free space for Partial Backup!#\n"); + s_printf(gui->txt_buf, "\n#FFDD00 Not enough free space for Partial Backup!#\n"); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); @@ -580,7 +580,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t res = f_open(&fp, outFilename, FA_CREATE_ALWAYS | FA_WRITE); if (res) { - s_printf(gui->txt_buf, "#FF0000 Error (%d) while creating#\n#FFDD00 %s#\n", res, outFilename); + s_printf(gui->txt_buf, "\n#FF0000 Error (%d) while creating#\n#FFDD00 %s#\n", res, outFilename); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); @@ -598,7 +598,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t while (!sdmmc_storage_read(storage, lba_curr, num, buf)) { s_printf(gui->txt_buf, - "#FFDD00 Error reading %d blocks @ LBA %08X,#\n" + "\n#FFDD00 Error reading %d blocks @ LBA %08X,#\n" "#FFDD00 from eMMC (try %d). #", num, lba_curr, ++retryCount); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); @@ -629,7 +629,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t if (res) { - s_printf(gui->txt_buf, "#FF0000 Fatal error (%d) when writing to SD Card#\nPlease try again...\n", res); + s_printf(gui->txt_buf, "\n#FF0000 Fatal error (%d) when writing to SD Card#\nPlease try again...\n", res); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); @@ -644,7 +644,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t { lv_bar_set_value(gui->bar, pct); s_printf(gui->txt_buf, " "SYMBOL_DOT" %d%%", pct); - lv_label_set_text(gui->label_pct, gui->txt_buf); + lv_label_set_array_text(gui->label_pct, gui->txt_buf, 32); manual_system_maintenance(true); prevPct = pct; @@ -720,23 +720,24 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui) { int res = 0; u32 timer = 0; - //! TODO switch to 800MHz - manual_system_maintenance(true); char *txt_buf = (char *)malloc(0x1000); gui->txt_buf = txt_buf; s_printf(txt_buf, ""); lv_label_set_array_text(gui->label_log, txt_buf, 0x1000); + lv_label_set_static_text(gui->label_info, "Checking for available free space..."); + manual_system_maintenance(true); + + // Do a reinit to refresh tuning. + sd_unmount(true); + if (!sd_mount()) { lv_label_set_static_text(gui->label_info, "#FFDD00 Failed to init SD!#"); goto out; } - lv_label_set_static_text(gui->label_info, "Checking for available free space..."); - manual_system_maintenance(true); - // Get SD Card free space for Partial Backup. f_getfree("", &sd_fs.free_clst, NULL); @@ -891,13 +892,16 @@ out: if (!partial_sd_full_unmount) sd_unmount(false); else + { + partial_sd_full_unmount = false; sd_unmount(true); + } } static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part, sdmmc_storage_t *storage, emmc_part_t *part, bool allow_multi_part) { const u32 SECTORS_TO_MIB_COEFF = 11; - //! TODO switch to 800MHz + u32 totalSectors = part->lba_end - part->lba_start + 1; u32 currPartIdx = 0; u32 numSplitParts = 0; @@ -953,7 +957,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa if (f_stat(outFilename, &fno) && !gui->raw_emummc) { - s_printf(gui->txt_buf, "#FFDD00 Error (%d) file not found '%s'. Aborting...#\n", res, outFilename); + s_printf(gui->txt_buf, "#FFDD00 Error (%d) file not found#\n#FFDD00 %s.#\n#FFDD00 Aborting...#", res, outFilename); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); @@ -1194,7 +1198,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa {; lv_bar_set_value(gui->bar, pct); s_printf(gui->txt_buf, " "SYMBOL_DOT" %d%%", pct); - lv_label_set_text(gui->label_pct, gui->txt_buf); + lv_label_set_array_text(gui->label_pct, gui->txt_buf, 32); manual_system_maintenance(true); prevPct = pct; } @@ -1252,14 +1256,14 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui) int res = 0; u32 timer = 0; - //! TODO switch to 800MHz - manual_system_maintenance(true); - char *txt_buf = (char *)malloc(0x1000); gui->txt_buf = txt_buf; s_printf(txt_buf, ""); lv_label_set_array_text(gui->label_log, txt_buf, 0x1000); + manual_system_maintenance(true); + sd_unmount(true); + s_printf(txt_buf, "#FFDD00 This may render your device inoperative!#\n\n" "#FFDD00 Are you really sure?#"); diff --git a/nyx/nyx_gui/frontend/fe_emummc_tools.c b/nyx/nyx_gui/frontend/fe_emummc_tools.c index f83fa14..42e5a65 100644 --- a/nyx/nyx_gui/frontend/fe_emummc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emummc_tools.c @@ -50,6 +50,9 @@ extern hekate_config h_cfg; extern bool sd_mount(); extern void sd_unmount(bool deinit); +#pragma GCC push_options +#pragma GCC target ("thumb") + void save_emummc_cfg(u32 part_idx, u32 sector_start, const char *path) { sd_mount(); @@ -98,6 +101,8 @@ void save_emummc_cfg(u32 part_idx, u32 sector_start, const char *path) f_close(&fp); } +#pragma GCC pop_options + static void _update_emummc_base_folder(char *outFilename, u32 sdPathLen, u32 currPartIdx) { if (currPartIdx < 10) @@ -255,7 +260,7 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto if (res) { - s_printf(gui->txt_buf, "#FF0000 Fatal error (%d) when writing to SD Card#\nPlease try again...\n", res); + s_printf(gui->txt_buf, "\n#FF0000 Fatal error (%d) when writing to SD Card#\nPlease try again...\n", res); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); manual_system_maintenance(true); @@ -270,7 +275,7 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto { lv_bar_set_value(gui->bar, pct); s_printf(gui->txt_buf, " "SYMBOL_DOT" %d%%", pct); - lv_label_set_text(gui->label_pct, gui->txt_buf); + lv_label_set_array_text(gui->label_pct, gui->txt_buf, 32); manual_system_maintenance(true); prevPct = pct; @@ -300,18 +305,19 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto void dump_emummc_file(emmc_tool_gui_t *gui) { - FILINFO fno; int res = 0; int base_len = 0; u32 timer = 0; - //! TODO switch to 800MHz - manual_system_maintenance(true); char *txt_buf = (char *)malloc(0x1000); gui->txt_buf = txt_buf; s_printf(txt_buf, ""); lv_label_set_array_text(gui->label_log, txt_buf, 0x1000); + manual_system_maintenance(true); + + sd_unmount(true); + if (!sd_mount()) { lv_label_set_static_text(gui->label_info, "#FFDD00 Failed to init SD!#"); @@ -343,7 +349,7 @@ void dump_emummc_file(emmc_tool_gui_t *gui) for (int j = 0; j < 100; j++) { _update_emummc_base_folder(sdPath, base_len, j); - if(f_stat(sdPath, &fno) == FR_NO_FILE) + if(f_stat(sdPath, NULL) == FR_NO_FILE) break; } @@ -489,7 +495,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part while (!sdmmc_storage_read(storage, lba_curr, num, buf)) { s_printf(gui->txt_buf, - "#FFDD00 Error reading %d blocks @LBA %08X,#\n" + "\n#FFDD00 Error reading %d blocks @LBA %08X,#\n" "#FFDD00 from eMMC (try %d). #", num, lba_curr, ++retryCount); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); @@ -517,7 +523,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part while (!sdmmc_storage_write(&sd_storage, sd_sector_off + lba_curr, num, buf)) { s_printf(gui->txt_buf, - "#FFDD00 Error writing %d blocks @LBA %08X,#\n" + "\n#FFDD00 Error writing %d blocks @LBA %08X,#\n" "#FFDD00 to SD (try %d). #", num, lba_curr, ++retryCount); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); @@ -544,7 +550,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part { lv_bar_set_value(gui->bar, pct); s_printf(gui->txt_buf, " "SYMBOL_DOT" %d%%", pct); - lv_label_set_text(gui->label_pct, gui->txt_buf); + lv_label_set_array_text(gui->label_pct, gui->txt_buf, 32); manual_system_maintenance(true); prevPct = pct; @@ -562,7 +568,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part { u8 *mbr = (u8 *)malloc(0x200); sdmmc_storage_read(&sd_storage, 0, 1, mbr); - mbr[MBR_1ST_PART_TYPE_OFF + (0x10 * part_idx)] = 0xEE; + mbr[MBR_1ST_PART_TYPE_OFF + (0x10 * part_idx)] = 0xE0; sdmmc_storage_write(&sd_storage, 0, 1, mbr); free(mbr); } @@ -574,14 +580,16 @@ void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start) { int res = 0; u32 timer = 0; - //! TODO switch to 800MHz - manual_system_maintenance(true); char *txt_buf = (char *)malloc(0x1000); gui->txt_buf = txt_buf; s_printf(txt_buf, ""); lv_label_set_array_text(gui->label_log, txt_buf, 0x1000); + manual_system_maintenance(true); + + sd_unmount(true); + if (!sd_mount()) { lv_label_set_static_text(gui->label_info, "#FFDD00 Failed to init SD!#"); diff --git a/nyx/nyx_gui/frontend/gui.c b/nyx/nyx_gui/frontend/gui.c index 1a19773..06181a6 100644 --- a/nyx/nyx_gui/frontend/gui.c +++ b/nyx/nyx_gui/frontend/gui.c @@ -743,7 +743,7 @@ static bool do_reload = false; static void _check_sd_card_removed(void *params) { - // The following checks if sdmmc_1 is initialized. + // The following checks if SDMMC_1 is initialized. // If yes and card was removed, shows a message box, // that will reload Nyx, when the card is inserted again. if (!do_reload && get_sd_card_removed()) @@ -1421,6 +1421,27 @@ static lv_res_t _launch_action(lv_obj_t *btn) return LV_RES_OK; } + +typedef struct _launch_button_pos_t +{ + u16 btn_x; + u16 btn_y; + u16 lbl_x; + u16 lbl_y; + +} launch_button_pos_t; + +static const launch_button_pos_t launch_button_pos[8] = { + { 19, 36, 0, 245 }, + { 340, 36, 321, 245 }, + { 661, 36, 642, 245 }, + { 982, 36, 963, 245 }, + { 19, 313, 0, 522 }, + { 340, 313, 321, 522 }, + { 661, 313, 642, 522 }, + { 982, 313, 963, 522 } +}; + static lv_res_t _create_window_home_launch(lv_obj_t *btn) { char *icon_path; @@ -1428,6 +1449,7 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn) static lv_style_t btn_home_transp_rel; lv_style_copy(&btn_home_transp_rel, lv_theme_get_current()->btn.rel); btn_home_transp_rel.body.opa = LV_OPA_0; + btn_home_transp_rel.body.border.width = 4; static lv_style_t btn_home_transp_pr; lv_style_copy(&btn_home_transp_pr, lv_theme_get_current()->btn.pr); @@ -1457,17 +1479,14 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn) u32 max_entries = 8; lv_btn_ext_t * ext; - //! TODO: Use an array/loop for the initialization. // Create CFW buttons. - btn_boot_entry = lv_btn_create(win, NULL); - launch_ctxt[0] = btn_boot_entry; - - // Buttons are 200 x 200 with 4 pixel borders. // Icons must be <= 192 x 192. - // Button 0. + // Create first Button. + btn_boot_entry = lv_btn_create(win, NULL); + launch_ctxt[0] = btn_boot_entry; lv_obj_set_size(btn_boot_entry, 200, 200); - lv_obj_set_pos(btn_boot_entry, 19, 36); + lv_obj_set_pos(btn_boot_entry, launch_button_pos[0].btn_x, launch_button_pos[0].btn_y); lv_obj_set_opa_scale(btn_boot_entry, LV_OPA_0); lv_obj_set_opa_scale_enable(btn_boot_entry, true); lv_btn_set_layout(btn_boot_entry, LV_LAYOUT_OFF); @@ -1481,77 +1500,20 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn) lv_cont_set_fit(boot_entry_lbl_cont, false, false); lv_cont_set_layout(boot_entry_lbl_cont, LV_LAYOUT_CENTER); lv_obj_set_size(boot_entry_lbl_cont, 238, 20); - lv_obj_set_pos(boot_entry_lbl_cont, 0, 245); + lv_obj_set_pos(boot_entry_lbl_cont, launch_button_pos[0].lbl_x, launch_button_pos[0].lbl_y); - // Button 1. - btn_boot_entry = lv_btn_create(win, btn_boot_entry); - launch_ctxt[2] = btn_boot_entry; - lv_obj_set_pos(btn_boot_entry, 340, 36); + // Create the rest of the buttons. + for (u32 btn_idx = 2; btn_idx < 16; btn_idx += 2) + { + btn_boot_entry = lv_btn_create(win, btn_boot_entry); + launch_ctxt[btn_idx] = btn_boot_entry; + lv_obj_set_pos(btn_boot_entry, launch_button_pos[btn_idx >> 1].btn_x, launch_button_pos[btn_idx >> 1].btn_y); - boot_entry_lbl_cont = lv_cont_create(win, boot_entry_lbl_cont); - boot_entry_label = lv_label_create(boot_entry_lbl_cont, boot_entry_label); - lv_obj_set_pos(boot_entry_lbl_cont, 321, 245); - launch_ctxt[3] = boot_entry_label; - - // Button 2. - btn_boot_entry = lv_btn_create(win, btn_boot_entry); - launch_ctxt[4] = btn_boot_entry; - lv_obj_set_pos(btn_boot_entry, 661, 36); - - boot_entry_lbl_cont = lv_cont_create(win, boot_entry_lbl_cont); - boot_entry_label = lv_label_create(boot_entry_lbl_cont, boot_entry_label); - lv_obj_set_pos(boot_entry_lbl_cont, 642, 245); - launch_ctxt[5] = boot_entry_label; - - // Button 3. - btn_boot_entry = lv_btn_create(win, btn_boot_entry); - launch_ctxt[6] = btn_boot_entry; - lv_obj_set_pos(btn_boot_entry, 982, 36); - - boot_entry_lbl_cont = lv_cont_create(win, boot_entry_lbl_cont); - boot_entry_label = lv_label_create(boot_entry_lbl_cont, boot_entry_label); - lv_obj_set_pos(boot_entry_lbl_cont, 963, 245); - launch_ctxt[7] = boot_entry_label; - - // Button 4. - btn_boot_entry = lv_btn_create(win, btn_boot_entry); - launch_ctxt[8] = btn_boot_entry; - lv_obj_set_pos(btn_boot_entry, 19, 313); - - boot_entry_lbl_cont = lv_cont_create(win, boot_entry_lbl_cont); - boot_entry_label = lv_label_create(boot_entry_lbl_cont, boot_entry_label); - lv_obj_set_pos(boot_entry_lbl_cont, 0, 522); - launch_ctxt[9] = boot_entry_label; - - // Button 5. - btn_boot_entry = lv_btn_create(win, btn_boot_entry); - launch_ctxt[10] = btn_boot_entry; - lv_obj_set_pos(btn_boot_entry, 340, 313); - - boot_entry_lbl_cont = lv_cont_create(win, boot_entry_lbl_cont); - boot_entry_label = lv_label_create(boot_entry_lbl_cont, boot_entry_label); - lv_obj_set_pos(boot_entry_lbl_cont, 321, 522); - launch_ctxt[11] = boot_entry_label; - - // Button 6. - btn_boot_entry = lv_btn_create(win, btn_boot_entry); - launch_ctxt[12] = btn_boot_entry; - lv_obj_set_pos(btn_boot_entry, 661, 313); - - boot_entry_lbl_cont = lv_cont_create(win, boot_entry_lbl_cont); - boot_entry_label = lv_label_create(boot_entry_lbl_cont, boot_entry_label); - lv_obj_set_pos(boot_entry_lbl_cont, 642, 522); - launch_ctxt[13] = boot_entry_label; - - // Button 7. - btn_boot_entry = lv_btn_create(win, btn_boot_entry); - launch_ctxt[14] = btn_boot_entry; - lv_obj_set_pos(btn_boot_entry, 982, 313); - - boot_entry_lbl_cont = lv_cont_create(win, boot_entry_lbl_cont); - boot_entry_label = lv_label_create(boot_entry_lbl_cont, boot_entry_label); - lv_obj_set_pos(boot_entry_lbl_cont, 963, 522); - launch_ctxt[15] = boot_entry_label; + boot_entry_lbl_cont = lv_cont_create(win, boot_entry_lbl_cont); + boot_entry_label = lv_label_create(boot_entry_lbl_cont, boot_entry_label); + lv_obj_set_pos(boot_entry_lbl_cont, launch_button_pos[btn_idx >> 1].lbl_x, launch_button_pos[btn_idx >> 1].lbl_y); + launch_ctxt[btn_idx + 1] = boot_entry_label; + } // Parse ini boot entries and set buttons/icons. char *tmp_path = calloc(0x80, 1); @@ -1577,6 +1539,7 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn) icon_path = NULL; bool payload = false; lv_img_dsc_t *bmp = NULL; + lv_obj_t *img = NULL; // Check for icons. LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link) @@ -1613,31 +1576,38 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn) if (!bmp) bmp = icon_switch; - //Set icon and border/radius mask. + //Set icon. if (bmp) { - lv_obj_t *img = lv_img_create(launch_ctxt[x], NULL); + img = lv_img_create(launch_ctxt[x], NULL); lv_img_set_src(img, bmp); - lv_obj_t *btn = lv_btn_create(launch_ctxt[x], NULL); - lv_obj_set_size(btn, 200, 200); - lv_btn_set_style(btn, LV_BTN_STYLE_REL, &btn_home_transp_rel); - lv_btn_set_style(btn, LV_BTN_STYLE_PR, &btn_home_transp_pr); - lv_obj_align(img, NULL, LV_ALIGN_CENTER, 0, 0); - ext = lv_obj_get_ext_attr(btn); - ext->idx = i; - - if (!more_cfg) - lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _launch_action); - else - lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _launch_more_cfg_action); } + // Add button mask/radius and align icon. + lv_obj_t *btn = lv_btn_create(launch_ctxt[x], NULL); + lv_obj_set_size(btn, 200, 200); + lv_btn_set_style(btn, LV_BTN_STYLE_REL, &btn_home_transp_rel); + lv_btn_set_style(btn, LV_BTN_STYLE_PR, &btn_home_transp_pr); + if (img) + lv_obj_align(img, NULL, LV_ALIGN_CENTER, 0, 0); + + // Set autoboot index. + ext = lv_obj_get_ext_attr(btn); + ext->idx = i; + + // Set action. + if (!more_cfg) + lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _launch_action); + else + lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _launch_more_cfg_action); + // Set button's label text. lv_label_set_array_text(launch_ctxt[x + 1], ini_sec->name, strlen(ini_sec->name)); lv_obj_set_opa_scale(launch_ctxt[x + 1], LV_OPA_COVER); - //! TODO: Check strlen and decide on rolling text - //lv_label_set_long_mode(boot_entry_label, LV_LABEL_LONG_ROLL); + // Set rolling text if name is big. + if (strlen(ini_sec->name) > 22) + lv_label_set_long_mode(boot_entry_label, LV_LABEL_LONG_ROLL); i++; x += 2; diff --git a/nyx/nyx_gui/frontend/gui_emmc_tools.c b/nyx/nyx_gui/frontend/gui_emmc_tools.c index 036cd92..0071e8b 100644 --- a/nyx/nyx_gui/frontend/gui_emmc_tools.c +++ b/nyx/nyx_gui/frontend/gui_emmc_tools.c @@ -61,7 +61,11 @@ static void _create_window_backup_restore(emmcPartType_t type, const char* win_l emmc_tool_gui_ctxt.raw_emummc = emmc_btn_ctxt.raw_emummc; - lv_obj_t *win = nyx_create_standard_window(win_label); + char win_label_full[80]; + + s_printf(win_label_full, "%s%s", emmc_btn_ctxt.restore ? SYMBOL_DOWNLOAD" Restore " : SYMBOL_UPLOAD" Backup ", win_label+3); + + lv_obj_t *win = nyx_create_standard_window(win_label_full); //Disable buttons. nyx_window_toggle_buttons(win, true); @@ -108,20 +112,18 @@ static void _create_window_backup_restore(emmcPartType_t type, const char* win_l lv_obj_align(label_info, label_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 10); emmc_tool_gui_ctxt.label_info = label_info; - lv_style_t *bar_teal_bg, *bar_white_ind; - bar_teal_bg = (lv_style_t *)malloc(sizeof(lv_style_t)); - bar_white_ind = (lv_style_t *)malloc(sizeof(lv_style_t)); + static lv_style_t bar_teal_bg, bar_white_ind; - lv_style_copy(bar_teal_bg, lv_theme_get_current()->bar.bg); - bar_teal_bg->body.main_color = LV_COLOR_HEX(0x005a47); - bar_teal_bg->body.grad_color = bar_teal_bg->body.main_color; + lv_style_copy(&bar_teal_bg, lv_theme_get_current()->bar.bg); + bar_teal_bg.body.main_color = LV_COLOR_HEX(0x005a47); + bar_teal_bg.body.grad_color = bar_teal_bg.body.main_color; - lv_style_copy(bar_white_ind, lv_theme_get_current()->bar.indic); - bar_white_ind->body.main_color = LV_COLOR_HEX(0xF0F0F0); - bar_white_ind->body.grad_color = bar_white_ind->body.main_color; + lv_style_copy(&bar_white_ind, lv_theme_get_current()->bar.indic); + bar_white_ind.body.main_color = LV_COLOR_HEX(0xF0F0F0); + bar_white_ind.body.grad_color = bar_white_ind.body.main_color; - emmc_tool_gui_ctxt.bar_teal_bg = bar_teal_bg; - emmc_tool_gui_ctxt.bar_white_ind = bar_white_ind; + emmc_tool_gui_ctxt.bar_teal_bg = &bar_teal_bg; + emmc_tool_gui_ctxt.bar_white_ind = &bar_white_ind; lv_obj_t * bar = lv_bar_create(h1, NULL); lv_obj_set_size(bar, LV_DPI * 38 / 10, LV_DPI / 5); @@ -154,9 +156,6 @@ static void _create_window_backup_restore(emmcPartType_t type, const char* win_l restore_emmc_selected(type, &emmc_tool_gui_ctxt); nyx_window_toggle_buttons(win, false); - - free(bar_teal_bg); - free(bar_white_ind); } static lv_res_t _emmc_backup_buttons_decider(lv_obj_t *btn) diff --git a/nyx/nyx_gui/frontend/gui_emummc_tools.c b/nyx/nyx_gui/frontend/gui_emummc_tools.c index 626f287..1cecd1d 100644 --- a/nyx/nyx_gui/frontend/gui_emummc_tools.c +++ b/nyx/nyx_gui/frontend/gui_emummc_tools.c @@ -178,7 +178,7 @@ static void _create_mbox_emummc_raw() u32 curr_part_size = *(u32 *)&mbr[0x0C + (0x10 * i)]; sector_start = *(u32 *)&mbr[0x08 + (0x10 * i)]; u8 type = mbr[0x04 + (0x10 * i)]; - if ((curr_part_size > storage.sec_cnt) && sector_start && type != 0x83) //! TODO: For now it skips linux partitions. + if ((curr_part_size >= (storage.sec_cnt + 0x8000)) && sector_start && type != 0x83) //! TODO: For now it skips linux partitions. { part_idx = i; sector_start += 0x8000; @@ -191,7 +191,7 @@ static void _create_mbox_emummc_raw() if (part_idx) { s_printf(txt_buf, - "#C7EA46 Found applicable partition [%d]!#\n" + "#C7EA46 Found applicable partition: [Part %d]!#\n" "#FF8000 Do you want to continue?#\n\n", part_idx); } else @@ -283,7 +283,7 @@ static void _change_raw_emummc_part_type() static void _migrate_sd_raw_based() { - sector_start += 2; + sector_start = 2; sd_mount(); f_mkdir("emuMMC"); @@ -295,8 +295,6 @@ static void _migrate_sd_raw_based() f_write(&fp, §or_start, 4, NULL); f_close(&fp); - _change_raw_emummc_part_type(); - save_emummc_cfg(1, sector_start, "emuMMC/ER00"); sd_unmount(false); } @@ -391,9 +389,7 @@ static void _migrate_sd_backup_file_based() bool multipart = false; s_printf(path2, "%s/rawnand.bin", path); - FILINFO fno; - - if(f_stat(path2, &fno)) + if(f_stat(path2, NULL)) multipart = true; if (!multipart) @@ -572,24 +568,23 @@ static lv_res_t _create_mbox_emummc_migrate(lv_obj_t *btn) } } - FILINFO fno; s_printf(txt_buf, "%c%c%c%c%s", 's', 'x', 'o','s', "/emunand/boot0.bin"); - if(!f_stat(txt_buf, &fno)) + if(!f_stat(txt_buf, NULL)) file_based = true; bool rawnand_backup_found = false; emmcsn_path_impl(txt_buf, "", "BOOT0", &storage); - if(!f_stat(txt_buf, &fno)) + if(!f_stat(txt_buf, NULL)) backup = true; emmcsn_path_impl(txt_buf, "", "rawnand.bin", &storage); - if(!f_stat(txt_buf, &fno)) + if(!f_stat(txt_buf, NULL)) rawnand_backup_found = true; emmcsn_path_impl(txt_buf, "", "rawnand.bin.00", &storage); - if(!f_stat(txt_buf, &fno)) + if(!f_stat(txt_buf, NULL)) rawnand_backup_found = true; if (backup && rawnand_backup_found) @@ -637,7 +632,7 @@ static lv_res_t _create_mbox_emummc_migrate(lv_obj_t *btn) } else { - s_printf(txt_buf, "No foreign emunand or emuMMC found!\n\n"); + s_printf(txt_buf, "No emuMMC or foreign emunand found!\n\n"); lv_mbox_add_btns(mbox, mbox_btn_map3, mbox_action); } @@ -829,7 +824,7 @@ static lv_res_t _create_change_emummc_window() { s_printf(path, "emuMMC/%s/file_based", &emummc_img->dirlist[emummc_idx * 256]); - if(!f_stat(path, &fno)) + if(!f_stat(path, NULL)) { strcpy(&emummc_img->dirlist[file_based_idx * 256], &emummc_img->dirlist[emummc_idx * 256]); file_based_idx++; @@ -867,79 +862,58 @@ out0:; lv_line_set_style(line_sep, lv_theme_get_current()->line.decor); lv_obj_align(line_sep, label_txt, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 8); - // Create RAW 1 button. - lv_obj_t *btn = lv_btn_create(h1, NULL); - lv_btn_ext_t *ext = lv_obj_get_ext_attr(btn); - ext->idx = 0; - lv_obj_t *btn_label = lv_label_create(btn, NULL); - if (emummc_img->part_type[0] != 0x83) - lv_label_set_static_text(btn_label, "SD RAW 1"); - else - lv_label_set_static_text(btn_label, "Linux"); - if (!emummc_img->part_sector[0] || emummc_img->part_type[0] == 0x83 || !emummc_img->part_path[0]) - { - lv_btn_set_state(btn, LV_BTN_STATE_INA); - lv_obj_set_click(btn, false); - } - - lv_btn_set_fit(btn, false, true); - lv_obj_set_width(btn, LV_DPI * 3); - lv_obj_align(btn, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 2, LV_DPI / 5); - lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _save_raw_emummc_cfg_action); - - lv_obj_t *lv_desc = lv_label_create(h1, NULL); - lv_label_set_recolor(lv_desc, true); + lv_obj_t *btn = NULL; + lv_btn_ext_t *ext; + lv_obj_t *btn_label = NULL; + lv_obj_t *lv_desc = NULL; char *txt_buf = malloc(0x500); - s_printf(txt_buf, "Sector start: 0x%08X\nFolder: %s", emummc_img->part_sector[0], &emummc_img->part_path[0]); - lv_label_set_array_text(lv_desc, txt_buf, 0x500); - lv_obj_set_style(lv_desc, &hint_small_style); - lv_obj_align(lv_desc, btn, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 5); - // Create RAW 2 button. - btn = lv_btn_create(h1, btn); - ext = lv_obj_get_ext_attr(btn); - ext->idx = 1; - btn_label = lv_label_create(btn, btn_label); - if (emummc_img->part_type[1] != 0x83) - lv_label_set_static_text(btn_label, "SD RAW 2"); - else - lv_label_set_static_text(btn_label, "Linux"); - if (!emummc_img->part_sector[1] || emummc_img->part_type[1] == 0x83 || !emummc_img->part_path[32]) + // Create RAW buttons. + for (u32 raw_btn_idx = 0; raw_btn_idx < 3; raw_btn_idx++) { - lv_btn_set_state(btn, LV_BTN_STATE_INA); - lv_obj_set_click(btn, false); + btn = lv_btn_create(h1, btn); + ext = lv_obj_get_ext_attr(btn); + ext->idx = raw_btn_idx; + btn_label = lv_label_create(btn, btn_label); + + lv_btn_set_state(btn, LV_BTN_STATE_REL); + lv_obj_set_click(btn, true); + + if (emummc_img->part_type[raw_btn_idx] != 0x83) + { + s_printf(txt_buf, "SD RAW %d", raw_btn_idx + 1); + lv_label_set_array_text(btn_label, txt_buf, 32); + } + + if (!emummc_img->part_sector[raw_btn_idx] || emummc_img->part_type[raw_btn_idx] == 0x83 || !emummc_img->part_path[raw_btn_idx * 128]) + { + lv_btn_set_state(btn, LV_BTN_STATE_INA); + lv_obj_set_click(btn, false); + + if (emummc_img->part_type[raw_btn_idx] == 0x83) + lv_label_set_static_text(btn_label, "Linux"); + } + + if (!raw_btn_idx) + { + lv_btn_set_fit(btn, false, true); + lv_obj_set_width(btn, LV_DPI * 3); + lv_obj_align(btn, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 2, LV_DPI / 5); + } + else + lv_obj_align(btn, lv_desc, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3); + + lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _save_raw_emummc_cfg_action); + + lv_desc = lv_label_create(h1, lv_desc); + lv_label_set_recolor(lv_desc, true); + lv_obj_set_style(lv_desc, &hint_small_style); + + s_printf(txt_buf, "Sector start: 0x%08X\nFolder: %s", emummc_img->part_sector[raw_btn_idx], &emummc_img->part_path[raw_btn_idx * 128]); + lv_label_set_array_text(lv_desc, txt_buf, 0x500); + lv_obj_align(lv_desc, btn, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 5); } - lv_obj_align(btn, lv_desc, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3); - lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _save_raw_emummc_cfg_action); - - lv_desc = lv_label_create(h1, lv_desc); - s_printf(txt_buf, "Sector start: 0x%08X\nFolder: %s", emummc_img->part_sector[1], &emummc_img->part_path[32]); - lv_label_set_array_text(lv_desc, txt_buf, 0x500); - lv_obj_align(lv_desc, btn, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 5); - - // Create RAW 3 button. - btn = lv_btn_create(h1, btn); - ext = lv_obj_get_ext_attr(btn); - ext->idx = 2; - btn_label = lv_label_create(btn, btn_label); - if (emummc_img->part_type[2] != 0x83) - lv_label_set_static_text(btn_label, "SD RAW 3"); - else - lv_label_set_static_text(btn_label, "Linux"); - - if (!emummc_img->part_sector[2] || emummc_img->part_type[2] == 0x83 || !emummc_img->part_path[64]) - { - lv_btn_set_state(btn, LV_BTN_STATE_INA); - lv_obj_set_click(btn, false); - } - lv_obj_align(btn, lv_desc, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3); - lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _save_raw_emummc_cfg_action); - - lv_desc = lv_label_create(h1, lv_desc); - s_printf(txt_buf, "Sector start: 0x%08X\nFolder: %s", emummc_img->part_sector[2], &emummc_img->part_path[64]); - lv_label_set_array_text(lv_desc, txt_buf, 0x500); - lv_obj_align(lv_desc, btn, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 5); // Create SD File Based container. lv_obj_t *h2 = lv_cont_create(win, NULL); diff --git a/nyx/nyx_gui/frontend/gui_info.c b/nyx/nyx_gui/frontend/gui_info.c index 62af1bd..32b7747 100644 --- a/nyx/nyx_gui/frontend/gui_info.c +++ b/nyx/nyx_gui/frontend/gui_info.c @@ -275,11 +275,7 @@ static lv_res_t _create_window_fuses_info_status(lv_obj_t *btn) { case 0: case 4: - memcpy(dram_man, "Samsung ", 9); - if (!dram_id) - memcpy(dram_man + strlen(dram_man), "4GB", 4); - else - memcpy(dram_man + strlen(dram_man), "6GB", 4); + s_printf(dram_man, "Samsung %s", (!dram_id) ? "4GB" : "6GB"); break; case 1: memcpy(dram_man, "Hynix 4GB", 10); @@ -1078,7 +1074,7 @@ void create_tab_info(lv_theme_t *th, lv_obj_t *parent) lv_line_set_style(line_sep, &line_style); // Create Fuses button. - lv_obj_t *btn3 = lv_btn_create(h1, NULL); + lv_obj_t *btn3 = lv_btn_create(h1, btn); label_btn = lv_label_create(btn3, NULL); lv_btn_set_fit(btn3, true, true); lv_label_set_static_text(label_btn, SYMBOL_CIRCUIT" Fuses "); diff --git a/nyx/nyx_gui/frontend/gui_tools.c b/nyx/nyx_gui/frontend/gui_tools.c index 532e53f..f1f9843 100644 --- a/nyx/nyx_gui/frontend/gui_tools.c +++ b/nyx/nyx_gui/frontend/gui_tools.c @@ -121,7 +121,7 @@ static lv_res_t _create_mbox_autorcm_status(lv_obj_t *btn) { lv_mbox_set_text(mbox, "AutoRCM is now #FF8000 DISABLED!#\n\n" - "The boot process is now normal and you need the #FF8000 VOL-# + #FF8000 HOME# (jig) combo to enter RCM.\n"); + "The boot process is now normal and you need the #FF8000 VOL+# + #FF8000 HOME# (jig) combo to enter RCM.\n"); } lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); @@ -611,17 +611,14 @@ void sept_run_dump() _create_window_dump_pk12_tool(NULL); } -static void _create_tab_tools_emmc_pkg12(lv_theme_t *th, lv_obj_t *parent) +static lv_obj_t *_create_container(lv_obj_t *parent) { - lv_page_set_scrl_layout(parent, LV_LAYOUT_PRETTY); - static lv_style_t h_style; lv_style_copy(&h_style, &lv_style_transp); h_style.body.padding.inner = 0; h_style.body.padding.hor = LV_DPI - (LV_DPI / 4); h_style.body.padding.ver = LV_DPI / 6; - // Create Backup & Restore container. lv_obj_t *h1 = lv_cont_create(parent, NULL); lv_cont_set_style(h1, &h_style); lv_cont_set_fit(h1, false, true); @@ -629,6 +626,16 @@ static void _create_tab_tools_emmc_pkg12(lv_theme_t *th, lv_obj_t *parent) lv_obj_set_click(h1, false); lv_cont_set_layout(h1, LV_LAYOUT_OFF); + return h1; +} + +static void _create_tab_tools_emmc_pkg12(lv_theme_t *th, lv_obj_t *parent) +{ + lv_page_set_scrl_layout(parent, LV_LAYOUT_PRETTY); + + // Create Backup & Restore container. + lv_obj_t *h1 = _create_container(parent); + lv_obj_t *label_sep = lv_label_create(h1, NULL); lv_label_set_static_text(label_sep, ""); @@ -675,19 +682,14 @@ static void _create_tab_tools_emmc_pkg12(lv_theme_t *th, lv_obj_t *parent) label_txt2 = lv_label_create(h1, NULL); lv_label_set_recolor(label_txt2, true); lv_label_set_static_text(label_txt2, - "Allows you to restore your eMMC partitions individually or as\n" - "a whole raw image to your SD card.\n" + "Allows you to restore your eMMC/emuMMC partitions individually\n" + "or as a whole raw image from your SD card.\n" "#FF8000 Supports SD cards from 4GB and up. FAT32 and exFAT. #"); lv_obj_set_style(label_txt2, &hint_small_style); lv_obj_align(label_txt2, btn2, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3); // Create Misc container. - lv_obj_t *h2 = lv_cont_create(parent, NULL); - lv_cont_set_style(h2, &h_style); - lv_cont_set_fit(h2, false, true); - lv_obj_set_width(h2, (LV_HOR_RES / 9) * 4); - lv_obj_set_click(h2, false); - lv_cont_set_layout(h2, LV_LAYOUT_OFF); + lv_obj_t *h2 = _create_container(parent); lv_obj_align(h2, h1, LV_ALIGN_OUT_RIGHT_TOP, 0, 0); label_sep = lv_label_create(h2, NULL); @@ -731,19 +733,8 @@ static void _create_tab_tools_arc_autorcm(lv_theme_t *th, lv_obj_t *parent) { lv_page_set_scrl_layout(parent, LV_LAYOUT_PRETTY); - static lv_style_t h_style; - lv_style_copy(&h_style, &lv_style_transp); - h_style.body.padding.inner = 0; - h_style.body.padding.hor = LV_DPI - (LV_DPI / 4); - h_style.body.padding.ver = LV_DPI / 6; - // Create Misc container. - lv_obj_t *h1 = lv_cont_create(parent, NULL); - lv_cont_set_style(h1, &h_style); - lv_cont_set_fit(h1, false, true); - lv_obj_set_width(h1, (LV_HOR_RES / 9) * 4); - lv_obj_set_click(h1, false); - lv_cont_set_layout(h1, LV_LAYOUT_OFF); + lv_obj_t *h1 = _create_container(parent); lv_obj_t *label_sep = lv_label_create(h1, NULL); lv_label_set_static_text(label_sep, ""); @@ -798,12 +789,7 @@ static void _create_tab_tools_arc_autorcm(lv_theme_t *th, lv_obj_t *parent) lv_obj_align(label_txt2, btn2, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3); // Create Others container. - lv_obj_t *h2 = lv_cont_create(parent, NULL); - lv_cont_set_style(h2, &h_style); - lv_cont_set_fit(h2, false, true); - lv_obj_set_width(h2, (LV_HOR_RES / 9) * 4); - lv_obj_set_click(h2, false); - lv_cont_set_layout(h2, LV_LAYOUT_OFF); + lv_obj_t *h2 = _create_container(parent); lv_obj_align(h2, h1, LV_ALIGN_OUT_RIGHT_TOP, 0, 0); label_sep = lv_label_create(h2, NULL); diff --git a/nyx/nyx_gui/libs/lv_conf.h b/nyx/nyx_gui/libs/lv_conf.h index efd4667..d53f09f 100644 --- a/nyx/nyx_gui/libs/lv_conf.h +++ b/nyx/nyx_gui/libs/lv_conf.h @@ -163,7 +163,7 @@ * LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't caused problem * LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail */ -# define LV_LOG_LEVEL LV_LOG_LEVEL_TRACE +# define LV_LOG_LEVEL LV_LOG_LEVEL_ERROR /* 1: Print the log with 'printf'; 0: user need to register a callback*/ # define LV_LOG_PRINTF 1 #endif /*USE_LV_LOG*/ diff --git a/nyx/nyx_gui/libs/lvgl/lv_objx/lv_win.c b/nyx/nyx_gui/libs/lvgl/lv_objx/lv_win.c index 8f1cc87..318da42 100644 --- a/nyx/nyx_gui/libs/lvgl/lv_objx/lv_win.c +++ b/nyx/nyx_gui/libs/lvgl/lv_objx/lv_win.c @@ -201,6 +201,7 @@ lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src, const char * lab else if (label_src) { lv_obj_t *label = lv_label_create(btn, NULL); + lv_label_set_recolor(label, true); lv_label_set_text(label, label_src); } diff --git a/nyx/nyx_gui/libs/lvgl/ref/2017031823595300-57B4628D2267231D57E0FC1078C0596D.jpg b/nyx/nyx_gui/libs/lvgl/ref/2017031823595300-57B4628D2267231D57E0FC1078C0596D.jpg deleted file mode 100644 index 1d1ed80..0000000 Binary files a/nyx/nyx_gui/libs/lvgl/ref/2017031823595300-57B4628D2267231D57E0FC1078C0596D.jpg and /dev/null differ diff --git a/nyx/nyx_gui/libs/lvgl/ref/2017031823595900-57B4628D2267231D57E0FC1078C0596D.jpg b/nyx/nyx_gui/libs/lvgl/ref/2017031823595900-57B4628D2267231D57E0FC1078C0596D.jpg deleted file mode 100644 index 3eff3d3..0000000 Binary files a/nyx/nyx_gui/libs/lvgl/ref/2017031823595900-57B4628D2267231D57E0FC1078C0596D.jpg and /dev/null differ diff --git a/nyx/nyx_gui/libs/lvgl/ref/2017031900001400-57B4628D2267231D57E0FC1078C0596D.jpg b/nyx/nyx_gui/libs/lvgl/ref/2017031900001400-57B4628D2267231D57E0FC1078C0596D.jpg deleted file mode 100644 index 7b5d70f..0000000 Binary files a/nyx/nyx_gui/libs/lvgl/ref/2017031900001400-57B4628D2267231D57E0FC1078C0596D.jpg and /dev/null differ diff --git a/nyx/nyx_gui/libs/lvgl/ref/2017091517134300-57B4628D2267231D57E0FC1078C0596D.jpg b/nyx/nyx_gui/libs/lvgl/ref/2017091517134300-57B4628D2267231D57E0FC1078C0596D.jpg deleted file mode 100644 index 31e49ab..0000000 Binary files a/nyx/nyx_gui/libs/lvgl/ref/2017091517134300-57B4628D2267231D57E0FC1078C0596D.jpg and /dev/null differ diff --git a/nyx/nyx_gui/libs/lvgl/ref/2017091903111300-57B4628D2267231D57E0FC1078C0596D.jpg b/nyx/nyx_gui/libs/lvgl/ref/2017091903111300-57B4628D2267231D57E0FC1078C0596D.jpg deleted file mode 100644 index 471aafc..0000000 Binary files a/nyx/nyx_gui/libs/lvgl/ref/2017091903111300-57B4628D2267231D57E0FC1078C0596D.jpg and /dev/null differ diff --git a/nyx/nyx_gui/nyx.c b/nyx/nyx_gui/nyx.c index 8836e67..941bac0 100644 --- a/nyx/nyx_gui/nyx.c +++ b/nyx/nyx_gui/nyx.c @@ -85,7 +85,11 @@ bool sd_mount() int res = 0; if (!sd_init_done) + { res = !sdmmc_storage_init_sd(&sd_storage, &sd_sdmmc, SDMMC_1, SDMMC_BUS_WIDTH_4, 11); + if (!res) + sd_init_done = true; + } if (res) { @@ -93,11 +97,10 @@ bool sd_mount() } else { - sd_init_done = true; int res = f_mount(&sd_fs, "", 1); if (res == FR_OK) { - sd_mounted = 1; + sd_mounted = true; return true; } else @@ -111,7 +114,7 @@ bool sd_mount() void sd_unmount(bool deinit) { - if (sd_mounted) + if (sd_init_done && sd_mounted) { f_mount(NULL, "", 1); sd_mounted = false; @@ -290,8 +293,6 @@ lv_res_t launch_payload(lv_obj_t *list) void (*ext_payload_ptr)() = (void *)EXT_PAYLOAD_ADDR; - msleep(100); - // Launch our payload. (*ext_payload_ptr)(); } @@ -326,7 +327,11 @@ void load_saved_configuration() else if (!strcmp("verification", kv->key)) h_cfg.verification = atoi(kv->val); else if (!strcmp("backlight", kv->key)) + { h_cfg.backlight = atoi(kv->val); + if (h_cfg.backlight <= 20) + h_cfg.backlight = 30; + } else if (!strcmp("autohosoff", kv->key)) h_cfg.autohosoff = atoi(kv->val); else if (!strcmp("autonogc", kv->key)) @@ -398,9 +403,6 @@ extern void pivot_stack(u32 stack_top); void ipl_main() { - //Pivot the stack so we have enough space. - pivot_stack(IPL_STACK_TOP); - //Tegra/Horizon configuration goes to 0x80000000+, package2 goes to 0xA9800000, we place our heap in between. heap_init(IPL_HEAP_START); diff --git a/nyx/nyx_gui/power/max7762x.c b/nyx/nyx_gui/power/max7762x.c index 2c8cff4..0a76867 100644 --- a/nyx/nyx_gui/power/max7762x.c +++ b/nyx/nyx_gui/power/max7762x.c @@ -23,6 +23,9 @@ #define REGULATOR_SD 0 #define REGULATOR_LDO 1 +#pragma GCC push_options +#pragma GCC target ("thumb") + typedef struct _max77620_regulator_t { u8 type; @@ -163,3 +166,5 @@ void max77620_low_battery_monitor_config() i2c_send_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_CNFGGLBL1, MAX77620_CNFGGLBL1_LBDAC_EN | MAX77620_CNFGGLBL1_LBHYST_N | MAX77620_CNFGGLBL1_LBDAC_N); } + +#pragma GCC pop_options diff --git a/nyx/nyx_gui/soc/bpmp.c b/nyx/nyx_gui/soc/bpmp.c index 0c61d85..a0551d1 100644 --- a/nyx/nyx_gui/soc/bpmp.c +++ b/nyx/nyx_gui/soc/bpmp.c @@ -72,6 +72,9 @@ #define MMU_EN_READ (1 << 2) #define MMU_EN_WRITE (1 << 3) +#pragma GCC push_options +#pragma GCC target ("thumb") + bpmp_mmu_entry_t mmu_entries[] = { { 0x80000000, 0xFFFFFFFF, MMU_EN_READ | MMU_EN_WRITE | MMU_EN_EXEC | MMU_EN_CACHED, true }, @@ -215,3 +218,4 @@ void bpmp_clk_rate_set(bpmp_freq_t fid) } } +#pragma GCC pop_options diff --git a/nyx/nyx_gui/soc/clock.c b/nyx/nyx_gui/soc/clock.c index 2a472eb..df9634d 100644 --- a/nyx/nyx_gui/soc/clock.c +++ b/nyx/nyx_gui/soc/clock.c @@ -19,6 +19,9 @@ #include "../utils/util.h" #include "../storage/sdmmc.h" +#pragma GCC push_options +#pragma GCC target ("thumb") + /* clock_t: reset, enable, source, index, clk_src, clk_div */ static const clock_t _clock_uart[] = { @@ -527,3 +530,5 @@ void clock_sdmmc_disable(u32 id) _clock_sdmmc_clear_enable(id); _clock_sdmmc_is_reset(id); } + +#pragma GCC pop_options diff --git a/nyx/nyx_gui/soc/cluster.c b/nyx/nyx_gui/soc/cluster.c index 1976e11..4633bae 100644 --- a/nyx/nyx_gui/soc/cluster.c +++ b/nyx/nyx_gui/soc/cluster.c @@ -23,6 +23,9 @@ #include "../power/max77620.h" #include "../power/max7762x.h" +#pragma GCC push_options +#pragma GCC target ("thumb") + void _cluster_enable_power() { u8 tmp = i2c_recv_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_AME_GPIO); // Get current pinmuxing @@ -131,3 +134,5 @@ void cluster_boot_cpu0(u32 entry) // < 5.x: 0x411F000F, Clear CPU{0,1,2,3} POR and CORE, CX0, L2, and DBG reset. CLOCK(CLK_RST_CONTROLLER_RST_CPUG_CMPLX_CLR) = 0x41010001; } + +#pragma GCC pop_options diff --git a/nyx/nyx_gui/soc/fuse.c b/nyx/nyx_gui/soc/fuse.c index 54a93a0..4704abb 100644 --- a/nyx/nyx_gui/soc/fuse.c +++ b/nyx/nyx_gui/soc/fuse.c @@ -22,6 +22,9 @@ #include "../soc/fuse.h" #include "../soc/t210.h" +#pragma GCC push_options +#pragma GCC target ("thumb") + #define ARRAYSIZE(x) (sizeof(x) / sizeof(*x)) static const u32 evp_thunk_template[] = { @@ -347,3 +350,5 @@ bool fuse_check_patched_rcm() return false; } + +#pragma GCC pop_options diff --git a/nyx/nyx_gui/start.S b/nyx/nyx_gui/start.S index 534f963..c520ef1 100644 --- a/nyx/nyx_gui/start.S +++ b/nyx/nyx_gui/start.S @@ -36,7 +36,7 @@ _start: /* If we are not in the right location already, copy a relocator to upper IRAM. */ ADR R2, _reloc_ipl - LDR R3, =0x4003FF00 + LDR R3, =0x4003FFE0 MOV R4, #(_real_start - _reloc_ipl) _copy_loop: LDMIA R2!, {R5} @@ -48,7 +48,7 @@ _copy_loop: LDR R2, =__ipl_end SUB R2, R2, R1 LDR R3, =_real_start - LDR R4, =0x4003FF00 + LDR R4, =0x4003FFE0 BX R4 _reloc_ipl: @@ -61,7 +61,7 @@ _reloc_ipl: _real_start: /* Initially, we place our stack in IRAM but will move it to SDRAM later. */ - LDR SP, =0x4003FF00 + LDR SP, =0x90010000 LDR R0, =__bss_start EOR R1, R1, R1 LDR R2, =__bss_end diff --git a/nyx/nyx_gui/storage/sdmmc.c b/nyx/nyx_gui/storage/sdmmc.c index a28d3dd..a893d08 100644 --- a/nyx/nyx_gui/storage/sdmmc.c +++ b/nyx/nyx_gui/storage/sdmmc.c @@ -29,6 +29,9 @@ extern hekate_config h_cfg; +#pragma GCC push_options +#pragma GCC target ("thumb") + static inline u32 unstuff_bits(u32 *resp, u32 start, u32 size) { const u32 mask = (size < 32 ? 1 << size : 0) - 1; @@ -1199,3 +1202,5 @@ int sdmmc_storage_init_gc(sdmmc_storage_t *storage, sdmmc_t *sdmmc) return 1; } + +#pragma GCC pop_options diff --git a/nyx/res/icon_lakka.bmp b/nyx/resources/icon_lakka.bmp similarity index 100% rename from nyx/res/icon_lakka.bmp rename to nyx/resources/icon_lakka.bmp diff --git a/nyx/res/icon_payload.bmp b/nyx/resources/icon_payload.bmp similarity index 100% rename from nyx/res/icon_payload.bmp rename to nyx/resources/icon_payload.bmp diff --git a/nyx/res/icon_switch.bmp b/nyx/resources/icon_switch.bmp similarity index 100% rename from nyx/res/icon_switch.bmp rename to nyx/resources/icon_switch.bmp