This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM3352: FATFS thread-safety

Part Number: AM3352

Dear TI support team,

I use an AM3352 device with TI RTOS and I sometimes have problems with file system corruption.
The device runs
- 1st stage bootloader (-> StarterWare bootloader)
- 2nd stage bootloader (-> decides whether to jump into an existing application or into a firmware update application)
- firmware update app or application

The system features an eMMC which usually works fine (f_read, f_write, f_mkdir, f_unlink, f_stat).
But in some cases the file system gets corrupt which leads to unaccessible files and therefore the system may not boot anymore (depends on the affected files).

I have checked the FATFS files (ffconf.h) and it looks like the 're-entrancy' feature is disabled by default:
#define _FS_REENTRANT    0

Because our application reads and writes (different!) files from different tasks (in which a FATFS function may be interrupted by itself in another task), I assume that there may be a problem with re-entrancy.
Can you please confirm if the TI RTOS FATFS implementation for AM335x is thread-safe/allows re-entrancy or not?

Toolchain:
- PDK 1.0.10
- SYS/BIOS 6.52.0.12

Thank you,
Markus

  • Is anyone working on this yet?
    If so, please post a short response.

    Thank you,
    Markus

  • Hi Markus,

    I apologize for the delayed response. I'm looking further into this and discussing it with the software team. I will try and have an answer to you by Friday.

    Thanks,

    Max

  • Hi Markus,

    The FATFS code is open source from the below location.

    elm-chan.org/.../config.html

    It supports re-entrancy, but by default, we do not use the feature by DEFAULT (We set the flag _FS_REENTRANT to zero by default) and do not test it.

    Thanks,

    Max

  • Hello Max,

    thank you for the information.

    If the REENTRANT option is enabled by setting the flag "_FS_REENTRANT" to 1, FATFS requires me to define the symbol "_SYNC_t" and 4 functions (ff_cre_syncobj, ff_del_syncobj, ff_req_grant, ff_rel_grant).
    Are there any templates available in TI RTOS on how to do this?
    (I have found a syscall.c file in the directory "starterware\library\third_party\ff9b\src\option" but it looks like it is the original template from FATFS)

    If there are no TI RTOS templates available: What solution would you suggest?
    For example, is it possible to use the TI RTOS Semphore type for this procedure or would you suggest an other type (mutex etc.)?

    Kind regards,
    Markus

  • Hi Markus,

    We unfortunately don't have any templates on how to use re-entrancy with FATFS.

    In ff.c, there is a struct "FILESEM" which may be used to lock and unlock files.

    Additionally TI has RTOS supported semaphores in our osal libraries, specifically SemaphoreP_tirtos.c

    Thanks,

    Max