<h3>Using eLua</h3><p> So, you already <ahref="building.html">built</a> and <ahref="installing.html">installed</a><b>eLua</b>, and now it is time to (finally) have some fun with it :)
You can compile <b>eLua</b> with either console over UART (by far the most popular) and console over TCP/IP (still experimental, but working quite well), so there are two different usage
<p>All you need to use <b>eLua</b> over a serial connection is your <b>eLua</b>
board connected to a PC running a terminal emulator program.<br>If
you're using Windows, I strongly recommend <atarget="_blank"href="http://www.ayera.com/teraterm/">TeraTerm</a>.
It's a freeware, it's very powerful and also easy to use. The native Hyper Terminal progam can do too, but give TeraTerm a chance, it's much better than HyperTerm IMO.<br>On
<ul><li>port setup: 115200 baud (38400 for <ahref="installing_str7.html">STR7)</a>, 8N1(8 data bits, no parity, one stop bit). </li><li>hardware flow control: none</li><li>newline handling: "CR" on receive, "CR+LF" on send (some terminal programs won't give you a choice here). </li></ul>
<p>Things are even easier if you decide to enable console over TCP/IP:
<ul>
<li>make sure you know the address of your board. If you enabled static IPs (see <ahref="building.html">building</a>) remember what you chose for the static IP; if DHCP is used instead, your
DHCP server should've added the address of the <b>eLua</b> board to your DNS. The board name is always "elua", so if you execute "ping elua" from a shell you should see that the board is
alive.</li>
<li>telnet to the address of the board (or simply "telnet elua" if DHCP is used), and you'll be greeted with the shell prompt (if the shell is enabled, see the next paragraph for details).
Note that you can only have an active telnet session to the <b>eLua</b> board at a given time.</li>
</ul>
</p>
<p>If you're under Windows, make sure you're using a proper telnet client, which basically means "just about everything <b>but</b> the build-in telnet client".
<atarget="_blank"href="http://www.chiark.greenend.org.uk/~sgtatham/putty/">PuTTY</a> is a very good and popular choice.</p>
<aname="pc"><h3>Using standalone eLua on PC</h3></a>
<p>If you build <b>eLua</b> for the i386 platform, you can boot your PC directly in <b>eLua</b>! No underlying OS, nothing but plain <b>eLua</b>. It won't have any actual peripherals to
access, but it can use the <b>term</b> module to run <i>hangman.lua</i> and <i>life.lua</i>, as well as other samples, which makes it a nice demo :) Follow <ahref="installing_i386.html">
this link</a> for specific informations about the i386 port. </p>
<p>No matter what's your physical connection (serial, TCP/IP or you PC's monitor after booting <b>eLua</b>), after you setup the PC-<b>eLua</b> board connection (if applicable) and press
the "RESET" button on your board or simply press ENTER if you're using the serial connection, you should see the <b>eLua</b> shell prompt (if you enabled the shell in your build, as described <ahref="building.html">here</a>). The shell is a simple
interactive command interpreter that allows you to:
<ul>
<li>get help on shell usage with the help command</li>
<li>run the Lua interpreter in interactive mode just like you'd do on a desktop machine</li>
<li>run a Lua program from the eLua File System</li>
<li>upload a Lua source file via XMODEM and execute in on board</li>
<li>query the eLua version</li>
<li>list files on eLua file systems</li>
</ul></p>
<p>A detailed description of all the shell commands is given below.</p>
<h2>help</h2>
<p>Show a list of all shell commands.</p>
<h2>ver</h2>
<p>Print the version of the <b>eLua</b> image installed on the board. Currently, the version only increments for official releases, so if there's inter-release code in the
development tree, this isn't reflected in the version number.</p>
<h2>recv</h2>
<p>Allows you to receive a Lua file (either source or compiled bytecode) via
XMODEM and execute it on your board. To use this, your <b>eLua</b> taret image must be built with support for XMODEM
(see <ahref="building.html">building</a> for details).Also, your terminal emulation program must
support sending files via the XMODEM protocol. Both XMODEM with checksum and XMODEM with CRC are supported, but only XMODEM with 128
<p>If you want to execute a file from the <ahref="">##ROM file system</a>, remember to prefix it with <i>/rom</i>. For example, to execute <b>hello.lua</b>, do this:</p>
<p>Shows a list of all the files in the filesystems used by <b>eLua</b> (currently only the ROM file system), as well as their size and the total size of the given file system.</p>
<h2>exit</h2>
<p>Exits the shell. This only makes sense if <b>eLua</b> is compiled with terminal support over TCP/IP , as it closes the telnet session to the <b>eLua</b> board. Otherwise it just
<p>In order to use cross-compilation, the two Lua targets (in this case your desktop PC and your <b>eLua</b> board) must be compatible
(they should have the same data types, with the same size and the same memory
representation). This isn't true all the time. For example, some gcc toolchains for ARM targets use a very specific representation for double precision numbers (called FPA
format) by default, which makes bytecode files generated on the PC with the regular Lua compiler useless on
ARM boards. Other toolchains don't have this problem. Other targets (like AVR32) are big endian, as opposed to Intel PCs that are little endian.<br>
To overcome this kind of problems, a "Lua cross-compilation patch" was posted on the
Lua mailing list a while ago, and it was further modified as part of the <b>eLua</b>
project to work with ARM targets. This is how to use it (the following
instructions were tested on Linux, not Windows, but they should work on Windows
too with little or no tweaking):
<ul>
<li>first, make sure that your PC has already a build system intalled (gcc,
binutils, libc, headers...). You'll also need scons. The good news is that
you should have it already installed, since otherwise you won't be able to
build even regular <b>eLua</b> (see <ahref="building.html">building</a> for more in-depth instructions).</li>
<li>from the <b>eLua</b> base directory, issue this command:</li>
<p>You should get a file called <i>luac</i> in the same directory after this. It's almost the same as the regular Lua compiler, but it has a few arguments that deal with differences between
<td><code>./luac -ccn int 32 -cce little -o <script.luac> -s <script.lua></code></td>
</tr>
<tr>
<td>Floating point (lua)</td>
<td>AVR32</td>
<td><ahref="toolchains.html">avr32-gcc</a>
<td><code>./luac -ccn float 64 -cce big -o <script.luac> -s <script.lua></code></td>
</tr>
<tr>
<td>Integer (lualong)</td>
<td>AVR32</td>
<td><ahref="toolchains.html">avr32-gcc</a>
<td><code>./luac -ccn int 32 -cce big -o <script.luac> -s <script.lua></code></td>
</tr>
</tbody>
</table>
<p>(note that if for some reason you want to cross-compile <b>eLua</b> for the x86 target you can use the regular Lua compiler).<br>
You can omit the <i>-s</i> (strip) parameter from compilation, but this will result in larger bytecode files (as the debug information is not stripped if you don't use <i>-s</i>).</p>
<p>You can use your bytecode file in two ways:</p>