# romFS or read-only RAM/ROM disk

**URL:** <https://forums.freertos.org/t/romfs-or-read-only-ram-rom-disk/6072>\
**Category:** Kernel\
**Created:** [July 25, 2016, 8:06am UTC](https://forums.freertos.org/t/romfs-or-read-only-ram-rom-disk/6072 "2016-07-25T08:06:45Z")\
**Posts on this page:** 6\
**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:** [July 25, 2016, 8:06am UTC](https://forums.freertos.org/t/romfs-or-read-only-ram-rom-disk/6072/1 "2016-07-25T08:06:45Z")

</div>

**[rasty1](https://sourceforge.net/u/rasty1/)** wrote on [Monday, July 25, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/006045df/#e795):

Hi,  
I’m curious if someone tried (or can suggest any tool or ide) to create an image of RAM/ROM-disk that can be mounted by freeRTOS fs.  
I’d like to create a disk image with files (for Web server) on my host and statically link it to application code.

Thanks  
Rasty

---

<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:** [July 25, 2016, 9:42am UTC](https://forums.freertos.org/t/romfs-or-read-only-ram-rom-disk/6072/2 "2016-07-25T09:42:38Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Monday, July 25, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/006045df/#e795/74ac):

FreeRTOS+FAT is a standard FAT file system, so any FAT image should  
work. However I use a simpler approach whereby I create C structures  
from the files I want on the disk, then during initialisation just copy  
those structures onto the disk. You can see this being done in the  
Win32 demo, where a RAM disk is created then the files from the  
\FreeRTOS-Plus\Demo\Common\FreeRTOS\_Plus\_TCP\_Demos\include\DefaultWebPages.h  
header file are copied onto the RAM disk. The bottom of the header file  
has the following structure that describes the files being copied.

```
const xFileToCopy_t xHTTPFilesToCopy[] =
{
	{ "freertos.html", sizeof( pcFreeRTOS_HTML_Data ), pcFreeRTOS_HTML_Data },
	{ "logo.jpg", sizeof( pcLogo_JPG_Data ), pcLogo_JPG_Data },
	{ "ftp.png", sizeof( pcFTP_PNG_Data ), pcFTP_PNG_Data }
};
```

I use a hex editor (hexedit) to create the structures - you just open  
the file in the editor, copy it to the clipboard, then save the  
clipboard as a C structure (which is one of the save options). It is  
just a byte for byte copy so I’m sure you could create a very simple  
script to do the same thing and thus have it automated.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 25, 2016, 11:37am UTC](https://forums.freertos.org/t/romfs-or-read-only-ram-rom-disk/6072/3 "2016-07-25T11:37:25Z")

</div>

**[rasty1](https://sourceforge.net/u/rasty1/)** wrote on [Monday, July 25, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/006045df/#cc6b):

Hi,  
I see what you do in demo, that is nice, but requires RAM disk and Flash - 2 times more memory. Plus I’m not able to make a small RAM-disk (separate thread).  
Under linux I’d create a virtual device, copy all files and dd’d it to a file, which can be converted to initilized C-array.  
Above metioned can be done in script.  
At run-time I’d just mount file system (RAM-disk) to that array.  
Unfortunately we work with Windows and I did not discover yet how to do the same.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [July 30, 2016, 12:24pm UTC](https://forums.freertos.org/t/romfs-or-read-only-ram-rom-disk/6072/4 "2016-07-30T12:24:55Z")

</div>

**[rasty1](https://sourceforge.net/u/rasty1/)** wrote on [Saturday, July 30, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/006045df/#bbb3):

Hi  
I found how to make an image of disk.  
Is there any example how to mount file system to something like:  
const char romfs[]={  
0xeb,0x3c,0x90,0x4d,0x53,0x44,0x4f,0x53,0x35,0x2e,0x30,0x00,0x02,0x01,0x06,0x00,0x02,0x00,0x02,0xc3,0x00,0xf8,0x01,0x00,0x3f,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x00  
,0x00,0x00,0x00,0x80,0x00,0x29,0x12…

Thanks  
Rasty

---

<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:** [July 30, 2016, 5:21pm UTC](https://forums.freertos.org/t/romfs-or-read-only-ram-rom-disk/6072/5 "2016-07-30T17:21:54Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Saturday, July 30, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/006045df/#bbb3/a01f):

This is not something I have every attempted to do, but presumably if  
you have suitable read and write functions, which no doubt would be very  
similar to the RAM disk read and write functions (which just see the  
disk as an array of bytes), then you could mount it in a very similar  
way to the RAM disk.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [August 2, 2016, 12:37pm UTC](https://forums.freertos.org/t/romfs-or-read-only-ram-rom-disk/6072/6 "2016-08-02T12:37:38Z")

</div>

**[rasty1](https://sourceforge.net/u/rasty1/)** wrote on [Tuesday, August 02, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/006045df/#d5f6):

it works.  
imdisk.exe -a -s 102400 -m a: -p “/fs:fat /q /y” -f romfs.img  
bin2h.exe -cimage\_size romfs \< romfs.img \> romfs.c

Used RAM disk code without “format”, probably need to put NULL into fnWriteBlocks in order to make it truely read-only.  
Tested 100Kb FAT12.
