-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
71 lines (46 loc) · 1.3 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
CC=avr-g++
DEVICE=85
#Signature
#ATtiny25 0x1E 0x91 0x08
#ATtiny45 0x1E 0x92 0x06
#ATtiny85 0x1E 0x93 0x0B
#Fuses
EFUSE=0xff
HFUSE=0xdc
LFUSE=0x62
CFLAGS=-g -std=c++11 -Os -Wall -mcall-prologues -mmcu=attiny$(DEVICE) -DF_CPU=8000000
## Use short (8-bit) data types
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
LDFLAGS = -Wl,-Map,$(TARGET).map
## Optional, but often ends up with smaller code
LDFLAGS += -Wl,--gc-sections
OBJ2HEX=avr-objcopy
SIZE=avr-size
UISP=avrdude
TARGET=cd-changer
C_FILES = $(wildcard *.c)
OBJS = $(C_FILES:.c=.o)
all : program
program : flash eeprom
#program : flash
fuse :
$(UISP) -p t$(DEVICE) -c USBasp -v -U hfuse:w:${HFUSE}:m -U lfuse:w:${LFUSE}:m
flash : $(TARGET).hex
$(UISP) -p t$(DEVICE) -c USBasp -v -U flash:w:$(TARGET).hex:i
eeprom : $(TARGET).eep
$(UISP) -p t$(DEVICE) -c USBasp -v -U eeprom:w:$(TARGET).eep:i
build : $(TARGET).hex $(TARGET).eep
ls -l $(TARGET).*
%.hex : %.elf
$(OBJ2HEX) -R .eeprom -O ihex $< $@
%.eep : %.elf
$(OBJ2HEX) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
%.elf : $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@
$(SIZE) -t $@
%.o : %.c Makefile
$(CC) $(CFLAGS) -c $< -o $@
clean :
@rm -f *.hex *.eep *.elf *.o
help :
@echo "make [help | clean | build | eeprom | flash | program | fuse]"