This blog explores STM32 and ARM Cortex-M development and concepts using software tools which are open source and freely available.

Learn how to set up a development environment and start writing code with short concise examples using both real hardware and the QEMU virtual machine emulator.


Demonstrates examples running on real hardware (JTAG programming/debugging, GPIO control), the hardware is based on the ARM Cortex-M4F CPU.

STM32-P405 Introduction

Guide to setting up the STM32-P405 board, a development environment and some simple startup code to validate the setup.


Guide to enable and use the GPIO pins on the STM32-P405 board.

Arm Cortex-M

Arm Cortex-M Introduction

Set up a QEMU emulator and run and debug some startup code.

Arm Cortex-M Exception Example – Usage Fault

Generate a usage fault and demonstate the correct handler being called

Arm Cortex-M Exception Example – Stack Frame

Examine the stack frame after an exception is called

Arm Cortex-M Serial I/O Example

Generate output on the PL1011 serial device

Arm Cortex-M SysTick Example

Enable the SysTick timer

Arm Cortex-M Context Switching Part 1

Initialise an initial task and switching to thread mode using the SysTick exception

Arm Cortex-M Context Switching Part 2

Implement a simple round robin scheduler capable of executing multiple tasks

Arm Cortex-M Context Switching Part 3

Use the PendSV exception to enable deferred context switching

Arm Cortex-M Context Switching Part 4

Implement a simple priory mechanism for tasks

Please note: All code presented is licensed under the GNU Public License V3 and examples are provided purely for educational purposes and may lack constructs such as boundary checking, sanity tests etc.

Do not use this code for secure or safety critical applications.