Update: Much of this content has been updated over at ioprog.com

Bare metal programming of the STM32F0Discovery and STM32VLDiscovery board in Linux

Bare metal programming involves you, a compiler, a microprocessor development kit, programmer and a datasheet. There are no libraries, you might have some useful header files that declare stuff like register locations and contents but generally speaking you are on your own. The alternative is to use a framework or set of libraries of some kind. These are complex software constructs, perhaps just as complex as the underlying hardware. The net gain, at lease for one-off type projects, is small as you are swapping the complexity of the processor hardware for the complexity of a software abstraction layer on top of it.
The hardware used here is the STM32F0Discovery board. This is a cheap board (approx 8 euro) and is great value for money. It contains an ARM Cortex M0 based processor with loads of IO, Timers and other interfaces of various sorts


The toolchain (NOTE: a great ready-made toolchain (minus openocd) can be found here: https://launchpad.net/gcc-arm-embedded)
The big header file
First program: Blinky
Running blinky
Using timer interrupts
Interrupt driven serial communications
Using an HD44780 compatible display
Using a matrix keypad
A better initialization routine
Using the systick timer
Controlling a pair of servo motors
Interfacing an STM32F0Discovery with a Raspberry Pi


Similar examples to the above for the STM32VLDiscovery board may be found here

Additional material

Introduction to C
C language keywords and operators

Further reading

Other microcontroller examples are in Bare-metal ARM home
Send me a mail if you spot any error or have any suggestions to frank dot duignan at dit dot ie