summaryrefslogtreecommitdiffhomepage
path: root/digital/avr/make
diff options
context:
space:
mode:
authorNicolas Schodet2012-05-06 11:04:54 +0200
committerNicolas Schodet2012-05-06 11:04:54 +0200
commit84bcdfe2f6ada6a6baf3a49c4274f761fcb8732d (patch)
tree0016ac7ce9be05303b34bdbdc7ae870c4ef4685e /digital/avr/make
parentdf835ce0ea880c57652e90ea21f21d0866d1cf41 (diff)
digital/avr/make: add rule to program board in Makefile
Diffstat (limited to 'digital/avr/make')
-rw-r--r--digital/avr/make/Makefile.avr19
1 files changed, 18 insertions, 1 deletions
diff --git a/digital/avr/make/Makefile.avr b/digital/avr/make/Makefile.avr
index 1fe5ff31..73ec6a2a 100644
--- a/digital/avr/make/Makefile.avr
+++ b/digital/avr/make/Makefile.avr
@@ -19,6 +19,11 @@ endif
AVR_COMPILE.S := $(AVR_CC) $(AVR_ASFLAGS) $(AVR_CPPFLAGS) -c
AVR_LINK.o := $(AVR_CC) $(AVR_CFLAGS) $(AVR_LDFLAGS)
+AVRDUDE := avrdude
+AVRDUDE_PROGRAMMER ?= stk500v2
+AVRDUDE_PORT ?= /dev/ttyUSB1
+AVR_PROGRAM ?= $(AVRDUDE) -c $(AVRDUDE_PROGRAMMER) -P $(AVRDUDE_PORT) -p $(AVR_MCU) -U flash:w:$<
+
# Main rules.
avr: elf lst hex size
@@ -26,7 +31,7 @@ avr: elf lst hex size
simu: simuelf
.PHONY: avr simu clean.avr clean.simu elf simuelf lst \
- text hex srec bin eeprom ehex esrec ebin
+ text hex srec bin eeprom ehex esrec ebin program
# General rules.
@@ -125,6 +130,18 @@ esrec: $(AVR_PROGS:%=%_eeprom.srec)
%_eeprom.bin: %.avr.elf
$(AVR_OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
+# Rules for programming AVR.
+
+ifeq ($(words $(AVR_PROGS)),1)
+program: $(AVR_PROGS:%=%.program)
+else
+program:
+ @echo Several programs, choose which one to program with "make name.program".
+endif
+
+%.program: %.hex
+ $(AVR_PROGRAM)
+
# Cleaning.
clean.avr: