cancel
Showing results for 
Search instead for 
Did you mean: 

How to flash STM32 MCU using USB

FrankNatoli
Associate III

Using IAR to develop software for and burn flash via USB on STM32 7B3I and Discovery eval boards.

Need to develop my own Windows software to burn flash via USB on our own product.

Am familiar with AN2606 [bootloader] and AN3156 [DFU] but neither appear to document how to use host USB to burn client flash.

Can anyone point to a relevant document?

1 ACCEPTED SOLUTION

Accepted Solutions

Ahhh stop your waste time with this USB idea. DFU Driver is part of instalation STM_Programmer from my first post.

When you plan use discovery boards skip trying DFU and use STLINK to every board.

View solution in original post

16 REPLIES 16
MM..1
Chief III

If you set properly board to DFU mode then

STM32_Programmer_CLI.exe -c port=USB1 -d c:\***\Debug\prjprj.elf

Thank you, but, I'm looking for either DFU implementation documentation or open source.

I think I've found that with dfu-util-master over at sourceforge.net.

Although that has both source and Visual Studio solution files, it unfortunately references but does not include libusb project sources and getopt project sources, which I am trying to find and merge into the dfu-util-master solution.

Please forgive my relative ignorance on this matter, but are STM32 development boards, e.g., Discovery or 7B3I, not by default in "DFU" mode?

I have gone through the considerable effort of downloading dfu-util-master from SourceForge.net, plus libusb, plus getopt, getting all three projects to successfully compile and link under Microsoft Visual Studio 2022, and the resultant EXE cannot find any DFU capable devices, although IAR has no problem recognizing, programming and debugging the Discovery and 7B3I via USB.

The NUCLEO and DISCO boards have an on-board ST-LINK debugger / SWD/JTAG connection, they use THAT in the IDE and STM32 Cube Program in ST-LINK mode.

You'd have to make a specific EFFORT to connect to a USB connector that goes to the target STM32 MCU, and pull BOOT0 HIGH so that the ROM based System Loader would start, and the device would instantiate on the PC as a "STM32 BOOT LOADER" type device, ie USB in DFU mode, and then STM32 Cube Programmer could connect in USB mode, and you could send a DFU file.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Tesla, thank you for your reply.

However, at this time, the only connection between my Windows 10 x64 development system and the STMicro Discovery and 7B3I eval systems is USB and IAR is quite capable of downloading flash and debugging the targets.

Both eval systems have two micro-B connectors, one marked "STM" the other "USB OTG".

IAR downloads flash via the STM connector.

My own software development, serial data exchanged between PC application and target system, targets the USB OTG connector.

Thus, I infer, IAR has a way of putting the target in DFU mode, so that IAR can download flash via the USB STM connector.

There is no JTAG wiring between the PC and the targets.

How is that done?

You miss " IAR has a way of putting the target in DFU mode" = false

Every DISCO board have STLINK chip with USB and use it for FLASH or DEBUG target MCU.

So "STLINK chip with USB and use it for FLASH or DEBUG target MCU" is not DFU?

So DFU has to be done through the OTG USB port?

  1. yes isnt
  2. yes and condition in AN2606

OK, thanks.

I believe the 7B3I eval has an STM32H7B3I MCU.

AN2606, all of 426 pages, on page 267 describes bootloader for STM32H7A3xx/B3xx, which I believe is what I need.

Page 270 covers DFU bootloader, which uses USB.

That requires programming USB_DM pin and USB_DP pin.

Do you know if Windows applications can use serial port model control signals to toggle USB_DM and/or USB_DP?

And how does the bootloader on the STM32H7B3I know whether to watch the STM USB port or the OTG USB port?

Or is the bootloader watching both USB ports?

Thanks for your time.