PlatformIO Community

BOOTUPLOADERFLAGS not applied to final command

Im trying to upload the atmega328 bootloader from optiboot to an arduino nano board from platfomrio via ArduinoAsISP.

platform = atmelavr
framework = arduino
board = ATmega328P

upload_protocol = stk500v1

upload_port = COM7
board_bootloader.file = optiboot/optiboot_atmega328.hex
extra_scripts =

I stumbled when trying to change the uploader flags. If I try to use the bootloader target it responds with:

avrdude: ser_open(): can't open device "unknown": The system cannot find the file specified.

To add a port I tried to add an extra script apending the flag.


        "-P", "COM7"

When checking env.Dump() the flags are there but they dont show up in the final command thats run.

avrdude -p atmega328p -C "path...\avrdude.conf" -e -c stk500v1 -Ulock:w:0x3F:m -Uhfuse:w:0xd6:m -Ulfuse:w:0xf7:m -Uefuse:w:0xfd:m

Any ideas to what I am doing wrong?

On a sidenote, I updated my account information via pio account update but none of the changes are showing up here. Will that take additional time or info here cant be changed?

Indeed, when I run I get pio run -t bootloader -v

Selected fuses: [lfuse = 0xf7, hfuse = 0xd6, efuse = 0xfd]
avrdude -p atmega328p -C "C:\Users\Max\.platformio\packages\tool-avrdude\avrdude.conf" -e -c stk500v1 -Ulock:w:0x3F:m -Uhfuse:w:0xd6:m -Ulfuse:w:0xf7:m -Uefuse:w:0xfd:m
avrdude: ser_open(): can't open device "unknown": Das System kann die angegebene Datei nicht finden.

Burning a bootloader is a two-step process: First the fuses, then the bootloader.

The command you show also doesn’t have the bootloader file in it, which is a hint. What fails is

which is controlled by a different set of flags

So your script must do


        "-P", "COM7"
        "-P", "COM7"

which for me, causes a pio run -t bootloader -v to show

avrdude -p atmega328p -C “C:\Users\Max.platformio\packages\tool-avrdude\avrdude.conf” -e -c stk500v1 -P COM7 -Ulock:w:0x3F:m -Uhfuse:w:0xd6:m -Ulfuse:w:0xf7:m -Uefuse:w:0xfd:m

As the command.