1
0
mirror of https://github.com/CTCaer/hekate.git synced 2024-11-05 20:26:52 +00:00

nyx: clear nand patrol for resized emummc

On used eMMCs, the usage size might exceed the new resized size.
In such cases if the nand patrol points there, it will cause the sd card to timeout because of out of bounds access.

Clearing that allows resized emuMMC to always have the same speed as full sized emuMMC.
This commit is contained in:
CTCaer 2021-08-28 18:09:34 +03:00
parent 9ba867f19e
commit 792a3511da

View File

@ -38,8 +38,9 @@
#include <utils/sprintf.h>
#include <utils/util.h>
#define NUM_SECTORS_PER_ITER 8192 // 4MB Cache.
#define OUT_FILENAME_SZ 128
#define NAND_PATROL_SECTOR 0xC20
#define NUM_SECTORS_PER_ITER 8192 // 4MB Cache.
extern hekate_config h_cfg;
extern volatile boot_cfg_t *b_cfg;
@ -590,9 +591,8 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part
manual_system_maintenance(false);
retryCount = 0;
// Write data to SD card.
retryCount = 0;
while (!sdmmc_storage_write(&sd_storage, sd_sector_off + lba_curr, num, buf))
{
s_printf(gui->txt_buf,
@ -668,9 +668,9 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part
manual_system_maintenance(true);
// Format USER partition.
u8 *buf = malloc(0x400000);
int mkfs_error = f_mkfs("emu:", FM_FAT32 | FM_SFD | FM_PRF2, 16384, buf, 0x400000);
free(buf);
u8 *buff = malloc(0x400000);
int mkfs_error = f_mkfs("emu:", FM_FAT32 | FM_SFD | FM_PRF2, 16384, buff, 0x400000);
free(buff);
// Mount sd card back.
sd_mount();
@ -745,6 +745,10 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part
// Write MBR.
sdmmc_storage_write(&sd_storage, sd_sector_off, 1, &mbr);
// Clear nand patrol.
memset(buf, 0, NX_EMMC_BLOCKSIZE);
sdmmc_storage_write(&sd_storage, sd_part_off + NAND_PATROL_SECTOR, 1, buf);
free(gpt);
}