Fix hard-coded "{emmcsn}" to display actual serial

This commit is contained in:
eXhumer 2020-12-31 01:20:22 -07:00
parent 2fba9848ae
commit 29b0ddccd3
No known key found for this signature in database
GPG key ID: 3A1CA61549E890F3
2 changed files with 17 additions and 9 deletions

View file

@ -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.

View file

@ -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.