Arm Mbed OS support forum

Reading SD card on a PC

I have successfully implemented the MBED SD card example (mbed-os-example-sd-driver) on an NXP LPC54114 with an added Sparkfun SD card holder. The example program successfully writes to the card and then reads the created file. The problem is, the SD card is then no longer readable by my Windows PCs (I tried several, both Win 7 and Win 10). Each time the PC wants to reformat the card. I allow this and follow the recommended settings in the SD card example (FAT32, 4096 cluster size, Quick Format.) Of course the data on the SD card is now unreadable by the PC. I have verified this issue with multiple SD cards of different sizes from Kinston and SanDisk.

On rerunning the SD card program on the MBED board, I get the following errors:

lfs error:494: Corrupted dir pair at 0 1
lfs error:2222: Invalid superblock at 0 1
lfs error:494: Corrupted dir pair at 0 1
lfs error:2222: Invalid superblock at 0 1
Mounting the filesystem… No filesystem found, formatting… done.

As noted in the last line, the card is now reformatted and works on the MBED board. So really the big question is, how do I format the SD card or configure the MBED SD card example, so that the card is readable by both Windows and the MBED board?

Hello,

usually is good to share with us some informations about Mbed OS version, about a tool what you use and share a link of the example what you tried.

I found this one what is based on LittleFileSystem and the documentation says

For storage on an SD card that is accessible from a PC, use the FATFileSystem due to its portability.

That is probably the reason.

BR, Jan

Jan:

Thank you for your comments. I’m using a downloaded version of the MBED OS, version is 5.14.1, on the online compiler. The code I am using is the one you linked above, based on the LittleFileSystem. I did not see the comment on using the FatFileSystem instead and will try that.

Thanks again.

Just an update – I have confirmed that using the FATFileSystem instead of the LittleFileSystem works and the SD card is now readable on my PC.

Thanks again for the help,

Patrick

@pleonhardt
LittleFileSystem is not really widespread. On desktops you have to install some tools (like this one) to gain access to the card.

If your end-users are on desktop systems the best choice is to stick with FATFileSystem.