How to use PIO with USB programmer

PIO says my serial port is COM1 which it is and where my USB programmer is attached. I don’t have a “board” per se so I’m uploading directly to an Atmega 328P (same MCU as UNO, NANO). In Arduino IDE, I have the option of the regular upload or, if I use the programmer, “Upload using programmer”. It works fine in Arduino, but PIO complains it can’t find the port (which I mentioned displays as Port 1 in PIO). So what am I missing? Do I have to define the programmer…somehow?

I use the Uno, amongst others, and a “usbTiny” programmer. In platformio.ini I would add the details found at Atmel AVR — PlatformIO latest documentation for my programmer.

If you are on Linux, you’ll need some udev rules:

Your login will also need to be in dialout group, possibly plugdev depending on your distro. No harm in adding both.

From the command line, I would:

pio run --target program

which uses the programmer. There are also targets to upload EEPROM data:

pio run --target uploadeep

And fuse setting:

pio run --target fuses

From inside VSCode, on the left, drop down the PlatformIO Tasks, and choose your option, possibly under Advanced Options.

(Sorry I’m vague here – I’m nowhere near VSCode right now.)