FreeRTOS+FAT slow write on 64GB eMMC and concurrency

***** Final update *****

At the risk of revealing to the world how little I know about clocking, here goes:

I had a chat with the FPGA engineer on our team and he found it incredibly strange that changing the frequency from 50MHz to 52MHz made the device fast all of a sudden. And after doing some reading, I was in agreement with him. So I reset the FPGA HW to what it was before; 50MHz clock going to SDIO instead of 52. And as expected, the eMMC was still fast. So the clock was not the issue.

In an attempt to understand what changed to make the device fast all of a sudden, I looked at my git diff. There was only a single line of code that had changed -

-        xError = FF_Format( pxDisk, PARTITION_NUMBER, pdTRUE, pdTRUE );
+        xError = FF_Format( pxDisk, PARTITION_NUMBER, pdFALSE, pdFALSE );

When I was setting up the formatting functionality in my program, I had copied the example usage from the FF_Format() documentation page. In the example, the variables xPreferFAT16 and xSmallClusters are both set to pdTRUE. I was being ignorant and didn’t pay attention to this. I made this change after Hein’s recommendation from a previous comment in this thread:

So yes, everything works as expected now and it was indeed a firmware issue and not an FPGA issue like I said before.

For anyone who cares, the f_mkfs function from the xilffs driver formats the drive to FAT32 and uses big clusters, which is why that example was working for me. And after running this example, when I switched back to running my project application, I initially didn’t do a re-format, which is why the writes I was doing there also sped up. Today I did a format using the FF_Format function with the parameters mentioned above and everything is still working fast as expected.

I hope that my experience with this will be of help to whoever goes through an issue like this.

1 Like