I've tried to create a program that dumps all the nand to a single binary file... but it doesn't work as expected.
Code: Select all
nblocks = sceNandGetTotalBlocks();
ppb = sceNandGetPagesPerBlock();
cbBlock = ppb * sceNandGetPageSize();
block = (u8 *)malloc(cbBlock);
for (i = 0; i < nblocks; i++)
{
sceNandLock(0);
if (!sceNandIsBadBlock(i))
{
memset(block, 0, cbBlock);
goodb++;
if (sceNandReadBlockWithRetry(i*ppb, block, NULL) < 0)
{
printf("Error reading block #%d\n", i);
sceNandUnlock();
continue;
}
writtenb++;
printf("Dumping block #%d\n", i);
sceIoWrite(fd, block, cbBlock);
}
else
{
printf("bad block :#%d\n", i);
}
sceNandUnlock();
}
printf("Done. good blocks: %d, written: %d\n", goodb, writtenb);
At the end, goodb (good blocks) = 64 and writtenb (written blocks) = 61, and the file is less than 1 MB when it should be exactly 32 MB if it had written the 2048 blocks.
What are exactly bad blocks? and why 3 of the good blocks are not read correctly? does the kernel block access to read them?