MQX MFS FAT32 support for SD Cards larger than 2G

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

MQX MFS FAT32 support for SD Cards larger than 2G

Jump to solution
2,485 Views
johnmccollin
Contributor II

I have a custom board which uses a Kenetis K64 processor and has an SD card for recording data. 

The firmware has been developed using KDS_V3 and KSDK_1.3.0 and I am using the MQX OS and MFS to provide a filing system. The design of the SD card interface is identical to the FRDM-K64 board so I am using the mfs_frdmk64f project as the basis for the file system firmware.

The application records data to a 32GB SD card which has been formatted as FAT32. Individual files can be up to 100MB.

Everything works correctly until the total disk space used reaches 2GB at which point the open and write functions fail. 

My understanding is that although individual files cannot be larger that 2GB, FAT32 should support disks much bigger than this. I haven't been able to find any documentation which states the limits but I would like to understand if this is a bug in MFS and, if so, are there any patches I can apply to correct it.

Thank you in advance.

0 Kudos
Reply
1 Solution
2,464 Views
johnmccollin
Contributor II

Thank you very much for your replies.

I believe I have managed to get this to work by finding all the instances of lseek and making sure that the parameters and return variables are defined as off_t which I have typedefed as int64. In many places mfs used int32s which only has a positive range of 2G so hopefully that was the cause of my problems.

Anyway, I have managed to write a file beyond the 2G boundary and I have been able to read that file on my PC. I now need to let my test run and make sure I don't hit any other limits.

Again thank you for your help, I will check out FatFs as an alternative going forward.

 

View solution in original post

0 Kudos
Reply
4 Replies
2,465 Views
johnmccollin
Contributor II

Thank you very much for your replies.

I believe I have managed to get this to work by finding all the instances of lseek and making sure that the parameters and return variables are defined as off_t which I have typedefed as int64. In many places mfs used int32s which only has a positive range of 2G so hopefully that was the cause of my problems.

Anyway, I have managed to write a file beyond the 2G boundary and I have been able to read that file on my PC. I now need to let my test run and make sure I don't hit any other limits.

Again thank you for your help, I will check out FatFs as an alternative going forward.

 

0 Kudos
Reply
2,451 Views
danielchen
NXP TechSupport
NXP TechSupport

@johnmccollin  welcome, glad to hear it can work on your side.

 

Regards

Daniel

0 Kudos
Reply
2,473 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi @johnmccollin :

 

Not sure but you can  refer to my attached file, try to merge them to your project.

 

Regards

Daniel

0 Kudos
Reply
2,481 Views
myke_predko
Senior Contributor III

@johnmccollin 

I played around with the MQX SD Card drivers (8??) years ago when I first started designing the Jade Robot and ending up ditching it because there were too many issues with size being a big one.  I did port the then current version of FatFs to MQX and it worked quite well but didn't end up going with it as I could use the Flash built in the Kinetis as its file system media (with a custom written file system driver).  

I don't know how many updates have been made in the example driver, but I can't imagine there have been too many and for that reason, I'd recommend that you implement the generic FatFs code (FatFs - Generic FAT Filesystem Module) like I did.  It's highly configurable and quite reliable (and supported for questions).

myke

0 Kudos
Reply