car004f/Makefile

Fri, 27 Dec 2013 12:16:58 +0100

author
mbayer
date
Fri, 27 Dec 2013 12:16:58 +0100
changeset 155
9e27eb837d3f
parent 152
e787f47c084b
permissions
-rw-r--r--

timing finetune

147
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
1 PRG=main
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
2
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
3 MCU=atmega8
151
0e71b51c83a5 car: finished set_id function
mbayer
parents: 149
diff changeset
4 #FUSES=-U lfuse:w:0xAE:m -U hfuse:w:0xd9:m
0e71b51c83a5 car: finished set_id function
mbayer
parents: 149
diff changeset
5 FUSES=-U lfuse:w:0x83:m -U hfuse:w:0xd8:m
147
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
6 # original fuses: 83 / d8
152
e787f47c084b finished car id programming and brake function
mbayer
parents: 151
diff changeset
7
147
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
8 BOOTFUSES=-U lfuse:w:0xff:m -U hfuse:w:0xce:m
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
9
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
10 #F_CPU=4185600
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
11 #F_CPU = 14318000
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
12
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
13 F_CPU = 4000000
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
14 BAUD=38400
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
15
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
16 ISP_BAUD = 115200
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
17 ifdef USB
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
18 PORT=/dev/ttyUSB$(USB)
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
19 else
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
20 PORT=/dev/ttyS0
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
21 endif
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
22
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
23 PROGRAMMER=-P $(PORT) -c stk500v2
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
24 ifdef IF
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
25 PROGRAMMER=-c $(IF)
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
26 endif
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
27
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
28
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
29 #SRC = main.c seriald.c driver/ADC.c driver/clock.c driver/timer.c
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
30 #SRC = main.c driver/rs232.c driver/manchester.c
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
31 #SRC = main.c driver/rs232.c
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
32 SRC = main.c
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
33
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
34 ###################################################################
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
35 # You possibly do not need to change settings below this marker
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
36 ###################################################################
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
37
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
38 # Binaries to be used
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
39 # You may add the path to them if they are not in the PATH variable.
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
40 CC = avr-gcc
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
41 OBJCOPY = avr-objcopy
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
42 OBJDUMP = avr-objdump
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
43 AVRDUDE = avrdude
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
44 PERL = perl
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
45
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
46 # Optional library search path
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
47 LIBS =
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
48
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
49 # Compiler options for all c source files
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
50 CFLAGS += -g -Wall -mmcu=$(MCU) -DBAUD=$(BAUD) -DF_CPU=$(F_CPU)UL -std=gnu99
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
51 CFLAGS += -funsigned-char
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
52 CFLAGS += -funsigned-bitfields
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
53 CFLAGS += -fpack-struct
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
54 CFLAGS += -fshort-enums
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
55 CFLAGS += -Wstrict-prototypes
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
56 CFLAGS += -Wundef
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
57 #CFLAGS += -save-temps
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
58
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
59 # optimize for size
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
60 CFLAGS += -Os
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
61 # dont optimize
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
62 #CFLAGS += -O0
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
63
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
64 # Linker options
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
65 LDFLAGS = -Wl,-Map,$(PRG).map
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
66
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
67 # Enable floating-point support in printf
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
68 #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
69
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
70 ###################################################################
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
71 # TARGET DEFINITIONS:
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
72
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
73
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
74 all: code
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
75
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
76 code: $(PRG).hex
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
77
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
78 $(PRG).elf: $(SRC:.c=.o)
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
79 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
80
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
81 %.lst: %.elf
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
82 $(OBJDUMP) -h -S $< > $@
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
83
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
84 %.hex: %.elf
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
85 $(OBJCOPY) -j .text -j .data -O ihex $< $@
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
86 rm $(PRG).elf
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
87 rm $(PRG).map
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
88
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
89 program: code
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
90 $(AVRDUDE) $(PROGRAMMER) -i 1 -p $(MCU) -V -U flash:w:$(PRG).hex:i
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
91
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
92 backup:
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
93 $(AVRDUDE) -P $(PORT) -c stk500v2 -b $(ISP_BAUD) -i 1 -p $(MCU) -V -U flash:r:$(PRG)_backup.hex:i
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
94
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
95 fuse:
149
1c3425af9aa0 car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents: 147
diff changeset
96 $(AVRDUDE) $(PROGRAMMER) -p $(MCU) -V $(FUSES)
147
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
97
152
e787f47c084b finished car id programming and brake function
mbayer
parents: 151
diff changeset
98 calibration:
e787f47c084b finished car id programming and brake function
mbayer
parents: 151
diff changeset
99 $(AVRDUDE) $(PROGRAMMER) -p $(MCU) -U calibration:r:calibration.data:h
e787f47c084b finished car id programming and brake function
mbayer
parents: 151
diff changeset
100 $(AVRDUDE) $(PROGRAMMER) -p $(MCU) -U eeprom:w:`cut -d ',' -f 3 ./calibration.data`,0xff:m
e787f47c084b finished car id programming and brake function
mbayer
parents: 151
diff changeset
101
147
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
102 clean:
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
103 rm -rf *.o *.elf *.elf.src *.s *.i
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
104 rm -rf driver/*.o
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
105
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
106 upgrade: code
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
107 $(RESETCOMMAND)
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
108 ./bootloader -d $(NETDEV) -b $(UPGRADE_BAUD) -p $(PRG).hex
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
109
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
110 bootloader: bootload.hex
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
111 $(AVRDUDE) -p $(MCU) -c stk500 -V -U flash:w:bootload.hex:i
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
112
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
113 bootfuses:
f66c5b3b3ed2 started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
114 $(AVRDUDE) -p $(MCU) -c stk500 $(BOOTFUSES)

mercurial