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
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 ---------------------------------------------------
# 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.
# 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 \
--change-section-address .noinit-0x800000 \
--change-section-address .eeprom-0x810000
-
coff: $(TARGET).elf
$(COFFCONVERT) -O coff-avr $(TARGET).elf $(TARGET).cof