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.
This commit is contained in:
CTCaer 2024-03-27 09:41:55 +02:00
parent 8b1486c74b
commit f764bf04b1

View file

@ -25,6 +25,7 @@
#include "hos.h" #include "hos.h"
#include "hos_config.h" #include "hos_config.h"
#include "secmon_exo.h" #include "secmon_exo.h"
#include "../frontend/fe_tools.h"
#include "../config.h" #include "../config.h"
#include "../storage/emummc.h" #include "../storage/emummc.h"
@ -785,12 +786,6 @@ int hos_launch(ini_sec_t *cfg)
goto error; 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. // Try to parse config if present.
if (ctxt.cfg && !parse_boot_config(&ctxt)) if (ctxt.cfg && !parse_boot_config(&ctxt))
{ {
@ -798,6 +793,24 @@ int hos_launch(ini_sec_t *cfg)
goto error; 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; bool emummc_enabled = emu_cfg.enabled && !h_cfg.emummc_force_disable;
// Enable emummc patching. // Enable emummc patching.