diff --git a/bdk/storage/sdmmc.c b/bdk/storage/sdmmc.c index 6cde1b4..58e813e 100644 --- a/bdk/storage/sdmmc.c +++ b/bdk/storage/sdmmc.c @@ -845,7 +845,7 @@ int _sd_storage_get_scr(sdmmc_storage_t *storage, u8 *buf) _sd_storage_parse_scr(storage); //gfx_hexdump(0, storage->raw_scr, 8); - return _sdmmc_storage_check_result(tmp); + return _sdmmc_storage_check_card_status(tmp); } int _sd_storage_switch_get(sdmmc_storage_t *storage, void *buf) @@ -861,12 +861,12 @@ int _sd_storage_switch_get(sdmmc_storage_t *storage, void *buf) reqbuf.is_multi_block = 0; reqbuf.is_auto_cmd12 = 0; - if (!sdmmc_execute_cmd(storage->sdmmc, &cmdbuf, &reqbuf, 0)) + if (!sdmmc_execute_cmd(storage->sdmmc, &cmdbuf, &reqbuf, NULL)) return 0; u32 tmp = 0; sdmmc_get_rsp(storage->sdmmc, &tmp, 4, SDMMC_RSP_TYPE_1); - return _sdmmc_storage_check_result(tmp); + return _sdmmc_storage_check_card_status(tmp); } int _sd_storage_switch(sdmmc_storage_t *storage, void *buf, int mode, int group, u32 arg) @@ -885,12 +885,12 @@ int _sd_storage_switch(sdmmc_storage_t *storage, void *buf, int mode, int group, reqbuf.is_multi_block = 0; reqbuf.is_auto_cmd12 = 0; - if (!sdmmc_execute_cmd(storage->sdmmc, &cmdbuf, &reqbuf, 0)) + if (!sdmmc_execute_cmd(storage->sdmmc, &cmdbuf, &reqbuf, NULL)) return 0; u32 tmp = 0; sdmmc_get_rsp(storage->sdmmc, &tmp, 4, SDMMC_RSP_TYPE_1); - return _sdmmc_storage_check_result(tmp); + return _sdmmc_storage_check_card_status(tmp); } void _sd_storage_set_current_limit(sdmmc_storage_t *storage, u16 current_limit, u8 *buf) @@ -1064,6 +1064,44 @@ int _sd_storage_enable_hs_high_volt(sdmmc_storage_t *storage, u8 *buf) return sdmmc_setup_clock(storage->sdmmc, SDHCI_TIMING_SD_HS25); } +u32 sd_storage_ssr_get_au(sdmmc_storage_t *storage) +{ + u32 au_size = storage->ssr.uhs_au_size; + + if (!au_size) + au_size = storage->ssr.au_size; + + if (au_size <= 10) + { + u32 shift = au_size; + au_size = shift ? 8 : 0; + au_size <<= shift; + } + else + { + switch (au_size) + { + case 11: + au_size = 12288; + break; + case 12: + au_size = 16384; + break; + case 13: + au_size = 24576; + break; + case 14: + au_size = 32768; + break; + case 15: + au_size = 65536; + break; + } + } + + return au_size; +} + static void _sd_storage_parse_ssr(sdmmc_storage_t *storage) { // unstuff_bits supports only 4 u32 so break into 2 x 16byte groups @@ -1113,6 +1151,9 @@ static void _sd_storage_parse_ssr(sdmmc_storage_t *storage) storage->ssr.video_class = unstuff_bits(raw_ssr1, 384 - 384, 8); storage->ssr.app_class = unstuff_bits(raw_ssr2, 336 - 256, 4); + + storage->ssr.au_size = unstuff_bits(raw_ssr1, 428 - 384, 4); + storage->ssr.uhs_au_size = unstuff_bits(raw_ssr1, 392 - 384, 4); } static int _sd_storage_get_ssr(sdmmc_storage_t *storage, u8 *buf) diff --git a/bdk/storage/sdmmc.h b/bdk/storage/sdmmc.h index 76d2f91..5e8114f 100644 --- a/bdk/storage/sdmmc.h +++ b/bdk/storage/sdmmc.h @@ -95,6 +95,8 @@ typedef struct _sd_ssr u8 uhs_grade; u8 video_class; u8 app_class; + u8 au_size; + u8 uhs_au_size; u32 protected_size; } sd_ssr_t; diff --git a/nyx/nyx_gui/frontend/gui_info.c b/nyx/nyx_gui/frontend/gui_info.c index e7d1c56..edfa081 100644 --- a/nyx/nyx_gui/frontend/gui_info.c +++ b/nyx/nyx_gui/frontend/gui_info.c @@ -1574,14 +1574,22 @@ static lv_res_t _create_window_sdcard_info_status(lv_obj_t *btn) break; } + bool uhs_au_mb = false; + u32 uhs_au_size = sd_storage_ssr_get_au(&sd_storage); + if (uhs_au_size >= 1024) + { + uhs_au_mb = true; + uhs_au_size /= 1024; + } + s_printf(txt_buf, - "#00DDFF v%d.0#\n%02X\n%d MiB\n%X (CP %X)\n%d\n%d MB/s (%d MHz)\n%d\nU%d\nV%d\nA%d\n%s", + "#00DDFF v%d.0#\n%02X\n%d MiB\n%X (CP %X)\n%d\n%d MB/s (%d MHz)\n%d (AU: %d %s\nU%d\nV%d\nA%d\n%s", sd_storage.csd.structure + 1, sd_storage.csd.cmdclass, sd_storage.sec_cnt >> 11, sd_storage.sec_cnt, sd_storage.ssr.protected_size >> 9, sd_storage.ssr.bus_width, sd_storage.csd.busspeed, (sd_storage.csd.busspeed > 10) ? (sd_storage.csd.busspeed * 2) : 50, - sd_storage.ssr.speed_class, sd_storage.ssr.uhs_grade, sd_storage.ssr.video_class, - sd_storage.ssr.app_class, wp_info); + sd_storage.ssr.speed_class, uhs_au_size, uhs_au_mb ? "MiB)" : "KiB)", sd_storage.ssr.uhs_grade, + sd_storage.ssr.video_class, sd_storage.ssr.app_class, wp_info); lv_label_set_text(lb_val2, txt_buf);