通过FATFS同时对多个文件写数据的问题

2019-12-21 12:12发布

我通过RT-Thread开了两个优先级相同的线程。在两个线程中分别用FATFS向U盘中写数据,也是写成两个不同的文件用的独立的文件句柄。数据是从DMA传来的,但是写数据的过程中发现f_write返回的是FR_INT_ERR错误。两个线程如果只开其中一个写数据是正常的,FATFS不能同时向多个文件写数据么。请问出现问题的原因在哪?谢谢。
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
3条回答
not_at_all
2019-12-21 21:11
配置文件有相关设置,下面的设了没有(ff13a )
  
第一项是重复打开操作同一个文件
第二项是FATFS的可重入

#define FF_FS_LOCK                0
/* The option FF_FS_LOCK switches file lock function to control duplicated file open
/  and illegal operation to open objects. This option must be 0 when FF_FS_READONLY
/  is 1.
/
/  0:  Disable file lock function. To avoid volume corruption, application program
/      should avoid illegal open, remove and rename to the open objects.
/  >0: Enable file lock function. The value defines how many files/sub-directories
/      can be opened simultaneously under file lock control. Note that the file
/      lock control is independent of re-entrancy. */


#define FF_FS_REENTRANT        0
#define FF_FS_TIMEOUT        1000
#define FF_SYNC_t                HANDLE
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
/  module itself. Note that regardless of this option, file access to different
/  volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
/  and f_fdisk() function, are always not re-entrant. Only file/directory access
/  to the same volume is under control of this function.
/
/   0: Disable re-entrancy. FF_FS_TIMEOUT and FF_SYNC_t have no effect.
/   1: Enable re-entrancy. Also user provided synchronization handlers,
/      ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
/      function, must be added to the project. Samples are available in
/      option/syscall.c.
/
/  The FF_FS_TIMEOUT defines timeout period in unit of time tick.
/  The FF_SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
/  SemaphoreHandle_t and etc. A header file for O/S definitions needs to be
/  included somewhere in the scope of ff.h. */

一周热门 更多>