From: Jon Langseth Date: Sat, 29 Jun 2013 22:43:46 +0000 (+0200) Subject: Updated to support bootloader programming w/Optiboot. X-Git-Url: https://git.defcon.no/?p=avrfbosd;a=commitdiff_plain;h=2ea18f7e751c7464c664362f7907529e9fc869f0 Updated to support bootloader programming w/Optiboot. Use Optiboot v4.4, modify target optiboot-target "atmega328" and set AVR_FREQ to atmega328: AVR_FREQ = 20000000L Get Optiboot v4.4 from https://code.google.com/p/optiboot/downloads/list --- diff --git a/Makefile b/Makefile index 783fdcd..2569c38 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,10 @@ AVRDUDE_PROGRAMMER = usbtiny AVRDUDE_PORT = usb +AVRDUDE_BL_PROGRAMMER = arduino +AVRDUDE_BL_PORT = COM3 +AVRDUDE_BL_SPEED = 115200 + # Target name and MCU setup ------------------------------------------------- TARGET = fbosd @@ -50,6 +54,12 @@ F_CPU = 20000000 FUSE_LOW = 0xAF FUSE_HIGH = 0xD9 FUSE_EXT = 0x7 +FUSE_LOCK = 0x3F + +BL_FUSE_LOW = 0xBF +BL_FUSE_HIGH = 0xDE +BL_FUSE_EXT = 0x7 +BL_FUSE_LOCK = 0x2F # Source files to compile --------------------------------------------------- @@ -180,8 +190,8 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex # to submit bug reports. #AVRDUDE_VERBOSE = -v -v -AVRDUDE_BASIC = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -AVRDUDE_FLAGS = $(AVRDUDE_BASIC) $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER) +AVRDUDE_PROG = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS = $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER) # Define all object files. @@ -218,22 +228,34 @@ size: # Program the device. program: $(TARGET).hex $(TARGET).eep - $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + $(AVRDUDE) -p $(MCU) $(AVRDUDE_PROG) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) +bl_program: $(TARGET).hex $(TARGET).eep + $(AVRDUDE) -p $(MCU) -c $(AVRDUDE_BL_PROGRAMMER) -P $(AVRDUDE_BL_PORT) -b $(AVRDUDE_BL_SPEED) $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER) $(AVRDUDE_WRITE_FLASH) # make fuseread can be used to test programmer connectivity, and naturally to verify fuses.. fuseread: - $(AVRDUDE) $(AVRDUDE_BASIC) -q -U lfuse:r:-:h -U hfuse:r:-:h -U efuse:r:-:h + $(AVRDUDE) -p $(MCU) $(AVRDUDE_PROG) -q -U lfuse:r:-:h -U hfuse:r:-:h -U efuse:r:-:h FUSES = ifdef FUSE_EXT FUSES += -U efuse:w:$(FUSE_EXT):m endif -FUSES += -U hfuse:w:$(FUSE_HIGH):m +FUSES += -U efuse:w:$(FUSE_EXT):m FUSES += -U lfuse:w:$(FUSE_LOW):m fusebits: $(TARGET).hex - $(AVRDUDE) $(AVRDUDE_BASIC) $(FUSES) + $(AVRDUDE) -p $(MCU) $(AVRDUDE_PROG) $(FUSES) + +lockbits: $(TARGET).hex + $(AVRDUDE) -p $(MCU) $(AVRDUDE_PROG) -e -u -U lock:w:$(FUSE_LOCK):m + +bl_fusebits: $(TARGET).hex + $(AVRDUDE) -p $(MCU) $(AVRDUDE_PROG) -U efuse:w:$(BL_FUSE_EXT):m -U efuse:w:$(BL_FUSE_EXT):m -U lfuse:w:$(BL_FUSE_LOW):m + +bl_lockbits: $(TARGET).hex + $(AVRDUDE)-p $(MCU) $(AVRDUDE_PROG) -e -u -U lock:w:$(BL_FUSE_LOCK):m + # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. COFFCONVERT=$(OBJCOPY) --debugging \ --change-section-address .data-0x800000 \ @@ -241,7 +263,6 @@ COFFCONVERT=$(OBJCOPY) --debugging \ --change-section-address .noinit-0x800000 \ --change-section-address .eeprom-0x810000 - coff: $(TARGET).elf $(COFFCONVERT) -O coff-avr $(TARGET).elf $(TARGET).cof