cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use STM32CubeProgrammer to access the USB-DFU bootloader on my STM32 board?

Stefanie LAU
ST Employee

In our example here, we will use the Nucleo-H742ZI as our STM32 board to show you how to use the STM32CubeProgrammer to access the target’s USB-DFU bootloader.
Every STM32 MCU comes pre-programmed from our factory with a system memory bootloader stored in the internal boot ROM, which is also referred to as system memory. Its main purpose is to download the application program to the internal Flash memory through one of the available serial peripherals (e.g. USART, CAN, USB DFU, I2C, and SPI). To verify which peripheral interfaces support the activation of the bootloader, the communication protocol 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).

Keeping up to date with the latest version of STM32CubeProgrammer
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.
943.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.
945.png

Using STM32CubeProgrammer to access the USB-DFU bootloader

Step 1. 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.
946.png
Step 2. Locate the pattern denoted in your target MCU’s bootloader configuration description and in the bootloader, activation patterns table. Note that if there are multiple options for a pattern, you may select any option of your choice to apply.
947.png
In our example, the pattern we must use is pattern 10.
948.png

Step 3.
As pattern 10 has two different options, we will select the second pattern 10 option: Boot(pin) = 1 and BOOT_ADD1(optionbyte) = 0x1FF0. On the Nucleo-H743ZI, I have verified that the BOOT_CM7_ADD1 value and address in the MCU’s option bytes is set to 0x1FF0 using STM32CubeProgrammer. I have also connected the BOOT0 pin (located on CN11 pin 7) to VDD.

950.png

Step 4.
You will need two micro-USB cables, one to power the board and another to launch the USB DFU bootloader.

First, locate the user USB port on your board and attach the board to your host machine with a micro-USB cable.
951.png
Second, locate the ST-LINK USB port on your board and connect to the port using the second micro-USB. Note that there are various ways to power the board such as using the on-board ST-LINK or an external 5V power source. Whatever the board’s power source is selected to be; you will need to modify the board’s jumper 2 (JP2) to reflect the 5V power supply source to the Nucleo-H743ZI board.
953.png
STMicroelectronics offers 3 flavors of Nucleo-boards: 32-pin, 64-pin, and 144-pin.
954.png
For more information on the nucleo board’s different power supply and power selection available, please refer to your respective nucleo board’s user manuals. In particular section, Power Supply and Power Selection:  


Step 5. Launch your computer’s device manager. Here you should be able to see that the USB bootloader is now running, and the board is detected as a DFU device.
956.png

Step 6.
In STM32CubeProgrammer you will want to select the USB connectivity option in the drop-down menu next to the green “Connect” icon.  

957.png

Step 7.
Next to where you selected USB connectivity, click on the ‘Connect’ icon. Congratulations! We have successfully used STM32CubeProgrammer to launch ST’s internal USB-DFU bootloader on the Nucleo-H743ZI board.

959.png
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 Documentation and Links:

 
Comments
MStev.4
Associate II

The picture in step 3 of the Option Bytes options is no longer correct (v2.10.0). There is no "Boot address Option Bytes" choice. What need to do to have the Programmer let me load code into my STM32L041xx?

Stefanie LAU
ST Employee

Hello Mike,

Please note that for your device, the STM32L041xx, you will follow the information given in AN2606 section 53 STM32L031xx/041xx devices bootloader. The bootloader is activated by applying pattern 2 in Table 2: Bootloader activation pattern. Pattern 2 is Boot0(pin) = 1 and nBoot1(bit) = 1.

You will need to use STM32CubeProgrammer to verify the value of nBoot1 in the user option bytes, and set this bit to 1 if not already done so.

Then after, you can continue to follow the steps denoted in this article.

Best Regards,

ST MCU Support Team

MStev.4
Associate II

What about jumping to the boot loader location noted in AN2606 section 5?

The ST video at https://www.youtube.com/watch?v=cvKC-4tCRgw shows a way to do this...is the L041xx system bootloader no longer supporting this method?

Stefanie LAU
ST Employee

Hello Mike,

Unfortunately the video that you have shared is not a video directly produced from STMicroelectronics so I cannot comment on that.

Can you kindly help clarify what you mean by 'jumping to the bootloader location noted in AN2606 section 5'? I checked AN2606, and section 5 is STM32C011xx devices bootloader which is another device.

Your device is the L041xx so you will need to review section 53 STM32L031xx/041xx devices bootloader in AN2606 for the supported HW configurations that can launch the ST bootloader.

Best Regards,

ST MCU Support Team

mathieusteketee
Associate III

Hey @Stefanie LAU,

I have an STM32F405RGT6 and also noticed I dont have the tab in Step 3 (Boot address and Option bytes).

I looked at AN2606 section 28 (STM32F40xxx/41xxx devices) and verified that I need Pattern 1:

mathieusteketee_1-1713861378560.png

Which gives me Boot0(pin) = 1 and Boot1(pin) = 0:

mathieusteketee_2-1713861418184.png

 

When you replied to @MStev.4  about needing to verify the value of nBoot1 in the user option bytes, where is this done? As seen in the image below I have the following settings in the Option bytes:

mathieusteketee_0-1713861203623.png

 

Thank you.

 

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