Baremetal programming of the STM32l011 from ST Microelectronics


Blinky


The STM32L011 Nucleo board is an mbed enabled development kit featuring the STM32Lo11K4 MCU. This is a Cortex M0+ device with some interesting features such as a "Firewall" which seems to prevent code and data from being extracted from the device. The board is meant to be programmed with a large IDE or using the mbed online development environment. I was curious to see could it be done from the command line with all code contained in a single directory. Normally I would tackle this with OpenOCD and GDB but this is such a new board that OpenOCD/GDB can't interface with it properly (yet). All is not lost however! The mbed feature of this board means that it appears as a removable storage device to the operating system. Programming the board is simply a matter of dropping a correctly formatted executable (binary) file into this removable storage device. The utility objcopy can be used to prepare the executable file. Assuming you have compiled your code to an "elf" file called main.elf, you can generate a binary file as follows:
objcopy -O binary main.elf main.bin
The "bin" file can be dropped on the Nucleo and should run fine.

Sample Code

Code for blinky
Serial communications over the nucleo serial interface to the host PC
Read the ADC and output the result over the serial port to the host PC
Minimize power consumption and wake using the internal RTC every second
Back to my ARM project page