can't call fopen using RTOS threads

02 Mar 2012

Whenever I try to use fopen to read a file from the USB filesystem, while using RTOS threading, the mbed immediately goes to siren lights.

I would use the internal filesystem, but I need to stream audio, and when I used fopen on a file on the internal filesystem, the program would just hang. If there is a workaround to either problem, please let me know.

Thanks

07 Mar 2012

Hi Alexander, could you publish an example program presenting the issue?

I can not understand which is the "USB filesystem" you are talking about. (there are a couple of candidate libraries).

Anyway, we reproduced a similar issue with the "SDFileSystem + FATFileSystem".

It turns out that the call stack for these libraries is pretty deep.

The stack of the thread writing to the file system has to be set about 2.25 times the default stack size:

Thread t(sd_thread, NULL, osPriorityNormal, (DEFAULT_STACK_SIZE * 2.25));

This is an example program with such a thread:

Import programSDThread

Simple RTOS example with a thread writing to an SD card, requiring custom stack size

Let me know if increasing the stack size resolves your problem.

Cheers, Emilio