cancel
Showing results for 
Search instead for 
Did you mean: 

Use FATS in non-blocking mode without OS

gaetanbusson
Associate II
Posted on September 21, 2016 at 08:37

Hi!

I'd like to use FATFS functionalities in my code (I don't use any OS). I tried to use FATS middleware generated by the cube but it only works when I disable my watchdog. I have seen that only blocking functions such as HAL_SD_ReadBlocks or HAL_SD_WriteBlocks are used in FATFS and that is why it's not working for me. Is there a kind of FATFS that would be working like the standalone version of LWIP?

#fatfs-non-blocking
3 REPLIES 3
Walid FTITI_O
Senior II
Posted on September 21, 2016 at 16:11

Hi Gates,

It seems like you have a speed or/and interrupt priorities configuration problem(s) . Make sure that you are selecting ''the 4 bits wide bus mode for SDIO'' on STM32cubeMx.

Set the SDIO_IRQn the highest priority (value 0).

I recommend, also, that you check the user Manual

http://www.st.com/content/ccc/resource/technical/document/user_manual/10/c5/1a/43/3a/70/43/7d/DM00104712.pdf/files/DM00104712.pdf/jcr:content/translations/en.DM00104712.pdf

''STM32CubeMx for STM32 configuration and initialization C code generation --> part ''7. Tutorial 2 - Example of FatFs on an SD card using STM32429I-EVAL evaluation board

Otherwise, share with us your .ioc file to help you more.

-Hannibal-
Posted on September 22, 2016 at 01:32

I would tend to push the FATFS/SDIO into it's own thread, without an OS one could do this by having that in the main loop, and doing other work in IRQ Handlers to manage buffers/queues which are then consumed in the loop.

Building a non-blocking, asynchronous type, IO stack is a non-trivial exercise, and I'm not sure FATFS was built to fit well into such a system, it is a much flatter/simpler implementation.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
gaetanbusson
Associate II
Posted on September 23, 2016 at 09:19

Thank you for replying.

The tutorial you are talking about is the one I tested. I just removed LED code lines because I am not using an eval board. The watchdog reset happen when it tries to format the SD card (with f_mkfs function). If I comment this line everything is working but I wonder if a watchdog reset could happen again if I try to read/write something bigger than a simple ''Hello world'' string in my real code. You will find attached the IOC of my board.