SDK fatfs_usdcard not working with 2gb cards

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SDK fatfs_usdcard not working with 2gb cards

1,332 Views
mspenard603
Contributor IV

Hi All,

 I'm using NXP's SDK example project fatfs_usdcard. It does not seem to be working with 2gb SD cards. Others have posted similar issues with the LPC's SDK but there is no reported solution: https://community.nxp.com/thread/416897


The issue is not with the card, as multiples have been tried new out of box. And they function correctly in Windows.

Specifically, when issuing a f_mount() command it fails with FR_NO_FILESYSTEM. Drilling down further it is find_volume() that is unable to find a partition. 

From find_volume():

/* Find an FAT partition on the drive. Supports only generic partitioning rules, FDISK and SFD. */
bsect = 0;
fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT-VBR as SFD */
if (fmt == 2 || (fmt < 2 && LD2PT(vol) != 0)) { /* Not an FAT-VBR or forced partition number */
for (i = 0; i < 4; i++) { /* Get partition offset */
pt = fs->win + (MBR_Table + i * SZ_PTE);
br[i] = pt[PTE_System] ? ld_dword(pt + PTE_StLba) : 0;
}
i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced */
if (i != 0) i--;
do { /* Find an FAT volume */
bsect = br[i];
fmt = bsect ? check_fs(fs, bsect) : 3; /* Check the partition */
} while (LD2PT(vol) == 0 && fmt >= 2 && ++i < 4);
}
if (fmt == 4) return FR_DISK_ERR; /* An error occured in the disk I/O layer */
if (fmt >= 2) return FR_NO_FILESYSTEM; /* No FAT volume is found */

Drilling down further it is check_fs() that returns 2. Meaning it found a BS, but not a FAT one, despite there really being a FAT filesystem.

from check_fs()

if (fs->win[BS_JmpBoot] == 0xE9 || fs->win[BS_JmpBoot] == 0xEB || fs->win[BS_JmpBoot] == 0xE8) { /* Valid JumpBoot code? */
if (!mem_cmp(fs->win + BS_FilSysType, "FAT", 3)) return 0; /* Is it an FAT VBR? */
if (!mem_cmp(fs->win + BS_FilSysType32, "FAT32", 5)) return 0; /* Is it an FAT32 VBR? */
}
return 2; /* Valid BS but not FAT */

The bytes associated with the filesystem types are the index positions as follows:

#define BS_FilSysType 54 /* Filesystem type string (8-byte) */

#define BS_FilSysType32 82 /* FAT32: Filesystem type string (8-byte) */

However, when inspecting what fs->win contains at runtime these positions are 0s.

This issue does not occur when I move up to a 4GB SD card. And every great once in a while a 2GB card will return with a valid FAT. Indicating, perhaps, the issue doesn't lie with ff.c but the lower level NXP driver fetching bits via SPI ... ???

Labels (1)
0 Kudos
2 Replies

1,061 Views
lonlypan
Contributor I

I'm having this issue too.My solution is:

 

formatted my sdcard ,File system set as FAT32,Allocation unit size set as default,and it is well。

f_mount error.png

0 Kudos

1,061 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Mike Spenard

Do your SD cards support the "SDHC standard"? According to Reference Manual, the RT105x uses the uSDHC module that supports the SD Host Controller Standard Specification version 2.0/3.0. I believe that 2gb memories use the "SD standard" (Up to 2GB SD memory card using FAT 12 and 16 file systems).


Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

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

0 Kudos