Using eLua with the LM3S (Cortex-M3) CPUs from Luminary Micro
Luminary Micro is the company that produced the world's first silicon implementation of the Cortex-M3 processor. Their device portfolio is quite impressive, ranging from relatively simple devices to full-featured CPUs (with on-chip USB, EMAC, CAN, and many other peripherals). The support package for these devices is also very good, with drivers for all the CPU peripherals and ports of 3rd party applications. And, on a personal note, I contacted Luminary Micro some while ago with a request to support this project with one of their evaluation kits, and their response was excellent (thanks again, Luminary!). That's how a EKx-LM3S8962K landed on my desk. This is the development board that I'm going to use in this tutorial. eLua also supports the EKx-LM3S6965 board from Luminary (which can be programmed exactly like the EKx-LM3S8962) and the Eagle 100 board from Micromint, which uses a different installation procedure.
Pre-requisites
Before you'll be able to use eLua on the LM3S CPU, make sure that:
- you're using Windows. Yes, I really said Windows. The reason is quite simple: we're going to use Luminary's tools to burn eLua to the board, and they're Windows specific. This is the case with many CPUs and vendors out there. You can have Windows installed on your HDD, or under an emulator in Linux, it doesn't matter, you can even try to run it from Wine if you're really, really brave. I'm using XP, Vista should work too.
- you have installed the LM Flash Programmer tool from Luminary. Look for it on this page, for example (the link is in the "Software updates" table).
- you already have your eLua image for the LM3S8962 CPU (built or downloaded).
Installing eLua on EKx-LM3S8962EK and EKx-LM3S6965
Fortunately, this is as easy and painless as possible. One of the nicest things about these two kits is they use the on-board USB port for both firmware downloading and for emulating a serial port (via a hardware USB to UART converter, so you don't need any special software on the CPU to access this UART port). Moreover, it automagically knows how (and when) to switch from the firmware download mode to the UART emulation mode, so you don't need to move jumpers around or anything like this. It's zero effort firmware upgrading at its best. So, let's do it:
- connect your board to your PC using a suitable USB cable. If you didn't install the board drivers yet, you'll be asked to install them now.
- if you're already using the USB connection on the board in the UART emulation mode, close your terminal program (or at least disconnect it from the USB COM port).
- fire up the "Luminary Micro Flash Programmer" application.
- in the "Configuration" tab, select "LM3S8962 Ethernet and CAN Evaluation board" or "LM3S6965 Ethernet Evaluation Board" (depending on your board).
- in the "Program" tab, select the eLua .bin file that you got from the compilation step.
- select the "Options" as you like (I generally choose "Erase entire flash" and "Reset MCU after program").
- hit the "Program" button.
- wait until programming is over, then exit the flash programmer application.
It's worth to mention that since these boards come with an USB to JTAG converter it should be possible to use OpenOCD (or a similar package) instead of the Luminary tool to program the image. The Luminary Micro forums are a good place to look for information if you're exploring the OpenOCD option.
Installing eLua on Eagle 100
The Eagle 100 board can also be programmed via JTAG, but it doesn't include an on-board USB to JTAG adapter, so you'd need an external adapter if you
want to use JTAG for programming. Fortunately, it also comes with an Ethernet bootloader, so you can upload your image via Ethernet. The only requirement
to use the bootloader is to start your image at address 0x2000 instead of the usual 0x0, since that's where the bootloader jumps. The
eLua build system does this automatically if the "board=eagle-100" parameter is given at build time.
For a full description of the Ethernet bootloader consult the Eagle 100 board manual, (look for section 2.7, Firmware Updates using the Ethernet Bootloader).
You still need the LM Flash Tool to use the Ethernet bootloader, but since the board can use JTAG for firmware uploading, it should be possible to use it
with OpenOCD (or a similar package) and an external USB to JTAG adapter. The Luminary Micro forums are a good place to look for information if you're exploring the OpenOCD option.