各位高手,小弟正在向NIOS上移植FATFS文件系统。移植完成后,调用f_open创建并打开一个文件,这个时候遇到“打开失败”。调试了一下,发现check_fs函数中的LD_WORD
(&fs->win[BS_55AA])!=0xAA55判断失败,返回2。请教其中的原因。谢谢!部分代码如下:
static
BYTE check_fs ( /* 0:FATboor sector, 1:Valid boor sector but not FAT, 2:Not a boot sector, 3:Disk error*/
FATFS* fs, /* File system object */
DWORD sect /* Sector# (lba) to check if it is an FAT boot record ornot */
)
{
WORD temp;
fs->wflag = 0; fs->winsect = 0xFFFFFFFF; /* Invaidatewindow */
if (move_window(fs, sect) != FR_OK) /* Load bootrecord */
return 3;
if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check bootrecord signature (always placed at offset 510 even if the sector size is>512) */
return 2;
if ((LD_DWORD(&fs->win[BS_FilSysType])& 0xFFFFFF) == 0x544146) /* Check "FAT" string */
return 0;
if ((LD_DWORD(&fs->win[BS_FilSysType32]) &0xFFFFFF) == 0x544146) /* Check "FAT" string */
return 0;
return 1; }
|