NOTICE: This website will be shut down in the near future. Product content has moved to nxp.com. Forum content and FAQs have been moved to community.nxp.com. We encourage you to create a user account on nxp.com to use the new community forums and access NXP microcontroller content. We greatly appreciate your contributions and look forward to seeing you at our new web location.

 

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

4 replies [Last post]
sipel_tp
Offline
Joined: 2012-05-18
Posts: 45

[i]
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:
[/i]
---------------------------------------------------------------------------------------
en_Mci_CardType cardType;
uint32_t i,j;
BYTE buffer[64];
FRESULT result;
static FATFS fs;
FIL objectFIL;

memset(buffer, 0, 64);

disk_initialize(0);

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 */
fmt = check_fs(fs, bsect); /* Check the partition */
}
}
if (fmt == 3) return FR_DISK_ERR;
if (fmt || LD_WORD(fs->win+BPB_BytsPerSec) != SS(fs)) /* No valid FAT patition is found */
return FR_NO_FILESYSTEM;

----------------------------------------------------------------------------------------------------------------------------

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:

--------------------------------------------------------------------------------------------------------------------
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 (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 !

0
Your rating: None

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
f_roozdar
Offline
Joined: 2014-01-24
Posts: 1

Hi
What is the output of disk_initialize() function?

nigude
Offline
Joined: 2014-08-31
Posts: 1

I am facing exactly same issue while working on LPC2478. Any help ? The Disk initialize function works well.

siangming
Offline
Joined: 2014-10-28
Posts: 13

Hi all,

i am also using this FATFs library on my LPC11u37H via the SPI interface.

the disk_initialize() function is ok also... able to detect SD card ver 2.. Communicating with the sdcard also seems ok, with the commands (reset, read etc) all going to the card and the card responding correctly (R1 responses and able to read data from card..)..

When i try to f_mount and f_open the card, i get a FR_NO_FILESYSTEM return.. and it is exactly the same problem with threadstart above where:

........................
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 */
fmt = check_fs(fs, bsect); /* Check the partition */
}
}
if (fmt == 3) return FR_DISK_ERR;
if (fmt || LD_WORD(fs->win+BPB_BytsPerSec) != SS(fs)) /* No valid FAT patition is found */
return FR_NO_FILESYSTEM;

----------------------------------------------------------------------------------------------------------------------------

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:

--------------------------------------------------------------------------------------------------------------------
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 (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;
}
--------------------------------------------------------------------------------------------------------------------------------------------------

.......................
the return of 2 is the result of above BOLD statement where the record signature (0xAA55) is not found...

i formatted my sdcard but i got the same result...

Anyone can help? i do not have a second card to try out...

thank you.

MikeSimmonds
Offline
Joined: 2012-09-18
Posts: 591

To all of you.

Can your windoze or linucks boxes read the card (via a card reader adapter)?

Maybe the card really is not formatted properly.

Apart from that, I know sod all about SD cards.

Mike

Old programmers never die. They go into infinite recursion.

Old programmers never die. They go into infinite recursion.

feedback