X-Git-Url: http://git.linex4red.de/pub/USBaspLoader.git/blobdiff_plain/5b0272d9af73a164da192d796fc33ec736b93f0a..refs/heads/master:/updater/Makefile diff --git a/updater/Makefile b/updater/Makefile index e1b1fbb..db0cd8c 100644 --- a/updater/Makefile +++ b/updater/Makefile @@ -8,9 +8,11 @@ include ../Makefile.inc # elsewise gcc would complain unnecessary -CFLAGS = -Wall -Wno-pointer-to-int-cast -Os -fno-move-loop-invariants -fno-tree-scev-cprop -fno-inline-small-functions -I. -mmcu=$(DEVICE) -DF_CPU=$(F_CPU) -DNEW_BOOTLOADER_ADDRESS=$(NEW_BOOTLOADER_ADDRESS) $(DEFINES) +CFLAGS = -Wall -Wno-pointer-to-int-cast -Os -g3 -ggdb -fno-move-loop-invariants -fno-tree-scev-cprop -fno-inline-small-functions -I. -mmcu=$(DEVICE) -DF_CPU=$(F_CPU) -DBOOTLOADER_ADDRESS=$(BOOTLOADER_ADDRESS) -DNEW_BOOTLOADER_ADDRESS=$(NEW_BOOTLOADER_ADDRESS) -DFLASHADDRESS=$(FLASHADDRESS) $(DEFINES) LDFLAGS = -Wl,--relax,--gc-sections +DEPENDS = ../firmware/bootloaderconfig.h ../Makefile.inc + ifneq ($(FLASHADDRESS), 0) ifneq ($(FLASHADDRESS), 00) ifneq ($(FLASHADDRESS), 000) @@ -34,45 +36,60 @@ endif endif endif -all: updater.hex - -../firmware/main.bin: - $(MAKE) -C ../firmware main.hex - -updater.o: updater.c firmware.h - $(CC) updater.c -c -o updater.o $(CFLAGS) - -updater.elf: updater.o - $(CC) updater.o -o updater.elf $(CFLAGS) $(LDFLAGS) +all: updater.hex $(DEPENDS) -updater.hex: updater.elf - $(OBC) -j .text -j .data -O ihex updater.elf updater.hex - $(ECHO) "." - avr-size updater.elf +flash: all $(ECHO) "." $(AVRDUDE) -D -U flash:w:updater.hex:i $(ECHO) "." + $(ECHO) "." +../firmware/main.elf: $(DEPENDS) + $(MAKE) -C ../firmware main.hex + -firmware_gen.o: firmware_gen.c - $(GCC) firmware_gen.c -c -o firmware_gen.o +usbasploader.raw: ../firmware/main.elf $(DEPENDS) + $(OBC) -j .text -j .data -O binary ../firmware/main.elf usbasploader.raw -firmware_gen: firmware_gen.o - $(GCC) firmware_gen.o -o firmware_gen +usbasploader.o: usbasploader.raw $(DEPENDS) + $(OBC) -B $(MCUARCH) -I binary -O elf32-avr --rename-section .data=.text --redefine-sym _binary_usbasploader_raw_start=usbasploader usbasploader.raw usbasploader.o -firmware.h: firmware_gen ../firmware/main.bin - $(OBC) -j .text -j .data -O binary ../firmware/main.bin usbasploader.raw - @./firmware_gen > firmware.h +updater.o: updater.c usbasploader.h usbasploader.raw usbasploader.o $(DEPENDS) +ifndef UPDATECRC32 + $(CC) updater.c -c -o updater.o -DSIZEOF_new_firmware=$(shell stat -c %s usbasploader.raw) $(CFLAGS) +else +ifeq ($(UPDATECRC32), 0) + $(CC) updater.c -c -o updater.o -DSIZEOF_new_firmware=$(shell stat -c %s usbasploader.raw) -DUPDATECRC32=0x$(shell crc32 usbasploader.raw) $(CFLAGS) +else + $(CC) updater.c -c -o updater.o -DSIZEOF_new_firmware=$(shell stat -c %s usbasploader.raw) -DUPDATECRC32=$(UPDATECRC32) $(CFLAGS) +endif +endif +# $(CC) updater.c -c -o updater.o $(CFLAGS) + +updater.elf: updater.o usbasploader.o $(DEPENDS) + $(CC) updater.o usbasploader.o -o updater.elf -Wl,-Map,updater.map $(CFLAGS) $(LDFLAGS) + +updater.asm: updater.elf $(DEPENDS) + $(OBD) -Stdr updater.elf > updater.asm + +updater.hex: updater.elf updater.asm $(DEPENDS) + $(OBC) -j .text -j .data -O ihex updater.elf updater.hex + $(ECHO) "." + $(ECHO) "." + $(SIZ) updater.elf + $(ECHO) "." deepclean: clean $(RM) *~ clean: - $(RM) *.o - $(RM) *.raw + $(RM) usbasploader.o + $(RM) updater.o + $(RM) usbasploader.raw $(RM) updater.hex + $(RM) updater.asm $(RM) updater.elf - $(RM) firmware_gen - $(RM) firmware.h \ No newline at end of file + $(RM) updater.map + $(RM) usbasploader.raw \ No newline at end of file