summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/target/arm/imx233/app.lds14
-rw-r--r--firmware/target/arm/imx233/boot.lds2
-rw-r--r--firmware/target/arm/imx233/crt0.S9
3 files changed, 16 insertions, 9 deletions
diff --git a/firmware/target/arm/imx233/app.lds b/firmware/target/arm/imx233/app.lds
index b378f9ea16..335aa4fcc3 100644
--- a/firmware/target/arm/imx233/app.lds
+++ b/firmware/target/arm/imx233/app.lds
@@ -39,7 +39,7 @@ SECTIONS
39 { 39 {
40 _dramcopystart = .; 40 _dramcopystart = .;
41 } > DRAM 41 } > DRAM
42 42
43 .text : 43 .text :
44 { 44 {
45 *(.text*) 45 *(.text*)
@@ -47,6 +47,8 @@ SECTIONS
47 *(.rodata*) 47 *(.rodata*)
48 } > DRAM 48 } > DRAM
49 49
50 _dramtextend = .;
51
50 .itext : 52 .itext :
51 { 53 {
52 _iramstart = .; // always 0 54 _iramstart = .; // always 0
@@ -77,12 +79,17 @@ SECTIONS
77 79
78 _initcopy = LOADADDR(.init); 80 _initcopy = LOADADDR(.init);
79 81
82 /* crt0 needs a temporary stack which does not overlap with init and itext
83 * and is in physical memory: put it *after* init and itext. A small one suffices */
84 crt0_tmpstack_phys = _dramcopyend + 0x200 - CACHED_DRAM_ADDR + UNCACHED_DRAM_ADDR;
85
80 .dramcopyend (NOLOAD) : 86 .dramcopyend (NOLOAD) :
81 { 87 {
82 _dramcopyend = .; 88 _dramcopyend = .;
83 } > DRAM 89 } > DRAM
84 90
85 .stack (NOLOAD) : 91 /* the stack overlaps the init and itext region, to reclaim space */
92 .stack _dramtextend (NOLOAD) :
86 { 93 {
87 *(.stack) 94 *(.stack)
88 stackbegin = .; 95 stackbegin = .;
@@ -90,9 +97,6 @@ SECTIONS
90 stackend = .; 97 stackend = .;
91 } > DRAM 98 } > DRAM
92 99
93 /* physical address of the stack */
94 stackend_phys = stackend - CACHED_DRAM_ADDR + UNCACHED_DRAM_ADDR;
95
96 /* treat .bss and .ncbss as a single section */ 100 /* treat .bss and .ncbss as a single section */
97 .bss (NOLOAD) : 101 .bss (NOLOAD) :
98 { 102 {
diff --git a/firmware/target/arm/imx233/boot.lds b/firmware/target/arm/imx233/boot.lds
index 68472d129c..ca455b47ca 100644
--- a/firmware/target/arm/imx233/boot.lds
+++ b/firmware/target/arm/imx233/boot.lds
@@ -74,7 +74,7 @@ SECTIONS
74 } > DRAM 74 } > DRAM
75 75
76 /* physical address of the stack */ 76 /* physical address of the stack */
77 stackend_phys = stackend - CACHED_DRAM_ADDR + UNCACHED_DRAM_ADDR; 77 crt0_tmpstack_phys = stackend - CACHED_DRAM_ADDR + UNCACHED_DRAM_ADDR;
78 78
79 /* treat .bss and .ncbss as a single section */ 79 /* treat .bss and .ncbss as a single section */
80 .bss (NOLOAD) : 80 .bss (NOLOAD) :
diff --git a/firmware/target/arm/imx233/crt0.S b/firmware/target/arm/imx233/crt0.S
index 0a71da5d08..5e1720c7c9 100644
--- a/firmware/target/arm/imx233/crt0.S
+++ b/firmware/target/arm/imx233/crt0.S
@@ -56,9 +56,12 @@ start:
56 bic r0, r1 56 bic r0, r1
57 mcr p15, 0, r0, c1, c0, 0 57 mcr p15, 0, r0, c1, c0, 0
58 58
59 /* To call the C code we need a stack, since the stack is in virtual memory 59 /* To call the C code we need a stack, since the loader's stack might be
60 * use the stack's physical address */ 60 * in virtual memory, we need a physical address for the stack. Furthermore,
61 ldr sp, =stackend_phys 61 * we cannot use the main firmware stack yet because it overlaps with the
62 * init code which will be moved later. We rely on the linker to provide
63 * a safe, temporary stack */
64 ldr sp, =crt0_tmpstack_phys
62 65
63 /* Enable MMU */ 66 /* Enable MMU */
64 bl memory_init 67 bl memory_init