A boilerplate for generating projects for stm32 blue pill board using makefile. The projects does not use any tools provided by ST Microelectronics. Everything from development, flashing to debugging can be done in Visual Studio Code only.
-
make Make utility is required for configuring and building this project. You can install make on linux by running command:
sudo apt install build-essential
-
gcc-arm-none-eabi toolchain ARM cross-platform toolchain is required to build applications for arm mcus. Toolchain can be installed by running following command:
sudo apt install gcc-arm-none-eabi
-
openocd It is an Open On Circuit Debugging tool used to flash and debug arm micro controllers. You can install openocd on linux by running command:
sudo apt install openocd -y
-
Cortex Debug extension x`
src
directory contains all source files for the projectinclude
directory contains all header files for the project
STM32F103C8TX_FLASH.ld
- linker scriptsrc\main.c
- application codesrc\startup_stm32f103c8tx.s
- assembly startup script for blue pill boardsystem_stm32f1xx.c
- clock configuration and system initialization functions
Running the project is super easy. Just clone, build, and flash.
-
Using https
git clone https://github.com/csrohit/bluepill-template-project.git cd bluepill-template-project
-
Using ssh
git clone [email protected]:csrohit/bluepill-template-project.git cd bluepill-template-project
All the configuration required for building this project is given below.
-
Build output directory In
Makefile
, output directory can be configured using variableBUILD_DIR
. -
Build type In
Makefile
, build type can be configured using variableDEBUG
. Possible values areDebug
andRelease
. -
Binary name In
CMakeLists.txt
, output binary name can be configured usingproject(<binary-name>)
macro. ** update above info in.vscode/launch.json
as well for debugging to work.
Run following command in terminal to generate flashable binaries for blue pill board. Build files will be written to Build Output Directory as configured.
make all
- Connect Stlink to PC and blue pill board using swd headers.
- Put blue pill board in programming mode.
- Run following to flash board with binary.
make flash
Onboard led connected to Pin C13 can be observed to be blinking after 500ms.
Click in Run and Debug
option in VsCode sidebar. Then launch Cortex Debug
target.
Happy debugging....