One time per board. But ok I understand. I already read this thread and end up with this code:
import sys
Import("env")
print env.Dump()
def miss(variable):
sys.stderr.write(
"Error: Please specify `%s` in the board config json " % variable
)
exit(1)
if "BOARD" in env:
if "bootloader.low_fuses" in env.BoardConfig():
env.Replace(
LOW_FUSES = env.BoardConfig().get("bootloader.low_fuses")
)
else:
miss('low_fuses')
if "bootloader.high_fuses" in env.BoardConfig():
env.Replace(
HIGH_FUSES = env.BoardConfig().get("bootloader.high_fuses")
)
else:
miss('high_fuses')
if "bootloader.extended_fuses" in env.BoardConfig():
env.Replace(
EXTENDED_FUSES = env.BoardConfig().get("bootloader.extended_fuses")
)
else:
miss('extended_fuses')
if "bootloader.unlock_bits" in env.BoardConfig():
env.Replace(
UNLOCK_BITS = env.BoardConfig().get("bootloader.unlock_bits")
)
else:
miss('unlock_bits')
if "bootloader.lock_bits" in env.BoardConfig():
env.Replace(
LOCK_BITS = env.BoardConfig().get("bootloader.lock_bits")
)
else:
miss('lock_bits')
if "bootloader.file" in env.BoardConfig():
env.Replace(
FILE = env.BoardConfig().get("bootloader.file")
)
else:
miss('file')
if "build.mcu" in env.BoardConfig():
env.Replace(
MCU = env.BoardConfig().get("build.mcu")
)
else:
miss('build.mcu')
else:
sys.stderr.write(
"Error: Please specify in platform ini which board"
)
env.Exit(1)
env.Replace(
SETFUSECMD='$UPLOADER $UPLOADERFLAGS -v -p$MCU -cstk500v1 -Ulock:w:$UNLOCK_BITS:m -Uefuse:w:$EXTENDED_FUSES:m -Uhfuse:w:$HIGH_FUSES:m -Ulfuse:w:$LOW_FUSES:m',
UPLOADBOOTCMD='$UPLOADER $UPLOADERFLAGS -v -p$MCU -cstk500v1 -Uflash:w:$SOURCES:i -Ulock:w:$LOCK_BITS:m',
)
uploadboot = env.Alias(
"bootloader", './$FILE',
[
env.VerboseAction(env.AutodetectUploadPort, "Looking for upload port..."),
env.VerboseAction("$SETFUSECMD", "Setting fuses"),
env.VerboseAction("$UPLOADBOOTCMD", "Uploading bootloader $SOURCE")
]
)
AlwaysBuild(uploadboot)