summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2011-02-26 16:06:48 +1000
committerKeith Packard <keithp@keithp.com>2011-03-16 15:57:38 -0700
commitfc5d014721a7e5a7b22f07eb4ab0bb3c764473fe (patch)
tree16c9d95beb28bf1ccf93f888c41852a24c3397c0
parent0e4c55d78852415e79f7318471f4d00c89703b78 (diff)
ao_intflash: Avoid overwriting code
Require firmware to specify the end of its codespace in its Makefile, and use this to determine where the start of available flash is. Should give compile time errors if either there's no room left for storage, or if there's not enough room for code.
-rw-r--r--src/Makefile.proto6
-rw-r--r--src/ao_intflash.c2
-rw-r--r--src/telemini-v0.1/Makefile.defs1
3 files changed, 6 insertions, 3 deletions
diff --git a/src/Makefile.proto b/src/Makefile.proto
index 625ca459..ee3b4d6c 100644
--- a/src/Makefile.proto
+++ b/src/Makefile.proto
@@ -13,9 +13,11 @@ ifndef VERSION
include ../Version
endif
-CFLAGS=--model-small --debug --opt-code-speed
+CFLAGS=--model-small --debug --opt-code-speed -DCODESIZE=$(CODESIZE)
-LDFLAGS=--out-fmt-ihx --code-loc 0x0000 --code-size 0x8000 \
+CODESIZE ?= 0x8000
+
+LDFLAGS=--out-fmt-ihx --code-loc 0x0000 --code-size $(CODESIZE) \
--xram-loc 0xf000 --xram-size 0xda2 --iram-size 0xff
INC = \
diff --git a/src/ao_intflash.c b/src/ao_intflash.c
index ad5e5aac..450d94a3 100644
--- a/src/ao_intflash.c
+++ b/src/ao_intflash.c
@@ -24,7 +24,7 @@
#define FCTL_WRITE (1 << 1)
#define FCTL_ERASE (1 << 0)
-#define ENDOFCODE (0x51f0 + 1500)
+#define ENDOFCODE (CODESIZE)
#define NUM_PAGES ((0x8000-ENDOFCODE)/1024)
#define SIZE (1024*NUM_PAGES)
#define LOCN (0x8000 - SIZE)
diff --git a/src/telemini-v0.1/Makefile.defs b/src/telemini-v0.1/Makefile.defs
index 8a3e1ef9..94ac1268 100644
--- a/src/telemini-v0.1/Makefile.defs
+++ b/src/telemini-v0.1/Makefile.defs
@@ -6,3 +6,4 @@ SRC = \
PRODUCT=TeleMini-v0.1
PRODUCT_DEF=-DTELEMINI_V_0_1
IDPRODUCT=0x000a
+CODESIZE=0x6700