X-Git-Url: http://git.linex4red.de/pub/USBaspLoader.git/blobdiff_plain/fa0b51823454caae26a476ec1e156a73377b4546..40fa0566e149b4f384454b4f1ab07d366ea4ab7e:/firmware/Makefile diff --git a/firmware/Makefile b/firmware/Makefile index fb1db72..486003f 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -17,20 +17,15 @@ include ../Makefile.inc -# Options: -DEFINES = #-DDEBUG_LEVEL=2 # Remove the -fno-* options when you use gcc 3, it does not understand them -CFLAGS = -Wall -Os -fno-move-loop-invariants -fno-tree-scev-cprop -fno-inline-small-functions -I. -mmcu=$(DEVICE) -DBOOTLOADER_ADDRESS=$(BOOTLOADER_ADDRESS) -DF_CPU=$(F_CPU) $(DEFINES) -LDFLAGS = -Wl,--relax,--gc-sections -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS) +CFLAGS = -Wall -Os -g3 -ggdb -fno-move-loop-invariants -fno-tree-scev-cprop -fno-inline-small-functions -I. -mmcu=$(DEVICE) -DBOOTLOADER_ADDRESS=$(BOOTLOADER_ADDRESS) -DF_CPU=$(F_CPU) $(DEFINES) +LDFLAGS = -Wl,--relax,--gc-sections -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS) -Wl,--defsym=nullVector=0 OBJECTS = usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o # symbolic targets: all: main.hex -install: main.hex - cp -Rvp main.hex ./hexfiles/usbasploader.hex - .c.o: $(CC) $(CFLAGS) -c $< -o $@ @@ -45,57 +40,73 @@ install: main.hex $(CC) $(CFLAGS) -S $< -o $@ flash: all + $(ECHO) "." $(AVRDUDE) -U flash:w:main.hex:i + $(ECHO) "." + $(ECHO) "." readflash: + $(ECHO) "." $(AVRDUDE) -U flash:r:read.hex:i + $(ECHO) "." + $(ECHO) "." + fuse: + $(ECHO) "." $(AVRDUDE) $(FUSEOPT) + $(ECHO) "." + $(ECHO) "." + lock: + $(ECHO) "." $(AVRDUDE) $(LOCKOPT) + $(ECHO) "." + $(ECHO) "." + read_fuses: $(UISP) --rd_fuses deepclean: clean - rm -f *~ + $(RM) *~ clean: - rm -f main.hex main.bin *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s + $(RM) main.hex + $(RM) main.asm + $(RM) main.map + $(RM) main.elf + $(RM) main.o + $(RM) main.s + $(RM) usbdrv/usbdrvasm.o + $(RM) usbdrv/oddebug.o + $(RM) usbdrv/oddebug.s + $(RM) usbdrv/usbdrv.s # file targets: -main.bin: $(OBJECTS) - $(CC) $(CFLAGS) -o main.bin $(OBJECTS) $(LDFLAGS) - -main.hex: main.bin - rm -f main.hex main.eep.hex - avr-objcopy -j .text -j .data -O ihex main.bin main.hex - avr-size main.bin - -disasm: main.bin - avr-objdump -d main.bin +main.elf: $(OBJECTS) bootloaderconfig.h + $(CC) $(CFLAGS) -o main.elf $(OBJECTS) -Wl,-Map,main.map $(LDFLAGS) + +main.asm: main.elf + $(OBD) -Stdr main.elf > main.asm + +main.hex: main.elf main.asm + $(RM) main.hex main.eep.hex + $(OBC) -j .text -j .data -O ihex main.elf main.hex + $(ECHO) "." + $(ECHO) "." + $(ECHO) "." + $(ECHO) "!!!ATTANTION!!!" + $(ECHO) "(data+text) MUST fit into your MCUs bootloader section" + $(ECHO) "." + $(SIZ) --mcu $(DEVICE) main.elf + $(ECHO) "." + $(ECHO) "." + $(ECHO) "." + +disasm: main.elf + $(OBD) -d main.elf cpp: $(CC) $(CFLAGS) -E main.c - -# Special rules for generating hex files for various devices and clock speeds -ALLHEXFILES = hexfiles/mega8_12mhz.hex hexfiles/mega8_15mhz.hex hexfiles/mega8_16mhz.hex \ - hexfiles/mega88_12mhz.hex hexfiles/mega88_15mhz.hex hexfiles/mega88_16mhz.hex hexfiles/mega88_20mhz.hex\ - hexfiles/mega168_12mhz.hex hexfiles/mega168_15mhz.hex hexfiles/mega168_16mhz.hex hexfiles/mega168_20mhz.hex\ - hexfiles/mega328p_12mhz.hex hexfiles/mega328p_15mhz.hex hexfiles/mega328p_16mhz.hex hexfiles/mega328p_20mhz.hex - -allhexfiles: $(ALLHEXFILES) - $(MAKE) clean - avr-size hexfiles/*.hex - -$(ALLHEXFILES): - @[ -d hexfiles ] || mkdir hexfiles - @device=`echo $@ | sed -e 's|.*/mega||g' -e 's|_.*||g'`; \ - clock=`echo $@ | sed -e 's|.*_||g' -e 's|mhz.*||g'`; \ - addr=`echo $$device | sed -e 's/\([0-9]\)8/\1/g' | awk '{printf("%x", ($$1 - 2) * 1024)}'`; \ - echo "### Make with F_CPU=$${clock}000000 DEVICE=atmega$$device BOOTLOADER_ADDRESS=$$addr"; \ - $(MAKE) clean; \ - $(MAKE) main.hex F_CPU=$${clock}000000 DEVICE=atmega$$device BOOTLOADER_ADDRESS=$$addr DEFINES=-DUSE_AUTOCONFIG=1 - mv main.hex $@