Uploading to multiple devices in the same machine over serial mode

Hi ,

I wanted to upload the code into multiple boards which is STM32 F429ZI Nucleo connected to the same machine(It does not have to be simultaneously).
With ST-Link it is works thanks to Max ,by using the drive letters and use upload protocol as mbed .

But i really looking into use serial method with the given USB-OTG and getting rid of ST-Link board .As per Max instruction i tried to put Boot0 PIN High and use upload_protocol = serial but it does not recognized .Since it is in DFU mode not serial bootloader mode .
Any ideas of how to flash the code using serial mode ? Appreciate for your help.

This is what the device manager shows ,

This is how i set the boot0 high ,


Once BOOT0 is high and the board is reset, the microcontroller executes a very general bootloader that simultaneously opens some interfaces to accept a new firmware, over serial (=UART), USB, SPI, I2C, CAN-bus and more fancy stuff.

Please have alook at https://www.st.com/resource/en/application_note/cd00167594-stm32-microcontroller-system-memory-boot-mode-stmicroelectronics.pdf chapter 33 “STM32F42xxx/43xxx devices bootloader” for your device.

Regarding USB:

When the microcontroller running in bootloader mode is connected via USB, the upload method is called “DFU” (Device Firmware Upgrade).

However… the weird thing is that PlatformIO doesn’t seem to support USB-DFU firmware uploads for some STM32F4 series chips? It’s not listed here but e.g. listed in the STM32F417VE board, as upload_protocol = dfu as usual.

Can you confirm that when using e.g. STM32Cubeprog, upload via the “USB” method works?

If yes, that can be bug-fixed in the board manifest (I’ll instruct how) and at the source repo.

However, I don’t think the underlying USB-DFU program that PIO uses for upload can differentiate multiple boards connected to one computer.

Regarding Serial:

This really means, serial as in UART, not USB. To flash the device via upload_protocol = serial, you need to have USB-UART converter attached, whereas the TX of the adapter goes to PA9 of the target chip and RX goes to PA10 (see aforementioned document). Multiple devices at once can be used that way, by stating seperate upload_port = COMx serial-adapter ports for each device.

For the nucleo, it may be the case that the on-board ST-Link, which also acts as a USB-serial adapter, is already connected to these standard pins, so it can be used.

Still, the board has to be manually put into bootloader mode everytime a new firmware is uploaded, and then put out of bootloader mode to run it again after a reset. So really, either upload_protocol = stlink (with modifications to discern multiple ST-Links) or mbed is the most convenient one, since it does not require manual fiddling with the BOOT jumpers.

Hi Max,

Thank you for the response .I did manage to upload via USB-OTG using DFU method .
Only thing i did was set the BOOT0 pin High and then Change the driver using Zadig program ,
and by using upload_protocol = dfu on .ini

I tried to just now to upload using serial to UART converter and follow your instructions ,by connecting TX to PA9 and RX to PA10 ,and set the BOOT0 pin high .Change the upload_protocol = serial on .ini

when i try to upload it gives the following error ,

Am i doing something wrong here ?

Appreciate for your time .


Ah that’s great :slight_smile:

Hm the device doesn’t seem to be answering via UART. Accroding to the user manual of the Nucleo board (https://www.st.com/resource/en/user_manual/dm00244518.pdf, table 10) PA9 and PA10 might actually be used for some USB stuff. But the bootloader is also on UART3. Maybe you can try and connect the RX of the USB-serial adapter to PB10 and the TX to PB9 (info from initially linked doc).

You must also unplug the USB connection to the target MCU, it directly “locks on” to be flashed via USB once it enumerates with the PC.

Thanks Max ,
I manage to flash using a usb to uart converter by attaching the usb ground .I’m not sure how particle.io manage to upload to their boards i.e; electron STM32 chip using USB-OTG in serial mode . May be they have some sort of driver that can behave like a physical UART on the USB-OTG .
I basically need this for testing purposes where i can attach multiple ST boards to the same computer flash and debug each board consecutively or else i would have used DFU method which is pretty straight forward.

Thanks again!