ATTiny 85 - Programming as ISP via USB - How To

I think I’m pretty close to the correct config. I’m not finding information on what setting is required to program via USB using the “Programming as ISP” approach. I’m using an Arduino Uno with a shield I made that I’ve been programming successfully with the Arduino IDE, but I’m trying to migrate all my IDE needs to PlatformIO, but programming ATTiny chips has proven to be difficult with a high learning curve. Thanks for the help!

This is the error I’m getting:

avrdude: ser_open(): can’t open device “usb”: The system cannot find the file specified.

Here’s my config:
;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
; Redirecting...

[env:attiny85env]
platform = atmelavr
board = attiny85
framework = arduino
upload_protocol = stk500v1
; each flag in a new line
upload_flags =
    ;-P$UPLOAD_PORT
    -Pusb
    -b$UPLOAD_SPEED

; edit these lines
;upload_port = SERIAL_PORT_HERE
upload_speed = 19200

So what you did is put the Arduino as ISP sketch on the Uno? According to [the docs(Atmel AVR — PlatformIO latest documentation) it requires

upload_protocol = stk500v1
; each flag in a new line
upload_flags =
    -P$UPLOAD_PORT
    -b$UPLOAD_SPEED

; edit these lines
upload_port = SERIAL_PORT_HERE
upload_speed = 19200

I.e. what you’ve commented out is actually right, plus you need to replace SERIAL_PORT_HERE with the COM port of your Arduino Uno.

1 Like

Thanks! Is there documentation specifying what options satisfy upload_port = ?
I looked around and found no matches, but posts indicated that -Pusb would work, but I found that not to be the case.

If a feature request were to come of this it would be awesome if the COM port requirement would just negotiate itself like the existing upload process does.

Documentation for upload_port is here.

You could always try omitting upload_port, but since it is being passed in via the upload_flags parameter… it will probably fail miserably. If you know your programmer changes between several serial ports (due to order of plugging in devices or which port they are plugged into, you can use wildcards - e.g. COM[13] would expand to COM1, COM2 & COM3, and all three would be tried.

Nothing stopping you putting in a feature request, as that does sound like something that would be useful. With a list of PIDs:VIDs, I don’t see a reason PlatformIO couldn’t also at least attempt to auto-detect programmers.

Ended up with:

[env:attiny85env]
platform = atmelavr
board = attiny85
framework = arduino
upload_protocol = stk500v1
; each flag in a new line
upload_flags =
-P$UPLOAD_PORT
-b$UPLOAD_SPEED

; edit these lines
upload_port = COM5
upload_speed = 19200

1 Like