-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile.attiny
112 lines (89 loc) · 3.15 KB
/
Makefile.attiny
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
# Pulse & Bloom
# Author: Samuel Clay
# Date: 2014-04-27
# Copyright: (c) 2014
DEVICE = attiny84
DEVICE_MCCU = attiny84 # See http://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html
PROGRAMMER ?= usbtiny
F_CPU = 8000000
# Ext Clock
# FUSE_L = 0xFF
# FUSE_H = 0xD7
# Int Clock
FUSE_L = 0xE2
FUSE_H = 0xDF
FUSE_E = 0xFF
AVRDUDE = avrdude -v -v -v -v -c $(PROGRAMMER) -p $(DEVICE) -P usb
LIBS = -I./libs/tiny
LIBS += -I./libs/avr
LIBS += -I./libs/SoftwareSerial
LIBS += -I./libs/neopixel
LIBS += -I./libs
LIBS += -I./src
LIBS += -I.
CFLAGS = $(LIBS) \
-fno-exceptions -ffunction-sections -fdata-sections \
-Wl,--gc-sections
C_SRC := libs/tiny/pins_arduino.o \
libs/tiny/wiring.o \
libs/tiny/wiring_analog.o \
libs/tiny/wiring_digital.o \
libs/tiny/wiring_pulse.o \
libs/tiny/wiring_shift.o
CPP_SRC := libs/tiny/main.o \
libs/tiny/Print.o \
libs/tiny/Tone.o \
libs/tiny/WMath.o \
libs/tiny/WString.o \
libs/SoftwareSerial/SoftwareSerial.o \
libs/neopixel/Adafruit_NeoPixel.o
SRC := src/pulse.o \
src/smooth.o \
src/sampler.o
OBJECTS = $(C_SRC:.c=.o) $(CPP_SRC:.cpp=.o) $(SRC:.cpp=.o)
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE_MCCU)
all: clean fuse program
# symbolic targets:
help:
@echo "Use one of the following:"
@echo "make program ... to flash fuses and firmware"
@echo "make fuse ...... to flash the fuses"
@echo "make flash ..... to flash the firmware (use this on metaboard)"
@echo "make hex ....... to build pulse.hex"
@echo "make clean ..... to delete objects and hex file"
hex: pulse.hex
# Add fuse to program once you're in production
program: flash
# rule for programming fuse bits:
fuse:
@[ "$(FUSE_H)" != "" -a "$(FUSE_L)" != "" ] || \
{ echo "*** Edit Makefile and choose values for FUSE_L and FUSE_H!"; exit 1; }
$(AVRDUDE) -U lfuse:w:$(FUSE_L):m -U hfuse:w:$(FUSE_H):m -U efuse:w:$(FUSE_E):m
# rule for uploading firmware:
flash: pulse.hex
$(AVRDUDE) -U flash:w:build/pulse.hex:i
read:
$(AVRDUDE) -U lfuse:r:lfuse.txt:h -U hfuse:r:hfuse.txt:h -U efuse:r:efuse.txt:h -U lock:r:lock.txt:h
# rule for deleting dependent files (those which can be built by Make):
clean:
rm -f build/* *.o **/*.o **/**/*.o *.d **/*.d **/**/*.d **/**/*.lst
# Generic rule for compiling C files:
.c.o:
$(COMPILE) -g -c $< -o $@
.cpp.o:
$(COMPILE) -g -c $< -o $@
# Generic rule for compiling C to assembler, used for debugging only.
.c.s:
$(COMPILE) -S $< -o $@
core:
avr-ar rcs build/core.a $(C_SRC:.c=.o) $(CPP_SRC:.cpp=.o)
# file targets:
pulse.elf: $(OBJECTS) core
$(COMPILE) -o build/pulse.elf $(SRC:.cpp=.o) build/core.a -L. -lm
pulse.hex: pulse.elf
rm -f build/pulse.hex build/pulse.eep.hex
avr-objcopy -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 -O ihex build/pulse.elf build/pulse.hex
avr-objcopy -O ihex -R .eeprom build/pulse.elf build/pulse.hex
avr-size build/pulse.hex
disasm: pulse.elf
avr-objdump -d build/pulse.elf