-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.all
60 lines (48 loc) · 1.28 KB
/
Makefile.all
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
ifndef TARGET
$(error TARGET not defined. This file souhld not be run directly)
endif
CC=avr-gcc
CFLAGS=-g -Os -Wall -mcall-prologues -mmcu=$(MCU) -DF_CPU=$(F_CPU)
OBJ2HEX=avr-objcopy
DEVICE?=linuxspi
PORT?=/dev/spidev0.0
PORT:=$(if $(PORT),-P $(PORT))
BAUD:=$(if $(BAUD),-b $(BAUD))
AVRDUDE=avrdude -p $(AVRDUDEMCU) $(PORT) -c $(DEVICE) $(BAUD)
LFUSE:=$(if $(LFUSE),-U lfuse:w:$(LFUSE):m)
HFUSE:=$(if $(HFUSE),-U hfuse:w:$(HFUSE):m)
EFUSE:=$(if $(EFUSE),-U efuse:w:$(EFUSE):m)
all:
$(CC) $(CFLAGS) $(TARGET).c -o $(TARGET).elf
$(OBJ2HEX) -R .eeprom -O ihex $(TARGET).elf $(TARGET).hex
avr-objdump -Pmem-usage $(TARGET).elf
flash: install
install: all
@if [ '$(DEVICE)' == 'linuxspi' ]; then \
gpio -g mode 5 out; \
gpio -g write 5 0; \
fi
$(AVRDUDE) -U flash:w:$(TARGET).hex
@if [ '$(DEVICE)' == 'linuxspi' ]; then \
gpio -g write 5 1; \
fi
read:
@if [ '$(DEVICE)' == 'linuxspi' ]; then \
gpio -g mode 5 out; \
gpio -g write 5 0; \
fi
$(AVRDUDE) -v
@if [ '$(DEVICE)' == 'linuxspi' ]; then \
gpio -g write 5 1; \
fi
fuse:
@if [ '$(DEVICE)' == 'linuxspi' ]; then \
gpio -g mode 5 out; \
gpio -g write 5 0; \
fi
$(AVRDUDE) $(LFUSE) $(HFUSE) $(EFUSE)
@if [ '$(DEVICE)' == 'linuxspi' ]; then \
gpio -g write 5 1; \
fi
clean:
rm -f *.hex *.obj *.o $(TARGET).elf