Cannot handle device: "/dev/" prefix

Hello,

I just found out about PlatformIO as a nice alternative to using the Arduino IDE and am trying out the VSCode extension at the moment. I want to upload a program using a USB-to-serial converter to a Black Pill (similar to Blue Pill STM32F103C8). This is my platformio.ini:

[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
framework = arduino

upload_protocol = serial
; upload_port = /dev/ttyUSB0
upload_speed = 115200

When I try to upload, I get the following log though:

Building .pioenvs/genericSTM32F103C8/firmware.bin
DATA: [= ] 12.3% (used 2520 bytes from 20480 bytes)
PROGRAM: [== ] 22.0% (used 14424 bytes from 65536 bytes)
Configuring upload protocol…
AVAILABLE: blackmagic, dfu, jlink, serial, stlink
CURRENT: upload_protocol = serial
Looking for upload port…
Auto-detected: /dev/ttyUSB0
Uploading .pioenvs/genericSTM32F103C8/firmware.bin
stm32flash Arduino_STM32_0.9

GitHub - rogerclarkmelbourne/Arduino_STM32: Arduino STM32. Hardware files to support STM32 boards, on Arduino IDE 1.8.x including LeafLabs Maple and other generic STM32F103 boards

Using Parser : Raw BINARY

Cannot handle device “/dev//dev/ttyUSB0”
Failed to open port: /dev//dev/ttyUSB0
*** [upload] Error 1

The same happens when I uncomment the upload_port line. When I take away the “/dev/” from upload_port, I get another error, which tells me to specify the upload port correctly.

Now it seems that the error comes from the “/dev/” prefix in front of the device name. Is there a simple way to fix this? It seems that PlatformIO and the arduino_stm32 interface handle the device port differently.

See platform-ststm32/main.py at develop · platformio/platform-ststm32 · GitHub

You can try to tune this code which is located in ~/.platformio/platforms on your machine.