Once you choose upload_protocol = stlink
(which is also the default for Nucleo boards), upload_port
has no effect. You are not uploading via /dev/ttyACM0
devices (that would take effect when you do a serial
bootloader upload), but via the ST-Link USB device.
Choosing stlink
will simply invoke openocd
saying “use the ST-Link adapter”, but not which.
openocd -d2 -s /home/martin/.platformio/packages/tool-openocd/scripts -f board/st_nucleo_l4.cfg -c "program {.pio/build/int-test-idle/firmware.elf} verify reset; shutdown;"
For that, special logic must be injected into openocd
(board scripts) and into PlatformIO to figure out the ST-Link UID.
This was discussed in Choosing STLink V2 programmer - #2 by maxgerhardt.
If you want an easy solution: If you work with Nucleos, they will expose themselves as a USB flashdrive device.
Choose the upload protocol mbed
and point upload_port
to the directory where the device is mounted.