romFS or read-only RAM/ROM disk

rasty1 wrote on Monday, July 25, 2016:

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

rtel wrote on Monday, July 25, 2016:

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.

rasty1 wrote on Monday, July 25, 2016:

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.

rasty1 wrote on Saturday, July 30, 2016:

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

rtel wrote on Saturday, July 30, 2016:

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.

rasty1 wrote on Tuesday, August 02, 2016:

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.