How can I use STM32CubeProgrammer to access the USB-DFU bootloader on my STM32 board?
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.
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.
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.
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.
In our example, the pattern we must use is pattern 10.
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.
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.
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.
STMicroelectronics offers 3 flavors of Nucleo-boards: 32-pin, 64-pin, and 144-pin.
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.
Step 6. In STM32CubeProgrammer you will want to select the USB connectivity option in the drop-down menu next to the green “Connect” icon. 
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.
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:
- AN2606
- AN3156 (USB DFU Protocol used in STM32 Bootloader)
- STM32CubeProgrammer
- Nucleo-H743ZI
- Nucleo-H743ZI Board Schematic
