From a80cc0ae2ca77aa17efd613d1eab7b9357797684 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Sat, 6 Feb 2021 03:05:41 +0200 Subject: [PATCH] hos: Add error message for mariko warmboot fw not found Ability to continue without sleep working also. --- bootloader/hos/hos.c | 12 +++++++++++- bootloader/hos/pkg1.c | 15 +++++++++++---- bootloader/hos/pkg1.h | 2 +- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/bootloader/hos/hos.c b/bootloader/hos/hos.c index 9d99449..23e3cac 100644 --- a/bootloader/hos/hos.c +++ b/bootloader/hos/hos.c @@ -875,7 +875,17 @@ int hos_launch(ini_sec_t *cfg) } // Configure and manage Warmboot binary. - pkg1_warmboot_config(&ctxt, warmboot_base); + if (!pkg1_warmboot_config(&ctxt, warmboot_base)) + { + // Can only happen on T210B01. + _hos_crit_error("Failed to match warmboot with fuses!\nIf you continue, sleep wont work!"); + + gfx_puts("\nPress POWER to continue.\nPress VOL to go to the menu.\n"); + display_backlight_brightness(h_cfg.backlight, 1000); + + if (!(btn_wait() & BTN_POWER)) + goto error; + } // Replace 'warmboot.bin' if requested. if (ctxt.warmboot) diff --git a/bootloader/hos/pkg1.c b/bootloader/hos/pkg1.c index 0874823..a1680d2 100644 --- a/bootloader/hos/pkg1.c +++ b/bootloader/hos/pkg1.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2018 naehrwert * Copyright (c) 2018 st4rk - * Copyright (c) 2018-2020 CTCaer + * Copyright (c) 2018-2021 CTCaer * Copyright (c) 2018 balika011 * * This program is free software; you can redistribute it and/or modify it @@ -331,10 +331,11 @@ static void _warmboot_filename(char *out, u32 fuses) strcat(out, ".bin"); } -void pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base) +int pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base) { launch_ctxt_t *ctxt = (launch_ctxt_t *)hos_ctxt; u32 kb = ctxt->pkg1_id->kb; + int res = 1; // Set warmboot address in PMC if required. if (kb <= KB_FIRMWARE_VERSION_301) @@ -347,7 +348,7 @@ void pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base) u32 fuses_fw = ctxt->pkg1_id->fuses; u8 burnt_fuses = fuse_count_burnt(fuse_read_odm(7)); - // Save current warmboot in storage cache and check if another one is needed. + // Save current warmboot in storage cache (MWS) and check if another one is needed. if (!ctxt->warmboot) { char path[128]; @@ -357,7 +358,7 @@ void pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base) if (f_stat(path, NULL)) sd_save_to_file((void *)warmboot_base, ctxt->warmboot_size, path); - // Load warmboot fw from storage if not matched. + // Load warmboot fw from storage (MWS) if not matched. if (burnt_fuses > fuses_fw) { u32 tmp_fuses = burnt_fuses; @@ -374,6 +375,10 @@ void pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base) break; tmp_fuses++; } + + // Check if proper warmboot firmware was found. + if (!ctxt->warmboot) + res = 0; } else // Replace burnt fuses with higher count. burnt_fuses = fuses_fw; @@ -406,4 +411,6 @@ void pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base) else if (kb == KB_FIRMWARE_VERSION_301) PMC(APBDEV_PMC_SECURE_SCRATCH32) = 0x104; // Warmboot 3.0.1/.2 PA address id. } + + return res; } diff --git a/bootloader/hos/pkg1.h b/bootloader/hos/pkg1.h index d427617..3997838 100644 --- a/bootloader/hos/pkg1.h +++ b/bootloader/hos/pkg1.h @@ -81,6 +81,6 @@ int pkg1_decrypt(const pkg1_id_t *id, u8 *pkg1); const u8 *pkg1_unpack(void *wm_dst, u32 *wb_sz, void *sm_dst, void *ldr_dst, const pkg1_id_t *id, u8 *pkg1); void pkg1_secmon_patch(void *hos_ctxt, u32 secmon_base, bool t210b01); void pkg1_warmboot_patch(void *hos_ctxt); -void pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base); +int pkg1_warmboot_config(void *hos_ctxt, u32 warmboot_base); #endif