Skip to content

Commit 89641bc

Browse files
committed
uVisor: Update K64F and EFM32GG linker scripts
This commit improves consistency between different platforms' linker scripts. In particular, we use "__UVISOR_SRAM_START" instead of "__UVISOR_BSS_START" as the uVisor BSS sections might be outside of the SRAM (for example, when using a tightly-coupled memory).
1 parent 3a53a5a commit 89641bc

File tree

2 files changed

+45
-38
lines changed
  • targets
    • TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_GCC_ARM
    • TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32GG/device/TARGET_1024K/TOOLCHAIN_GCC_ARM

2 files changed

+45
-38
lines changed

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_GCC_ARM/MK64FN1M0xxx12.ld

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ SECTIONS
9393
/* The program code and other data goes into internal flash */
9494
/* Note: The uVisor expects this section at a fixed location, as specified by
9595
* the porting process configuration parameter: FLASH_OFFSET. */
96-
__UVISOR_TEXT_OFFSET = 0x410;
97-
__UVISOR_TEXT_START = ORIGIN(m_interrupts) + __UVISOR_TEXT_OFFSET;
98-
.text __UVISOR_TEXT_START :
96+
__UVISOR_FLASH_OFFSET = 0x410;
97+
__UVISOR_FLASH_START = ORIGIN(m_interrupts) + __UVISOR_FLASH_OFFSET;
98+
.text __UVISOR_FLASH_START :
9999
{
100100
/* uVisor code and data */
101101
. = ALIGN(4);
@@ -197,27 +197,26 @@ SECTIONS
197197
__interrupts_ram_end__ = .; /* Define a global symbol at data end */
198198
} > m_data
199199

200-
/* Ensure that the uVisor BSS section is put first after the relocated
201-
* interrupt table in SRAM. */
202-
/* Note: The uVisor expects this section at a fixed location, as specified by
203-
* the porting process configuration parameter: SRAM_OFFSET. */
200+
/* uVisor own memory and private box memories
201+
/* If uVisor shares the SRAM with the OS/app, ensure that this section is
202+
* the first one after the VTOR relocation section. */
203+
/* Note: The uVisor expects this section at a fixed location, as specified
204+
by the porting process configuration parameter: SRAM_OFFSET. */
204205
__UVISOR_SRAM_OFFSET = 0x400;
205-
__UVISOR_BSS_START = ORIGIN(m_data) + __UVISOR_SRAM_OFFSET;
206-
ASSERT(__interrupts_ram_end__ <= __UVISOR_BSS_START,
207-
"The ISR relocation region overlaps with the uVisor BSS section.")
208-
.uvisor.bss __UVISOR_BSS_START (NOLOAD):
206+
__UVISOR_SRAM_START = ORIGIN(m_data) + __UVISOR_SRAM_OFFSET;
207+
.uvisor.bss __UVISOR_SRAM_START (NOLOAD):
209208
{
210209
. = ALIGN(32);
211210
__uvisor_bss_start = .;
212211

213-
/* protected uvisor main bss */
212+
/* Protected uVisor own BSS section */
214213
. = ALIGN(32);
215214
__uvisor_bss_main_start = .;
216215
KEEP(*(.keep.uvisor.bss.main))
217216
. = ALIGN(32);
218217
__uvisor_bss_main_end = .;
219218

220-
/* protected uvisor secure boxes bss */
219+
/* Protected uVisor boxes' static memories */
221220
. = ALIGN(32);
222221
__uvisor_bss_boxes_start = .;
223222
KEEP(*(.keep.uvisor.bss.boxes))
@@ -228,7 +227,10 @@ SECTIONS
228227
__uvisor_bss_end = .;
229228
} > m_data
230229

231-
/* Heap space for the page allocator */
230+
/* Heap space for the page allocator
231+
/* If uVisor shares the SRAM with the OS/app, ensure that this section is
232+
* the first one after the uVisor BSS section. Otherwise, ensure it is the
233+
* first one after the VTOR relocation section. */
232234
.page_heap (NOLOAD) :
233235
{
234236
. = ALIGN(32);
@@ -305,6 +307,7 @@ SECTIONS
305307
} > m_data_2
306308

307309
USB_RAM_GAP = DEFINED(__usb_ram_size__) ? __usb_ram_size__ : 0x800;
310+
308311
/* Uninitialized data section */
309312
.bss :
310313
{
@@ -354,11 +357,13 @@ SECTIONS
354357

355358
.ARM.attributes 0 : { *(.ARM.attributes) }
356359

357-
ASSERT(__StackLimit >= __HeapLimit, "region m_data_2 overflowed with stack and heap")
360+
ASSERT(__StackLimit >= __HeapLimit, "Region m_data_2 overflowed with stack and heap")
358361

359362
/* Provide the physical memory boundaries for uVisor. */
360363
__uvisor_flash_start = ORIGIN(m_interrupts);
361364
__uvisor_flash_end = ORIGIN(m_text) + LENGTH(m_text);
362365
__uvisor_sram_start = ORIGIN(m_data);
363366
__uvisor_sram_end = ORIGIN(m_data_2) + LENGTH(m_data_2);
367+
__uvisor_public_sram_start = __uvisor_sram_start;
368+
__uvisor_public_sram_end = __uvisor_sram_end;
364369
}

targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32GG/device/TARGET_1024K/TOOLCHAIN_GCC_ARM/efm32gg.ld

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,12 @@ __vector_size = 0xDC;
5656
*/
5757
ENTRY(Reset_Handler)
5858

59-
/* Note: The uVisor expects the text section at a fixed location, as specified
60-
by the porting process configuration parameter: FLASH_OFFSET. */
61-
__UVISOR_TEXT_OFFSET = 0x100;
62-
__UVISOR_TEXT_START = ORIGIN(FLASH) + __UVISOR_TEXT_OFFSET;
63-
6459
SECTIONS
6560
{
61+
/* Note: The uVisor expects the text section at a fixed location, as specified
62+
by the porting process configuration parameter: FLASH_OFFSET. */
63+
__UVISOR_FLASH_OFFSET = 0x100;
64+
__UVISOR_FLASH_START = ORIGIN(FLASH) + __UVISOR_FLASH_OFFSET;
6665
.text :
6766
{
6867
KEEP(*(.vectors))
@@ -71,7 +70,7 @@ SECTIONS
7170
__end__ = .;
7271

7372
/* uVisor code and data */
74-
. = __UVISOR_TEXT_OFFSET;
73+
. = __UVISOR_FLASH_OFFSET;
7574
. = ALIGN(4);
7675
__uvisor_main_start = .;
7776
*(.uvisor.main)
@@ -147,24 +146,26 @@ SECTIONS
147146
} > FLASH
148147
*/
149148

150-
/* Ensure that the uVisor BSS section is put first in SRAM. */
149+
/* uVisor own memory and private box memories
150+
/* If uVisor shares the SRAM with the OS/app, ensure that this section is
151+
* the first one after the VTOR relocation section. */
151152
/* Note: The uVisor expects this section at a fixed location, as specified
152153
by the porting process configuration parameter: SRAM_OFFSET. */
153154
__UVISOR_SRAM_OFFSET = 0x0;
154-
__UVISOR_BSS_START = ORIGIN(RAM) + __UVISOR_SRAM_OFFSET;
155-
.uvisor.bss __UVISOR_BSS_START (NOLOAD):
155+
__UVISOR_SRAM_START = ORIGIN(m_data) + __UVISOR_SRAM_OFFSET;
156+
.uvisor.bss __UVISOR_SRAM_START (NOLOAD):
156157
{
157158
. = ALIGN(32);
158159
__uvisor_bss_start = .;
159160

160-
/* uVisor main BSS section */
161+
/* Protected uVisor own BSS section */
161162
. = ALIGN(32);
162163
__uvisor_bss_main_start = .;
163164
KEEP(*(.keep.uvisor.bss.main))
164165
. = ALIGN(32);
165166
__uvisor_bss_main_end = .;
166167

167-
/* Secure boxes BSS section */
168+
/* Protected uVisor boxes' static memories */
168169
. = ALIGN(32);
169170
__uvisor_bss_boxes_start = .;
170171
KEEP(*(.keep.uvisor.bss.boxes))
@@ -175,15 +176,16 @@ SECTIONS
175176
__uvisor_bss_end = .;
176177
} > RAM
177178

178-
/* Heap space for the page allocator */
179+
/* Heap space for the page allocator
180+
/* If uVisor shares the SRAM with the OS/app, ensure that this section is
181+
* the first one after the uVisor BSS section. Otherwise, ensure it is the
182+
* first one after the VTOR relocation section. */
179183
.page_heap (NOLOAD) :
180184
{
181185
. = ALIGN(32);
182186
__uvisor_page_start = .;
183187
KEEP(*(.keep.uvisor.page_heap))
184-
185188
. = ALIGN( (1 << LOG2CEIL(LENGTH(RAM))) / 8);
186-
187189
__uvisor_page_end = .;
188190
} > RAM
189191

@@ -284,10 +286,6 @@ SECTIONS
284286
__bss_end__ = .;
285287
} > RAM
286288

287-
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
288-
__stack = __StackTop;
289-
__StackLimit = __StackTop - STACK_SIZE;
290-
291289
.heap (NOLOAD):
292290
{
293291
__uvisor_heap_start = .;
@@ -296,17 +294,21 @@ SECTIONS
296294
end = __end__;
297295
_end = __end__;
298296
. += HEAP_SIZE;
297+
__HeapLimit = .;
298+
__uvisor_heap_end = .;
299299
} > RAM
300300

301-
__HeapLimit = __StackLimit;
302-
__uvisor_heap_end = __StackLimit;
301+
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
302+
__stack = __StackTop;
303+
__StackLimit = __StackTop - STACK_SIZE;
304+
305+
ASSERT(__StackLimit >= __HeapLimit, "Region RAM overflowed with stack and heap")
303306

304307
/* Provide physical memory boundaries for uVisor. */
305308
__uvisor_flash_start = ORIGIN(FLASH);
306309
__uvisor_flash_end = ORIGIN(FLASH) + LENGTH(FLASH);
307310
__uvisor_sram_start = ORIGIN(RAM);
308311
__uvisor_sram_end = ORIGIN(RAM) + LENGTH(RAM);
309-
310-
/* Check if FLASH usage exceeds FLASH size. */
311-
ASSERT(LENGTH(FLASH) >= __uvisor_secure_end, "FLASH memory overflowed!")
312+
__uvisor_public_sram_start = __uvisor_sram_start;
313+
__uvisor_public_sram_end = __uvisor_sram_end;
312314
}

0 commit comments

Comments
 (0)