-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
58 lines (42 loc) · 1.25 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
# picoBoot - tiny bootloader for AVR MCUs
# @author: Ralph Doncaster
# @version: $Id$
# tested with avr-gcc version 4.3.2 and 4.8.1
#DEVICE = attiny88
#DEVICE = attiny85
#DEVICE = attiny84
#DEVICE = attiny2313
DEVICE = atmega328
CPU_SPEED = 16000000
#CPU_SPEED = 8000000
# calculate picoboot bootloader address
ADDRESS:=$(shell echo $(DEVICE)|cut -c7| awk '{ printf("0x%x", $$1 * 1024 -66) }')
CC = avr-gcc
LD = avr-ld
CFLAGS = -mmcu=$(DEVICE) -DF_CPU=$(CPU_SPEED)
#CFLAGS += -O
CFLAGS += -nostdlib
%.hex: %
avr-objcopy -O ihex $< $@
# avr-objcopy -j .text -j .data -O ihex $< $@
all: picobootSerial.hex
.elf.hex:
avr-objcopy -O ihex $< $@
# avr-objcopy -j .text -j .data -O ihex $< $@
picobootSerial.hex: picobootSerial.o
picobootSerial.hex: picobootSerial.elf
avr-objcopy -O ihex $< $@
picobootSTK500.hex: picobootSTK500.elf
avr-objcopy -O ihex $< $@
picoboot.bin: picoboot.o
$(CC) $(CFLAGS) -o $@ $<
picobootSerial.elf: picobootSerial.o
$(CC) $(CFLAGS) -Wl,-section-start=.bootloader=$(ADDRESS) -o $@ $<
picobootSTK500.elf: picobootSTK500.o
$(CC) $(CFLAGS) -Wl,-section-start=.bootloader=0x7E00 -o $@ $<
picoboot.bin: picoboot
avr-objcopy -j .text -j .data -O binary $< $@
.S.o:
$(CC) $(CFLAGS) -x assembler-with-cpp -c $< -o $@
clean:
rm *.o *.elf