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

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.
 

1. 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


2. 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.
 

3. 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 and select the USB Interface in the STM32CubeProgrammer 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.

 

4. Related links

 
Comments
OleksiiK
Associate

Is there a porting to stm32h7?

Pavel A.
Evangelist III

Only one STM32H7S board has a ready ported project for the bootloader. For other STM32H7 and boards you are free to port on your own.

Version history
Last update:
‎2024-06-04 05:51 AM
Updated by:
Contributors