ao_intflash: Avoid overwriting code
authorAnthony Towns <aj@erisian.com.au>
Sat, 26 Feb 2011 06:06:48 +0000 (16:06 +1000)
committerKeith Packard <keithp@keithp.com>
Wed, 16 Mar 2011 22:57:38 +0000 (15:57 -0700)
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.

src/Makefile.proto
src/ao_intflash.c
src/telemini-v0.1/Makefile.defs

index 625ca459f58e20916978b565272e7e2217a42a8e..ee3b4d6c60a3a23027447125be341ee3a2aaba66 100644 (file)
@@ -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 = \
index ad5e5aac80352594792f009bd8f8293403d205b5..450d94a32f66a9f172f8d8a63b6f4ff414bbecfc 100644 (file)
@@ -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)
index 8a3e1ef9dbbca87b683bcff6f8946529e2f1798f..94ac12685a99482c2d6b81dbb06f3d9736a15d11 100644 (file)
@@ -6,3 +6,4 @@ SRC = \
 PRODUCT=TeleMini-v0.1
 PRODUCT_DEF=-DTELEMINI_V_0_1
 IDPRODUCT=0x000a
+CODESIZE=0x6700