Skip to content

Files

Latest commit

9d49c2b · Jan 7, 2024

History

History

exti

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jan 7, 2024
Jan 7, 2024
Jan 7, 2024
Jan 7, 2024
Jan 7, 2024
Jan 7, 2024
Jan 7, 2024
Jan 7, 2024
Jan 7, 2024

Blue Pill Project Template using Makefile

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.

Build Passing GPLv3 License

Dependencies

  • 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`

Project Structure

  • src directory contains all source files for the project
  • include directory contains all header files for the project

Source file description

  • STM32F103C8TX_FLASH.ld - linker script
  • src\main.c - application code
  • src\startup_stm32f103c8tx.s - assembly startup script for blue pill board
  • system_stm32f1xx.c - clock configuration and system initialization functions

Run Locally

Running the project is super easy. Just clone, build, and flash.

Clone the project

  1. Using https

    git clone https://github.com/csrohit/bluepill-template-project.git
    cd bluepill-template-project
  2. Using ssh

    git clone [email protected]:csrohit/bluepill-template-project.git
    cd bluepill-template-project

Configuration

All the configuration required for building this project is given below.

  1. Build output directory In Makefile, output directory can be configured using variable BUILD_DIR.

  2. Build type In Makefile, build type can be configured using variableDEBUG. Possible values are Debug and Release.

  3. Binary name In CMakeLists.txt, output binary name can be configured using project(<binary-name>) macro. ** update above info in .vscode/launch.json as well for debugging to work.

Build

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

Flash

  1. Connect Stlink to PC and blue pill board using swd headers.
  2. Put blue pill board in programming mode.
  3. Run following to flash board with binary.
make flash

Output

Onboard led connected to Pin C13 can be observed to be blinking after 500ms.

Debug

Click in Run and Debug option in VsCode sidebar. Then launch Cortex Debug target.

Happy debugging....