STM32F1 Blue Pill Baremetal Programming in C

Programming STM32 Blue Pill using makefile

Build and Program STM32 blue pill board using a makefile and vs code, without using any IDE

Rohit Nimkar
2 min readSep 19, 2022

--

In this article, I will explain how to build and manage bare-metal embedded c projects for STM32 Blue Pill. We need header files for STM32F013C8T6, startup script, linker script, and our precious main.c .

STM32 Blue Pill with Vscode and Makefile logo
Gnu make + STM32 + VSCode

Dependencies

Gnu make
Make utility is required for configuring and building this project. You can install make on Linux by running the command:

sudo apt install build-essential

arm-none-eabi-gcc
ARM cross-platform toolchain is required to build applications for arm mcus. The toolchain can be installed by running the following command:

sudo apt install gcc-arm-none-eabi

openocd — OpenOn Circuit Debugger
It is an Open On Circuit Debugging tool used to flash and debug arm microcontrollers. You can install openocd on Linux by running the command:

sudo apt install openocd -y

Cortex Debug extension
This extension is required to enable debugging for cortex m microcontrollers in VSCode. Install all the recommended extensions for a better experience.

Get Project code

Clone repo from https://github.com/csrohit/bluepill-makefile-project.
Open the folder in VSCode and set up your local environment.

git clone https://github.com/csrohit/bluepill-template-project
code bluepill-template-project

Build Project

The project is nothing but a program to blink led connected to pin C13. Clone the following repository and follow the instructions mentioned in the README file and you are good to go.

Debugging

After installing the Cortex Debug extension, launch the debug target. The debugger will halt the first instruction in the main() function.

The debugger halted at the first instruction in main()

--

--

Rohit Nimkar

Know a little about coding but aim to self employ myself from it.