summaryrefslogtreecommitdiffstats
path: root/firmware/Makefile
blob: d9b89e7a0f5a08b4a1ea31d89e24388af8cfcbf2 (plain)
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
SOURCES		:= firmware.c
OBJECTS     := $(patsubst %.c, %.o, $(SOURCES))
CFLAGS		:= -O2 -std=c99 -mmcu=atmega48 -Wall -DF_CPU=16000000UL -DDEBUG=1
LDFLAGS     := -mmcu=atmega48 -lm

all: fw.hex

%.o: %.c
	@echo "[CC] $<"
	@avr-gcc -o $@ $(CFLAGS) -c $<

fw.hex: fw.elf
	@echo "[HEX] $@"
	@avr-objcopy $^ -O ihex -R .eeprom $@

fw.elf: ${OBJECTS}
	@echo "[LD] $@"
	@avr-gcc -o $@ $(LDFLAGS) $^

fw.S: fw.elf
	@avr-objdump -d fw.elf -h -m avr > fw.S

clean:
	@rm -f ${OBJECTS} fw.hex fw.elf fw.S

backup:
	avrdude -c buspirate -P /dev/ttyUSB0 -p m48 -U flash:r:"backup.hex":i noreset 

flash:
	avrdude -c buspirate -P /dev/ttyUSB0 -p m48 -U flash:w:"fw.hex":i reset

.PHONY: all clean backup flash