-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
84 lines (61 loc) · 2.31 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
##***************************************************************************
##
## File : Makefile
## Author : Paul Chote
## Description : Makefile to build the project using avr-gcc and avrdude
##
##***************************************************************************
# System port to find the timer on for upgrading via the bootloader
PORT := /dev/tty.usbserial-A5016EZP
##***************************************************************************
AVRDUDE = avrdude -c dragon_jtag -P usb -p $(DEVICE)
OBJECTS = usb.o gps.o camera.o main.o display.o
BOOTLOADER = avrdude -c avr109 -p $(DEVICE) -b 9600 -P $(PORT)
BOOT_OBJECTS = bootloader.o
DEVICE = atmega1284p
PARTCODE = 0x43
BOOTSTART = 0x1E000
PAGESIZE = 256
F_CPU = 10000000UL
HFUSE = 0x98
LFUSE = 0xF0
EFUSE = 0xFC
##***************************************************************************
COMPILE = avr-gcc -g -mmcu=$(DEVICE) -Wall -Wextra -Werror -Os -std=gnu99 -funsigned-bitfields -fshort-enums \
-DBOOTSTART=$(BOOTSTART) -DPAGESIZE=$(PAGESIZE) -DPARTCODE=$(PARTCODE) -DF_CPU=$(F_CPU)
all: main.hex bootloader.hex
.c.o:
$(COMPILE) -c $< -o $@
.c.s:
$(COMPILE) -S $< -o $@
reset:
$(CC) -o $@ reset.c
fuse:
$(AVRDUDE) -U hfuse:w:$(HFUSE):m -U lfuse:w:$(LFUSE):m efuse:w:$(EFUSE):m
install: main.hex reset
./reset $(PORT)
$(BOOTLOADER) -U flash:w:main.hex:i
jtag: combined.hex
$(AVRDUDE) -U flash:w:combined.hex:i
clean:
rm -f main.hex main.elf bootloader.hex bootloader.elf $(OBJECTS) $(BOOT_OBJECTS)
disasm: main.elf
avr-objdump -d main.elf
size: main.elf
avr-size -C --mcu=$(DEVICE) main.elf
debug: main.elf
avarice -g --part $(DEVICE) --dragon --jtag usb --file main.elf :4242
debug-bootloader: bootloader.elf
avarice -g --part $(DEVICE) --dragon --jtag usb --file bootloader.elf :4242
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
bootloader.elf: bootloader.o
$(COMPILE) -Wl,--section-start=.text=$(BOOTSTART) -o bootloader.elf $(BOOT_OBJECTS)
bootloader.hex: bootloader.elf
rm -f bootloader.hex
avr-objcopy -j .text -j .data -O ihex bootloader.elf bootloader.hex
combined.hex: bootloader.hex main.hex
srec_cat bootloader.hex -I main.hex -I -o combined.hex -I