summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2013-10-07 23:09:05 +0200
committerDaniel Friesel <derf@finalrewind.org>2013-10-07 23:09:05 +0200
commitf1ff0a16a5abdcd84e6794395b46ef0d7adbb9a4 (patch)
tree636af93e0085b82bac4c8f034529d4eefaf24100 /Makefile
parentb3b147e2ad402c33d143f16563be0e2c46690942 (diff)
move read-rom back to main now that it also supports search rom
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile47
1 files changed, 47 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..c31d4ec
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,47 @@
+MCU ?= attiny2313
+AVRDUDE_PROGRAMMER ?= usbasp
+
+AVRCC ?= avr-gcc
+AVRFLASH ?= avrdude
+AVRNM ?= avr-nm
+AVROBJCOPY ?= avr-objcopy
+AVROBJDUMP ?= avr-objdump
+
+CFLAGS += -mmcu=attiny2313 -DF_CPU=20000000UL
+#CFLAGS += -gdwarf-2 -fverbose-asm -save-temps
+CFLAGS += -I. -std=gnu99 -Os -Wall -Wextra -pedantic
+CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
+# r28 .. r31 hold the microsecond counters
+CFLAGS += -ffixed-28 -ffixed-29 -ffixed-30 -ffixed-31
+CFLAGS += -fwhole-program -flto -mstrict-X
+
+AVRFLAGS += -U lfuse:w:0xe4:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m
+AVRFLAGS += -U flash:w:main.hex
+# AVRFLAGS += -U eeprom:w:main.eep
+
+%.hex: %.elf
+ ${AVROBJCOPY} -O ihex -R .eeprom $< $@
+
+%.eep: %.elf
+ ${AVROBJCOPY} -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+ --change-section-lma .eeprom=0 -O ihex $< $@
+
+main.elf: main.c
+ ${AVRCC} ${CFLAGS} -o $@ ${@:.elf=.c} -Wl,-Map=main.map,--cref
+ avr-size -d $@
+
+program: main.hex main.eep
+ ${AVRFLASH} -p ${MCU} -c ${AVRDUDE_PROGRAMMER} ${AVRFLAGS}
+
+secsize: main.elf
+ ${AVROBJDUMP} -hw -j.text -j.bss -j.data main.elf
+
+funsize: main.elf
+ ${AVRNM} --print-size --size-sort main.elf
+
+.PHONY: program secsize funsize
+
+# Listing of phony targets.
+.PHONY : all begin finish end sizebefore sizeafter gccversion \
+build elf hex eep lss sym coff extcoff \
+clean clean_list program debug gdb-config