trackswitch/Makefile

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

mercurial