From f764bf04b11332e4933316000a539126256e9a97 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Wed, 27 Mar 2024 09:41:55 +0200 Subject: [PATCH] hos: reboot to ofw if stock fails If package1 fails to be read and conditions are valid, reboot to OFW automatically when stock mode is enabled. --- bootloader/hos/hos.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/bootloader/hos/hos.c b/bootloader/hos/hos.c index 5ef6b94..f319866 100644 --- a/bootloader/hos/hos.c +++ b/bootloader/hos/hos.c @@ -25,6 +25,7 @@ #include "hos.h" #include "hos_config.h" #include "secmon_exo.h" +#include "../frontend/fe_tools.h" #include "../config.h" #include "../storage/emummc.h" @@ -785,12 +786,6 @@ int hos_launch(ini_sec_t *cfg) goto error; } - // Read package1 and the correct keyblob. - if (!_read_emmc_pkg1(&ctxt)) - goto error; - - kb = ctxt.pkg1_id->kb; - // Try to parse config if present. if (ctxt.cfg && !parse_boot_config(&ctxt)) { @@ -798,6 +793,24 @@ int hos_launch(ini_sec_t *cfg) goto error; } + // Read package1 and the correct keyblob. + if (!_read_emmc_pkg1(&ctxt)) + { + // Check if stock is enabled and device can boot in OFW. + if (ctxt.stock && (h_cfg.t210b01 || !tools_autorcm_enabled())) + { + emmc_end(); + + WPRINTF("\nRebooting to OFW in 5s..."); + msleep(5000); + + power_set_state(REBOOT_BYPASS_FUSES); + } + goto error; + } + + kb = ctxt.pkg1_id->kb; + bool emummc_enabled = emu_cfg.enabled && !h_cfg.emummc_force_disable; // Enable emummc patching.