src-avr: Check RAM usage for telescience
authorKeith Packard <keithp@keithp.com>
Sun, 22 May 2011 04:06:29 +0000 (21:06 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 22 May 2011 04:06:29 +0000 (21:06 -0700)
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>
src-avr/check-avr-mem [new file with mode: 0644]
src-avr/telescience/Makefile

diff --git a/src-avr/check-avr-mem b/src-avr/check-avr-mem
new file mode 100644 (file)
index 0000000..c73edbd
--- /dev/null
@@ -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); }'
index b964e1e6b4d68c3a4d65df6bb4af6313ec1d5075..2618ee066292375660157e72aeb7305f759d99ae 100644 (file)
@@ -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)