diff --git a/bootloader168-diecimila/Makefile b/bootloader168-diecimila/Makefile index 1d87f9e31..d7230c9e9 100755 --- a/bootloader168-diecimila/Makefile +++ b/bootloader168-diecimila/Makefile @@ -15,8 +15,18 @@ ISPSPEED = -b 115200 MCU_TARGET = atmega168 LDSECTION = --section-start=.text=0x3800 -ISPFUSES = avrdude -c $(ISPTOOL) -p m168 -P $(ISPPORT) $(ISPSPEED) -u -U efuse:w:0xf8:m -U hfuse:w:0xd7:m -U lfuse:w:0xaf:m -ISPFLASH = avrdude -c $(ISPTOOL) -p m168 -P $(ISPPORT) $(ISPSPEED) -V -U flash:w:$(PROGRAM).hex + +# the efuse should really be 0xf8; since, however, only the lower +# three bits of that byte are used on the atmega168, avrdude gets +# confused if you specify 1's for the higher bits, see: +# http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/ +# +# similarly, the lock bits should be 0xff instead of 0x3f (to +# unlock the bootloader section) and 0xcf instead of 0x0f (to +# lock it), but since the high two bits of the lock byte are +# unused, avrdude would get confused. +ISPFUSES = avrdude -c $(ISPTOOL) -p m168 -P $(ISPPORT) $(ISPSPEED) -e -u -U lock:w:0x3f:m -U efuse:w:0x00:m -U hfuse:w:0xdf:m -U lfuse:w:0xff:m +ISPFLASH = avrdude -c $(ISPTOOL) -p m168 -P $(ISPPORT) $(ISPSPEED) -U flash:w:$(PROGRAM).hex -U lock:w:0x0f:m OBJ = $(PROGRAM).o @@ -39,8 +49,8 @@ OBJDUMP = avr-objdump all: $(PROGRAM).elf lst text isp: $(PROGRAM).hex + $(ISPFUSES) $(ISPFLASH) -# $(ISPFUSES) $(PROGRAM).elf: $(OBJ) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)