heinbali01 wrote on Wednesday, January 02, 2019:
I am not sure if Semaphores ( queues ) and Event Groups can be created safely before the kernel has been started?
Other API’s are not needed as long as the kernel does not run ( see here below ). Well, except for xEventGroupSetBits()
.
Can anyone comment on this please?
As far as I know, the FreeRTOS+FAT library needs the FreeRTOS kernel only in a few places.
Most importantly is the locking of the drive, of the FAT and of directory changes. Please have a look at ff_locking.c
.
Every FAT drive has a semaphore that protects against concurrent access to that drive from different tasks.
Also, every driver ( every I/O manager ) has an Event-Group that keeps track of temporary locks on the FAT and directory changes.
As long as the scheduler does not run, locking should not be necessary.
I’m thinking out loud: you could insert a statement in most of the functions:
void FF_PendSemaphore( void *pxSemaphore )
{
+ if( xTaskGetSchedulerState() != taskSCHEDULER_RUNNING )
+ {
+ return;
+ }
configASSERT( pxSemaphore );
xSemaphoreTakeRecursive( ( SemaphoreHandle_t ) pxSemaphore, portMAX_DELAY );
}
And avoid using Event Groups:
void FF_LockFAT( FF_IOManager_t *pxIOManager )
{
+ if( xTaskGetSchedulerState() != taskSCHEDULER_RUNNING )
+ {
+ return;
+ }
...
}
Another thing might be timeouts: if xTaskGetTickCount()
is used to limit actions, it will not work properly. But that is of later care.
I’m attaching a new version of ff_locking.c
that you can try out.