summaryrefslogtreecommitdiffstats
path: root/firmware/Makefile
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2012-08-11 23:02:47 +0200
committerSebastian Reichel <sre@ring0.de>2012-08-11 23:02:47 +0200
commit2b427f4bdfc71b055b7db8ffe2b9dd0ea3e4cc9a (patch)
treef67684ceafcdccd777cc3e1684ca72b63096be1b /firmware/Makefile
downloadatmostripe-master.tar.bz2
initial commitHEADmaster
Diffstat (limited to 'firmware/Makefile')
-rw-r--r--firmware/Makefile32
1 files changed, 32 insertions, 0 deletions
diff --git a/firmware/Makefile b/firmware/Makefile
new file mode 100644
index 0000000..d9b89e7
--- /dev/null
+++ b/firmware/Makefile
@@ -0,0 +1,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