2 # Project: USBaspLoader (updater)
3 # Author: Stephan Bärwolf
4 # Creation Date: 2012-09-01
6 # License: GNU GPL v2 (see License.txt)
8 include ..
/Makefile.inc
10 # elsewise gcc would complain unnecessary
11 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
)
12 LDFLAGS
= -Wl
,--relax
,--gc-sections
14 DEPENDS
= ..
/firmware
/bootloaderconfig.h ..
/Makefile.inc
16 ifneq ($(FLASHADDRESS
), 0)
17 ifneq ($(FLASHADDRESS
), 00)
18 ifneq ($(FLASHADDRESS
), 000)
19 ifneq ($(FLASHADDRESS
), 0000)
20 ifneq ($(FLASHADDRESS
), 00000)
21 ifneq ($(FLASHADDRESS
), 0x0)
22 ifneq ($(FLASHADDRESS
), 0x00)
23 ifneq ($(FLASHADDRESS
), 0x000)
24 ifneq ($(FLASHADDRESS
), 0x0000)
25 ifneq ($(FLASHADDRESS
), 0x00000)
26 FLASHPREAMBLE
= 0x0000
27 LDFLAGS
+= -Wl
,--section-start
=.text
=$(FLASHADDRESS
)
39 all: updater.hex
$(DEPENDS
)
43 $(AVRDUDE
) -D
-U flash
:w
:updater.hex
:i
48 ..
/firmware
/main.elf
: $(DEPENDS
)
49 $(MAKE
) -C ..
/firmware main.hex
52 usbasploader.raw
: ..
/firmware
/main.elf
$(DEPENDS
)
53 $(OBC
) -j .text
-j .data
-O binary ..
/firmware
/main.elf usbasploader.raw
55 usbasploader.o
: usbasploader.raw
$(DEPENDS
)
56 $(OBC
) -B
$(MCUARCH
) -I binary
-O elf32-avr
--rename-section .data
=.text
--redefine-sym _binary_usbasploader_raw_start
=usbasploader usbasploader.raw usbasploader.o
59 updater.o
: updater.c usbasploader.h usbasploader.raw usbasploader.o
$(DEPENDS
)
61 $(CC
) updater.c
-c
-o updater.o
-DSIZEOF_new_firmware
=$(shell stat
-c
%s usbasploader.raw
) $(CFLAGS
)
63 ifeq ($(UPDATECRC32
), 0)
64 $(CC
) updater.c
-c
-o updater.o
-DSIZEOF_new_firmware
=$(shell stat
-c
%s usbasploader.raw
) -DUPDATECRC32
=0x
$(shell crc32 usbasploader.raw
) $(CFLAGS
)
66 $(CC
) updater.c
-c
-o updater.o
-DSIZEOF_new_firmware
=$(shell stat
-c
%s usbasploader.raw
) -DUPDATECRC32
=$(UPDATECRC32
) $(CFLAGS
)
69 # $(CC) updater.c -c -o updater.o $(CFLAGS)
71 updater.elf
: updater.o usbasploader.o
$(DEPENDS
)
72 $(CC
) updater.o usbasploader.o
-o updater.elf
-Wl
,-Map
,updater.map
$(CFLAGS
) $(LDFLAGS
)
74 updater.asm
: updater.elf
$(DEPENDS
)
75 $(OBD
) -Stdr updater.elf
> updater.asm
77 updater.hex
: updater.elf updater.asm
$(DEPENDS
)
78 $(OBC
) -j .text
-j .data
-O ihex updater.elf updater.hex
90 $(RM
) usbasploader.raw
95 $(RM
) usbasploader.raw