diff --git a/bootloader/hos/hos.c b/bootloader/hos/hos.c index 8cbb8d4..2e05086 100644 --- a/bootloader/hos/hos.c +++ b/bootloader/hos/hos.c @@ -720,6 +720,9 @@ int hos_launch(ini_sec_t *cfg) bpmp_clk_rate_set(BPMP_CLK_NORMAL); minerva_change_freq(FREQ_800); + // emuMMC: Some cards (Sandisk U1), do not like a fast power cycle. Wait min 100ms. + sdmmc_storage_init_wait_sd(); + // Wait for secmon to get ready. if (smmu_is_used()) smmu_exit(); @@ -733,7 +736,7 @@ int hos_launch(ini_sec_t *cfg) // Halt ourselves in waitevent state and resume if there's JTAG activity. while (true) - FLOW_CTLR(FLOW_CTLR_HALT_COP_EVENTS) = 0x50000000; + bpmp_halt(); return 0; } diff --git a/bootloader/main.c b/bootloader/main.c index 095f4bc..3ab5597 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -324,7 +324,8 @@ int launch_payload(char *path, bool update) void (*ext_payload_ptr)() = (void *)EXT_PAYLOAD_ADDR; void (*update_ptr)() = (void *)RCM_PAYLOAD_ADDR; - msleep(100); + // Some cards (Sandisk U1), do not like a fast power cycle. Wait min 100ms. + sdmmc_storage_init_wait_sd(); // Launch our payload. if (!update) @@ -719,9 +720,7 @@ void nyx_load_run() minerva_periodic_training(); // Some cards (Sandisk U1), do not like a fast power cycle. Wait min 100ms. - u32 sd_poweroff_time = (u32)get_tmr_ms() - h_cfg.sd_timeoff; - if (sd_poweroff_time < 100) - msleep(100 - sd_poweroff_time); + sdmmc_storage_init_wait_sd(); (*nyx_ptr)(); } diff --git a/bootloader/storage/sdmmc.c b/bootloader/storage/sdmmc.c index a28d3dd..db37944 100644 --- a/bootloader/storage/sdmmc.c +++ b/bootloader/storage/sdmmc.c @@ -835,7 +835,7 @@ int _sd_storage_enable_highspeed_low_volt(sdmmc_storage_t *storage, u32 type, u8 u32 hs_type = 0; switch (type) { - case 11: + case 11: // SDR104. // Fall through if not supported. if (buf[13] & SD_MODE_UHS_SDR104) { @@ -845,7 +845,7 @@ int _sd_storage_enable_highspeed_low_volt(sdmmc_storage_t *storage, u32 type, u8 storage->csd.busspeed = 104; break; } - case 10: + case 10: // SDR50. if (buf[13] & SD_MODE_UHS_SDR50) { type = 10; @@ -854,7 +854,7 @@ int _sd_storage_enable_highspeed_low_volt(sdmmc_storage_t *storage, u32 type, u8 storage->csd.busspeed = 50; break; } - case 8: + case 8: // SDR12. if (!(buf[13] & SD_MODE_UHS_SDR12)) return 0; type = 8; @@ -1012,14 +1012,19 @@ static void _sd_storage_parse_csd(sdmmc_storage_t *storage) } } +void sdmmc_storage_init_wait_sd() +{ + u32 sd_poweroff_time = (u32)get_tmr_ms() - h_cfg.sd_timeoff; + if (sd_poweroff_time < 100) + msleep(100 - sd_poweroff_time); +} + int sdmmc_storage_init_sd(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32 bus_width, u32 type) { int is_version_1 = 0; // Some cards (Sandisk U1), do not like a fast power cycle. Wait min 100ms. - u32 sd_poweroff_time = (u32)get_tmr_ms() - h_cfg.sd_timeoff; - if (id == SDMMC_1 && (sd_poweroff_time < 100)) - msleep(100 - sd_poweroff_time); + sdmmc_storage_init_wait_sd(); memset(storage, 0, sizeof(sdmmc_storage_t)); storage->sdmmc = sdmmc; diff --git a/bootloader/storage/sdmmc.h b/bootloader/storage/sdmmc.h index 7ae20e3..2427324 100644 --- a/bootloader/storage/sdmmc.h +++ b/bootloader/storage/sdmmc.h @@ -107,6 +107,7 @@ int sdmmc_storage_read(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, vo int sdmmc_storage_write(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf); int sdmmc_storage_init_mmc(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32 bus_width, u32 type); int sdmmc_storage_set_mmc_partition(sdmmc_storage_t *storage, u32 partition); +void sdmmc_storage_init_wait_sd(); int sdmmc_storage_init_sd(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32 bus_width, u32 type); int sdmmc_storage_init_gc(sdmmc_storage_t *storage, sdmmc_t *sdmmc); diff --git a/nyx/nyx_gui/frontend/gui.c b/nyx/nyx_gui/frontend/gui.c index 64865f9..0b7839c 100644 --- a/nyx/nyx_gui/frontend/gui.c +++ b/nyx/nyx_gui/frontend/gui.c @@ -735,6 +735,9 @@ static void _reload_nyx() reconfig_hw_workaround(false, 0); + // Some cards (Sandisk U1), do not like a fast power cycle. Wait min 100ms. + sdmmc_storage_init_wait_sd(); + (*main_ptr)(); } diff --git a/nyx/nyx_gui/nyx.c b/nyx/nyx_gui/nyx.c index 1144f5d..b4baccd 100644 --- a/nyx/nyx_gui/nyx.c +++ b/nyx/nyx_gui/nyx.c @@ -293,6 +293,9 @@ lv_res_t launch_payload(lv_obj_t *list) void (*ext_payload_ptr)() = (void *)EXT_PAYLOAD_ADDR; + // Some cards (Sandisk U1), do not like a fast power cycle. Wait min 100ms. + sdmmc_storage_init_wait_sd(); + // Launch our payload. (*ext_payload_ptr)(); } diff --git a/nyx/nyx_gui/storage/sdmmc.c b/nyx/nyx_gui/storage/sdmmc.c index a52f411..b0837ec 100644 --- a/nyx/nyx_gui/storage/sdmmc.c +++ b/nyx/nyx_gui/storage/sdmmc.c @@ -1015,14 +1015,19 @@ static void _sd_storage_parse_csd(sdmmc_storage_t *storage) } } +void sdmmc_storage_init_wait_sd() +{ + u32 sd_poweroff_time = (u32)get_tmr_ms() - h_cfg.sd_timeoff; + if (sd_poweroff_time < 100) + msleep(100 - sd_poweroff_time); +} + int sdmmc_storage_init_sd(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32 bus_width, u32 type) { int is_version_1 = 0; // Some cards (Sandisk U1), do not like a fast power cycle. Wait min 100ms. - u32 sd_poweroff_time = (u32)get_tmr_ms() - h_cfg.sd_timeoff; - if (id == SDMMC_1 && (sd_poweroff_time < 100)) - msleep(100 - sd_poweroff_time); + sdmmc_storage_init_wait_sd(); memset(storage, 0, sizeof(sdmmc_storage_t)); storage->sdmmc = sdmmc; diff --git a/nyx/nyx_gui/storage/sdmmc.h b/nyx/nyx_gui/storage/sdmmc.h index 7ae20e3..2427324 100644 --- a/nyx/nyx_gui/storage/sdmmc.h +++ b/nyx/nyx_gui/storage/sdmmc.h @@ -107,6 +107,7 @@ int sdmmc_storage_read(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, vo int sdmmc_storage_write(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf); int sdmmc_storage_init_mmc(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32 bus_width, u32 type); int sdmmc_storage_set_mmc_partition(sdmmc_storage_t *storage, u32 partition); +void sdmmc_storage_init_wait_sd(); int sdmmc_storage_init_sd(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32 bus_width, u32 type); int sdmmc_storage_init_gc(sdmmc_storage_t *storage, sdmmc_t *sdmmc);