From 73d96b7ca8bd4360b288e53d95295fd98d1655e5 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 | 58 +++++-------------- bootloader/l4t/l4t.c | 31 ++++------ .../frontend/gui_tools_partition_manager.c | 9 --- 3 files changed, 26 insertions(+), 72 deletions(-) diff --git a/bootloader/hos/pkg1.c b/bootloader/hos/pkg1.c index 7fdc30fd..4471fcf3 100644 --- a/bootloader/hos/pkg1.c +++ b/bootloader/hos/pkg1.c @@ -341,18 +341,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; @@ -360,45 +348,27 @@ 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]; - strcpy(path, "warmboot_mariko/wb_"); - _warmboot_filename(path, fuses_fw); - - // Check if warmboot fw exists and save it. - if (ctxt->warmboot_size && f_stat(path, NULL)) - { - f_mkdir("warmboot_mariko"); - sd_save_to_file((void *)warmboot_base, ctxt->warmboot_size, path); - } - - // Load warmboot fw from storage (MWS) if not matched. + // Load sc7exit-fw from storage if low. if (burnt_fuses > fuses_fw) { - u32 tmp_fuses = burnt_fuses; - while (true) - { - _warmboot_filename(path, burnt_fuses); - if (!f_stat(path, NULL)) - { - ctxt->warmboot = sd_file_read(path, &ctxt->warmboot_size); - burnt_fuses = tmp_fuses; - break; - } - if (tmp_fuses >= fuses_max) - break; - tmp_fuses++; - } + //!TODO: Update on fuse burns. + void *warmboot_fw = sd_file_read("bootloader/sys/l4t/sc7exit_b01.bin", &ctxt->warmboot_size); + fuses_fw = *(u32 *)warmboot_fw; - // Check if proper warmboot firmware was not found. - if (!ctxt->warmboot) + // Check if high enough. + if (!warmboot_fw || burnt_fuses > fuses_fw) res = 0; + else + { + ctxt->warmboot = warmboot_fw + sizeof(u32); + ctxt->warmboot_size -= sizeof(u32) * 2; + burnt_fuses = fuses_fw; + } } else // Replace burnt fuses with higher count. burnt_fuses = fuses_fw; @@ -406,7 +376,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 c3e79836..69008527 100644 --- a/bootloader/l4t/l4t.c +++ b/bootloader/l4t/l4t.c @@ -304,7 +304,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" }, @@ -315,10 +314,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) @@ -335,9 +333,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) @@ -825,11 +820,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!"); @@ -1000,6 +993,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 { @@ -1018,13 +1018,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 82df8898..3d844730 100644 --- a/nyx/nyx_gui/frontend/gui_tools_partition_manager.c +++ b/nyx/nyx_gui/frontend/gui_tools_partition_manager.c @@ -1557,7 +1557,6 @@ static int _backup_and_restore_files(bool backup, lv_obj_t **labels) // 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) @@ -1568,8 +1567,6 @@ static int _backup_and_restore_files(bool backup, lv_obj_t **labels) // 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. @@ -1578,12 +1575,6 @@ static int _backup_and_restore_files(bool backup, lv_obj_t **labels) // 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");