summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Schodet2010-07-11 17:18:29 +0200
committerNicolas Schodet2010-08-20 00:18:22 +0200
commit5c0e26fb7be7d1e268462221c30998ddb2223580 (patch)
tree570a3832573f310d49aee00032c16e54932e0cbf
parent0f35027d33aafa32593e7c2e1fe54f7dc3fb33dc (diff)
gcc: automatically compute user flash size
This is done at link time. As a consequence, the user flash size is not available at compile time, which is a problem for the FILEHEADER type. This is solved by using a maximum size so that the static Header variable is big enough. It would not have been a problem if this variable was put on the stack.
-rw-r--r--AT91SAM7S256/SAM7S256/gcc/Makefile4
-rw-r--r--AT91SAM7S256/SAM7S256/gcc/nxt.ld3
-rw-r--r--AT91SAM7S256/Source/d_loader.h9
3 files changed, 14 insertions, 2 deletions
diff --git a/AT91SAM7S256/SAM7S256/gcc/Makefile b/AT91SAM7S256/SAM7S256/gcc/Makefile
index 171c5d7..4d58f99 100644
--- a/AT91SAM7S256/SAM7S256/gcc/Makefile
+++ b/AT91SAM7S256/SAM7S256/gcc/Makefile
@@ -23,7 +23,9 @@ vpath %.S $(CPUINCDIR)
INCLUDES =
MCU = arm7tdmi
-DEFINES = -DPROTOTYPE_PCB_4 -DNEW_MENU -DROM_RUN -DVECTORS_IN_RAM
+STARTOFUSERFLASH_DEFINES = -DSTARTOFUSERFLASH_FROM_LINKER=1
+DEFINES = -DPROTOTYPE_PCB_4 -DNEW_MENU -DROM_RUN -DVECTORS_IN_RAM \
+ $(STARTOFUSERFLASH_DEFINES)
OPTIMIZE = -Os -fno-strict-aliasing
WARNINGS = -Wall -W -Wundef -Wno-unused -Wno-format
THUMB_INTERWORK = -mthumb-interwork
diff --git a/AT91SAM7S256/SAM7S256/gcc/nxt.ld b/AT91SAM7S256/SAM7S256/gcc/nxt.ld
index 9a41b10..8e5f0cb 100644
--- a/AT91SAM7S256/SAM7S256/gcc/nxt.ld
+++ b/AT91SAM7S256/SAM7S256/gcc/nxt.ld
@@ -77,6 +77,9 @@ SECTIONS
_edata = . ;
PROVIDE (edata = .);
+ __STARTOFUSERFLASH_FROM_LINKER =
+ ALIGN (LOADADDR (.data) + SIZEOF (.data), 0x100);
+
/* .bss section which is used for uninitialized data */
.bss (NOLOAD) :
{
diff --git a/AT91SAM7S256/Source/d_loader.h b/AT91SAM7S256/Source/d_loader.h
index 4a12f12..902c7f7 100644
--- a/AT91SAM7S256/Source/d_loader.h
+++ b/AT91SAM7S256/Source/d_loader.h
@@ -18,7 +18,14 @@
#define FILETABLE_SIZE ((2 * SECTORSIZE)/4)
#define STARTOFFILETABLE (0x140000L - (FILETABLE_SIZE*4))
#define FILEPTRTABLE ((const ULONG*)(0x140000L - (FILETABLE_SIZE*4)))
+#ifndef STARTOFUSERFLASH_FROM_LINKER
#define STARTOFUSERFLASH (0x122100L)
+#define SIZEOFUSERFLASH_MAX SIZEOFUSERFLASH
+#else
+extern char __STARTOFUSERFLASH_FROM_LINKER;
+#define STARTOFUSERFLASH ((ULONG) &__STARTOFUSERFLASH_FROM_LINKER)
+#define SIZEOFUSERFLASH_MAX ((ULONG) (128 * 1024))
+#endif
#define SIZEOFUSERFLASH ((ULONG)STARTOFFILETABLE - STARTOFUSERFLASH)
#define SIZEOFFLASH 262144L
@@ -67,7 +74,7 @@ typedef struct
ULONG DataSize;
UWORD CheckSum;
UWORD FileType;
- UWORD FileSectorTable[(SIZEOFUSERFLASH/SECTORSIZE)];
+ UWORD FileSectorTable[(SIZEOFUSERFLASH_MAX/SECTORSIZE)];
}FILEHEADER;
void dLoaderInit(void);