2022-08-17 09:12 AM
Hi, I tried the example on formatting the sdcard and it works (https://www.youtube.com/watch?v=I9KDN1o6924).
How do I implement this with TouchGFX? I set everything the same and mount the SD card (f_mount), but the next command is no longer executed (f_mkfs) and the system stops working. I tried to compare the settings and everything is the same. Can anyone think of anything? Thank you
2022-08-17 12:04 PM
What's the actual error returned, by either FATFS or the DISKIO layer?
Getting some overrun? Caching Issue? Polled? DMA? IRQ Handler?
I'm not watching a video to unpack what you've implemented.
Which STM32?
I'd avoid f_mkfs, and frankly and write command, until you've debugged the issue.
Cards come optimally formatted, with awareness of the underlying block erase size of the array. I'd avoid reformatting cards unless you've irreparably trashed the file system data.
2022-08-17 12:11 PM
f_mkfs is a very time consuming operation if you are using a large SD card, it can be in the order of a few seconds (even using 4-bit mode with DMA on a 128GB card)... this should only need to be done once to format the drive and can then be omitted.
If you are running this on the same task as TouchGFX then it would probably lock up for a while, and maybe not recover. Also check the task stack size, if you are using FatFS and TouchGFX in the same task you may need to increase this.
Aside from that more information is required, do you end up in a fault handler? If you pause execution where is the code getting stuck? Maybe confirm interrupt priorities are as they should be.
Anthony
2022-08-18 07:47 AM
the code needs to be put in the task. Either to the DefaultTask or to the one specially created for the sd card.
JN
2022-08-18 09:15 AM
Well none of the peripherals, card or file system are multi-thread/task safe, so yes do the processing end-to-end in one task/thread, or arbitrate ownership via a mutex or semaphore.