STM32F1xx micro-controller C firmware template
Go to file
King Kévin f7b99dd76c adapt flash size to libopencm3 update 2022-04-17 15:41:43 +02:00
lib adapt flash size to libopencm3 update 2022-04-17 15:41:43 +02:00
libopencm3@664701d7a7 update libopencm3 submodule 2022-04-17 15:18:04 +02:00
.gitignore cherry-pick from busvoodoo branch, part 2 2018-02-18 15:20:01 +01:00
.gitmodules remove STM32duino-bootloader 2016-08-14 19:03:17 +02:00
Doxyfile doc: fix documentation 2020-01-03 00:16:59 +01:00
LICENSE.txt add GPLv3 license file 2018-02-13 15:14:10 +01:00
README.md README: update flash bootloader 2020-10-11 12:55:04 +02:00
Rakefile Rakefile: allow to specify CPUTADIP to use SWD with CKS32 2020-06-24 11:57:45 +02:00
application.c adapt clock setting to libopencm3 update 2022-04-17 15:37:57 +02:00
application.ld ld: update ld script to updated libopencm3 2020-01-12 15:52:27 +01:00
bootloader.c adapt clock setting to libopencm3 update 2022-04-17 15:37:57 +02:00
bootloader.ld ld: update ld script to updated libopencm3 2020-01-12 15:52:27 +01:00
global.c global: fix ADD_SAFE macro and add function returning sum 2020-12-10 20:16:02 +01:00
global.h fix bootloader compile warning 2022-04-17 15:04:06 +02:00

README.md

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

project

summary

describe project purpose

technology

described electronic details

board

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

The ST-LINK V2 mini clone has SWD test points on the board. Because read protection is enabled, you will first need to remove the protection to be able to flash the firmware. To remove the read protection (and erase flash), run rake remove_protection while a SWD adapter is connected.

The Altera USB-Blaster clone has a pin header for SWD and UART1 on the board. SWD is disabled in the main firmware, and it has read protection. To be able to flash using SWD (or the serial port), the BOOT0 pin must be set to 1 to boot the system memory install of the flash memory. To set BOOT0 to 1, apply 3.3 V on R11, between the resistor and the reference designator, when powering the device. The red LED should stay off while the green LED is on. Now you can remove the read protection (and erase flash), run rake remove_protection while a SWD adapter is connected.

connections

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

  • list board to peripheral pin connections

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

code

dependencies

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.

firmware

To compile the firmware run rake.

documentation

To generate doxygen documentation run rake doc.

flash

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 bootloader image will be flashed using SWD (Serial Wire Debug). For that you need an SWD adapter. The Makefile uses a ST-Link V2 programmer along OpenOCD software (default), or Black Magic Probe. To flash the booltoader using SWD run rake flash_booloader. If the development board uses the CKS32 chip STM32 alternative, use CPUTAPID=0x2ba01477 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.

debug

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

USB

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