car004f/Makefile

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

mercurial