From 29b0ddccd3d7c566fa5ff23325f67aa864aa5d6f Mon Sep 17 00:00:00 2001 From: eXhumer Date: Thu, 31 Dec 2020 01:20:22 -0700 Subject: [PATCH] Fix hard-coded "{emmcsn}" to display actual serial --- nyx/nyx_gui/frontend/gui_info.c | 5 ++++- nyx/nyx_gui/nyx.c | 21 +++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/nyx/nyx_gui/frontend/gui_info.c b/nyx/nyx_gui/frontend/gui_info.c index 255ce04..b0a6fa0 100644 --- a/nyx/nyx_gui/frontend/gui_info.c +++ b/nyx/nyx_gui/frontend/gui_info.c @@ -51,6 +51,7 @@ extern hekate_config h_cfg; extern volatile boot_cfg_t *b_cfg; extern volatile nyx_storage_t *nyx_str; +extern void emmcsn_impl(char *out_emmcSN, sdmmc_storage_t *storage); extern void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage); static u8 *cal0_buf = NULL; @@ -66,12 +67,14 @@ static lv_res_t _create_window_dump_done(int error, char *dump_filenames) lv_mbox_set_recolor_text(mbox, true); lv_obj_set_width(mbox, LV_HOR_RES / 9 * 5); + char emmcsn[9]; + emmcsn_impl(emmcsn, NULL); char *txt_buf = (char *)malloc(0x1000); if (error) s_printf(txt_buf, "#FFDD00 Failed to dump to# %s#FFDD00 !#\nError: %d", dump_filenames, error); else - s_printf(txt_buf, "Dumping to SD card finished!\nFiles: #C7EA46 backup/{emmc_sn}/dumps/#%s", dump_filenames); + s_printf(txt_buf, "Dumping to SD card finished!\nFiles: #C7EA46 backup/%s/dumps/#%s", emmcsn, dump_filenames); lv_mbox_set_text(mbox, txt_buf); lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); // Important. After set_text. diff --git a/nyx/nyx_gui/nyx.c b/nyx/nyx_gui/nyx.c index 7dcac47..30a833a 100644 --- a/nyx/nyx_gui/nyx.c +++ b/nyx/nyx_gui/nyx.c @@ -69,16 +69,13 @@ const volatile ipl_ver_meta_t __attribute__((section ("._ipl_version"))) ipl_ver volatile nyx_storage_t *nyx_str = (nyx_storage_t *)NYX_STORAGE_ADDR; volatile boot_cfg_t *b_cfg; -void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage) +void emmcsn_impl(char *out_emmcSN, sdmmc_storage_t *storage) { sdmmc_storage_t storage2; sdmmc_t sdmmc; char emmcSN[9]; bool init_done = false; - memcpy(path, "backup", 7); - f_mkdir(path); - if (!storage) { if (!sdmmc_storage_init_mmc(&storage2, &sdmmc, SDMMC_BUS_WIDTH_8, SDHCI_TIMING_MMC_HS400)) @@ -92,20 +89,28 @@ void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t else itoa(storage->cid.serial, emmcSN, 16); + memcpy(out_emmcSN + strlen(out_emmcSN), emmcSN, 9); + + if (init_done) + sdmmc_storage_end(&storage2); +} + +void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t *storage) +{ + memcpy(path, "backup", 7); + f_mkdir(path); + u32 sub_dir_len = strlen(sub_dir); // Can be a null-terminator. u32 filename_len = strlen(filename); // Can be a null-terminator. memcpy(path + strlen(path), "/", 2); - memcpy(path + strlen(path), emmcSN, 9); + emmcsn_impl(path, storage); f_mkdir(path); memcpy(path + strlen(path), sub_dir, sub_dir_len + 1); if (sub_dir_len) f_mkdir(path); memcpy(path + strlen(path), "/", 2); memcpy(path + strlen(path), filename, filename_len + 1); - - if (init_done) - sdmmc_storage_end(&storage2); } // This is a safe and unused DRAM region for our payloads.