You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i just create empty FAT32 image file with raspberry pi, the command bellow:
$ dd if=/dev/zero of=img.bin bs=1M count=32
$ mkfs -t vfat -F 32 -n BOOT img.bin > /dev/null 2>&1
$ mount -t vfat img.bin /mnt # mount it sucessfully!
then, i modify diskio.c to read image, the code just like that:
DRESULTdisk_read (
BYTEpdrv, /* Physical drive nmuber to identify the drive */BYTE*buff, /* Data buffer to store read data */LBA_tsector, /* Start sector in LBA */UINTcount/* Number of sectors to read */
)
{
FILE*fp=fopen("img.bin", "rb");
fseek(fp, sector*FF_MIN_SS, SEEK_SET);
fread(buff, FF_MIN_SS, count, fp);
fclose(fp);
return0;
}
when i call “f_mount(&fatfs, "0:", 1);”,it return 13, so i debug it with codeblocks. the source code bellow make me confused:
staticFRESULTmount_volume (){ # file: ff.c, line: 33323
...
nclst= (tsect-sysect) / fs->csize; /* Number of clusters */if (nclst==0) returnFR_NO_FILESYSTEM;
fmt=0;
if (nclst <= MAX_FAT32) fmt=FS_FAT32;
if (nclst <= MAX_FAT16) fmt=FS_FAT16; // my image size is 32MB, it set fmt equal to FS_FAT16if (nclst <= MAX_FAT12) fmt=FS_FAT12;
if (fmt==0) returnFR_NO_FILESYSTEM;
...
if (fmt==FS_FAT32) {
if (ld_word(fs->win+BPB_FSVer32) !=0) returnFR_NO_FILESYSTEM;
if (fs->n_rootdir!=0) returnFR_NO_FILESYSTEM; // logic different, in other cases(FAT16?)fs->dirbase=ld_dword(fs->win+BPB_RootClus32);
szbfat=fs->n_fatent*4;
} else {
if (fs->n_rootdir==0) returnFR_NO_FILESYSTEM; // touch here, then return 13, means mount failed fs->dirbase=fs->fatbase+fasize;
szbfat= (fmt==FS_FAT16) ?
fs->n_fatent*2 : fs->n_fatent*3 / 2+ (fs->n_fatent&1);
}
...
}
my image file is 32MB, i guess this procedure recognize type with img size?howerver, the logic "fs->n_rootdir == 0" is different between FS_FAT32 case and NON FS_FAT32 cases。
The text was updated successfully, but these errors were encountered:
i just create empty FAT32 image file with raspberry pi, the command bellow:
then, i modify diskio.c to read image, the code just like that:
when i call “f_mount(&fatfs, "0:", 1);”,it return 13, so i debug it with codeblocks. the source code bellow make me confused:
my image file is 32MB, i guess this procedure recognize type with img size?howerver, the logic "fs->n_rootdir == 0" is different between FS_FAT32 case and NON FS_FAT32 cases。
The text was updated successfully, but these errors were encountered: