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.