diff --git a/doc/en/building.html b/doc/en/building.html index a1322961..f489a3d1 100644 --- a/doc/en/building.html +++ b/doc/en/building.html @@ -2,235 +2,349 @@
If you decide to build your own eLua binary image (instead of downloading one) you need to check a few things first: +
If you decide to build your own eLua +binary image (instead of downloading +one) you need to check a few things first: +
$ sudo apt-get install python
$ sudo apt-get install scons
$ sudo apt-get install nasm
$ sudo apt-get install python
+$ sudo apt-get install scons
+$ sudo apt-get install nasm
+For each platform, eLua assumes a certain +name for the toolchain components, as shown below.
-For each platform, eLua assumes a certain name for the toolchain components, as shown below. -
-If your toolchain uses different names, you have to modify the toolchain definition in SConstruct. See the toolchains instructions for details.
+If your toolchain uses different names, you have to modify the +toolchain definition in SConstruct. See the toolchains instructions for +details.
eLua has a very flexible build system that can be used to select the components that are going to be part of the eLua binary image and to set the compile time (static) configuration. -To use it, you need to edit a single configuration file (platform_conf.h) located in the platform specific directory (src/platform/<platform name>/platform_conf.h). The configuration parameters are described in detail in the next paragraphs.
+eLua has a very flexible build system that +can be used to select the components that are going to be part of the eLua +binary image and to set the compile time (static) configuration. +To use it, you need to edit a single configuration file (platform_conf.h) +located in the platform specific directory (src/platform/<platform +name>/platform_conf.h). The configuration parameters +are described in detail in the next paragraphs.
A component is a feature that can be enabled to add functionality to eLua itself, without modifying its API (which is the part that the programmer uses to write eLua programs). The components that can be configured in eLua are: +
A component is a feature that can be +enabled to add functionality to eLua itself, +without modifying its API (which is the part that the programmer uses +to write eLua programs). The components that can be +configured in eLua are: +
Name | -Meaning | +Name | +Meaning |
---|---|---|---|
BUILD_XMODEM | -Define this to build support for XMODEM receive. If enabled, you can use the "recv" command from the shell to receive a Lua file (either source code - or precompiled byte code) and run in on the target. Works only over RS-232 connections (although in theory it's possible to make it work over any kind - of transport). | +BUILD_XMODEM | +Define this to build support for XMODEM receive. If +enabled, you can use the "recv" command from the shell to receive a Lua +file (either source code or precompiled byte code) and run in on the +target. Works only over RS-232 connections (although in theory it's +possible to make it work over any kind of transport). |
BUILD_SHELL | -This build the eLua shell (see Using eLua for details on the shell). If the shell is not enabled, the code looks for - a file called /rom/autorun.lua and executes it. If this file is not found, a regular Lua intepreter is started on the target. | +BUILD_SHELL | +This build the eLua shell (see Using eLua for details on the +shell). If the shell is not enabled, the code looks for a file called /rom/autorun.lua +and executes it. If this file is not found, a regular Lua intepreter is +started on the target. |
BUILD_ROMFS | -Enable the eLua read-only filesystem. See the ##ROMFS documentation for details about using the ROM file system. | +BUILD_ROMFS | +Enable the eLua read-only +filesystem. See the ##ROMFS +documentation for details about using the ROM file system. |
BUILD_TERM | -Enable ANSI terminal support. It allows eLua to interact with terminals that support ANSI escape sequences. Currently it works only over - RS-232 connections, although this is not a strict requirement. You need to enable this if you want to use the ##term module. | +BUILD_TERM | +Enable ANSI terminal support. It allows eLua +to interact with terminals that support ANSI escape sequences. +Currently it works only over RS-232 connections, although this is not a +strict requirement. You need to enable this if you want to use the ##term module. |
BUILD_UIP | -Enable TCP/IP networking support. You need to enable this if you want to use the ##net module. Also, your platform must - implement the uIP support functions (see the ##platform interface documentation for details). | +BUILD_UIP | +Enable TCP/IP networking support. You need to enable +this if you want to use the ##net +module. Also, your platform must implement the uIP support +functions (see the ##platform +interface documentation for details). |
BUILD_DHCPC | -If BUILD_UIP is enabled, you can enable this to include a DHCP client in the TCP/IP networking subsystem. | +BUILD_DHCPC | +If BUILD_UIP is enabled, you can enable this to include +a DHCP client in the TCP/IP networking subsystem. |
BUILD_DNS | -If BUILD_UIP is enabled, you can enable this to include a minimal DNS resolver in the TCP/IP networking subsystem. | +BUILD_DNS | +If BUILD_UIP is enabled, you can enable this to include +a minimal DNS resolver in the TCP/IP networking subsystem. |
BUILD_CON_GENERIC | -Generic console support. Enables console access (stdio/stdout/stderr) via a serial transport (currently RS-232, but others can be supported). - Enable this if you want to use console input/output over your RS-232 connection. Don't enable this if you need console input/ouput over Ethernet - (see the next option). - | +BUILD_CON_GENERIC | +Generic console support. Enables console access +(stdio/stdout/stderr) via a serial transport (currently RS-232, but +others can be supported). Enable this if you want to use console +input/output over your RS-232 connection. Don't enable this if you need +console input/ouput over Ethernet (see the next option). |
BUILD_CON_TCP | -Console input/output over TCP/IP connections only. Use this if you want to use your eLua board over a telnet session. - Don't enable this if you need console input/output over serial transports (see the previous option). | +BUILD_CON_TCP | +Console input/output over TCP/IP connections only. Use +this if you want to use your eLua board over a +telnet session. Don't enable this if you need console input/output over +serial transports (see the previous option). |
BUILD_ADC | -Generic ADC support code. You need to enable this if you want to use the ##adc module, or simply the ADC functions - from the platform interface. You don't need it if you're not planning to use the ADC. | +BUILD_ADC | +Generic ADC support code. You need to enable this if +you want to use the ##adc +module, or simply the ADC functions from the platform interface. You +don't need it if you're not planning to use the ADC. |
You can also choose the modules that are going to be part of the eLua image. Unlike components, the modules have a direct impact on the eLua API, so choose them carefully. - Disabling a module will save Flash space (and potentially RAM) but will also completely remove the possibility of using that module from eLua.
-The modules included in the build are specified by the LUA_PLATFORM_LIBS_ROM macro. An example is given below: -
#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 )
-Each module is defined by a _ROM( module_name, module_init_function, module_map_array ) macro, where: +
You can also choose the modules that are going to be part of +the eLua image. Unlike components, the modules have +a direct impact on the eLua API, so choose them +carefully. Disabling a module will save Flash space (and potentially +RAM) but will also completely remove the possibility of using that +module from eLua.
+The modules included in the build are specified by the +LUA_PLATFORM_LIBS_ROM macro. An example is given below:
+#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 )
+Each module is defined by a _ROM( module_name, +module_init_function, module_map_array ) macro, where: +
Please note that this notation is specific to LTR (the Lua Tiny RAM 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 ##LTR section for more information about LTR.
-For the full list of modules that can be enabled or disabled via platform_conf.h check ##the eLua reference manual.
+Please note that this notation is specific to LTR (the Lua +Tiny RAM 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 ##LTR +section for more information about LTR.
+For the full list of modules that can be enabled or disabled +via platform_conf.h check ##the +eLua reference manual.
"Static configuration" reffers to the compile-time configuration. Static configuration parameters are hard-coded in the firmware image and can't be changed at run-time. The table below lists the static configuration parameters and their semantics. +
"Static configuration" reffers to the compile-time +configuration. Static configuration parameters are hard-coded in the +firmware image and can't be changed at run-time. The table below lists +the static configuration parameters and their semantics. +
Name | -Meaning | +Name | +Meaning |
---|---|---|---|
CON_UART_ID CON_UART_SPEED |
- Used to configure console input/output over UART. The specified UART id will be used for console input/output, at the specified speed. The data format is always 8N1 (8 data bits, no parity, - 1 stop bits) at this point. | +CON_UART_ID +CON_UART_SPEED |
+Used to configure console input/output over UART. The +specified UART id will be used for console input/output, at the +specified speed. The data format is always 8N1 (8 data bits, no parity, +1 stop bits) at this point. |
XMODEM_TIMER_ID | -Defines the id of the timer used by XMODEM to handle timeouts (if XMODEM is enabled in the build). At this point, the XMODEM subsystem uses the same UART id as the one specified by - CON_UART_ID. | +XMODEM_TIMER_ID | +Defines the id of the timer used by XMODEM to handle +timeouts (if XMODEM is enabled in the build). At this point, the XMODEM +subsystem uses the same UART id as the one specified by CON_UART_ID. |
TERM_TIMER_ID TERM_LINES TERM_COLS TERM_TIMEOUT |
- Used to configure the ANSI terminal support (if enabled in the build). Used to specify (respectively): the timer id used by the "term" implementation to handle timeouts, the number of - lines and columns of the ANSI terminal, and the ANSI input timeout (used as a inter-char timeout when a key sends more than one code to the ANSI subsystem, for example the up, down, left - and right keys on a PC keyboard). | +TERM_TIMER_ID +TERM_LINES +TERM_COLS +TERM_TIMEOUT + |
+Used to configure the ANSI terminal support (if enabled +in the build). Used to specify (respectively): the timer id used by the +"term" implementation to handle timeouts, the number of lines and +columns of the ANSI terminal, and the ANSI input timeout (used as a +inter-char timeout when a key sends more than one code to the ANSI +subsystem, for example the up, down, left and right keys on a PC +keyboard). |
ELUA_CONF_IPADDR0..3 ELUA_CONF_NETMASK0..3 ELUA_CONF_DEFGW0..3 ELUA_CONF_DNS0..3 |
- Used by the TCP/IP implementation when the DHCP client is not enabled, or when it is enabled but can't be contacted. Specifies the IP address, network mask, default gateway and DNS server. - Only needed if BUILD_UIP is enabled. | +ELUA_CONF_IPADDR0..3 +ELUA_CONF_NETMASK0..3 +ELUA_CONF_DEFGW0..3 +ELUA_CONF_DNS0..3 |
+Used by the TCP/IP implementation when the DHCP client +is not enabled, or when it is enabled but can't be contacted. Specifies +the IP address, network mask, default gateway and DNS server. Only +needed if BUILD_UIP is enabled. |
VTMR_NUM_TIMERS VTMR_FREQ_HZ |
- Specify the virtual timers configuration for the platform (reffer to ##the timer module documentation for details). Define VTMR_NUM_TIMERS to 0 if this feature is not used. | +VTMR_NUM_TIMERS +VTMR_FREQ_HZ |
+Specify the virtual timers configuration for the +platform (reffer to ##the timer module +documentation for details). Define VTMR_NUM_TIMERS to 0 if +this feature is not used. |
PLATFORM_CPU_CONSTANTS | -If the ##cpu module is enabled, this defines a list of platform-specific constants (for example interrupt masks) that can be accessed using the cpu.<constant name>
- notation. Each constant name must be specified instead of a specific costruct (_C(<constant name>). For example:
-
- After compilation, you can access these constants using cpu.INT_GPIOx. Note that the implementation of this feature needs virtually no RAM at all, so you can define as many constants as you want here.
- |
+PLATFORM_CPU_CONSTANTS | +If the ##cpu module
+is enabled, this defines a list of platform-specific constants (for
+example interrupt masks) that can be accessed using the
+cpu.<constant name> notation. Each constant name must be
+specified instead of a specific costruct (_C(<constant
+name>). For example:
+
+After compilation, you can access these constants using cpu.INT_GPIOx.
+Note that the implementation of this feature needs virtually no RAM at
+all, so you can define as many constants as you want here. |
The rest of the static configuration data parameters are meant to be modified mainly by developers and thus they're not listed here.
-One more thing you might want to configure for your build is the contents of the ROM file system. See the ROMFS documentation for details on how to do this.
The rest of the static configuration data parameters are meant
+to be modified mainly by developers and thus they're not listed here.
+One more thing you might want to configure for your build is the
+contents of the ROM file system. See the ROMFS
+documentation for details on how to do this.
Once you have everything in place, all you have to do is to invoke the build system (scons) with the right arguments. This is a fairly easy step, although it might look intimidating because of - the multitude of options than can be given to scons. They are used to fine tune the final image to your specific needs, but unless your needs are very special you won't need to modify them, so - don't worry about the aparent complexity. The examples at the end of this section will show how easy it is to use the build system in practice. -
$ scons
- [target=lua | lualong]
- [cpu=at91sam7x256 | at91sam7x512 | i386 | str912fw44 | lm3s8962 |
- lm3s6965 | lm3s6918 | lpc2888 | str711fr2 | at32uc3a0512 | stm32f103ze
- [board=ek-lm3s8962 | ek-lm3s6965 | eagle-100 | str9-comstick | sam7-ex256 |
- lpc-h2888 | mod711 | pc | atevk1100 | stm3210e-eval ]
- [cpumode=arm | thumb]
- [allocator = newlib | multiple | simple]
- [toolchain = <toolchain name>]
- [optram = 0 | 1]
- [prog]
-Your build target is specified by two paramters: cpu and board. "cpu" gives the name of your CPU, and "board" the name of the board. A board can be associated with more than one CPU. - This allows the build system to be very flexible. You can use these two options together or separately, as shown below:
+Once you have everything in place, all you have to do is to +invoke the build system (scons) with the right arguments. This is a +fairly easy step, although it might look intimidating because of the +multitude of options than can be given to scons. They are used to fine +tune the final image to your specific needs, but unless your needs are +very special you won't need to modify them, so don't worry about the +aparent complexity. The examples at the end of this section will show +how easy it is to use the build system in practice. +
+$ scons
[target=lua | lualong]
[cpu=at91sam7x256 | at91sam7x512 | i386 | str912fw44 | lm3s8962 |
lm3s6965 | lm3s6918 | lpc2888 | str711fr2 | at32uc3a0512 | stm32f103ze
[board=ek-lm3s8962 | ek-lm3s6965 | eagle-100 | str9-comstick | sam7-ex256 |
lpc-h2888 | mod711 | pc | atevk1100 | stm3210e-eval ]
[cpumode=arm | thumb]
[allocator = newlib | multiple | simple]
[toolchain = <toolchain name>]
[optram = 0 | 1]
[prog]
+Your build target is specified by two paramters: cpu and +board. "cpu" gives the name of your CPU, and "board" the name of the +board. A board can be associated with more than one CPU. This allows +the build system to be very flexible. You can use these two options +together or separately, as shown below:
For board/CPU assignment look at the beginning of the SConstruct file (the platform_list array), it's self-explanatory.
+
For board/CPU assignment look at the beginning of the
+SConstruct file (the platform_list array), it's
+self-explanatory.
The other options are as follows:
The output will be a file named elua_[target]_[cpu].elf (and also another file with the same name but ending in .bin/.hex if "prog" was specified for platforms that need
- these files for programming).
-If you want the equivalent of a "make clean", invoke "scons" as shown above, but add a "-c" at the end of the command line. "scons -c" is also recommended after you reconfigure your build image,
-as scons seems to "overlook" the changes to these files on some occasions.
The output will be a file named elua_[target]_[cpu].elf
+(and also another file with the same name but ending in .bin/.hex if
+"prog" was specified for platforms that need these files for
+programming).
+If you want the equivalent of a "make clean", invoke "scons" as shown
+above, but add a "-c" at the end of the command line. "scons -c" is
+also recommended after you reconfigure your build image, as scons seems
+to "overlook" the changes to these files on some occasions.
A few examples:
-$ scons cpu=at91sam7x256 -c
Clear previously built intermediate files.
-$ scons cpu=at91sam7x256
-Build eLua for the AT91SAM7X256 CPU. The board name is detected as sam7-ex256.
- +Build eLua for the AT91SAM7X256 CPU. The board name is +detected as sam7-ex256.
$ scons board=sam7-ex256
-Build eLua for the SAM7-EX256 board. The CPU is detected as AT91SAM7X256.
- - +Build eLua for the SAM7-EX256 board. The CPU is detected as +AT91SAM7X256.
$ scons board=sam7-ex256 cpu=at91sam7x512
-Build eLua for the SAM7-EX256 board, but "overwrite" the default CPU. This is useful when you'd like to see how the specified board would behave (in terms of resources) with a different CPU - (in the case of the SAM7-EX256 board it's possible to switch the on-board AT91SAM7X256 CPU for an AT91SAM7X512 which has the same pinout but comes with more Flash/RAM memory).
- - +Build eLua for the SAM7-EX256 board, but "overwrite" the +default CPU. This is useful when you'd like to see how the specified +board would behave (in terms of resources) with a different CPU (in the +case of the SAM7-EX256 board it's possible to switch the on-board +AT91SAM7X256 CPU for an AT91SAM7X512 which has the same pinout but +comes with more Flash/RAM memory).
$ scons cpu=lpc2888 prog
-Build eLua for the lpc2888 CPU. The board name is detected as LPC-H2888. Also, -the bin file required for target programming is generated. The allocator is automatically detected as "multiple".
- +Build eLua for the lpc2888 CPU. The board name is detected as +LPC-H2888. Also, +the bin file required for target programming is generated. The +allocator is automatically detected as "multiple".
$ scons cpu=lm3s8962 toolchain=codesourcery prog
-Build the image for the Cortex LM3S8962 CPU, but use the 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
. - -