Quick UploadProgrammer settings

Hey there,

I use an ISP programmer USBtinyISP and currently in Platformio I need to type this command into the terminal to upload via the programmer:

pio run -t program

Is there any way I can instead just set up some sort of config in the ini file so I don’t have to type this out everytime and maybe just hit the upload button? Thank you!

If you are using VSCode, then on the far left toolbar, there’s the “alien” bug’s head. Click that.

In the list of tasks you can perform, you will find one to upload with your programmer. Click it. :wink:

Sometimes when I click the upload toolbutton in VSCode, it automagically does a program instead of an upload. I didn’t have to do anything special to configure this. I’m told that by having upload_protocol in my platformio.ini file, that the system knows to use program rather than upload.

Maybe try that and see? I use a usbTiny programmer too.


Thanks Norm. So yes, I figured out that if I add these lines it will do the programmer upload with my usbtinyasp

upload_protocol = usbtiny

upload_flags = -e

The -e option for the upload flags is essential here, it won’t always work without it. It has something to do with erasing the flash memory, but it’s unclear to me what it’s role exactly is. I got this from another thread, but even though I don’t understand it’s working great now.

1 Like

Flash RAM is erased when the value 0xFF is written to it. If you need to change a 1 bit to a 0 bit, you can do that without an erase first. You cannot change a 0 to a 1 without an erase.

The -e option erases the entire chip, Flash RAM and EEPROM. It ensures that all memory locations are able to be programmed with the new (sketch) contents.

EDIT: By all locations I include the bootloader too. This is why uploading with an ICSP wipes out the bootloader.

I believe the pio run -t program does this. pio run -t upload doesn’t erase everything as the bootloader does that in a quick erase-write cycle.



1 Like

Awesome, thank you for the info, very helpful!

1 Like