blackbox/Makefile

Wed, 19 Dec 2012 19:46:44 +0100

author
Malte Bayer <mbayer@neo-soft.org>
date
Wed, 19 Dec 2012 19:46:44 +0100
changeset 128
be47571ed2fd
parent 114
313aad7435a8
child 139
7127e7082ee0
permissions
-rw-r--r--

release prepare

0
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
1 PRG=main
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
2
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
3 MCU=atmega16
33
c261350bb394 fixed shortcut detection
Malte Bayer <mbayer@neo-soft.org>
parents: 0
diff changeset
4 #FUSES=-U lfuse:w:0x3f:m -U hfuse:w:0xd8:m
0
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
5 FUSES=-U lfuse:w:0x2f:m -U hfuse:w:0xc8:m
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
6 BOOTFUSES=-U lfuse:w:0xff:m -U hfuse:w:0xce:m
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
7
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
8 #F_CPU=4185600
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
9 #F_CPU = 14318000
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
10
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
11 F_CPU = 8000000
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
12
33
c261350bb394 fixed shortcut detection
Malte Bayer <mbayer@neo-soft.org>
parents: 0
diff changeset
13 BAUD=57600
80
393b63b8c95f added usb programmer option to blackbox makefile
Malte Bayer <mbayer@neo-soft.org>
parents: 33
diff changeset
14 ISP_BAUD=115200
393b63b8c95f added usb programmer option to blackbox makefile
Malte Bayer <mbayer@neo-soft.org>
parents: 33
diff changeset
15 ifdef USB
393b63b8c95f added usb programmer option to blackbox makefile
Malte Bayer <mbayer@neo-soft.org>
parents: 33
diff changeset
16 PORT=/dev/ttyUSB$(USB)
393b63b8c95f added usb programmer option to blackbox makefile
Malte Bayer <mbayer@neo-soft.org>
parents: 33
diff changeset
17 else
393b63b8c95f added usb programmer option to blackbox makefile
Malte Bayer <mbayer@neo-soft.org>
parents: 33
diff changeset
18 PORT=/dev/ttyS0
393b63b8c95f added usb programmer option to blackbox makefile
Malte Bayer <mbayer@neo-soft.org>
parents: 33
diff changeset
19 endif
0
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
20
114
313aad7435a8 fix #688
Malte Bayer <mbayer@neo-soft.org>
parents: 103
diff changeset
21 PROGRAMMER=-P $(PORT) -c stk500v2
313aad7435a8 fix #688
Malte Bayer <mbayer@neo-soft.org>
parents: 103
diff changeset
22 ifdef IF
313aad7435a8 fix #688
Malte Bayer <mbayer@neo-soft.org>
parents: 103
diff changeset
23 PROGRAMMER=-c $(IF)
313aad7435a8 fix #688
Malte Bayer <mbayer@neo-soft.org>
parents: 103
diff changeset
24 endif
313aad7435a8 fix #688
Malte Bayer <mbayer@neo-soft.org>
parents: 103
diff changeset
25
0
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
26 #SRC = main.c seriald.c driver/ADC.c driver/clock.c driver/timer.c
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
27 #SRC = main.c driver/rs232.c driver/manchester.c
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
28 SRC = main.c driver/rs232.c driver/adc.c
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
29 SRC += lowlevel.c
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
30
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
31 ###################################################################
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
32 # You possibly do not need to change settings below this marker
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
33 ###################################################################
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
34
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
35 # Binaries to be used
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
36 # You may add the path to them if they are not in the PATH variable.
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
37 CC = avr-gcc
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
38 OBJCOPY = avr-objcopy
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
39 OBJDUMP = avr-objdump
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
40 AVRDUDE = avrdude
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
41 PERL = perl
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
42
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
43 # Optional library search path
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
44 LIBS =
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
45
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
46 # Compiler options for all c source files
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
47 CFLAGS += -g -Wall -mmcu=$(MCU) -DBAUD=$(BAUD) -DF_CPU=$(F_CPU)UL -std=gnu99
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
48 CFLAGS += -funsigned-char
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
49 CFLAGS += -funsigned-bitfields
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
50 CFLAGS += -fpack-struct
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
51 CFLAGS += -fshort-enums
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
52 CFLAGS += -Wstrict-prototypes
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
53 CFLAGS += -Wundef
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
54 #CFLAGS += -save-temps
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
55
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
56 # optimize for size
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
57 CFLAGS += -Os
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
58 # dont optimize
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
59 #CFLAGS += -O0
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
60
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
61 # Linker options
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
62 LDFLAGS = -Wl,-Map,$(PRG).map
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
63
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
64 # Enable floating-point support in printf
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
65 #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
66
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
67 ###################################################################
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
68 # TARGET DEFINITIONS:
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
69
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
70
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
71 all: code
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
72
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
73 code: $(PRG).hex
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
74
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
75 $(PRG).elf: $(SRC:.c=.o)
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
76 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
77
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
78 %.lst: %.elf
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
79 $(OBJDUMP) -h -S $< > $@
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
80
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
81 %.hex: %.elf
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
82 $(OBJCOPY) -j .text -j .data -O ihex $< $@
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
83 rm $(PRG).elf
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
84 rm $(PRG).map
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
85
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
86 program: code
114
313aad7435a8 fix #688
Malte Bayer <mbayer@neo-soft.org>
parents: 103
diff changeset
87 $(AVRDUDE) $(PROGRAMMER) -b $(ISP_BAUD) -i 1 -p $(MCU) -V -U flash:w:$(PRG).hex:i
0
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
88
103
52fd4283cd2c added learn and teach modes for intelligent ghostcars
Malte Bayer <mbayer@neo-soft.org>
parents: 80
diff changeset
89 backup:
114
313aad7435a8 fix #688
Malte Bayer <mbayer@neo-soft.org>
parents: 103
diff changeset
90 $(AVRDUDE) $(PROGRAMMER) -b $(ISP_BAUD) -i 1 -p $(MCU) -V -U flash:r:$(PRG)_backup.hex:i
103
52fd4283cd2c added learn and teach modes for intelligent ghostcars
Malte Bayer <mbayer@neo-soft.org>
parents: 80
diff changeset
91
128
be47571ed2fd release prepare
Malte Bayer <mbayer@neo-soft.org>
parents: 114
diff changeset
92 restore:
be47571ed2fd release prepare
Malte Bayer <mbayer@neo-soft.org>
parents: 114
diff changeset
93 $(AVRDUDE) $(PROGRAMMER) -b $(ISP_BAUD) -i 1 -p $(MCU) -V -U flash:w:$(PRG).hex:i
be47571ed2fd release prepare
Malte Bayer <mbayer@neo-soft.org>
parents: 114
diff changeset
94
0
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
95 fuse:
114
313aad7435a8 fix #688
Malte Bayer <mbayer@neo-soft.org>
parents: 103
diff changeset
96 $(AVRDUDE) -c $(PROGRAMMER) -p $(MCU) -V $(FUSES)
0
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
97
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
98 clean:
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
99 rm -rf *.o *.elf *.elf.src *.s *.i
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
100 rm -rf driver/*.o
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
101
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
102 upgrade: code
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
103 $(RESETCOMMAND)
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
104 ./bootloader -d $(NETDEV) -b $(UPGRADE_BAUD) -p $(PRG).hex
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
105
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
106 bootloader: bootload.hex
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
107 $(AVRDUDE) -p $(MCU) -c stk500 -V -U flash:w:bootload.hex:i
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
108
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
109 bootfuses:
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
110 $(AVRDUDE) -p $(MCU) -c stk500 $(BOOTFUSES)

mercurial