Skip to main content
fabio239955
Associate II
March 2, 2023
Question

fx_file_open does not work from a different thread

  • March 2, 2023
  • 4 replies
  • 1411 views

I have an application using STM32L475, threadx, filex.

Functions in the filex API work well when called from a specific thread: the same thread that initialized and mounted the file system. If I call the same functions from a different thread, the system crashes.

I have seen the calls to FX_PROTECT and it looks like the filex API should be working across multiple threads, however, something is not working here.

However the documentation does not tell much.

Just asking if someone has encounterd the same problems I have.

4 replies

Haithem Rahmani
ST Employee
March 5, 2023

Ciao @fabio239955​,

Could you please share the code snippet how the 2 threads are using the FileX API?

regards

Haithem.

DmitryR
Associate III
November 11, 2024

Hi Fabio,

 

first of all you should make sure that the FileX is not configured as single-threaded, i.e. that FX_SINGLE_THREAD is not defined.

 

Regards,

Dmitry

Associate
January 29, 2025

I'm having the same exact issue.

I'm calling fx_file_create from a thread that is different from the one that mounted the file system. The system crashes on FX_PROTECT, trying to lock the mutex.

No issues when the same function is called within the thread that initialized the fs.

FX_SINGLE_THREAD is disabled by CubeMX.

Help needed.

Associate
January 29, 2025

I've just found the solution. Increase the stack size of the thread where you are calling FILEX functions (in my case at least to 2048 bytes).