Cannot flash two or three devices in the same machine over COM port

Hi,

I have attached two STM nucleo boards on the same machine and need to flash each device individually over COM port .I try to flash each individual device by defining the COM port on the upload_port on .ini but its flashing to the same device .

I.E : Two nucleo boards which in COM3, COM 5 attach to same pc .
once i define
upload_port = COM3 it should flash to the device in COM3 and once i define
upload_port = COM5 it should flash to the device in COM 5 instead it is flashing to COM3 device .
Is this a bug or am i do something wrong ?

.ini

[env:nucleo_f429zi]

platform = ststm32

board = nucleo_f429zi

framework = arduino

lib_deps = C:\Users\samson.wijeratne\Desktop\ESP32

upload_port= COM3

Thanks.

No, upload is not done via the COM interface of the Nucleo board, but via the USB STLink device on the board. Only pure UART communication goes through the COM port normally. You cannot control the target upload device by specifying a COM port when right now the default upload protocol of upload_protocol = stlink is being used. (That would only be the case when upload_protocol = serial is used and the chip is in UART bootloader mode by resetting while BOOT0 pin high… special case, not important here)

Now sadly PlatformIO does not have the ability to specify the serial number of the STLink you’re trying to upload to by default because it just invokes openocd with the information to use a STLink adapter, but not which one. With some openocd modifications that’s possible. See topics Choosing STLink V2 programmer - #2 by maxgerhardt and More than one ST-Link for upload (several devices are connected to PC_.

However, if you use only Nucleo boards which have an STLink that also exposes a virtual USB disk, there is another possibility. Change to upload_protocol = mbed for all environments and then point upload_port = .. to the drive that the virtual USB disk is mounted, e.g. H:. That is documented here and here. That should work.

Thank you sir for all the info .For now i tried the last method that you recommend which is
" Change to upload_protocol = mbed for all environments and then point upload_port = .."

it works!! will try the other option later too .

Thanks again !