STM32F1xx micro-controller C firmware template
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
King Kévin c5fc45b5a1 terminal: make prefix bold 5 years ago
lib terminal: make prefix bold 5 years ago
libopencm3@6e65170390 updated libopencm3 submodule 5 years ago
.gitignore cherry-pick from busvoodoo branch, part 2 5 years ago
.gitmodules remove STM32duino-bootloader 7 years ago
Doxyfile add changes from spark abacus project 7 years ago
LICENSE.txt add GPLv3 license file 5 years ago README: replace make with rake 6 years ago
Rakefile Rakefile (minor): make dfu-util command more readable 5 years ago
application.c application: integrate terminal and menu 5 years ago
application.ld ld: improve flash size enforcing description 5 years ago
bootloader.c global: remove BV specific LEDs functions 5 years ago
bootloader.ld ld: improve flash size enforcing description 5 years ago
global.c global: remove BV specific LEDs functions 5 years ago
global.h global: add macro for TIM_SR_CCOF and RST_USART 5 years ago

This firmware template is designed for development boards based around STM32 F1 series micro-controller.



describe project purpose


described electronic details


The current implementation uses a core board.

The underlying template also supports following board:

Which board is used is defined in the Makefile. This is required to map the user LED and button provided on the board


Connect the peripherals the following way (STM32F10X signal; STM32F10X pin; peripheral pin; peripheral signal; comment):

  • list board to preipheral pin connections

All pins are configured using defines in the corresponding source code.



The source code uses the libopencm3 library. The projects is already a git submodules. It will be initialized when compiling the firmware. Alternatively you can run once: git submodule init and git submodule update.


To compile the firmware run rake.


To generate doxygen documentation run rake doc.


There are two firmware images: bootloader and application. The bootloader image allows to flash the application over USB using the DFU protocol. The bootloader is started first and immediately jumps to the application if it is valid and the DFU mode is not forced (i.e. by pressing the user button on the board or requesting a DFU detach in the application). The application image is the main application and is implemented in application.c. It is up to the application to advertise USB DFU support (i.e. as does the provided USB CDC ACM example).

The bootlaoder image will be flashed using SWD (Serial Wire Debug). For that you need an SWD adapter. The Makefile uses a Black Magic Probe (per default), or a ST-Link V2 along OpenOCD software. To flash the booltoader using SWD run rake flash_booloader.

Once the bootloader is flashed it is possible to flash the application over USB using the DFU protocol by running rake flash. To force the bootloader to start the DFU mode press the user button or short a pin, depending on the board. It is also possible to flash the application image using SWD by running rake flash_application.


SWD also allows to debug the code running on the micro-controller using GDB. To start the debugging session run rake debug.


The firmware offers serial communication over USART1 and USB (using the CDC ACM device class).

You can also reset the board by setting the serial width to 5 bits over USB. To reset the board run rake reset. This only works if provided USB CDC ACM is running correctly and the micro-controller isn't stuck.