-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
67 lines (51 loc) · 1.73 KB
/
makefile
File metadata and controls
67 lines (51 loc) · 1.73 KB
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
#
# Makefile template for ATtiny85
# Derived from AVR Crosspack template
#
DEVICE = atmega1284p
DEVDUDE = m1284p
#CLOCK = 8000000
PROGRAMMER = -c linuxspi -P /dev/spidev0.0
OBJECTS = SPIKE.o main.o # Add more objects for each .c file here
C_FLAGS = -Wl,--gc-sections -Wl,--relax -ffunction-sections -fdata-sections -fno-inline-small-functions -fpack-struct -fshort-enums -mshort-calls
# fuse settings:
# use http://www.engbedded.com/fusecalc
#FUSES = -U lfuse:w:0x42:m -U hfuse:w:0x99:m -U efuse:w:0xff:m # 1mhz
#FUSES = -U lfuse:w:0xc2:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m # 8mhz
FUSES = -U lfuse:w:0xfe:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m # 16mhz
AVRDUDE = sudo avrdude -b 200000 $(PROGRAMMER) -p $(DEVDUDE)
AVRDUDE_FAST = sudo avrdude -b 1000000 $(PROGRAMMER) -p $(DEVDUDE)
COMPILE = avr-gcc -Wall -O3 -mmcu=$(DEVICE) $(C_FLAGS)
# symbolic targets:
all: main.hex
.c.o:
$(COMPILE) -c $< -o $@
.S.o:
$(COMPILE) -x assembler-with-cpp -c $< -o $@
.c.s:
$(COMPILE) -S $< -o $@
flash: all
$(AVRDUDE) -U flash:w:main.hex:i
fast: all
$(AVRDUDE_FAST) -U flash:w:main.hex:i
fuse:
$(AVRDUDE) $(FUSES)
install: flash fuse
# if you use a bootloader, change the command below appropriately:
load: all
bootloadHID main.hex
clean:
rm -f main.hex main.elf $(OBJECTS)
# file targets:
main.elf: $(OBJECTS)
$(COMPILE) -o main.elf $(OBJECTS)
main.hex: main.elf
rm -f main.hex
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
avr-nm -S -td --size-sort main.elf
avr-size --format=avr --mcu=$(DEVICE) main.elf
# If you have an EEPROM section, you must also create a hex file for the
# EEPROM and add it to the "flash" target.
# Targets for code debugging and analysis:
disasm: main.elf
avr-objdump -d main.elf