logo

Contents

STM32 Bare-Metal Startup And Blinky

Foreword

I've always been interested in bare-metal programming. My first LED blinky was done by setting a bit on my RP2040's register rather than using the SDK.

However, there are 'things' that happen in between your MCU receiving power and beginning execution of main() - it's what this article is going to cover as it's one of the more interesting topics due to the amount of moving parts it involves. It's also going to be a short article as most of the heavy learning warrants its own article - they are deep enough topics.

So if you've ever been interested in how an STM32 gets around to running your HAL_GPIO_TogglePin() code, let's find out!

Take note that I'm using an Nucleo STM32H7S3L8, there may be differences between certain STM32 boards.

Pre Requisites

These are the tools I use to flash my STM32 boards. You can use the same, or find substitutes. If you choose to follow what I use, this page has instructions on how to actually use them, otherwise you'll have to do some Googling.

I use:

Other Nice-To-Have Things

These will help you on any project, from personal experience:

Linker Script

In short, a linker script informs the linker of the target's memory layout, so it knows where to place code and data within it.

This is a topic with enough depth to demand its own article, so if you want an in-depth explanation to the best of my ability, you can find it here.

Here is the linker script for this article (once again, specific to the STM32H7S3L8) - I may update this page with a linker script for the STM32G031K8.

OOPS! This article is currently unfinished

Working on it!

Sources

STM32World YouTube