mirror of
https://github.com/elua/elua.git
synced 2025-01-25 01:02:54 +08:00
added a page about LTR in the docs; other pages updated with links to this new LTR patch
This commit is contained in:
parent
00ee06e90f
commit
27ffc016b7
@ -150,7 +150,17 @@ RAM) but will also completely remove the possibility of using that
|
||||
module from <b>eLua</b>.</p>
|
||||
<p>The modules included in the build are specified by the
|
||||
LUA_PLATFORM_LIBS_ROM macro. An example is given below: </p>
|
||||
<pre><code>#define LUA_PLATFORM_LIBS_ROM\<br> _ROM( AUXLIB_PIO, luaopen_pio, pio_map )\<br> _ROM( AUXLIB_TMR, luaopen_tmr, tmr_map )\<br> _ROM( AUXLIB_PD, luaopen_pd, pd_map )\<br> _ROM( AUXLIB_UART, luaopen_uart, uart_map )\<br> _ROM( AUXLIB_TERM, luaopen_term, term_map )\<br> _ROM( AUXLIB_PWM, luaopen_pwm, pwm_map )\<br> _ROM( AUXLIB_PACK, luaopen_pack, pack_map )\<br> _ROM( AUXLIB_BIT, luaopen_bit, bit_map )\<br> _ROM( AUXLIB_CPU, luaopen_cpu, cpu_map )\<br> _ROM( LUA_MATHLIBNAME, luaopen_math, math_map )</code></pre>
|
||||
<pre><code>#define LUA_PLATFORM_LIBS_ROM\
|
||||
_ROM( AUXLIB_PIO, luaopen_pio, pio_map )\
|
||||
_ROM( AUXLIB_TMR, luaopen_tmr, tmr_map )\
|
||||
_ROM( AUXLIB_PD, luaopen_pd, pd_map )\
|
||||
_ROM( AUXLIB_UART, luaopen_uart, uart_map )\
|
||||
_ROM( AUXLIB_TERM, luaopen_term, term_map )\
|
||||
_ROM( AUXLIB_PWM, luaopen_pwm, pwm_map )\
|
||||
_ROM( AUXLIB_PACK, luaopen_pack, pack_map )\
|
||||
_ROM( AUXLIB_BIT, luaopen_bit, bit_map )\
|
||||
_ROM( AUXLIB_CPU, luaopen_cpu, cpu_map )\
|
||||
ROM( LUA_MATHLIBNAME, luaopen_math, math_map )</code></pre>
|
||||
<p>Each module is defined by a <b>_ROM( module_name,
|
||||
module_init_function, module_map_array )</b> macro, where:
|
||||
</p>
|
||||
@ -165,7 +175,7 @@ functions and constants exported by a module</li>
|
||||
<p>Please note that this notation is specific to LTR (the <b>L</b>ua
|
||||
<b>T</b>iny <b>R</b>AM patch) and it's not the
|
||||
only way to specify the list of modules included in the build (although
|
||||
it is the most common one). Check the <a href="">##LTR
|
||||
it is the most common one). Check the <a href="arch_ltr.html#config">LTR
|
||||
section</a> for more information about LTR.</p>
|
||||
<p>For the full list of modules that can be enabled or disabled
|
||||
via <i>platform_conf.h</i> check <a href="">##the
|
||||
@ -304,7 +314,7 @@ very resource-constrained systems.
|
||||
this specifies the name of the toolchain used to build the image. See <a href="toolchains.html#configuration">this link</a> for
|
||||
details.</li>
|
||||
<li><b>optram=0 | 1</b>: enables of disables the
|
||||
LTR patch, see the <a href="">##LTR documentation</a>
|
||||
LTR patch, see the <a href="arch_ltr.html">LTR documentation</a>
|
||||
for more details. The default is 1, which enables the LTR patch.</li>
|
||||
<li><b>prog</b>: by default, the above 'scons'
|
||||
command will build only the 'elf' (executable) file. Specify "prog" to
|
||||
@ -347,4 +357,4 @@ CodeSourcery toolchain instead of the default toolchain (which is a
|
||||
"generic" ARM GCC toolchain, usually the one built by following
|
||||
the tutorials from this site</p>
|
||||
.
|
||||
</body></html>
|
||||
</body></html>
|
||||
|
@ -23,6 +23,8 @@ It is assumed that you already know what <b>eLua</b>, so here's a list of questi
|
||||
<li><a href="faq.html#bytecode">I know that Lua can be compiled to bytecode, so I compiled one of the eLua examples with luac and tried to run it on
|
||||
my eLua board, but it didn't work. Is this a bug in eLua?</li>
|
||||
<li><a href="faq.html#outofmemory">I get "out of memory" errors when I run my Lua programs, what should I do?</li>
|
||||
<li><a href="faq.html#rotables">I enabled the LTR patch, but now all my module tables (math, io, string, spi and so on) are read only. Do I have to
|
||||
disable LTR if I want write access to these modules?</a>
|
||||
</ul>
|
||||
<hr>
|
||||
|
||||
@ -123,7 +125,7 @@ prove just fine. It largely depends on your needs.</p>
|
||||
<p>There are a number of things you can try to overcome this:</p>
|
||||
<ul>
|
||||
<li><b>enable the LTR patch</b>: you can get very significant improvements if you enable the LTR patch in your <b>eLua</b> image. See
|
||||
<a href="">##here</a> for more details about LTR, and <a href="building.html">here</a> for instructions about enabling LTR.</li>
|
||||
<a href="arch_ltr.html">here</a> for more details about LTR, and <a href="building.html">here</a> for instructions about enabling LTR.</li>
|
||||
<li><b>precompile your source to bytecode</b>: if you use bytecode instead of source code Lua won't need to compile your source, so you save some RAM.</li>
|
||||
<li><b>try to avoid using too many strings</b>: strings are immutable in Lua. That means that a statement like <i>s = s .. "\n"</i> (where s is a string)
|
||||
will create a new string each time it's called. If this happens a lot (for example in a loop), your memory will quickly run out because of all the
|
||||
@ -132,4 +134,17 @@ prove just fine. It largely depends on your needs.</p>
|
||||
<li><b>control Lua's garbage collection manually</b>: if you're still running out of memory, try calling <i>collectgarbage('collect')</i> from your code,
|
||||
which will force a garbage collection and thus might free some memory.</li>
|
||||
</ul>
|
||||
|
||||
<a name="rotables"><h2>I enabled the LTR patch, but now all my module tables (math, io, string, spi and so on) are read only. Do I have to
|
||||
disable LTR if I want write access to these modules?</h2></a>
|
||||
<p>You don't really have to disable LTR to get write access to your rotables, you can use some simple Lua "tricks" instead. Let's suppose that you need
|
||||
write access to the <b>math</b> module. With LTR enabled, <b>math</b> is a rotable, so you can't change its keys/values. But you can use metatables
|
||||
to overcome this limitation:</p>
|
||||
<p><pre><code>local oldmath = math
|
||||
math = { __index = oldmath }
|
||||
setmetatable( math, math )
|
||||
</code></pre></p>
|
||||
<p>This way you can use <i>math</i> in "write mode" now (since it is a regular table), but you can still access the keys from the original <i>math</i>
|
||||
rotable. Of course, if you need write access to <b>all</b> your modules (or to most of them) it makes more sense to disable LTR instead, but from our
|
||||
observations this doesn't happen in practice.</p>
|
||||
</body></html>
|
||||
|
@ -495,7 +495,7 @@ difference between generic modules and platform specific modules, check
|
||||
<td style="text-align: center;"><img src="../wb_img/stat_not_implemented.png"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: left;">eLua LTR (Lua Tiny RAM) patch ##a link to a small description...</td>
|
||||
<td style="text-align: left;"><a href="arch_ltr.html">eLua LTR (Lua Tiny RAM) patch</a></td>
|
||||
<td style="text-align: center;"><img src="../wb_img/stat_ok.png"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
Loading…
x
Reference in New Issue
Block a user