-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
144 lines (92 loc) · 3.65 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
SRC = $(wildcard *.c)
ASRC = $(wildcard *.s)
OBJS = $(SRC:%.c=%.o)
AOBJS = $(ASRC:%.s=%.o)
HEADERS = $(SRC:%.c=%.h)
PRG = main
OBJ = program.o
MCU_TARGET = atmega328
OPTIMIZE = -O2
# DEFS = -W1,-u,vprintf -lprintf_flt -lm
DEFS =
LIBS =
# You should not have to change anything below here.
AS =avr-as
CC = avr-gcc
CXX = avr-g++
# Override is only needed by avr-lib build system.
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) -I/usr/lib/avr/include
#override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) -I/usr/local/avr/avr/include
override CXXFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
override LDFLAGS = -Wl,-Map,$(PRG).map
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
all: $(PRG).elf lst text eeprom size
$(PRG).elf: $(SRC) $(HEADERS) $(ASRC)
$(CC) $(CFLAGS) $(LDFLAGS) -o $(PRG).elf $(SRC) $(LIBS)
clean:
rm -rf *.o $(PRG).elf *.eps *.bak
rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)
install:
avrdude -c pony-stk200 -P /dev/parport0 -p m328 -e -U flash:w:$(PRG).hex
usbinstall:
avrdude -c avrisp2 -P usb -p m328p -e -U flash:w:$(PRG).hex
tominstall:
avrdude -c avrisp -P usb -p m328p -e -U flash:w:$(PRG).hex
arduinoinstall0:
avrdude -c arduino -P /dev/ttyUSB0 -b 57600 -p m328p -e -U flash:w:$(PRG).hex
genuineard0:
avrdude -c arduino -P /dev/ttyACM0 -b 115200 -p m328p -e -U flash:w:$(PRG).hex
fakeard0:
avrdude -c arduino -P /dev/ttyACM0 -b 57600 -p m328p -e -U flash:w:$(PRG).hex
fastarduinoinstall0:
avrdude -c arduino -P /dev/ttyUSB0 -b 115200 -p m328p -e -U flash:w:$(PRG).hex
arduinoinstall1:
avrdude -c arduino -P /dev/ttyUSB1 -b 57600 -p m328p -e -U flash:w:$(PRG).hex
fastarduinoinstall1:
avrdude -c arduino -P /dev/ttyUSB1 -b 115200 -p m328p -e -U flash:w:$(PRG).hex
arduinoinstall2:
avrdude -c arduino -P /dev/ttyUSB2 -b 57600 -p m328p -e -U flash:w:$(PRG).hex
arduinoinstall3:
avrdude -c arduino -P /dev/ttyUSB3 -b 57600 -p m328p -e -U flash:w:$(PRG).hex
aspinstall:
avrdude -c usbasp -P usb -p m328p -e -U flash:w:$(PRG).hex
icefuseint:
avrdude -c atmelice_isp -p m328p -U lfuse:w:0x62:m -U hfuse:w:0xd9:m -U efuse:w:0xfe:m
usbfuseint:
avrdude -c avrisp2 -P usb -p m328p -U lfuse:w:0x62:m -U hfuse:w:0xd9:m -U efuse:w:0xfe:m
usbfuseint8m:
avrdude -c avrisp2 -P usb -p m328p -U lfuse:w:0xE2:m -U hfuse:w:0xd9:m -U efuse:w:0xfd:m
usbfuseext:
avrdude -c avrisp2 -P usb -p m328p -U lfuse:w:0xf7:m -U hfuse:w:0xd9:m -U efuse:w:0x06:m
lst: $(PRG).lst
%.lst: %.elf
$(OBJDUMP) -h -S $< > $@
# Rules for building the .text rom images
text: hex bin srec
hex: $(PRG).hex
bin: $(PRG).bin
srec: $(PRG).srec
%.hex: %.elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@
%.srec: %.elf
$(OBJCOPY) -j .text -j .data -O srec $< $@
%.bin: %.elf
$(OBJCOPY) -j .text -j .data -O binary $< $@
# Rules for building the .eeprom rom images
eeprom: ehex ebin esrec
ehex: $(PRG)_eeprom.hex
ebin: $(PRG)_eeprom.bin
esrec: $(PRG)_eeprom.srec
%_eeprom.hex: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
%_eeprom.srec: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@
%_eeprom.bin: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
size: ${PRG}.elf
avr-size -C --mcu=${MCU_TARGET} ${PRG}.elf
# Every thing below here is used by avr-libc's build system and can be ignored
# by the casual user.
FIG2DEV = fig2dev
EXTRA_CLEAN_FILES = *.hex *.bin *.srec