# FreeRTOS+FAT use with and without the RTOS

**URL:** <https://forums.freertos.org/t/freertos-fat-use-with-and-without-the-rtos/6610>\
**Category:** Kernel\
**Created:** [June 12, 2017, 4:29pm UTC](https://forums.freertos.org/t/freertos-fat-use-with-and-without-the-rtos/6610 "2017-06-12T16:29:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 12, 2017, 4:29pm UTC](https://forums.freertos.org/t/freertos-fat-use-with-and-without-the-rtos/6610/1 "2017-06-12T16:29:17Z")

</div>

**[sachingole](https://sourceforge.net/u/sachingole/)** wrote on [Monday, June 12, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/430a7d2c/#d8c8):

Hi All,

This link [[http://www.freertos.org/FreeRTOS-Plus/FreeRTOS\_Plus\_FAT/index.html](http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/index.html)] says that

_FreeRTOS+FAT is an open source, thread aware and scalable FAT12/FAT16/FAT32 DOS/Windows compatible embedded FAT file system which was recently acquired by Real Time Engineers ltd. **for use with and without the RTOS**._

On my Nucleo board, when I have tried to create RamDisk before calling vTaskStartScheduler(); then it doesnt create RamDisk.

But when I have tried to create inside thread after vTaskStartScheduler() starts then RamDisk created successfully…

**1. Is there anything specific need to be done to create RamDisk without using vTaskStartScheduler inside thread ?  
2. Is FreeRTOS+FAT soruce is tightly coupled with FreeRTOS source code, Can we make compatible with other os or non-os platform.  
3. Can FreeRTOS+FAT used with other RTOS like ThreadX or VxWork?**

Best regards,  
Sachin

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [June 12, 2017, 5:03pm UTC](https://forums.freertos.org/t/freertos-fat-use-with-and-without-the-rtos/6610/2 "2017-06-12T17:03:26Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Monday, June 12, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/430a7d2c/#d8c8/ebfc):

The FAT library has to be ported to storage media, so the port layer is  
not really part of the FAT library itself, and I suspect the RAM disk  
(which works on any device with enough RAM) has a dependency on the RTOS

- although I’ve not checked to see if that is true. It may also be the  
case that the ‘without an RTOS’ claim is no longer valid.

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [June 12, 2017, 5:54pm UTC](https://forums.freertos.org/t/freertos-fat-use-with-and-without-the-rtos/6610/3 "2017-06-12T17:54:14Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Monday, June 12, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/430a7d2c/#ccd7):

Hi Sachin, as far as I remember, the only dependency is `ff_locking.c`.

If you’re a single user, you should make an empty version of each function:

```auto
BaseType_t FF_HasSemaphore (void *pxSemaphore)
{
	return 0;
}

BaseType_t FF_TrySemaphore( void *pxSemaphore, uint32_t ulTime_ms )
{
	return 1;
}
/*-----------------------------------------------------------*/

void FF_PendSemaphore( void *pxSemaphore )
{
}
/*-----------------------------------------------------------*/

void FF_ReleaseSemaphore( void *pxSemaphore )
{
}
/*-----------------------------------------------------------*/

void FF_Sleep( uint32_t ulTime_ms )
{
}
/*-----------------------------------------------------------*/

BaseType_t FF_CreateEvents( FF_IOManager_t *pxIOManager )
{
	return pdTRUE;
}
/*-----------------------------------------------------------*/

void FF_LockDirectory( FF_IOManager_t *pxIOManager )
{
}
/*-----------------------------------------------------------*/

void FF_UnlockDirectory( FF_IOManager_t *pxIOManager )
{
}
/*-----------------------------------------------------------*/

int FF_Has_Lock( FF_IOManager_t *pxIOManager, uint32_t aBits )
{
	return pdTRUE;
}

void FF_Assert_Lock( FF_IOManager_t *pxIOManager, uint32_t aBits )
{
}

void FF_LockFAT( FF_IOManager_t *pxIOManager )
{
}
/*-----------------------------------------------------------*/

void FF_UnlockFAT( FF_IOManager_t *pxIOManager )
{
}
/*-----------------------------------------------------------*/

BaseType_t FF_BufferWait( FF_IOManager_t *pxIOManager, uint32_t xWaitMS )
{
	return pdTRUE;
}
/*-----------------------------------------------------------*/

void FF_BufferProceed( FF_IOManager_t *pxIOManager )
{
}
/*-----------------------------------------------------------*/

```

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 12, 2017, 11:58pm UTC](https://forums.freertos.org/t/freertos-fat-use-with-and-without-the-rtos/6610/4 "2017-06-12T23:58:26Z")

</div>

**[sachingole](https://sourceforge.net/u/sachingole/)** wrote on [Monday, June 12, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/430a7d2c/#ec7d):

Hi Hein,

1. You are suggesting that if its one user means only main thread then it will be possible to create RamDisk with above mentioned empty functions for semaphore.

2. Is FreeRTOS+FAT soruce is tightly coupled with FreeRTOS source code, Can we make compatible with other os or non-os platform.  
But it is multi threaded system then it is coupled with FreeRTOS scheduler, right.

3. Can FreeRTOS+FAT used with other RTOS like ThreadX or VxWork?  
??

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [June 13, 2017, 5:35am UTC](https://forums.freertos.org/t/freertos-fat-use-with-and-without-the-rtos/6610/5 "2017-06-13T05:35:07Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Tuesday, June 13, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/430a7d2c/#30d2):

Hi Sachin,

The +FAT locking mechanism, as it has been implemented in `ff_locking.c`, is using FreeRTOS kernel API’s, notably mutexes and Event Groups.  
These functions have been put together in a single module, so that all other modules remain independent from the kernel.  
At least, that was the intention. But, through time, through the years, the library has been ( new verb ) : freertos-ised.

Also, the project got a nice extension: a new layer called `ff_stdio`. That module makes use of an `errno` that is local to a task.  
Each task can have 1 or more pointers for local storage.

I’m trying to compile a +FAT project that uses a RAM-disk with the FreeRTOS header files excluded, that is any of these files:

```auto
    //#include "FreeRTOS.h"
    //#include "task.h"
    //#include "semphr.h"
    //#include "portable.h"

```

Most modules do not miss a lot, mainly the following defines:

```auto
    /* Get the standard types like 'int32_t'. */
    #include <stdint.h>

    typedef long BaseType_t;
    typedef unsigned long UBaseType_t;

    #define pdFALSE ( ( BaseType_t ) 0 )
    #define pdTRUE ( ( BaseType_t ) 1 )

    #ifndef portINLINE
        #define portINLINE __inline
    #endif

    #ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS
        #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 3 /* FreeRTOS+FAT requires 2 pointers if a CWD is supported. */
    #endif

```

That is not too much.

Today I found a few more dependencies, two of them are locking mechanisms:

ff\_ioman.c is using :

```auto
    taskENTER_CRITICAL
    taskEXIT_CRITICAL

```

ff\_sys.c is using :

```auto
    vTaskSuspendAll
    xTaskResumeAll

```

ff\_stdio.c is using :

```auto
    vTaskSetThreadLocalStoragePointer
    pvTaskGetThreadLocalStoragePointer

```

Coming back to your questions:

> You are suggesting that if its one user means only main thread then it will  
> be possible to create RamDisk with above mentioned empty functions for semaphore.

Yes.  
Beside the locking mechanism there are 6 more functions that must be simulated, listed here above.

> If FreeRTOS+FAT source is tightly coupled with FreeRTOS source code, can we make  
> compatible with other os or non-os platform.

Yes you can.

> But if it is multi threaded system then it is coupled with FreeRTOS scheduler, right.

It will equally work together with another scheduler.

> Can FreeRTOS+FAT used with other RTOS like ThreadX or VxWork?

You can also use it with a different RTOS, provided that you implement the locking mechanisms with primitives from that RTOS.  
In case there is only a single user, things are a lot simpler.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 14, 2017, 7:45pm UTC](https://forums.freertos.org/t/freertos-fat-use-with-and-without-the-rtos/6610/6 "2017-06-14T19:45:16Z")

</div>

**[sachingole](https://sourceforge.net/u/sachingole/)** wrote on [Wednesday, June 14, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/430a7d2c/#3c2f):

Thanks Hein for your valueable response which has research included in it.

In summary :-

1. Intention was not to create +FAT which is independant than FreeRTOS, if taking as it is then it is not compatible with other OS but if someone want he can make it with single user.

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [June 15, 2017, 3:01am UTC](https://forums.freertos.org/t/freertos-fat-use-with-and-without-the-rtos/6610/7 "2017-06-15T03:01:25Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Thursday, June 15, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/430a7d2c/#41ca):

Sounds like a good summary, except that it is also possible to port +FAT to a different multi-tasking OS.

The FreeRTOS version of `ff_locking.c` is using both mutexes and event groups. If a different platform only has semaphores that is enough to create a reliable locking.

Regards
