Skip to content

Commit c14d715

Browse files
authored
Merge pull request #3397 from AlessandroA/stm32f4_support
Add uVisor support for the DISCO_F429ZI
2 parents 469b547 + 5f1c047 commit c14d715

File tree

26 files changed

+291
-95
lines changed

26 files changed

+291
-95
lines changed

features/FEATURE_UVISOR/AUTHORS.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
584 Milosch Meriac
2-
501 Alessandro Angelino
1+
588 Milosch Meriac
2+
506 Alessandro Angelino
33
95 Jaeden Amero
44
61 Niklas Hauser
55
4 Irit Arkin
6+
3 Hugo Vincent
67
3 JaredCJR
78
3 Jim Huang
8-
3 Hugo Vincent
9-
2 tonyyanxuan
109
2 Vincenzo Frascino
10+
2 tonyyanxuan
1111
1 Aksel Skauge Mellbye
12-
1 ccli8
1312
1 Nathan Chong
13+
1 ccli8

features/FEATURE_UVISOR/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.26.1
1+
v0.26.2

features/FEATURE_UVISOR/source/page_allocator.c_inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ void page_allocator_init(void * const heap_start, void * const heap_end, const u
8484
"Page size pointer (0x%08x) is not in flash memory.\n",
8585
(unsigned int) page_size);
8686
}
87-
if (!heap_start || !vmpu_sram_addr((uint32_t) heap_start)) {
87+
if (!heap_start || !vmpu_public_sram_addr((uint32_t) heap_start)) {
8888
HALT_ERROR(SANITY_CHECK_FAILED,
8989
"Page heap start pointer (0x%08x) is not in sram memory.\n",
9090
(unsigned int) heap_start);
9191
}
92-
if (!heap_end || !vmpu_sram_addr((uint32_t) heap_end)) {
92+
if (!heap_end || !vmpu_public_sram_addr((uint32_t) heap_end)) {
9393
HALT_ERROR(SANITY_CHECK_FAILED,
9494
"Page heap end pointer (0x%08x) is not in sram memory.\n",
9595
(unsigned int) heap_end);

features/FEATURE_UVISOR/source/rtx/unsupported_page_allocator.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#define vmpu_is_box_id_valid(...) 0
3131
#define vmpu_public_flash_addr(...) 1
3232
#define vmpu_sram_addr(...) 1
33+
#define vmpu_public_sram_addr(...) 1
3334
#define HALT_ERROR(id, ...) {}
3435
#define UVISOR_PAGE_ALLOCATOR_MUTEX_AQUIRE page_allocator_mutex_aquire()
3536
#define UVISOR_PAGE_ALLOCATOR_MUTEX_RELEASE osMutexRelease(g_page_allocator_mutex_id)

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_STM/TARGET_STM32F4/TARGET_B96B_F446VE/device/system_stm32f4xx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Cloc
100100
* @{
101101
*/
102102

103+
extern void SystemInitPre(void);
103104
extern void SystemInit(void);
104105
extern void SystemCoreClockUpdate(void);
105106
extern void SetSysClock(void);

targets/TARGET_STM/TARGET_STM32F4/TARGET_DISCO_F429ZI/device/TOOLCHAIN_GCC_ARM/STM32F429ZI.ld

Lines changed: 149 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
/* Linker script to configure memory regions. */
1+
M_VECTOR_RAM_SIZE = 0x400;
2+
3+
/* Heap: 1/4 of RAM. Stack: 1/8 of RAM. */
4+
STACK_SIZE = 0x6000;
5+
HEAP_SIZE = 0xC000;
6+
7+
/* Specify the memory areas */
28
MEMORY
3-
{
4-
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048k
5-
CCM (rwx) : ORIGIN = 0x10000000, LENGTH = 64K
6-
RAM (rwx) : ORIGIN = 0x200001AC, LENGTH = 192k - 0x1AC
9+
{
10+
VECTORS (rx) : ORIGIN = 0x08000000, LENGTH = 0x400
11+
FLASH (rx) : ORIGIN = 0x08000400, LENGTH = 2048k - 0x400
12+
CCM (rwx) : ORIGIN = 0x10000000, LENGTH = 64K
13+
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 192k
714
}
815

916
/* Linker script to place sections and symbol values. Should be used together
1017
* with other linker script that defines memory regions FLASH and RAM.
1118
* It references following symbols, which must be defined in code:
1219
* Reset_Handler : Entry of reset handler
13-
*
20+
*
1421
* It defines following symbols, which code can use without definition:
1522
* __exidx_start
1623
* __exidx_end
@@ -37,10 +44,28 @@ ENTRY(Reset_Handler)
3744

3845
SECTIONS
3946
{
40-
.text :
47+
.isr_vector :
4148
{
49+
__vector_table = .;
4250
KEEP(*(.isr_vector))
51+
. = ALIGN(4);
52+
} > VECTORS
53+
54+
/* Note: The uVisor expects this section at a fixed location, as specified
55+
* by the porting process configuration parameter:
56+
* FLASH_OFFSET. */
57+
__UVISOR_FLASH_OFFSET = 0x400;
58+
__UVISOR_FLASH_START = ORIGIN(VECTORS) + __UVISOR_FLASH_OFFSET;
59+
.text __UVISOR_FLASH_START :
60+
{
61+
/* uVisor code and data */
62+
. = ALIGN(4);
63+
__uvisor_main_start = .;
64+
*(.uvisor.main)
65+
__uvisor_main_end = .;
66+
4367
*(.text*)
68+
4469
KEEP(*(.init))
4570
KEEP(*(.fini))
4671

@@ -69,6 +94,7 @@ SECTIONS
6994
} > FLASH
7095

7196
__exidx_start = .;
97+
7298
.ARM.exidx :
7399
{
74100
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
@@ -78,8 +104,62 @@ SECTIONS
78104
__etext = .;
79105
_sidata = .;
80106

81-
.data : AT (__etext)
107+
.interrupts_ram :
108+
{
109+
. = ALIGN(4);
110+
__VECTOR_RAM__ = .;
111+
__interrupts_ram_start__ = .; /* Create a global symbol at data start */
112+
*(.m_interrupts_ram) /* This is a user defined section */
113+
. += M_VECTOR_RAM_SIZE;
114+
. = ALIGN(4);
115+
__interrupts_ram_end__ = .; /* Define a global symbol at data end */
116+
} > RAM
117+
118+
/* uVisor own memory and private box memories
119+
/* Note: The uVisor expects this section at a fixed location, as specified
120+
by the porting process configuration parameter: SRAM_OFFSET. */
121+
__UVISOR_SRAM_OFFSET = 0x0;
122+
__UVISOR_SRAM_START = ORIGIN(CCM) + __UVISOR_SRAM_OFFSET;
123+
.uvisor.bss __UVISOR_SRAM_START (NOLOAD):
124+
{
125+
. = ALIGN(32);
126+
__uvisor_bss_start = .;
127+
128+
/* Protected uVisor own BSS section */
129+
. = ALIGN(32);
130+
__uvisor_bss_main_start = .;
131+
KEEP(*(.keep.uvisor.bss.main))
132+
. = ALIGN(32);
133+
__uvisor_bss_main_end = .;
134+
135+
/* Protected uVisor boxes' static memories */
136+
. = ALIGN(32);
137+
__uvisor_bss_boxes_start = .;
138+
KEEP(*(.keep.uvisor.bss.boxes))
139+
. = ALIGN(32);
140+
__uvisor_bss_boxes_end = .;
141+
142+
. = ALIGN(32);
143+
__uvisor_bss_end = .;
144+
} > CCM
145+
146+
/* Heap space for the page allocator
147+
/* If uVisor shares the SRAM with the OS/app, ensure that this section is
148+
* the first one after the uVisor BSS section. Otherwise, ensure it is the
149+
* first one after the VTOR relocation section. */
150+
.page_heap (NOLOAD) :
82151
{
152+
. = ALIGN(32);
153+
__uvisor_page_start = .;
154+
KEEP(*(.keep.uvisor.page_heap))
155+
. = ALIGN((1 << LOG2CEIL(LENGTH(RAM))) / 8);
156+
__uvisor_page_end = .;
157+
} > RAM
158+
159+
.data :
160+
{
161+
PROVIDE( __etext = LOADADDR(.data) );
162+
83163
__data_start__ = .;
84164
_sdata = .;
85165
*(vtable)
@@ -112,9 +192,54 @@ SECTIONS
112192
__data_end__ = .;
113193
_edata = .;
114194

195+
} > RAM AT > FLASH
196+
197+
/* uVisor configuration section
198+
* This section must be located after all other flash regions. */
199+
.uvisor.secure :
200+
{
201+
. = ALIGN(32);
202+
__uvisor_secure_start = .;
203+
204+
/* uVisor secure boxes configuration tables */
205+
. = ALIGN(32);
206+
__uvisor_cfgtbl_start = .;
207+
KEEP(*(.keep.uvisor.cfgtbl))
208+
. = ALIGN(32);
209+
__uvisor_cfgtbl_end = .;
210+
211+
/* Pointers to the uVisor secure boxes configuration tables */
212+
/* Note: Do not add any further alignment here, as uVisor will need to
213+
* have access to the exact list of pointers. */
214+
__uvisor_cfgtbl_ptr_start = .;
215+
KEEP(*(.keep.uvisor.cfgtbl_ptr_first))
216+
KEEP(*(.keep.uvisor.cfgtbl_ptr))
217+
__uvisor_cfgtbl_ptr_end = .;
218+
219+
/* Pointers to all boxes register gateways. These are grouped here to
220+
allow discoverability and firmware verification. */
221+
__uvisor_register_gateway_ptr_start = .;
222+
KEEP(*(.keep.uvisor.register_gateway_ptr))
223+
__uvisor_register_gateway_ptr_end = .;
224+
225+
. = ALIGN(32);
226+
__uvisor_secure_end = .;
227+
} > FLASH
228+
229+
/* Uninitialized data section
230+
* This region is not initialized by the C/C++ library and can be used to
231+
* store state across soft reboots. */
232+
.uninitialized (NOLOAD):
233+
{
234+
. = ALIGN(32);
235+
__uninitialized_start = .;
236+
*(.uninitialized)
237+
KEEP(*(.keep.uninitialized))
238+
. = ALIGN(32);
239+
__uninitialized_end = .;
115240
} > RAM
116241

117-
.bss :
242+
.bss (NOLOAD):
118243
{
119244
. = ALIGN(4);
120245
__bss_start__ = .;
@@ -126,29 +251,27 @@ SECTIONS
126251
_ebss = .;
127252
} > RAM
128253

129-
.heap (COPY):
254+
.heap (NOLOAD):
130255
{
256+
__uvisor_heap_start = .;
131257
__end__ = .;
132258
end = __end__;
133-
*(.heap*)
259+
. += HEAP_SIZE;
134260
__HeapLimit = .;
261+
__uvisor_heap_end = .;
135262
} > RAM
136263

137-
/* .stack_dummy section doesn't contains any symbols. It is only
138-
* used for linker to calculate size of stack sections, and assign
139-
* values to stack symbols later */
140-
.stack_dummy (COPY):
141-
{
142-
*(.stack*)
143-
} > RAM
144-
145-
/* Set stack top to end of RAM, and stack limit move down by
146-
* size of stack_dummy section */
147264
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
148-
_estack = __StackTop;
149-
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
150-
PROVIDE(__stack = __StackTop);
265+
__stack = __StackTop;
266+
__StackLimit = __StackTop - STACK_SIZE;
267+
268+
ASSERT(__StackLimit >= __HeapLimit, "Region RAM overflowed with stack and heap")
151269

152-
/* Check if data + heap + stack exceeds RAM limit */
153-
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
270+
/* Provide physical memory boundaries for uVisor. */
271+
__uvisor_flash_start = ORIGIN(VECTORS);
272+
__uvisor_flash_end = ORIGIN(FLASH) + LENGTH(FLASH);
273+
__uvisor_sram_start = ORIGIN(CCM);
274+
__uvisor_sram_end = ORIGIN(CCM) + LENGTH(CCM);
275+
__uvisor_public_sram_start = ORIGIN(RAM);
276+
__uvisor_public_sram_end = ORIGIN(RAM) + LENGTH(RAM);
154277
}

0 commit comments

Comments
 (0)