From 4da1d1055348271be4558dadad445d244dcb46d4 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Mon, 19 Dec 2022 05:09:37 +0200 Subject: [PATCH] nyx: Force 4MiB eMMC boot0/1 on backup/restore Simplify ops on big eMMC replacements. --- nyx/nyx_gui/frontend/fe_emmc_tools.c | 12 ++++++++++-- nyx/nyx_gui/frontend/fe_emummc_tools.c | 8 ++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/nyx/nyx_gui/frontend/fe_emmc_tools.c b/nyx/nyx_gui/frontend/fe_emmc_tools.c index 4d40324..51e67ae 100644 --- a/nyx/nyx_gui/frontend/fe_emmc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emmc_tools.c @@ -789,11 +789,15 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui) if (dumpType & PART_BOOT) { const u32 BOOT_PART_SIZE = emmc_storage.ext_csd.boot_mult << 17; + const u32 BOOT_PART_SECTORS = 0x2000; // Force 4 MiB for emuMMC. emmc_part_t bootPart; memset(&bootPart, 0, sizeof(bootPart)); bootPart.lba_start = 0; - bootPart.lba_end = (BOOT_PART_SIZE / EMMC_BLOCKSIZE) - 1; + if (!gui->raw_emummc) + bootPart.lba_end = (BOOT_PART_SIZE / EMMC_BLOCKSIZE) - 1; + else + bootPart.lba_end = BOOT_PART_SECTORS - 1; for (i = 0; i < 2; i++) { strcpy(bootPart.name, "BOOT"); @@ -1436,11 +1440,15 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui) if (restoreType & PART_BOOT) { const u32 BOOT_PART_SIZE = emmc_storage.ext_csd.boot_mult << 17; + const u32 BOOT_PART_SECTORS = 0x2000; // Force 4 MiB for emuMMC. emmc_part_t bootPart; memset(&bootPart, 0, sizeof(bootPart)); bootPart.lba_start = 0; - bootPart.lba_end = (BOOT_PART_SIZE / EMMC_BLOCKSIZE) - 1; + if (!gui->raw_emummc) + bootPart.lba_end = (BOOT_PART_SIZE / EMMC_BLOCKSIZE) - 1; + else + bootPart.lba_end = BOOT_PART_SECTORS - 1; for (i = 0; i < 2; i++) { strcpy(bootPart.name, "BOOT"); diff --git a/nyx/nyx_gui/frontend/fe_emummc_tools.c b/nyx/nyx_gui/frontend/fe_emummc_tools.c index 87827d2..5810a53 100644 --- a/nyx/nyx_gui/frontend/fe_emummc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emummc_tools.c @@ -410,12 +410,12 @@ void dump_emummc_file(emmc_tool_gui_t *gui) strcpy(gui->base_path, sdPath); timer = get_tmr_s(); - const u32 BOOT_PART_SIZE = emmc_storage.ext_csd.boot_mult << 17; + const u32 BOOT_PART_SECTORS = 0x2000; // Force 4 MiB. emmc_part_t bootPart; memset(&bootPart, 0, sizeof(bootPart)); bootPart.lba_start = 0; - bootPart.lba_end = (BOOT_PART_SIZE / EMMC_BLOCKSIZE) - 1; + bootPart.lba_end = BOOT_PART_SECTORS - 1; for (i = 0; i < 2; i++) { @@ -884,12 +884,12 @@ void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start, u32 r strcpy(gui->base_path, sdPath); timer = get_tmr_s(); - const u32 BOOT_PART_SIZE = emmc_storage.ext_csd.boot_mult << 17; + const u32 BOOT_PART_SECTORS = 0x2000; // Force 4 MiB. emmc_part_t bootPart; memset(&bootPart, 0, sizeof(bootPart)); bootPart.lba_start = 0; - bootPart.lba_end = (BOOT_PART_SIZE / EMMC_BLOCKSIZE) - 1; + bootPart.lba_end = BOOT_PART_SECTORS - 1; // Clear partition start. memset((u8 *)MIXD_BUF_ALIGNED, 0, SZ_16M);