Disable verification for now & add memcmp32sparse

When the commit with the configuration will be a available, these 3 options will exist:

- Disable verification
- Sparse verification (Fast)
- Full (Slow)

Sparse will take approx 8 minutes for rawnand.bin and Full will take 4.5 hours.
This commit is contained in:
Kostas Missos 2018-06-24 23:02:35 +03:00
parent 60f4000e9d
commit c215b1c74c
3 changed files with 62 additions and 15 deletions

View file

@ -693,6 +693,7 @@ int dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char* outFilename,
{
FIL fp;
u32 prevPct = 200;
int res = 0;
if (f_open(&fp, outFilename, FA_READ) == FR_OK)
{
@ -734,8 +735,12 @@ int dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char* outFilename,
f_close(&fp);
return 1;
}
if(memcmp(bufEm, bufSd, num << 9))
//TODO: Replace with the config check 2.
if (1)
res = memcmp32sparse((u32 *)bufEm, (u32 *)bufSd, num << 9);
else
res = memcmp((u32 *)bufEm, (u32 *)bufSd, num << 9);
if(res)
{
EPRINTFARGS("\nSD card and eMMC data (@LBA %08X),\ndo not match!\n\nVerification failed..\n", num, lba_curr);
@ -911,6 +916,9 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
memset(&fp, 0, sizeof(fp));
currPartIdx++;
//TODO: Replace with the config check.
if (1)
{
// Verify part.
if (dump_emmc_verify(storage, lbaStartPart, outFilename, part))
{
@ -919,6 +927,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
free(buf);
return 0;
}
}
if (numSplitParts >= 10 && currPartIdx < 10)
{
@ -1027,6 +1036,9 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
free(buf);
f_close(&fp);
//TODO: Replace with the config check.
if (0)
{
// Verify last part or single file backup.
if (dump_emmc_verify(storage, lbaStartPart, outFilename, part))
{
@ -1037,6 +1049,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
}
else
tui_pbar(&gfx_con, 0, gfx_con.y, 100, 0xFF96FF00, 0xFF155500);
}
// Remove partial backup index file if no fatal errors occurred.
if(isSmallSdCard)
@ -1164,8 +1177,10 @@ static void dump_emmc_selected(dumpType_t dumpType)
gfx_putc(&gfx_con, '\n');
gfx_printf(&gfx_con, "Time taken: %d seconds.\n", (get_tmr() - timer) / 1000000);
sdmmc_storage_end(&storage);
if (res)
if (res && 0) //TODO: Replace with the config check.
gfx_printf(&gfx_con, "\n%kFinished and verified!%k\nPress any key...\n",0xFF96FF00, 0xFFCCCCCC);
else if (res)
gfx_printf(&gfx_con, "\nFinished! Press any key...\n");
out:;
sd_unmount();

View file

@ -49,3 +49,31 @@ u32 crc32c(const void *buf, u32 len)
}
return ~crc;
}
u32 memcmp32sparse(const u32 *buf1, const u32 *buf2, u32 len)
{
u32 len32 = len / 4;
if (!(len32 % 32))
{
while (len32)
{
len32 -= 32;
if(buf1[len32] != buf2[len32])
return 1;
}
}
else
{
while (len32)
{
len32 -= 32;
if(buf1[len32] != buf2[len32])
return 1;
if (len32 < 32)
return 0;
}
}
return 0;
}

View file

@ -34,4 +34,8 @@ void sleep(u32 ticks);
void exec_cfg(u32 *base, const cfg_op_t *ops, u32 num_ops);
u32 crc32c(const void *buf, u32 len);
/* This is a faster implementation of memcmp that checks two u32 values */
/* every 128 Bytes block. Intented for only for Backup and Restore */
u32 memcmp32sparse(const u32 *buf1, const u32 *buf2, u32 len);
#endif