new feature "HAVE_UNPRECISEWAIT" for save some flash
[pub/USBaspLoader.git] / updater / Makefile
1 # Name: Makefile
2 # Project: USBaspLoader (updater)
3 # Author: Stephan Bärwolf
4 # Creation Date: 2012-09-01
5 # Tabsize: 4
6 # License: GNU GPL v2 (see License.txt)
7
8 include ../Makefile.inc
9
10 # elsewise gcc would complain unnecessary
11 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) -DBOOTLOADER_ADDRESS=$(BOOTLOADER_ADDRESS) -DNEW_BOOTLOADER_ADDRESS=$(NEW_BOOTLOADER_ADDRESS) $(DEFINES)
12 LDFLAGS = -Wl,--relax,--gc-sections
13
14 ifneq ($(FLASHADDRESS), 0)
15 ifneq ($(FLASHADDRESS), 00)
16 ifneq ($(FLASHADDRESS), 000)
17 ifneq ($(FLASHADDRESS), 0000)
18 ifneq ($(FLASHADDRESS), 00000)
19 ifneq ($(FLASHADDRESS), 0x0)
20 ifneq ($(FLASHADDRESS), 0x00)
21 ifneq ($(FLASHADDRESS), 0x000)
22 ifneq ($(FLASHADDRESS), 0x0000)
23 ifneq ($(FLASHADDRESS), 0x00000)
24 FLASHPREAMBLE = 0x0000
25 LDFLAGS += -Wl,--section-start=.text=$(FLASHADDRESS)
26 endif
27 endif
28 endif
29 endif
30 endif
31 endif
32 endif
33 endif
34 endif
35 endif
36
37 all: updater.hex
38
39 ../firmware/main.bin:
40 $(MAKE) -C ../firmware main.hex
41
42
43 usbasploader.raw: ../firmware/main.bin
44 $(OBC) -j .text -j .data -O binary ../firmware/main.bin usbasploader.raw
45
46 usbasploader.o: usbasploader.raw
47 $(OBC) -B $(MCUARCH) -I binary -O elf32-avr --rename-section .data=.text --redefine-sym _binary_usbasploader_raw_start=usbasploader usbasploader.raw usbasploader.o
48
49
50 updater.o: updater.c usbasploader.h usbasploader.raw usbasploader.o
51 $(CC) updater.c -c -o updater.o -DSIZEOF_new_firmware=$(shell stat -c %s usbasploader.raw) $(CFLAGS)
52 # $(CC) updater.c -c -o updater.o $(CFLAGS)
53
54 updater.elf: updater.o usbasploader.o
55 $(CC) updater.o usbasploader.o -o updater.elf $(CFLAGS) $(LDFLAGS)
56
57 updater.hex: updater.elf
58 $(OBC) -j .text -j .data -O ihex updater.elf updater.hex
59 $(ECHO) "."
60 $(ECHO) "."
61 $(SIZ) updater.elf
62 $(ECHO) "."
63 $(AVRDUDE) -D -U flash:w:updater.hex:i
64 $(ECHO) "."
65
66
67 deepclean: clean
68 $(RM) *~
69
70 clean:
71 $(RM) usbasploader.o
72 $(RM) updater.o
73 $(RM) usbasploader.raw
74 $(RM) updater.hex
75 $(RM) updater.elf
76 $(RM) usbasploader.raw