-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (33 loc) · 1.08 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
# SRC := $(wildcard src/*.c)
SRC := $(shell find src/ -type f -name '*.c')
OUT := out
BINARY := $(OUT)/tap_fw
MCU := attiny13a
F_CPU := 1000000UL
P_MCU := t13
A_MCU := avr2 # https://www.nongnu.org/avr-libc/user-manual/using_tools.html
C_FLAGS := -Os -DF_CPU=$(F_CPU) -mmcu=$(MCU) -flto
build: $(BINARY).hex
$(OUT):
mkdir out
$(BINARY).hex: $(BINARY).elf
avr-objcopy -O ihex -R .eeprom $(BINARY).elf $(BINARY).hex
$(BINARY).elf: $(OUT) Makefile $(SRC)
avr-gcc $(C_FLAGS) -o $(BINARY).elf $(SRC)
flash: $(BINARY).hex
avrdude -c usbasp-clone -p $(P_MCU) -U flash:w:$(BINARY).hex:i
clean:
rm -rf $(OUT)
## dev ##
size: $(BINARY).elf
avr-size -C --mcu=$(MCU) $(BINARY).elf
dump: $(BINARY).elf
avr-objdump -S $(BINARY).elf > $(BINARY).dump
hex_dump: # $(BINARY).hex
avr-objdump -D -m $(A_MCU) $(BINARY).hex > $(BINARY).hex.dump
read_flash: $(OUT)
avrdude -c usbasp-clone -p $(P_MCU) -U flash:r:$(BINARY).hex:i
read_eeprom: $(OUT)
avrdude -c usbasp-clone -p $(P_MCU) -U eeprom:r:$(BINARY).eeprom.hex:i
read_fuse:
avrdude -c usbasp-clone -p $(P_MCU) -U lfuse:r:-:h -U lock:r:-:h 2>/dev/null