From 4659e60810c3252e641a7da49ea4846bc84f9dd1 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Wed, 18 Jul 2007 22:11:27 +0000 Subject: [PATCH] One bootloader for the Diecimila and NG - just different makefile targets to pass in slightly different defines. --- bootloader168-diecimila/ATmegaBOOT_168.c | 7 ++-- bootloader168-diecimila/Makefile | 46 ++++++++++++++---------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/bootloader168-diecimila/ATmegaBOOT_168.c b/bootloader168-diecimila/ATmegaBOOT_168.c index f7018075f..c542af144 100755 --- a/bootloader168-diecimila/ATmegaBOOT_168.c +++ b/bootloader168-diecimila/ATmegaBOOT_168.c @@ -78,7 +78,8 @@ /* 20060803: hacked by DojoCorp */ /* 20070626: hacked by David A. Mellis to decrease waiting time for auto-reset */ /* set the waiting time for the bootloader */ -#define MAX_TIME_COUNT (F_CPU>>4) +/* get this from the Makefile instead */ +/* #define MAX_TIME_COUNT (F_CPU>>4) */ /* 20070707: hacked by David A. Mellis - after this many errors give up and launch application */ #define MAX_ERROR_COUNT 5 @@ -357,9 +358,9 @@ int main(void) /* flash onboard LED to signal entering of bootloader */ #ifdef __AVR_ATmega128__ // 4x for UART0, 5x for UART1 - flash_led(3 + bootuart); + flash_led(NUM_LED_FLASHES + bootuart); #else - flash_led(1); + flash_led(NUM_LED_FLASHES); #endif /* 20050803: by DojoCorp, this is one of the parts provoking the diff --git a/bootloader168-diecimila/Makefile b/bootloader168-diecimila/Makefile index d7230c9e9..5a82bf4b9 100755 --- a/bootloader168-diecimila/Makefile +++ b/bootloader168-diecimila/Makefile @@ -2,6 +2,18 @@ # E.Lins, 18.7.2005 # $Id$ +# Instructions +# +# To build the bootloader for the Diecimila: +# make diecimila +# +# To build the bootloader for the NG/Mini: +# make ng +# +# To burn the bootloader: +# make TARGET=diecimila isp +# make TARGET=ng isp + # program name should not be changed... PROGRAM = ATmegaBOOT_168 @@ -26,13 +38,13 @@ LDSECTION = --section-start=.text=0x3800 # 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 +ISPFLASH = avrdude -c $(ISPTOOL) -p m168 -P $(ISPPORT) $(ISPSPEED) -U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x0f:m OBJ = $(PROGRAM).o OPTIMIZE = -O2 -DEFS = +DEFS = LIBS = CC = avr-gcc @@ -41,37 +53,35 @@ CC = avr-gcc # Override is only needed by avr-lib build system. override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS) -override LDFLAGS = -Wl,-Map,$(PROGRAM).map,$(LDSECTION) +override LDFLAGS = -Wl,$(LDSECTION) +#override LDFLAGS = -Wl,-Map,$(PROGRAM).map,$(LDSECTION) OBJCOPY = avr-objcopy OBJDUMP = avr-objdump -all: $(PROGRAM).elf lst text +all: -isp: $(PROGRAM).hex +diecimila: TARGET = diecimila +diecimila: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' +diecimila: $(PROGRAM)_diecimila.hex + +ng: TARGET = ng +ng: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>1' '-DNUM_LED_FLASHES=3' +ng: $(PROGRAM)_ng.hex + +isp: $(PROGRAM)_$(TARGET).hex $(ISPFUSES) $(ISPFLASH) -$(PROGRAM).elf: $(OBJ) +%.elf: $(OBJ) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) clean: - rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep - rm -rf $(PROGRAM).hex $(PROGRAM).srec $(PROGRAM).bin - -lst: $(PROGRAM).lst + rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex %.lst: %.elf $(OBJDUMP) -h -S $< > $@ -# Rules for building the .text rom images - -text: hex bin srec - -hex: $(PROGRAM).hex -bin: $(PROGRAM).bin -srec: $(PROGRAM).srec - %.hex: %.elf $(OBJCOPY) -j .text -j .data -O ihex $< $@