From fc5d014721a7e5a7b22f07eb4ab0bb3c764473fe Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Sat, 26 Feb 2011 16:06:48 +1000 Subject: [PATCH] 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. --- src/Makefile.proto | 6 ++++-- src/ao_intflash.c | 2 +- src/telemini-v0.1/Makefile.defs | 1 + 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 -- 2.30.2