blackbox/Makefile

Wed, 26 Jun 2013 11:37:23 +0200

author
Malte Bayer <mbayer@neo-soft.org>
date
Wed, 26 Jun 2013 11:37:23 +0200
changeset 141
467e6351986e
parent 140
f910ad6ed0b6
child 145
80be5eb283d3
permissions
-rw-r--r--

improved car detection

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
139
7127e7082ee0 switched firmware to binary protocol, TODO: client implementation
Malte Bayer <mbayer@neo-soft.org>
parents: 128
diff changeset
12 #F_CPU = 16000000
0
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
13
140
f910ad6ed0b6 client binary protocol implementation
Malte Bayer <mbayer@neo-soft.org>
parents: 139
diff changeset
14 BAUD=57600
f910ad6ed0b6 client binary protocol implementation
Malte Bayer <mbayer@neo-soft.org>
parents: 139
diff changeset
15 #BAUD=33600
80
393b63b8c95f added usb programmer option to blackbox makefile
Malte Bayer <mbayer@neo-soft.org>
parents: 33
diff changeset
16 ISP_BAUD=115200
393b63b8c95f added usb programmer option to blackbox makefile
Malte Bayer <mbayer@neo-soft.org>
parents: 33
diff changeset
17 ifdef USB
393b63b8c95f added usb programmer option to blackbox makefile
Malte Bayer <mbayer@neo-soft.org>
parents: 33
diff changeset
18 PORT=/dev/ttyUSB$(USB)
393b63b8c95f added usb programmer option to blackbox makefile
Malte Bayer <mbayer@neo-soft.org>
parents: 33
diff changeset
19 else
393b63b8c95f added usb programmer option to blackbox makefile
Malte Bayer <mbayer@neo-soft.org>
parents: 33
diff changeset
20 PORT=/dev/ttyS0
393b63b8c95f added usb programmer option to blackbox makefile
Malte Bayer <mbayer@neo-soft.org>
parents: 33
diff changeset
21 endif
0
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
22
114
313aad7435a8 fix #688
Malte Bayer <mbayer@neo-soft.org>
parents: 103
diff changeset
23 PROGRAMMER=-P $(PORT) -c stk500v2
313aad7435a8 fix #688
Malte Bayer <mbayer@neo-soft.org>
parents: 103
diff changeset
24 ifdef IF
313aad7435a8 fix #688
Malte Bayer <mbayer@neo-soft.org>
parents: 103
diff changeset
25 PROGRAMMER=-c $(IF)
313aad7435a8 fix #688
Malte Bayer <mbayer@neo-soft.org>
parents: 103
diff changeset
26 endif
313aad7435a8 fix #688
Malte Bayer <mbayer@neo-soft.org>
parents: 103
diff changeset
27
0
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
28 #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
29 #SRC = main.c driver/rs232.c driver/manchester.c
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
30 SRC = main.c driver/rs232.c driver/adc.c
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
31 SRC += lowlevel.c
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
32
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 # 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
35 ###################################################################
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
36
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
37 # Binaries to be used
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
38 # 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
39 CC = avr-gcc
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
40 OBJCOPY = avr-objcopy
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
41 OBJDUMP = avr-objdump
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
42 AVRDUDE = avrdude
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
43 PERL = perl
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
44
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
45 # Optional library search path
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
46 LIBS =
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
47
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
48 # Compiler options for all c source files
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
49 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
50 CFLAGS += -funsigned-char
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
51 CFLAGS += -funsigned-bitfields
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
52 CFLAGS += -fpack-struct
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
53 CFLAGS += -fshort-enums
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
54 CFLAGS += -Wstrict-prototypes
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
55 CFLAGS += -Wundef
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
56 #CFLAGS += -save-temps
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
57
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
58 # optimize for size
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
59 CFLAGS += -Os
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
60 # dont optimize
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
61 #CFLAGS += -O0
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
62
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
63 # Linker options
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
64 LDFLAGS = -Wl,-Map,$(PRG).map
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
65
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
66 # Enable floating-point support in printf
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
67 #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
68
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 # TARGET DEFINITIONS:
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
71
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 all: code
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 code: $(PRG).hex
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
76
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
77 $(PRG).elf: $(SRC:.c=.o)
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
78 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
79
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
80 %.lst: %.elf
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
81 $(OBJDUMP) -h -S $< > $@
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
82
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
83 %.hex: %.elf
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
84 $(OBJCOPY) -j .text -j .data -O ihex $< $@
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
85 rm $(PRG).elf
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
86 rm $(PRG).map
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
87
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
88 program: code
114
313aad7435a8 fix #688
Malte Bayer <mbayer@neo-soft.org>
parents: 103
diff changeset
89 $(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
90
103
52fd4283cd2c added learn and teach modes for intelligent ghostcars
Malte Bayer <mbayer@neo-soft.org>
parents: 80
diff changeset
91 backup:
114
313aad7435a8 fix #688
Malte Bayer <mbayer@neo-soft.org>
parents: 103
diff changeset
92 $(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
93
128
be47571ed2fd release prepare
Malte Bayer <mbayer@neo-soft.org>
parents: 114
diff changeset
94 restore:
be47571ed2fd release prepare
Malte Bayer <mbayer@neo-soft.org>
parents: 114
diff changeset
95 $(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
96
0
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
97 fuse:
114
313aad7435a8 fix #688
Malte Bayer <mbayer@neo-soft.org>
parents: 103
diff changeset
98 $(AVRDUDE) -c $(PROGRAMMER) -p $(MCU) -V $(FUSES)
0
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
99
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
100 clean:
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
101 rm -rf *.o *.elf *.elf.src *.s *.i
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
102 rm -rf driver/*.o
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
103
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
104 upgrade: code
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
105 $(RESETCOMMAND)
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
106 ./bootloader -d $(NETDEV) -b $(UPGRADE_BAUD) -p $(PRG).hex
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
107
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
108 bootloader: bootload.hex
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
109 $(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
110
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
111 bootfuses:
9b7de464f0ea initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
112 $(AVRDUDE) -p $(MCU) -c stk500 $(BOOTFUSES)

mercurial