lpcware

LPC1114 FR_NO_FILESYSTEM

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by JuliaJ on Mon Nov 09 09:12:20 MST 2015
Hello everyone.

I have LPC1114 opening, reading, writing to "ordinary" sd card using FatFs lib. Everything is fine until I try to use EyeFi sd card. It is a card which lets to download files from card via wifi to your computer, it looks like ordinary sd card, and to my understanding should behave like sd card.
But, when I use EyeFi card - file opening crashes with error FR_NO_FILESYSTEM.
The complete code I am using can be found here LPC1114

So here is a sequence which leads to error:
1.  f_open
res = f_open (&fil, "info.dat", FA_READ | FA_WRITE | FA_CREATE_NEW);


2. inside it we go to chk_mounted
res = chk_mounted(&path, &dj.fs, (BYTE)(mode & (FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)));


3.inside it we go to check_fs
fmt = check_fs(fs, bsect = 0);/* Check sector 0 as an SFD format */

its actualy interesting here, because it works fine, it returns 1 - which is ok. (why this is interesting, at least to me, I will explain in the next step.)
here is a code of check_fs
/*-----------------------------------------------------------------------*/
/* Load boot record and check if it is an FAT boot record                */
/*-----------------------------------------------------------------------*/

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 */
)
{
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 */
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;
}


4.after check_fs finished well here comes this code:
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 */
fmt = check_fs(fs, bsect);       /* Check the partition */
}
}

we get inside and get to line
 fmt = check_fs(fs, bsect); 

which at this point is the same call of function check_fs as we had before (bsect=0)
and here comes the strange thing, when we get inside the check
if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55)/* Check record signature */
return 2;
fails i.e. there is no 55AA record signature at appropriate indexes, BUT it was there when the function was called (debugged it and saw it with my own eyes).

So, somehow, between the function check_fs call and checks performed inside it, record signature has gone ((( That is awkward. With "ordinary" - just normal sd card - this processes finishes as it should, no errors and record signature is at its place.

Getting back to place where I said it was interesting to me. How come first check_fs finishes well and second (subsequent) fails?

Any ideas?

I suppose that this may have to do smth with the fact that EyeFi sd card is something more than just sd card. But since it doesnt fail right away (at first check_fs) and there is a fat system inside - I dont see why its not working.

EyeFi card: FAT32, 8Gb.

In addition, after I got FR_NO_FILESYSTEM I tried to run
res = f_mkfs(0, 0, "0:");

to make file system (since there is no one according to error).
It fails as well inside disk_write function when trying to write partition table.

I have checked a lot in the web regarding the same error FR_NO_FILESYSTEM, but nothing I have found helped (tried to play with #define _CODE_PAGE in ffcong.h - nothing changed).

I am stuck. I would really appreciate any help. Thanks.

Outcomes