Im trying to upload the atmega328 bootloader from optiboot to an arduino nano board from platfomrio via ArduinoAsISP.
[env:ArduinoAsISP]
platform = atmelavr
framework = arduino
board = ATmega328P
upload_protocol = stk500v1
upload_port = COM7
board_bootloader.file = optiboot/optiboot_atmega328.hex
extra_scripts = bootloader.py
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.
Import("env")
env.Append(
BOOTUPLOADERFLAGS=[
"-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
print(
"\nSelected fuses: [lfuse = %s, hfuse = %s%s]"
% (lfuse, hfuse, ", efuse = %s" % efuse if efuse else "")
)
fuses_action = env.VerboseAction("$SETFUSESCMD", "Setting fuses")
which is controlled by a different set of flags
env.Replace(
FUSESUPLOADER="avrdude",
FUSESUPLOADERFLAGS=[
"-p",
"$BOARD_MCU",
"-C",
'"%s"'
% join(env.PioPlatform().get_package_dir("tool-avrdude") or "", "avrdude.conf"),
],
FUSESFLAGS=[
"-Ulock:w:%s:m" % lock,
"-Uhfuse:w:%s:m" % hfuse,
"-Ulfuse:w:%s:m" % lfuse,
],
SETFUSESCMD="$FUSESUPLOADER $FUSESUPLOADERFLAGS $UPLOAD_FLAGS $FUSESFLAGS",
)
So your bootloader.py
script must do
Import("env")
env.Append(
BOOTUPLOADERFLAGS=[
"-P", "COM7"
],
FUSESUPLOADERFLAGS=[
"-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.