From 9a082c1b18cfb3f39744f922cd7b8169574272c1 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Wed, 4 Dec 2019 17:46:12 +0200 Subject: [PATCH] hos: Improve errors more for HOS launch --- bootloader/hos/hos.c | 24 +++++++++++++++++++----- bootloader/hos/sept.c | 9 +++++++-- bootloader/main.c | 1 + bootloader/storage/emummc.c | 15 ++++++--------- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/bootloader/hos/hos.c b/bootloader/hos/hos.c index fe8cb93..ca30a5b 100644 --- a/bootloader/hos/hos.c +++ b/bootloader/hos/hos.c @@ -329,13 +329,18 @@ int keygen(u8 *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt, launch_ctxt_t *hos_ctxt) static int _read_emmc_pkg1(launch_ctxt_t *ctxt) { - int res = 0; sdmmc_storage_t storage; sdmmc_t sdmmc; - if (!emummc_storage_init_mmc(&storage, &sdmmc)) + int res = emummc_storage_init_mmc(&storage, &sdmmc); + + if (res) { - _hos_crit_error("Failed to init emuMMC"); + if (res == 2) + _hos_crit_error("Failed to init eMMC"); + else + _hos_crit_error("Failed to init emuMMC"); + return 0; } @@ -368,9 +373,15 @@ static u8 *_read_emmc_pkg2(launch_ctxt_t *ctxt) sdmmc_storage_t storage; sdmmc_t sdmmc; - if (!emummc_storage_init_mmc(&storage, &sdmmc)) + int res = emummc_storage_init_mmc(&storage, &sdmmc); + + if (res) { - _hos_crit_error("Failed to init emuMMC"); + if (res == 2) + _hos_crit_error("Failed to init eMMC"); + else + _hos_crit_error("Failed to init emuMMC"); + return NULL; } @@ -562,6 +573,8 @@ int hos_launch(ini_sec_t *cfg) if (!pkg2_hdr) { _hos_crit_error("Pkg2 decryption failed!"); + if (ctxt.pkg1_id->kb >= KB_FIRMWARE_VERSION_700) + EPRINTF("Is Sept updated?"); return 0; } @@ -590,6 +603,7 @@ int hos_launch(ini_sec_t *cfg) if (!ctxt.pkg2_kernel_id) { _hos_crit_error("Failed to identify kernel!"); + return 0; } diff --git a/bootloader/hos/sept.c b/bootloader/hos/sept.c index 614bf8c..672e7dd 100644 --- a/bootloader/hos/sept.c +++ b/bootloader/hos/sept.c @@ -91,9 +91,14 @@ void check_sept() sdmmc_storage_t storage; sdmmc_t sdmmc; - if (!emummc_storage_init_mmc(&storage, &sdmmc)) + int res = emummc_storage_init_mmc(&storage, &sdmmc); + if (res) { - EPRINTF("Failed to init eMMC."); + if (res == 2) + EPRINTF("Failed to init eMMC"); + else + EPRINTF("Failed to init emuMMC"); + goto out_free; } diff --git a/bootloader/main.c b/bootloader/main.c index 504dbbf..155228f 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -1023,6 +1023,7 @@ skip_list: hos_launch(cfg_sec); EPRINTF("\nFailed to launch HOS!"); + gfx_printf("\nPress any key and try again...\n"); msleep(500); btn_wait(); } diff --git a/bootloader/storage/emummc.c b/bootloader/storage/emummc.c index 2945b30..e12d665 100644 --- a/bootloader/storage/emummc.c +++ b/bootloader/storage/emummc.c @@ -92,18 +92,14 @@ static int emummc_raw_get_part_off(int part_idx) return 2; } - int emummc_storage_init_mmc(sdmmc_storage_t *storage, sdmmc_t *sdmmc) { FILINFO fno; - if (!sdmmc_storage_init_mmc(storage, sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4)) - { - EPRINTF("Failed to init eMMC."); + if (!sdmmc_storage_init_mmc(storage, sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, SDHCI_TIMING_MMC_HS400)) + return 2; - goto out; - } if (h_cfg.emummc_force_disable) - return 1; + return 0; emu_cfg.active_part = 0; if (!sd_mount()) @@ -129,10 +125,11 @@ int emummc_storage_init_mmc(sdmmc_storage_t *storage, sdmmc_t *sdmmc) } emu_cfg.file_based_part_size = fno.fsize >> 9; } - return 1; + + return 0; out: - return 0; + return 1; } int emummc_storage_end(sdmmc_storage_t *storage)