From e14a7d1d4d1f45338d3e36bb36f4844e307f5b2e Mon Sep 17 00:00:00 2001 From: CTCaer Date: Thu, 30 Apr 2020 02:05:24 +0300 Subject: [PATCH] nyx: Clear partition start when creating emuMMC --- nyx/nyx_gui/frontend/fe_emmc_tools.c | 7 +++---- nyx/nyx_gui/frontend/fe_emummc_tools.c | 10 ++++++++-- nyx/nyx_gui/frontend/gui_info.c | 6 +++--- nyx/nyx_gui/frontend/gui_tools.c | 4 ++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/nyx/nyx_gui/frontend/fe_emmc_tools.c b/nyx/nyx_gui/frontend/fe_emmc_tools.c index e68d5ff..0577ddb 100644 --- a/nyx/nyx_gui/frontend/fe_emmc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emmc_tools.c @@ -713,7 +713,7 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui) int res = 0; u32 timer = 0; - char *txt_buf = (char *)malloc(0x1000); + char *txt_buf = (char *)malloc(0x4000); gui->txt_buf = txt_buf; s_printf(txt_buf, ""); @@ -1259,7 +1259,7 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui) int res = 0; u32 timer = 0; - char *txt_buf = (char *)malloc(0x1000); + char *txt_buf = (char *)malloc(0x4000); gui->txt_buf = txt_buf; s_printf(txt_buf, ""); @@ -1296,8 +1296,7 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui) lv_mbox_set_text(warn_mbox, txt_buf); manual_system_maintenance(true); - u32 btn = btn_wait(); - if (!(btn & BTN_POWER)) + if (!(btn_wait() & BTN_POWER)) { lv_label_set_text(gui->label_info, "#FFDD00 Restore operation was aborted!#"); lv_obj_del(warn_mbox_bg); diff --git a/nyx/nyx_gui/frontend/fe_emummc_tools.c b/nyx/nyx_gui/frontend/fe_emummc_tools.c index 470fce5..f4880c5 100644 --- a/nyx/nyx_gui/frontend/fe_emummc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emummc_tools.c @@ -24,6 +24,7 @@ #include "gui.h" #include "fe_emummc_tools.h" #include "../config/config.h" +#include "../config/ini.h" #include "../libs/fatfs/ff.h" #include "../mem/heap.h" #include "../sec/se.h" @@ -347,7 +348,7 @@ void dump_emummc_file(emmc_tool_gui_t *gui) int base_len = 0; u32 timer = 0; - char *txt_buf = (char *)malloc(0x1000); + char *txt_buf = (char *)malloc(0x4000); gui->txt_buf = txt_buf; s_printf(txt_buf, ""); @@ -635,7 +636,7 @@ void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start) int res = 0; u32 timer = 0; - char *txt_buf = (char *)malloc(0x1000); + char *txt_buf = (char *)malloc(0x4000); gui->txt_buf = txt_buf; s_printf(txt_buf, ""); @@ -674,6 +675,11 @@ void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start) memset(&bootPart, 0, sizeof(bootPart)); bootPart.lba_start = 0; bootPart.lba_end = (BOOT_PART_SIZE / NX_EMMC_BLOCKSIZE) - 1; + + // Clear partition start. + memset((u8 *)MIXD_BUF_ALIGNED, 0, 0x1000000); + sdmmc_storage_write(&sd_storage, sector_start - 0x8000, 0x8000, (u8 *)MIXD_BUF_ALIGNED); + for (i = 0; i < 2; i++) { strcpy(bootPart.name, "BOOT"); diff --git a/nyx/nyx_gui/frontend/gui_info.c b/nyx/nyx_gui/frontend/gui_info.c index 27bfc41..93bcf8a 100644 --- a/nyx/nyx_gui/frontend/gui_info.c +++ b/nyx/nyx_gui/frontend/gui_info.c @@ -265,7 +265,7 @@ static lv_res_t _create_window_fuses_info_status(lv_obj_t *btn) lv_obj_t * lb_val = lv_label_create(val, lb_desc); - char *txt_buf = (char *)malloc(0x1000); + char *txt_buf = (char *)malloc(0x4000); // Decode fuses. u8 burntFuses7 = 0; @@ -729,7 +729,7 @@ static lv_res_t _create_window_sdcard_info_status(lv_obj_t *btn) lv_obj_t * lb_val = lv_label_create(val, lb_desc); - char *txt_buf = (char *)malloc(0x1000); + char *txt_buf = (char *)malloc(0x4000); s_printf(txt_buf,"\n%02x\n%c%c\n%c%c%c%c%c\n%X\n%X\n%08x\n%02d/%04d", sd_storage.cid.manfid, (sd_storage.cid.oemid >> 8) & 0xFF, sd_storage.cid.oemid & 0xFF, @@ -898,7 +898,7 @@ static lv_res_t _create_window_battery_status(lv_obj_t *btn) lv_obj_t * lb_val = lv_label_create(val, lb_desc); - char *txt_buf = (char *)malloc(0x1000); + char *txt_buf = (char *)malloc(0x4000); int value = 0; max17050_get_property(MAX17050_RepSOC, &value); diff --git a/nyx/nyx_gui/frontend/gui_tools.c b/nyx/nyx_gui/frontend/gui_tools.c index 4c94d19..690b153 100644 --- a/nyx/nyx_gui/frontend/gui_tools.c +++ b/nyx/nyx_gui/frontend/gui_tools.c @@ -342,8 +342,8 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn) u8 *pkg2 = NULL; u8 kb = 0; - char *txt_buf = (char *)malloc(0x1000); - char *txt_buf2 = (char *)malloc(0x1000); + char *txt_buf = (char *)malloc(0x4000); + char *txt_buf2 = (char *)malloc(0x4000); tsec_ctxt_t tsec_ctxt;