mirror of
https://github.com/CTCaer/hekate.git
synced 2024-11-23 10:22:00 +00:00
[sdmmc] Change internal read/write retries
This can fix busy errors when writing to sd cards. Additionally it now returns properly on success
This commit is contained in:
parent
3877eddc3e
commit
391c28d6a2
2 changed files with 18 additions and 6 deletions
|
@ -867,8 +867,8 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
|
||||||
EPRINTFARGS("Error reading %d blocks @ LBA %08X from eMMC (try %d), retrying...",
|
EPRINTFARGS("Error reading %d blocks @ LBA %08X from eMMC (try %d), retrying...",
|
||||||
num, lba_curr, ++retryCount);
|
num, lba_curr, ++retryCount);
|
||||||
|
|
||||||
sleep(500000);
|
sleep(150000);
|
||||||
if (retryCount >= 10)
|
if (retryCount >= 3)
|
||||||
{
|
{
|
||||||
gfx_con_setfontsz(&gfx_con, 16);
|
gfx_con_setfontsz(&gfx_con, 16);
|
||||||
EPRINTFARGS("\nFailed to read %d blocks @ LBA %08X\nfrom eMMC. Aborting..\n",
|
EPRINTFARGS("\nFailed to read %d blocks @ LBA %08X\nfrom eMMC. Aborting..\n",
|
||||||
|
|
18
ipl/sdmmc.c
18
ipl/sdmmc.c
|
@ -165,15 +165,27 @@ static int _sdmmc_storage_readwrite(sdmmc_storage_t *storage, u32 sector, u32 nu
|
||||||
while (num_sectors)
|
while (num_sectors)
|
||||||
{
|
{
|
||||||
u32 blkcnt = 0;
|
u32 blkcnt = 0;
|
||||||
//Retry once on error.
|
//Retry 9 times on error.
|
||||||
if (!_sdmmc_storage_readwrite_ex(storage, &blkcnt, sector, MIN(num_sectors, 0xFFFF), bbuf, is_write))
|
u32 retries = 10;
|
||||||
if (!_sdmmc_storage_readwrite_ex(storage, &blkcnt, sector, MIN(num_sectors, 0xFFFF), bbuf, is_write))
|
do
|
||||||
|
{
|
||||||
|
if (_sdmmc_storage_readwrite_ex(storage, &blkcnt, sector, MIN(num_sectors, 0xFFFF), bbuf, is_write))
|
||||||
|
goto out;
|
||||||
|
else
|
||||||
|
retries--;
|
||||||
|
|
||||||
|
sleep(500000);
|
||||||
|
|
||||||
|
} while (retries);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
out:;
|
||||||
DPRINTF("readwrite: %08X\n", blkcnt);
|
DPRINTF("readwrite: %08X\n", blkcnt);
|
||||||
sector += blkcnt;
|
sector += blkcnt;
|
||||||
num_sectors -= blkcnt;
|
num_sectors -= blkcnt;
|
||||||
bbuf += 512 * blkcnt;
|
bbuf += 512 * blkcnt;
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sdmmc_storage_read(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf)
|
int sdmmc_storage_read(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf)
|
||||||
|
|
Loading…
Reference in a new issue