platformio / platform-atmelavr

Atmel AVR: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/atmelavr
Apache License 2.0
138 stars 105 forks source link

AVRispMkII fuse programming fails #88

Closed xelarep closed 3 years ago

xelarep commented 6 years ago

When trying to program fuses on a standalone Atmel device with an AVRispMkII Usb programmer by pio run --target fuses the programming fails. I get the unspecified upload_port error *** [fuses] could not open port -P usb: [Errno 2] No such file or directory: ‘-P usb’.

I did several testings like explained in the documentation. Here are some excerpts

platformio.ini

[env:custom_fuses]
platform = atmelavr
board_mcu = atmega328
board_f_cpu = 8000000L

upload_protocol = stk500v2
upload_flags = -P usb -e -v
upload_port = -P usb

extra_scripts = fuses.py

fuses.py

#Import('env')
from os.path import join
from SCons.Script import DefaultEnvironment

env = DefaultEnvironment()

#env.Replace(UPLOADHEXCMD="$UPLOADER $UPLOADERFLAGS -U flash:w:$SOURCES:i")
env.Replace(
    MYUPLOADERFLAGS=[
        "-v",
        "-p", "$BOARD_MCU",
        "-P", "usb",
        "-C",
        '"%s"' % join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude.conf"),
        "-c", "$UPLOAD_PROTOCOL",
        "-b", "$UPLOAD_SPEED"
     ],
    UPLOADHEXCMD='"$UPLOADER" $MYUPLOADERFLAGS -U flash:w:$SOURCES:i'
    )

env.Replace(FUSESCMD="avrdude $UPLOADERFLAGS -U lock:w:0xFF:m -U lfuse:w:0x62:m -U hfuse:w:0xD9:m -U efuse:w:0xFF:m")

# uncomment line below to see environment variables
print " ********************** fuses328p.py ***********************"
print env["UPLOADHEXCMD"]
print env["FUSESCMD"]
#print "-"
#print env.Dump()
print " ********************** fuses328p.py ***********************"

It's nearly the same behaviour like trying to upload instead of program

Currently I have to set up fuses externally with avrdude...

PS: initial discussion started in PlatformIO-community: https://community.platformio.org/t/avr-standalone-projects/3428

DerAndere1 commented 3 years ago

any news?

valeros commented 3 years ago

A lot has changed since this issue was filed, please read this doc https://docs.platformio.org/en/latest/platforms/atmelavr.html#fuses-programming