Toolchains for eLua

You need (at least) a toolchain if you decide to build eLua yourself. The toolchain must contain at least a compiler, an assembler, a linker and (most likely) a tool to extract binary data from the compiled image (in order to build the actual firmware). Also, a program that reports the sizes of different sections in the compiled image is often used to give an idea about the resource consumption of eLua. You can use as many toolchains as you want for a given target, as long as the build scripts know to handle them. This section outlines the different toolchain choices available for compiling eLua. Use the links below to navigate directly to your target of interest.

If you have a different toolchain, reffer to the toolchain configuration paragraph in this document.

Toolcains for ARM and Cortex

You have multiple options when building eLua for ARM and Cortex CPUs:

Because building a toolchain is already covered in another section of the documentation, we'll focus on installing a pre-compiled toolchain here. ARM is a very popular architecture, and because of this there are a lot of toolchains available for download free of charge. One of the most popular ones comes from CodeSourcery, and we'll cover it here for a number of important reasons:

Obtaining and installing the toolchain is very easy:

  1. go to the CodeSourcery download location for the toolchain.
  2. select from the table the current version in the "EABI" line (the link to the current version is just above the "All versions..." link).
  3. download and run the installer.

That's all! Make sure that the location of the toolchain is in your $PATH and build eLua with the toolchain=codesourcery option.

Toolchains for AVR32

Currently you have only one option for AVR32: download and install the toolchain from Atmel. Unfortuntely they don't provide an installer, just a bunch of Linux packages with some dependencies, so the installation process might be a bit tricky. These are the steps you should follow to install Atmel's AVR32 toolchain:

That's it. Your toolchain is already be in $PATH (since it installs itself in /usr/bin) so you should be ready to build eLua for AVR32.

Toolchains for i386

Currently the only tested procedure for building eLua for i386 is to build an i386 toolchain. Other toolchains might work equally well though, but none was tested so far.

Toolchain configuration in eLua (WIP)

The eLua build system makes provisions for specifying an unlimited number of toolchains for a given target, selectable via the scons toolchain=... option. The default structure of each of the toolchains supported by default is listed in the table below.

Toolchain Name Compiler Linker Assembler Size tool Image copy tool
Platform
ARM (ELF) arm-gcc arm-elf-gcc arm-elf-ld arm-elf-as arm-elf-size arm-elf-objcopy
ARM (EABI) codesourcery arm-none-eabi-gcc arm-none-eabi-ld arm-none-eabi-as arm-none-eabi-size arm-none-eabi-objcopy
Cortex (ELF) arm-gcc arm-elf-gcc arm-elf-ld arm-elf-as arm-elf-size arm-elf-objcopy
Cortex (EABI) codesourcery arm-none-eabi-gcc arm-none-eabi-ld arm-none-eabi-as arm-none-eabi-size arm-none-eabi-objcopy
AVR32 avr32-gcc avr32-gcc avr32-ld avr32-s avr32-size avr32-objcopy
i386 i686-gcc i686-elf-gcc i686-elf-ld nasm i686-elf-size i686-elf-objcopy

If you need to add a new toolchain or modify an existing one, take a look at the scons build script (SConstruct). A toolchain-related fragment of SConstruct is shown below:

# List of toolchains
toolchain_list = {
  # This defines a toolchain with the name "arm-elf"
  'arm-gcc' : { 
      'compile' : 'arm-elf-gcc', 
      'link' : 'arm-elf-ld', 
      'asm' : 'arm-elf-as', 
      'bin' : 'arm-elf-objcopy', 
      'size' : 'arm-elf-size' 
  },
  # Another toolchain, this time called "codesourcery"
  'codesourcery' : { 
    'compile' : 'arm-none-eabi-gcc', 
    'link' : 'arm-none-eabi-ld', 
    'asm' : 'arm-none-eabi-as', 
    'bin' : 'arm-none-eabi-objcopy', 
    'size' : 'arm-none-eabi-size' 
  },
................  
}

# List of platform/CPU/toolchains combinations
# The first toolchain in the toolchains list is the default one
# (the one that will be used if none is specified)
platform_list = {  
  'at91sam7x' : { 'cpus' : [ 'AT91SAM7X256', 'AT91SAM7X512' ], 'toolchains' : [ 'arm-gcc', 'codesourcery' ] },
  'lm3s' : { 'cpus' : [ 'LM3S8962', 'LM3S6965', 'LM3S6918' ], 'toolchains' : [ 'arm-gcc', 'codesourcery' ] },
  ................
}

From this fragment it's easy to understand that there are at most two places in SConstruct that must be taken into account when dealing with toolchain:

Please note that in order to add a new toolchain to eLua it's generally not enough to edit just SConstruct. As different toolchains have different command line options, one should also edit the platform's build configuration file (src/platform/<platform name>/conf.py) and make it aware of the new toolchain. The exact procedure for doing this is highly dependent on the toolchain and it's well beyond the scope of this tutorial.