summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2011-05-21 21:06:29 -0700
committerKeith Packard <keithp@keithp.com>2011-05-21 21:06:29 -0700
commit6c87e4f77e6072ae7e8587d327b2ff80af2c3e6a (patch)
tree45449480ce0e6bec595e290d220e7052eadbeb2e
parent7818f9962aa3375c29e32ee75038e998eaf53df8 (diff)
src-avr: Check RAM usage for telescience
ATmega32u4 has only 2.5kB of ram, so check the output of the compiler to make sure it will work. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--src-avr/check-avr-mem9
-rw-r--r--src-avr/telescience/Makefile3
2 files changed, 12 insertions, 0 deletions
diff --git a/src-avr/check-avr-mem b/src-avr/check-avr-mem
new file mode 100644
index 00000000..c73edbd1
--- /dev/null
+++ b/src-avr/check-avr-mem
@@ -0,0 +1,9 @@
+#!/bin/sh
+nm "$@" |
+grep ' N _end' |
+awk '{ iram = strtonum("0x" $1) % 0x10000;
+if ( iram > 0xaff) {
+ printf ("%d bytes of ram more than %d available\n", iram, 0xaff);
+ exit(1);
+} else
+ exit(0); }'
diff --git a/src-avr/telescience/Makefile b/src-avr/telescience/Makefile
index b964e1e6..2618ee06 100644
--- a/src-avr/telescience/Makefile
+++ b/src-avr/telescience/Makefile
@@ -77,8 +77,11 @@ quiet ?= $($1)
all: $(PROG)
+CHECK=sh ../check-avr-mem
+
$(PROG): Makefile $(OBJ)
$(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ)
+ $(call quiet,CHECK) $(PROG) || ($(RM) -f $(PROG); exit 1)
$(PROG).hex: $(PROG)
avr-size $(PROG)