Using eLua with the STM32 CPUs from ST
The STM32 family of MCUs from ST is a line of Cortex-M3 based chips with a lot of neat features, including (but not limited to) high amounts of on-chip Flash/RAM (up to 512k Flash and 64k RAM), external memory controller that covers (P)SRAM, NAND Flash and NOR flash, integrated ADC and DACs, advanced timers and many others. They also feature an integrated serial boot loader, so it's extremely easy to program them from anything that has a serial port. ST provides a tool that can be used to download a program to the STM32 using this serial bootloader, but it only works in Windows. Their bootloader protocol is documented in a separate application note though, so one can easily write a programming application for any other OS.
eLua currently works on two STM32F103 variants of the STM32 family, specifically on these boards: the STM3210E-EVAL from ST and the ETM-STM32 stamp from Futurlec. Instruction for installing eLua on each of them are provided below.
Prerequisites
Before you'll be able to use eLua on the STM32F103 CPU, make sure that:
- you're using Windows. As already explained, the software provided by ST for serial firmware downloading works only under Windows. It's quite likely that similar tools for Linux and other operating systems already exist or will be available shortly.
- you have installed the "Flash loader demonstrator" from this page (look for it in the "Software - PC" section).
- you already have your eLua image for the STM32F103 CPU (built or downloaded).
Programming eLUa on the STM3210E-EVAL board
Follow the steps below to install eLua on your STM3210-EVAL board:
- make sure you have a proper cable. You need a null modem cable for this board (a cable with two DB-9 female connectors, that connects RX to TX and TX to RX).
- connect the board to one of your PC serial ports using the null modem cable.
- locate the two adjacent BOOT0 and BOOT1 switches, make sure that BOOT0 is set to 1 and BOOT1 to 0.
- reset the board by pressing on the RESET button.
- start the ST Flash loader demonstrator. Choose your serial port in the first screen, make sure that the communication parameters are 57600 8E1 and press "Next" 3 times.
- select the "Download to device" radio button, then choose your eLua image file and hit "Next".
- wait until programming is over and press "Finish".
- move the BOOT0 switch to position 0.
- reset the board by pressing the RESET button again.
Programming eLua on the ET-STM32 stamp
Follow the steps below to install eLua on your ET-STM32 stamp:
- connect the board to one of your PC serial ports using the provided serial cable.
- put the BOOT1 jumper on your board in the ISP position (it should come like that from the factory, and must likely you won't need to change this).
- press on the BOOT0 switch. The green "BOOT0=1" LED should light up.
- reset the board by pressing on the RESET button.
- start the ST Flash loader demonstrator. Choose your serial port in the first screen, make sure that the communication parameters are 57600 8E1 and press "Next" 3 times.
- select the "Download to device" radio button, then choose your eLua image file and hit "Next".
- wait until programming is over and press "Finish".
- press on the BOOT0 switch again.
- reset the board by pressing the RESET button again.
Now you have eLua installed on your board, and you can choose the same port you used for programming as a general purpose serial port for eLua (but remember to use 115200 8N1 as the communication parameters this time).