FR_NO_FILESYSTEM error on FAFTS working SD card FAT32 with MCI interface on LPC1788

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Feb 24, 2020 by Lonly Pan
Content originally posted in LPCWare by sipel_tp on Thu Aug 22 08:54:00 MST 2013

Hello everybody,

I've tried to inicialize a SD card using the elm-chan.org FATFS library with a LPC1788 and the MCI interface.

I manage to recognize the card but I can't make the library work.

I've tried to inicialize a SD card like I show you right here but f_open keeps me throwing FR_NO_FILESYSTEM:

en_Mci_CardType cardType;
uint32_t i,j;
BYTE buffer[64];
FRESULT result;
static FATFS fs;      
FIL objectFIL;

memset(buffer, 0, 64);


result = f_mount(0, &fs);

cardType = MCI_GetCardType();

result = f_open(&objectFIL, "0:SDCARD/archive1.txt", FA_OPEN_EXISTING |FA_READ);

Here is the part of the code inside f_open where it makes that:

fmt = check_fs(fs, bsect = 0);/* Check sector 0 as an SFD format */
if (fmt == 1) {/* Not an FAT boot record, it may be patitioned */
/* Check a partition listed in top of the partition table */
tbl = &fs->win[MBR_Table + LD2PT(vol) * 16];/* Partition table */
if (tbl[4]) {/* Is the partition existing? */
bsect = LD_DWORD(&tbl[8]);/* Partition offset in LBA */
[color=#f00]fmt = check_fs(fs, bsect);/* Check the partition */[/color]
if (fmt == 3) return FR_DISK_ERR;
[color=#00c]if (fmt || LD_WORD(fs->win+BPB_BytsPerSec) != SS(fs))/* No valid FAT patition is found */
return FR_NO_FILESYSTEM;[/color]

The line in red returns me fmt=2 so later in the blue line it finds that the partition is not valid.

checl_fs is in here:

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 */
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 ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146)/* Check "FAT" string */
return 0;
if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146)
return 0;

return 1;

I would extremely apreciate any kind of help,

Thank you very much !