PlatformIO on Ubuntu - How to Reference COM and USB ports

At the moment I run a Windows10 platform but I plan to migrate to Ubuntu 24.04.

Currently I variously use Arduino as ISP via a COM port, USBASP via USB port and more recently via python script pymcuprog with modified USB to serial card for writing to series 0, 1, 2 devices.

I am new to Unix.

How do I get the platformio.ini to reference the upload port I want to use?

I have PlatformIO running on an Ubuntu platform. I can compile but I do not know how to reference the COM port or USB port.

SOLUTION - if you’re using a serial card in a COM port, plug it in and do a pio device list from a PlatformIO terminal to see how Ubuntu references your device - but also check on the permissions care of the link to the post by Max Gerhardt below. (This doesn’t work for USBASP progranners)

Here’s the platformio.ini I was using:

; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:attiny85]
platform = atmelavr
board = attiny85
framework = arduino

; device is USBASP V2.0 with updated firmware

upload_protocol = custom
; upload_port = usb *** this used to work on my Windows platform ***
upload_port = /dev/usb0
upload_flags =
-C
${platformio.packages_dir}/tool-avrdude/avrdude.conf
-p
$BOARD_MCU
-P
$UPLOAD_PORT
-c
usbasp
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

And here’s the error just after compile as it tries but fails on the upload:

Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [======    ]  59.8% (used 306 bytes from 512 bytes)
Flash: [==        ]  24.5% (used 2006 bytes from 8192 bytes)
Building .pio/build/attiny85/firmware.hex
Configuring upload protocol...
AVAILABLE: custom
CURRENT: upload_protocol = custom
Uploading .pio/build/attiny85/firmware.hex
avrdude: Warning: cannot open USB device: Permission denied
avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'

Please could you aim me at the appropriate documentation - as I said I’m new to Unix as in, I installed it today.

If I use an Arduino Uno and hook this up via a serial cable, then do a

pio device list

I can see a /dev/ttyACM0

If I change my upload_port to upload_port = /dev/ttyACM0

the error indicates

Uploading .pio/build/attiny85/firmware.hex
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied

avrdude done.  Thank you.

*** [upload] Error 1

So I have two issues, one is how to grant permissions but the other is both this and also how to reference my USBASP programmer if I use that - it never shows up in the device list as in pio device list

I’m making progress but v slowly.

I found this related post from Max Gerhardt but it didn’t help me.

AH - forgot to log out and back in. I can now successfully program an Attiny85 target with Arduino as ISP.

I’m still struggling with the USBASP programmer but I’ll open another post.

Because one ‘heart’ doesn’t do it justice…

Good job on writing up a coherent question, finding a solution, and then presenting that solution in a way that will help others…if they search for it. These solutions all seem right to me and it’s a good crash-landing for someone just needing to get a board flashed without every bit of trivia.

I wish more forum consumers would be forum producers like this.

Nicely done!