Hier tritt höchstwahrscheinlich der Fehler auf.
Code:
fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT boot sector as SFD */
if (fmt == 1 || (!fmt && (LD2PT(vol)))) { /* Not an FAT boot sector or forced partition number */
for (i = 0; i < 4; i++) { /* Get partition offset */
pt = fs->win + MBR_Table + i * SZ_PTE;
br[i] = pt[4] ? LD_DWORD(&pt[8]) : 0;
}
i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced */
if (i) i--;
do { /* Find an FAT volume */
bsect = br[i];
fmt = bsect ? check_fs(fs, bsect) : 2; /* Check the partition */
} while (!LD2PT(vol) && fmt && ++i < 4);
}
if (fmt == 3) return FR_DISK_ERR; /* An error occured in the disk I/O layer */
Code:
if (move_window(fs, sect) != FR_OK) /* Load boot record */
return 3;
Code:
staticFRESULT move_window (
FATFS* fs, /* File system object */
DWORD sector /* Sector number to make appearance in the fs->win[] */
)
{
FRESULT res = FR_OK;
if (sector != fs->winsect) { /* Window offset changed? */
#if !_FS_READONLY
res = sync_window(fs); /* Write-back changes */
#endif
if (res == FR_OK) { /* Fill sector window with new data */
if (disk_read(fs->drv, fs->win, sector, 1) != RES_OK) {
sector = 0xFFFFFFFF; /* Invalidate window if data is not reliable */
res = FR_DISK_ERR;
}
fs->winsect = sector;
}
}
return res;
}
Warum disk_read() fehlschlägt musst du selbst herausfinden. Ich habe weder die Hardware noch die Software.
mfg
Lesezeichen