RT,当SD卡跑到以下程序就出问题
static
BYTE check_fs ( /* 0:The FAT boot record, 1:Valid boot record but not an FAT, 2:Not a boot record, 3:Error */
FATFS *fs, /* File system object */
DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */
)
{
static const char fatstr[] = "FAT";
if (disk_read(fs->drive, fs->win, sect, 1) != RES_OK) /* Load boot record */
return 3;
if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check record signature (always placed at offset 510 even if the sector size is >512) */
return 2;
if (!mem_cmp(&fs->win[BS_FilSysType], fatstr, 3)) /* Check FAT signature */
return 0;
if (!mem_cmp(&fs->win[BS_FilSysType32], fatstr, 3) && !(fs->win[BPB_ExtFlags] & 0x80))
return 0;
return 1;
}
第3,第4个if不能通过,原因是SD卡有MBR区在0扇区,不能写,但系统在0扇区读到 FAT格式的标识,所认出错。但刚接触SD卡的运用,求各位兄弟指点
|