cancel
Showing results for 
Search instead for 
Did you mean: 

How to use STM32CubeProgrammer and the STLINK-V3SET to access the SPI bootloader on my STM32 board?

Stefanie LAU
ST Employee
How to use STM32CubeProgrammer and the STLINK-V3SET to access the SPI bootloader on my STM32 board? Our example here, we will use the Nucleo-G071RB as our STM32 reference board along with the STLINK-V3SET to show you how to leverage the STM32CubeProgrammer GUI to access the target’s SPI bootloader.
Every STM32 MCU comes pre-programmed with a system memory bootloader stored in the internal boot ROM (system memory). Its main purpose is to download the application program to the internal Flash memory through one of the available serial peripherals on the target device (e.g. USART, CAN, USB DFU, I2C, and SPI). To verify which peripheral interfaces support the activation of the bootloader, the communication protocols and respective command set and sequence, please review AN2606 (STM32 Microcontroller System Memory Boot Mode).
STM32CubeProgrammer is an all-in-one software tool for programming STM32 products, compatible across multiple operating systems and available in both Graphical User Interface (GUI) and Command Line Interface (CLI) versions. It’s an easy to use and efficient application for reading, writing, and verifying device memory through both the JTAG and SWD debug interfaces and bootloader interfaces (e.g. USART, CAN, USB DFU, I2C, and SPI). It is recommended to always keep up to date with the latest version of STM32CubeProgrammer.
You can find the latest version of STM32CubeProgrammer on st.com. See the relevant documentation and links section at the end of this article for direct link to STM32CubeProgrammer’s landing page.
On the other hand, if you already have STM32CubeProgrammer installed on your system you can refer to the steps below to check your current STM32CubeProgrammer version, and if there are any updates available.
Step 1. Launch the STM32CubeProgrammer GUI (Graphical User Interface). In the bottom
left-hand corner of the screen, select the ‘?’ icon. Then select the ‘Software Update’ option.
1055.png
Step 2. A STM32CubeProgrammer updater pop-up window will appear. Note that the contents of this window may differ, depending on the current version of STM32CubeProgrammer you are running. If you have any updates to make, please follow the pop-up window’s on-screen prompts.
1056.png
The STLINK-V3SET is a stand-alone modular debugger and programming probe for the STM8 and STM32 microcontrollers. It is composed of the main module and complementary adapter board. The STLINK-V3SET provides a proprietary USB interface allowing communication with any STM8 or STM32 target with several protocols: SPI, I2C, CAN, UART and GPIOs. This interface may be used to communicate with the target’s bootloader, which we will be demonstrating in this article.
SPI signals are available on MB1440 CN8 and CN9. To reach a high SPI frequency, it is recommended to use a flat ribbon on MB1440 CN8 with all unused signals tied to the ground on the target side.
Using STM32CubeProgrammer with STLINK-V3SET to access the SPI Bootloader
Locate your STM32 device in AN2606. This section will reveal the activation pattern you need to apply. In addition, provides the various available bootloader interfaces for your device, and even more importantly, the hardware resources required by the bootloader.
1058.png
STM32G071’s Bootloader Activation Pattern Selection

In this example, we will select activation pattern 11, row 2. However, feel free in your application to select any of the available activation patterns listed.
1059.png
Nucleo-G071RB Modifications
After connecting your target MCU board to STM32CubeProgrammer, on the left-hand side of the GUI select the “OB” tab and expand the “User Configuration” tab. Verify that Nucleo-G071RB’s option bytes bits nBoot1 = 1 and nBOOT0_SEL = 0.
1061.png

Once disconnected from STM32CubeProgrammer, connect PA14 (BOOT 0 pin) to VDD
1062.png
STM32G071’s SPI Entry Hardware Configurations
In this example, we will select SPI1 as our SPI bootloader entry point:
1063.png
STLINK-V3 Board Jumper Configurations
MB1441 attached/mounted to MB1440B via CN1, CN3 and CN4 connectors  
  • JP10 – both ON
  • JP1, JP2, JP11 and JP12 – ON
  • JP5 and JP3 – ON
  • JP4 – OFF
  • JP6 and JP7 – OFF
  • CN5 – OFF
  • JP8 and JP9 – ON

Nucleo-G071RB and STLINK-V3 Board Connections
Connection EstablishedNucleo-G071RBSTLINK-V3 Set
GND (Ground)JP5 or any other GND pin on the boardCN6 – Pin 3
T_VCC (Target Voltage)CN7 – Pin 16CN6 – Pin 1
SPI1_MOSI (Master Out, Slave In)CN10 – Pin 15, PA7CN9 – Pin 2
SPI1_MISO (Master In, Slave Out)CN10 – Pin 13, PA6CN9 – Pin 3
SPI1_SCK (Clock)CN10 – Pin 11, PA5CN9 – Pin 4
SPI1_NSS (Chip Select)CN7 – Pin 32, PA4CN9 – Pin 1

You will then need to power the Nucleo-G071RB board through the STLINK USB connector, and the STLINK-V3SET through CN5 of the MB1441 board, the USB-Micro B connector.
STM32CubeProgrammer Settings
1064.png
  • Serial Number: The ST-LINK V3SET’s
    • This field contains the serial numbers of all connected STLINK-V3 probes in case of use of SPI bootloader
  • Port: SPI
    • Selects the SPI devices connected to the PC. Use the refresh button to recheck the available devices
  • Baudrate: 375
    • Selects the SPI baud rate
  • Nss: Hard
    • Slave select software or hardware
  • Nsspulse: Pulse
    • The slave selection signal can operate in a pulse mode, where the master generates pulses on nss output signal between data frames for a duration of one SPI clock period where there is a continuous transfer period
  • Delay: No delay
    • Used to insert a delay of several microseconds between data
  • Direction: Full-Duplex
    • Must be always full duplex, both data lines are used, and synchronous data flows in both directions
Congratulations! We have successfully used STM32CubeProgrammer and STLINK-V3SET to launch ST’s internal SPI bootloader on the Nucleo-G071RB board. The STM32CubeProgrammer GUI has various applications that can help you with your project. Some of the things you can do include but are not limited to reading from / writing to flash memory and RAM, reading / programming the device option bytes, and checking CPU register contents.
Relevant Links & Documentation:

 
Version history
Last update:
‎2022-11-10 01:30 PM
Updated by: