From 4af99c9f7847a3a65f8e505ad1dddeeaa1ec643f Mon Sep 17 00:00:00 2001 From: CTCaer Date: Wed, 17 Dec 2025 06:28:36 +0200 Subject: [PATCH] hos/l4t: deduplicate sc7exit-b01 load And remove obsolete MWS (L4T one deprecated it 3 years ago). --- bootloader/hos/pkg1.c | 22 +++---------- bootloader/l4t/l4t.c | 31 +++++++------------ .../frontend/gui_tools_partition_manager.c | 9 ------ 3 files changed, 16 insertions(+), 46 deletions(-) diff --git a/bootloader/hos/pkg1.c b/bootloader/hos/pkg1.c index cbdfa5e0..3979d94d 100644 --- a/bootloader/hos/pkg1.c +++ b/bootloader/hos/pkg1.c @@ -343,18 +343,6 @@ void pkg1_warmboot_patch(void *hos_ctxt) *(vu32 *)(ctxt->pkg1_id->warmboot_base + warmboot_patchset[i].off) = warmboot_patchset[i].val; } -static void _warmboot_filename(char *out, u32 fuses) -{ - if (fuses < 16) - { - out[19] = '0'; - itoa(fuses, &out[19 + 1], 16); - } - else - itoa(fuses, &out[19], 16); - strcat(out, ".bin"); -} - int pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base, u32 fuses_fw, u8 mkey) { launch_ctxt_t *ctxt = (launch_ctxt_t *)hos_ctxt; @@ -362,11 +350,9 @@ int pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base, u32 fuses_fw, u8 mke if (h_cfg.t210b01) { - u32 pa_id; - u32 fuses_max = 32; // Current ODM7 max. u8 burnt_fuses = bit_count(fuse_read_odm(7)); - // Save current warmboot in storage cache (MWS) and check if another one is needed. + // Check if not overridden. if (!ctxt->warmboot) { char path[128]; @@ -386,7 +372,7 @@ int pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base, u32 fuses_fw, u8 mke u32 tmp_fuses = burnt_fuses; while (true) { - _warmboot_filename(path, burnt_fuses); + _warmboot_filename(path, tmp_fuses); if (!f_stat(path, NULL)) { ctxt->warmboot = emusd_file_read(path + 6, &ctxt->warmboot_size); @@ -398,7 +384,7 @@ int pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base, u32 fuses_fw, u8 mke tmp_fuses++; } - // Check if proper warmboot firmware was not found. + // Check if match was found. if (!ctxt->warmboot) res = 0; } @@ -408,7 +394,7 @@ int pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base, u32 fuses_fw, u8 mke // Configure warmboot parameters. Anything lower than 6.0.0 is not supported. // From 7.0.0 and up, it's not derived from PA segment but it's 0x21 * fuses. - pa_id = 0x21 * burnt_fuses; + u32 pa_id = 0x21 * burnt_fuses; if (burnt_fuses <= 8) // Old method. pa_id -= 0x60; diff --git a/bootloader/l4t/l4t.c b/bootloader/l4t/l4t.c index a104a0ce..975747a4 100644 --- a/bootloader/l4t/l4t.c +++ b/bootloader/l4t/l4t.c @@ -305,7 +305,6 @@ static const l4t_fw_t l4t_fw[] = { { BL33_LOAD_BASE, "bl33.bin" }, { SC7ENTRY_BASE, "sc7entry.bin" }, { SC7EXIT_BASE, "sc7exit.bin" }, - { SC7EXIT_B01_BASE, "sc7exit_b01.bin" }, //!TODO: Update on fuse burns. { BPMPFW_BASE, "bpmpfw.bin" }, { BPMPFW_B01_BASE, "bpmpfw_b01.bin" }, { BPMPFW_B01_MTC_TABLE_BASE, "mtc_tbl_b01.bin" }, @@ -316,10 +315,9 @@ enum { BL33_FW = 1, SC7ENTRY_FW = 2, SC7EXIT_FW = 3, - SC7EXIT_B01_FW = 4, - BPMPFW_FW = 5, - BPMPFW_B01_FW = 6, - BPMPFW_B01_MTC_TBL = 7 + BPMPFW_FW = 4, + BPMPFW_B01_FW = 5, + BPMPFW_B01_MTC_TBL = 6 }; static void _l4t_crit_error(const char *text, bool needs_update) @@ -336,9 +334,6 @@ static int _l4t_sd_load(u32 idx) FIL fp; void *load_address = (void *)l4t_fw[idx].addr; - if (idx == SC7EXIT_B01_FW) - load_address -= sizeof(u32); - strcpy(sd_path + sd_path_len, l4t_fw[idx].name); if (f_open(&fp, sd_path, FA_READ) != FR_OK) @@ -826,11 +821,9 @@ static int _l4t_sc7_exit_config(bool t210b01) } else { - launch_ctxt_t hos_ctxt = {0}; - u32 fw_fuses = *(u32 *)(SC7EXIT_B01_BASE - sizeof(u32)); // Fuses count in front of actual firmware. - // Get latest SC7-Exit if needed and setup PA id. - if (!pkg1_warmboot_config(&hos_ctxt, 0, fw_fuses, 0)) + launch_ctxt_t hos_ctxt = {0}; + if (!pkg1_warmboot_config(&hos_ctxt, 0, 0, 0)) { gfx_con.mute = false; gfx_wputs("\nFailed to match warmboot with fuses!\nIf you continue, sleep wont work!"); @@ -1001,6 +994,13 @@ void launch_l4t(const ini_sec_t *ini_sec, int entry_idx, int is_list, bool t210b _l4t_crit_error("loading BPMP-FW", true); return; } + + // Load SC7-Exit firmware. + if (!_l4t_sd_load(SC7EXIT_FW)) + { + _l4t_crit_error("loading SC7-Exit", true); + return; + } } else { @@ -1019,13 +1019,6 @@ void launch_l4t(const ini_sec_t *ini_sec, int entry_idx, int is_list, bool t210b } } - // Load SC7-Exit firmware. - if (!_l4t_sd_load(!t210b01 ? SC7EXIT_FW : SC7EXIT_B01_FW)) - { - _l4t_crit_error("loading SC7-Exit", true); - return; - } - // Set SC7-Exit firmware address to PMC for bootrom and do further setup. if (!_l4t_sc7_exit_config(t210b01)) return; diff --git a/nyx/nyx_gui/frontend/gui_tools_partition_manager.c b/nyx/nyx_gui/frontend/gui_tools_partition_manager.c index 685783c2..64c4419b 100644 --- a/nyx/nyx_gui/frontend/gui_tools_partition_manager.c +++ b/nyx/nyx_gui/frontend/gui_tools_partition_manager.c @@ -1954,7 +1954,6 @@ static int _backup_and_restore_files(bool backup, const char *drive, lv_obj_t ** // Check if Mariko Warmboot Storage exists in source drive. f_chdrive(src_drv); - bool backup_mws = !part_info.backup_possible && !f_stat("warmboot_mariko", NULL); bool backup_pld = !part_info.backup_possible && !f_stat("payload.bin", NULL); if (!part_info.backup_possible) @@ -1965,8 +1964,6 @@ static int _backup_and_restore_files(bool backup, const char *drive, lv_obj_t ** // Create hekate/Nyx/MWS folders in destination drive. f_chdrive(dst_drv); f_mkdir("bootloader"); - if (backup_mws) - f_mkdir("warmboot_mariko"); } // Copy all or hekate/Nyx files. @@ -1979,12 +1976,6 @@ static int _backup_and_restore_files(bool backup, const char *drive, lv_obj_t ** // If incomplete backup mode, copy MWS and payload.bin also. if (!res) { - if (backup_mws) - { - strcpy(path, "warmboot_mariko"); - res = _stat_and_copy_files(src_drv, dst_drv, path, &total_files, &total_size, labels); - } - if (!res && backup_pld) { strcpy(path, "payload.bin");