cancel
Showing results for 
Search instead for 
Did you mean: 

How to use the ST Open Bootloader for STM32 Microcontrollers

ST AME Support NF
ST Employee

How to use the ST Open Bootloader for STM32 Microcontrollers

1. Introduction


ST Open Bootloader is example application code for STM32 microcontrollers providing In-Application programming (IAP) and is offered in the STM32Cube MCU Packages and GitHub. It is fully compatible with the STM32 System Bootloader and supports the same communication interfaces and commands and can also be used with the STM32CubeProgrammer. Open Bootloader is provided as example code that can be used to build a customized bootloader. It allows for downloading the application program to the internal user memory (Flash, SRAM, OTP) without the need for a debugger using one of the available communication interfaces (USART, I2C, SPI, USB-DFU or FDCAN). 
Open Bootloader communicates via an interface link with the Host (STM32CubeProgrammer or another host) to download firmware to the device for writing into the targeted user memory. Open Bootloader relies on STM32Cube HAL/LL drivers for hardware system initialization and configuration of the clocks and the communication interfaces. Open Bootloader code can be loaded into user Flash or SRAM taking the necessary precautions to avoid erasing or corruption (i.e. using the write protection feature). Open Bootloader is executed in a non-secure domain from user Flash or SRAM at the initial base address using the following resources:
  • Non secure internal flash memory/SRAM1
  • Interrupts
  • Clocks and power
  • Communication interfaces
  • GPIOs
  • Systick
  • IWDG

This article shows where to find the ST Open Bootloader within the STM32Cube library package and steps through an example of programming it into an STM32 and using it with the STM32CubeProgrammer.
 

2. Example Prerequisites

  • Hardware
    • Micro USB cable: to power and program the board
    • Type-C USB cable: to connect to the USB peripheral of the STM32G0 on-board
    • STM32G0C1E-EV Evaluation board
1912.png
  • Software
    • STM32CubeIDE
    • STM32CubeProgrammer


3. Getting Started

The ST Open Bootloader is part of the STM32Cube Library package. This example uses the STM32G0C1 eval board and the Open Bootloader can be found here:
STM32Cube_FW_G0_Vx.x.x\Projects\STM32G0C1E-EV\Applications\OpenBootloader
Project examples are provided for the STM32CubeIDE, IAR EWARM and Keil uVision toolchains, while  STM32CubeIDE is used in this article. The ST Open Bootloader supports a variety of peripheral interfaces (UART, I2C, SPI, CAN, USB DFU) as does the STM32G0 System Memory Bootloader. USB DFU will be used in this example.
 

4.  Steps

  1. Download and unzip latest STM32G0CubeG0 Firmware Library:

STM32CubeG0 - STM32Cube MCU Package for STM32G0 series (HAL, Low-Layer APIs and CMSIS, USB PD, File system, RTOS - and examples running on ST boards) - STMicroelectronics
  1. Open The ST Open Bootloader project:

Within Windows File Explorer, double click on the STM32CubeIDE project filename, ".project" for ST Open Bootloader located in the STM32CubeG0 Library that was downloaded and unzipped at this location:
STM32Cube_FW_G0_V1.5.0\Projects\STM32G0C1E-EV\Applications\OpenBootloader\STM32CubeIDE
The project will then appear in the Project Explorer like this:
1913.png
 
  1. Build the project, enter debug mode and run the code

1914.png
Enter Debug session: this programs the code into the flash and then starts the debug session
1915.png
Exit the Debug Session by terminating it.
Boot mode is already set to execute from Flash by default.
Reset the board and the ST Open Bootloader will start executing. The ST Open Bootloader starts in the detection stage checking the various communication peripheral interfaces for activity looking for a host connection.
Plug in the USB Type C cable to the CN7 daughter board that is connected to the STM32G0 mother board. The USB host will begin communications enumerating the board as a USB DFU Device as confirmed in the Device Manager:
1916.png
Open STM32CubeProgammer:
 
  • Select the USB Interface in the STM32CubeProrgammer to establish the connection through USB:

1917.png
Confirm the USB connection is established as shown below. If it is not, click on the refresh button 1918.png:
1921.png
Now Connect by clicking on the Connect button:
1924.png
Once the connection is made, the content of the flash will be displayed as shown below:
1928.png
While the flash can now be read, erased or written, the primary objective is to upload a new application image into the STM32G0.
 

5. Links

STM32G0C1VE - Mainstream Arm Cortex-M0+ 32-bit MCU, up to 512KB Flash, 144KB RAM, 6x USART, timers, ADC, DAC, comm. I/Fs, AES, RNG, 1.7-3.6V - STMicroelectronics
STM32G0x1 advanced Arm®-based 32-bit MCUs - Reference manual
STM32CubeIDE - Integrated Development Environment for STM32 - STMicroelectronics
STM32CubeG0 - STM32Cube MCU Package for STM32G0 series (HAL, Low-Layer APIs and CMSIS, USB PD, File system, RTOS - and examples running on ST boards) - STMicroelectronics
STM32CubeProg - STM32CubeProgrammer software for all STM32 - STMicroelectronics
STM32G0C1E-EV - Evaluation board with STM32G0C1VE MCU - STMicroelectronics
AN2606 - STM32 microcontroller system memory boot mode
AN3155 - USART protocol used in the STM32 bootloader
AN4221 - I2C protocol used in the STM32 bootloader
AN4286 - SPI protocol used in the STM32 bootloader
AN3156 - USB DFU protocol used in the STM32 bootloader
AN5405 - FDCAN protocol used in the STM32 bootloader
AN3154 - CAN protocol used in the STM32 bootloader
 STM32 Open Bootloader on GitHub
 
Comments
yerunzhao
ST Employee

dears, 

is there any AN on the open bootloader? eg. how to port it into my application code?

if using UART, how to send the .bin(or new image), by YMODEM protocol?

Version history
Last update:
‎2021-11-30 01:09 AM
Updated by: