1
0
mirror of https://github.com/elua/elua.git synced 2025-01-08 20:56:17 +08:00
elua/doc/en/arch_romfs.html

75 lines
5.8 KiB
HTML
Raw Normal View History

- doc folder replaced by some work done on Led Lab for the new doc and site - This should actually be a merge but we made a mistake on the initial repo creation and a merge was not possible. - Below there is a resumed log of the commit messages for the few steps, just for the record. - The merged commit messages for this work are: - Removing Portuguese doc content - Ignore folder names fixed on .gitignore - Removed doc files which content migrated to the CMS - docdata.lua updated accordingly - Doc build checked ok - Overall doc structure and contents still being refined - Removing folder cache from git versioning - Removing folder dist from git versioning. The folders above are generated by the buildall.lua script and are not part of the sources - Adding .gitignore file with objects info to inform git what to ignore - Removed file - Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git - Moving all files and folders to a working doc folder - Css updated - Index page added and CSS adjusts - Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git - Signed-off-by: Guilherme Sanchez <guilhermesanchezpacheco@gmail.com> - Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git - files deleted - Changed function that creates functions submenus. - Menu inserted with árvore, CSS adjusts, google search - Changed past design to new design - CSS updated - initial import - The commit ids were also preserved but they are related to this "other" work done on Led Lab. We'll keep the repo just in case. 4dce3f77c47b0c3001a2075a946e80ee52759b49 - Removing Portuguese doc content 78d8847525cacf045fe7e672cff6bd1e058a6a4b Ignore folder names fixed on .gitignore 48dee6b7962168ab1098bf709ead6f3cfe6b7964 - Removed doc files which content migrated to the CMS - docdata.lua updated accordingly - Doc build checked ok - Overall doc structure and contents still being refined 2aa2fe0c554db03dbc7029c34d0f4500fe625b37 - Removing folder cache from git versioning - Removing folder dist from git versioning The folders above are generated by the buildall.lua script and are not part of the sources - Adding .gitignore file with objects info to inform git what to ignore af6cc2890edf1855af319dc999a03feee5f9bee0 Removed file 6a180e72eb4f4860620cafc0685000e9f2174cfe Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git eb430112e78ae537459ab315e228ebca84bdf2d4 Moving all files and folders to a working doc folder d28a7c99489915630bd2625f3756fecf0d08ce37 Css updated 32836ffe382f04ab07c3e6f018c7b449a20d7a8d Index page added and CSS adjusts 1461d9957d9d25a1467cb57ab8717aa213a37e8d Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git ae1934c04f35a29e25bb4495ae8a31cd9c000b5b Signed-off-by: Guilherme Sanchez <guilhermesanchezpacheco@gmail.com> b5f31d70f1fac8d3fba325c9867a03f976775698 Merge branch 'master' of git@repos.giga.puc-rio.br:elua-doc.git ec9ad8446b7ea38b252c6a416e70774349835e45 files deleted bd7a80151b2030720ba8d8a303467d8c25a4b4b2 Changed function that creates functions submenus. 6a7494acaec694fadbb13520bcbccc51a6b95dfe Inserido menu com árvore, ajustes no CSS, busca do google e979f1c259d425c9a3be83f9cda20eddffe073bb Changed past design to new design. 381459e95286886b052103a0253e60b29e064d7a CSS updated 4f81d2f1195efe733fe5f97517be325d75937bc3 initial import
2011-05-06 06:49:21 -03:00
$$HEADER$$
<h3>The ROM file system</h3>
<p>The ROM file system (ROMFS) is a small, read-only file system built for <b>eLua</b>. It is integrated with the C
library, so you can use standard POSIX calls (fopen/fread/fwrite...) to access it. It is also accessible directly from Lua via the <b>io</b> module.
The files in the file system are part of the <b>eLua</b> binary image, thus they can't be modified after the image is
built. For the same reason, you can't add/delete files after the image is built. ROMFS doesn't support
sub-directories.</p>
<p>ROMFS is integrated with <a href="building.html">the build system</a> for maximum flexibility on various platforms. As a result, you can select the ROMFS contents for each board on which
<b>eLua</b> runs. Moreover, you can specify what <b>applications</b> (instead of individual files) go to the file system, as a real application might need more than a single Lua program
to run (for example a HTTP page with all its dependencies).</p>
<h2>Using ROMFS</h2>
<p>To use ROMFS, you have to copy the required files to the <i>romfs/</i> directory, before building eLua.
Keep in mind that the maximum file name of a ROMFS file is 14 characters, including the dot between the file
name and its extension. Make sure that the file names from <i>romfs/</i> follow this rule. Then edit the main build script (<b>SConstruct</b>) to add a new application
or to modify an existing one.
All the applications that can be included in ROMFS are defined in the <b>romfs</b> array in <b>SConstruct</b>. Each application in the <b>romfs</b> array lists its files, as shown below
(note that <b>ltthpd</b>, <b>tvbgone</b> and <b>pong</b> applications require more than one file in order to run):</p>
<p><pre><code>romfs = {
'bisect' : [ 'bisect.lua' ],
'hangman' : [ 'hangman.lua' ],
'lhttpd' : [ 'index.pht', 'lhttpd.lua', 'test.lua' ],
'pong' : [ 'pong.lua', 'LM3S.lua' ],
'led' : [ 'led.lua' ],
'piano' : [ 'piano.lua' ],
'pwmled' : [ 'pwmled.lua' ],
'tvbgone' : [ 'tvbgone.lua', 'codes.bin' ],
'hello' : [ 'hello.lua' ],
'info' : [ 'info.lua' ],
'morse' : [ 'morse.lua' ],
'dualpwm' : [ 'dualpwm.lua' ],
'adcscope' : [ 'adcscope.lua' ],
'life' : [ 'life.lua' ]
}</code></pre></p>
<p>After this, you need to decide the application-to-board mapping. This is defined in another array in <b>SConsctruct</b>, named <b>file_list</b>. The definition of this array is shown below,
the format is self-explanatory:</p>
<p><pre><code>file_list = {
'SAM7-EX256' : [ 'bisect', 'hangman' , 'led', 'piano', 'hello', 'info', 'morse' ],
'EK-LM3S8962' : [ 'bisect', 'hangman', 'lhttpd', 'pong', 'led', 'piano', 'pwmled', 'tvbgone', 'hello', 'info', 'morse', 'adcscope' ],
'EK-LM3S6965' : [ 'bisect', 'hangman', 'lhttpd', 'pong', 'led', 'piano', 'pwmled', 'tvbgone', 'hello', 'info', 'morse', 'adcscope' ],
'STR9-COMSTICK' : [ 'bisect', 'hangman', 'led', 'hello', 'info' ],
'PC' : [ 'bisect', 'hello', 'info', 'life' ],
'LPC-H2888' : [ 'bisect', 'hangman', 'led', 'hello', 'info' ],
'MOD711' : [ 'bisect', 'hangman', 'led', 'hello', 'info', 'dualpwm' ],
'STM3210E-EVAL' : [ 'bisect', 'hello', 'info' ],
'ATEVK1100' : [ 'bisect', 'hangman', 'led', 'hello', 'info' ],
'ET-STM32' : [ 'hello', 'hangman', 'info', 'bisect' ],
'EAGLE-100' : [ 'bisect', 'hangman', 'lhttpd', 'led', 'hello', 'info' ]
}
</code></pre></p>
<p>What's left to do is <a href="building.html">build eLua</a>. As part of the build process, <b>mkfs.py</b> will be called, which will read the contents of the <i>romfs/</i> directory and
output a C header file that contains a binary description of the file system. To use ROMFS from C code, whevener you want to access a file, prefix its name with <b>/rom/</b>. For example,
if you want to open the <b>a.txt</b> file in ROMFS, you should call fopen like this:</p>
<p><pre><code>f = fopen( "/rom/a.txt", "rb" )</code></pre></p>
<p>If you want to execute one file from the ROM file system with Lua, simply do this from the shell:</p>
<p><pre><code>eLua# lua /rom/bisect.lua</code></pre></p>
<p>Or directly from Lua:</p>
<p><pre><code>&gt; dofile "/rom/bisect.lua"</code></pre></p>
<a name="mode" /><h2>ROMFS modes</h2>
<p>Starting with version 0.7, the ROMFS can be added to the <b>eLua</b> binary image in 3 different ways:</p>
<ul>
<li><b>verbatim</b>: this is the default option. All the files are copied to the ROMFS directly, without any processing.</li>
<li><b>compress</b>: compress the Lua source code by using <a href="http://luaforge.net/projects/luasrcdiet/">LuaSrcDiet</a> (included in <b>eLua</b>), a program
that can decrease the size of a Lua source file by applying different transformations. Every
Lua source file (extension <b>.lua</b>) from ROMFS is fed through LuaSrcDiet and the result is written in the <b>eLua</b> binary image. This option can yield
pretty good compression, the only downside being that the compressed Lua source files aren't generally easily readable. However, this isn't really a problem in
most practical cases.</li>
<li><b>compile</b>: precompile the Lua source code to bytecode. Every Lua source file (extension <b>.lua</b>) from ROMFS is fed through the Lua cross compiler
(see <a href="using.html#cross">here</a> for details on cross compilation and its benefits) and the result is written in the <b>eLua</b> binary image. This option
might decrease or increase the physical size of the ROMFS image, but its real benefits are increased speed (because <b>eLua</b> doesn't need to compile the Lua
code to bytecode first) and decreased RAM consumption (the Lua parser might get quite memory-hungry at times, which in turn might lead to stack overflows and very
hard to find bugs). </li>
</ul>
<p>See <a href="building.html#buildoptions">here</a> for instructions on how to specify the ROMFS compilation mode.</p>
$$FOOTER$$