Terminating a thread that is using f_write() from FatFS

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
hazelnusse
Posts: 77
Joined: Thu May 24, 2012 8:01 am

Terminating a thread that is using f_write() from FatFS

Post by hazelnusse »

I have a thread that is running a loop at 200Hz and in that loop it periodically calls f_write(). This is the only thread to use any of the FatFs calls, and this thread has the highest priority. While the thread is running, the system is responsive (the shell works). When I invoke a shell command to stop this thread, following the recommendations of [0], the shell becomes unresponsive and the system gets stuck in the idle thread. Using a debugger, I was able to determine that chThdWait() never returns, and this is why the shell thread remains blocked. If remove the calls to f_write(), this problem goes away and the thread terminates just fine. Is there something I should be doing differently when terminating this thread?

[0] -- http://www.chibios.org/dokuwiki/doku.ph ... os:stop_os
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Terminating a thread that is using f_write() from FatFS

Post by Giovanni »

Hi,

Which chThdWait() exactly?

Anyway, apparenly the problem is that FatFS does not include code for aborting I/O functions, you could reset that semaphore after requesting the termination of the thread but the behavior of FatFs after such reset must be assessed.

Giovanni
Post Reply