Difference between revisions of "ROMFS"

From uGFX Wiki
Jump to: navigation, search
(Created page with "The ROMFS is used to store files in the flash of your target system. The file system (the files and folders it contains) are listed in a file called romfs_files.h which you ha...")
 
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
The ROMFS is used to store files in the flash of your target system. The file system (the files and folders it contains) are listed in a file called romfs_files.h which you have to provide yourself.
+
ROMFS is used to store files in the flash (or anywhere else) of your target system. The file system (the files and folders it contains) are listed in a file called <code>romfs_files.h</code> which you have to provide yourself.
All files you want in your ROMFS must be converted into a C header file which then is #include'd into ''romfs_files.h''. This is done using the '''file2c''' program which is part of the µGFX repository. It can be found under ''/tools/file2c'' and it comes with precompiled binaries for Linux and Windows. However, note that we do not take any responsibility for the binaries, use them on your own risk!
+
All files you want in your ROMFS must be converted into a C array which then is #include'd into <code>romfs_files.h</code>. This is done using the <code>file2c</code> program which is part of the µGFX repository. It can be found under <code>/tools/file2c</code> and it comes with precompiled binaries for Linux and Windows. However, note that we do not take any responsibility for the binaries, use them on your own risk!
  
 
Let's take a look at the usage of file2c:
 
Let's take a look at the usage of file2c:
Line 18: Line 18:
 
./file2c -dcs image.gif image.h
 
./file2c -dcs image.gif image.h
 
</pre>
 
</pre>
A simple ''romfs_file.h'' looks like the following:
+
A simple <code>romfs_file.h</code> looks like the following:
 
<syntaxhighlight lang=c>
 
<syntaxhighlight lang=c>
 
/**
 
/**
  * This file contains the list of files for the ROMFS.
+
  * This file contains the list of files for ROMFS.
 
  *
 
  *
 
  * The files have been converted using...
 
  * The files have been converted using...
Line 30: Line 30:
 
#include "image3.h"
 
#include "image3.h"
 
</syntaxhighlight>
 
</syntaxhighlight>
The ROMFS does not provide directory handling as this would bloat. However, you can create a directory hierarchy yourself by changing the file names. For example, instead of ''myFile.h'' you can name it ''dir1/dir2/myfile.h''.
+
The ROMFS does not provide directory handling as this would bloat. However, you can create a directory hierarchy yourself by changing the file names. For example, instead of <code>myFile.h</code> you can name it <code>dir1/dir2/myfile.h</code>.
 +
 
 +
 
 +
 
 +
 
 +
[[Category:GFILE]]

Latest revision as of 18:02, 23 August 2021

ROMFS is used to store files in the flash (or anywhere else) of your target system. The file system (the files and folders it contains) are listed in a file called romfs_files.h which you have to provide yourself. All files you want in your ROMFS must be converted into a C array which then is #include'd into romfs_files.h. This is done using the file2c program which is part of the µGFX repository. It can be found under /tools/file2c and it comes with precompiled binaries for Linux and Windows. However, note that we do not take any responsibility for the binaries, use them on your own risk!

Let's take a look at the usage of file2c:

file2c [-dbcs] [-n name] [-f file] [inputfile] [outputfile]
        -?      This help
        -h      This help
        -d      Add a directory entry for the ROM file system
        -b      Break the arrays for compilers that won't handle large arrays
        -c      Declare as const (useful to ensure they end up in Flash)
        -s      Declare as static
        -n name Use "name" as the name of the array
        -f file Use "file" as the filename in the ROM directory entry

Any binary can be converted to a C-Header file using the following command. In this example we convert a GIF image. Note that the file will not be image decoded, the binary information is just expressed as a C-Array so we can include it into our project.

./file2c -dcs image.gif image.h

A simple romfs_file.h looks like the following:

/**
 * This file contains the list of files for ROMFS.
 *
 * The files have been converted using...
 * 		file2c -dcs infile outfile
 */
#include "image1.h"
#include "image2.h"
#include "image3.h"

The ROMFS does not provide directory handling as this would bloat. However, you can create a directory hierarchy yourself by changing the file names. For example, instead of myFile.h you can name it dir1/dir2/myfile.h.