Use the linker script variables for MPU setup for Keil Simulator Demo

Earlier we were using hard-coded addresses for MPU setup which
were ensured to be the same as linker script setup. This change
updates the Keil Simulator demo to use the variables exported
from the linker script. This ensures that the MPU setup does not
go out of sync with linker script.
This commit is contained in:
Gaurav Aggarwal 2019-12-17 00:14:26 +00:00
parent 66ce9f7d72
commit d449c8979d
2 changed files with 82 additions and 55 deletions

View file

@ -2,60 +2,77 @@
; *** Scatter-Loading Description File generated by uVision *** ; *** Scatter-Loading Description File generated by uVision ***
; ************************************************************* ; *************************************************************
; Privileged Code: ; Flash Layout
; Start : 0x00200000 ; [ ARMv8-M MPU requires that each region must start on a 32 byte aligned
; End : 0x00208000 - 1 ; address and the size of a region must be a multiple of 32 bytes. ]
; Size : 32 Kbytes
; ;
; Privileged Data: ; ---------------------
; Start : 0x20200000 ; | Privileged Code |
; End : 0x20201000 - 1 ; ---------------------
; Size : 4 Kbytes ; | System Calls |
LR_IROM_NS_PRIVILEGED 0x00200000 0x00008000 ; load region size_region ; ---------------------
; | Unprivileged Code |
; ---------------------
LR_CODE 0x00200000 ; load region
{ {
ER_IROM_NS_PRIVILEGED +0 ; load address = execution address ER_IROM_NS_PRIVILEGED +0 ALIGN 32
{ {
*.o(RESET, +First) *.o(RESET, +First)
*(InRoot$$Sections) ; All sections that must be in a root region *(InRoot$$Sections) ; All sections that must be in a root region
*(privileged_functions) *(privileged_functions)
} }
ER_IRAM_NS_PRIVILEGED 0x20200000 0x00001000 ER_IROM_NS_PRIVILEGED_ALIGN +0 ALIGN 32 EMPTY 0x0
{
}
ER_IROM_NS_FREERTOS_SYSTEM_CALLS +0 ALIGN 32
{
*(freertos_system_calls)
}
ER_IROM_NS_FREERTOS_SYSTEM_CALLS_ALIGN +0 ALIGN 32 EMPTY 0x0
{
}
ER_IROM_NS_UNPRIVILEGED +0 ALIGN 32
{
*(+RO)
}
ER_IROM_NS_UNPRIVILEGED_ALIGN +0 ALIGN 32 EMPTY 0x0
{
}
}
; RAM Layout
; [ ARMv8-M MPU requires that each region must start on a 32 byte aligned
; address and the size of a region must be a multiple of 32 bytes. ]
;
; ---------------------
; | Privileged Data |
; ---------------------
; | Unprivileged Data |
; ---------------------
LR_DATA 0x20200000 ; load region
{
ER_IRAM_NS_PRIVILEGED 0x20200000 ALIGN 32
{ {
*(privileged_data) *(privileged_data)
} }
}
; FreeRTOS System Calls: ER_IRAM_NS_PRIVILEGED_ALIGN +0 ALIGN 32 EMPTY 0x0
; Start : 0x00208000
; End : 0x00209000 - 1
; Size : 4 Kbytes
LR_IROM_NS_FREERTOS_SYSTEM_CALLS 0x00208000 0x00001000 ; load region size_region
{
ER_IROM_NS_FREERTOS_SYSTEM_CALLS +0 ; load address = execution address
{ {
*(freertos_system_calls)
}
}
; Unprivileged Code:
; Start : 0x00209000
; End : 0x00400000 - 1
; Size : 2012 Kbytes
;
; Unprivileged Data:
; Start : 0x20201000
; End : 0x20220000 - 1
; Size : 124 Kbytes
LR_IROM_NS_UNPRIVILEGED 0x00209000 0x001F7000 ; load region size_region
{
ER_IROM_NS_UNPRIVILEGED +0 ; load address = execution address
{
*(+RO)
} }
ER_IRAM_NS_UNPRIVILEGED 0x20201000 0x0001F000 ER_IRAM_NS_UNPRIVILEGED +0 ALIGN 32
{ {
*(+RW, +ZI) *(+RW, +ZI)
} }
ER_IRAM_NS_UNPRIVILEGED_ALIGN +0 ALIGN 32 EMPTY 0x0
{
}
} }

View file

@ -33,30 +33,40 @@
#include "tz_demo.h" #include "tz_demo.h"
#include "mpu_demo.h" #include "mpu_demo.h"
/* Externs needed by the MPU setup code. These must match the memory map as /* Externs needed by the MPU setup code. These are defined in Scatter-Loading
* specified in Scatter-Loading description file (FreeRTOSDemo_ns.sct). */ * description file (FreeRTOSDemo_ns.sct). */
extern uint32_t Image$$ER_IROM_NS_PRIVILEGED$$Base;
extern uint32_t Image$$ER_IROM_NS_PRIVILEGED_ALIGN$$Limit;
extern uint32_t Image$$ER_IROM_NS_FREERTOS_SYSTEM_CALLS$$Base;
extern uint32_t Image$$ER_IROM_NS_FREERTOS_SYSTEM_CALLS_ALIGN$$Limit;
extern uint32_t Image$$ER_IROM_NS_UNPRIVILEGED$$Base;
extern uint32_t Image$$ER_IROM_NS_UNPRIVILEGED_ALIGN$$Limit;
extern uint32_t Image$$ER_IRAM_NS_PRIVILEGED$$Base;
extern uint32_t Image$$ER_IRAM_NS_PRIVILEGED_ALIGN$$Limit;
extern uint32_t Image$$ER_IRAM_NS_UNPRIVILEGED$$Base;
extern uint32_t Image$$ER_IRAM_NS_UNPRIVILEGED_ALIGN$$Limit;
/* Privileged flash. */ /* Privileged flash. */
const uint32_t * __privileged_functions_start__ = ( uint32_t * ) ( 0x00200000 ); const uint32_t * __privileged_functions_start__ = ( uint32_t * ) &( Image$$ER_IROM_NS_PRIVILEGED$$Base );
const uint32_t * __privileged_functions_end__ = ( uint32_t * ) ( 0x00208000 - 0x1 ); /* Last address in privileged Flash region. */ const uint32_t * __privileged_functions_end__ = ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IROM_NS_PRIVILEGED_ALIGN$$Limit ) - 0x1 ); /* Last address in privileged Flash region. */
/* Flash containing system calls. */ /* Flash containing system calls. */
const uint32_t * __syscalls_flash_start__ = ( uint32_t * ) ( 0x00208000 ); const uint32_t * __syscalls_flash_start__ = ( uint32_t * ) &( Image$$ER_IROM_NS_FREERTOS_SYSTEM_CALLS$$Base );
const uint32_t * __syscalls_flash_end__ = ( uint32_t * ) ( 0x00209000 - 0x1 ); /* Last address in Flash region containing system calls. */ const uint32_t * __syscalls_flash_end__ = ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IROM_NS_FREERTOS_SYSTEM_CALLS_ALIGN$$Limit ) - 0x1 ); /* Last address in Flash region containing system calls. */
/* Unprivileged flash. Note that the section containing /* Unprivileged flash. Note that the section containing system calls is
* system calls is unprivilged so that unprivleged tasks * unprivileged so that unprivileged tasks can make system calls. */
* can make system calls. */ const uint32_t * __unprivileged_flash_start__ = ( uint32_t * ) &( Image$$ER_IROM_NS_UNPRIVILEGED$$Base );
const uint32_t * __unprivileged_flash_start__ = ( uint32_t * ) ( 0x00209000 ); const uint32_t * __unprivileged_flash_end__ = ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IROM_NS_UNPRIVILEGED_ALIGN$$Limit ) - 0x1 ); /* Last address in un-privileged Flash region. */
const uint32_t * __unprivileged_flash_end__ = ( uint32_t * ) ( 0x00400000 - 0x1 ); /* Last address in un-privileged Flash region. */
/* 512 bytes (0x200) of RAM starting at 0x30008000 is /* RAM with priviledged access only. This contains kernel data. */
* priviledged access only. This contains kernel data. */ const uint32_t * __privileged_sram_start__ = ( uint32_t * ) &( Image$$ER_IRAM_NS_PRIVILEGED$$Base );
const uint32_t * __privileged_sram_start__ = ( uint32_t * ) ( 0x20200000 ); const uint32_t * __privileged_sram_end__ = ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IRAM_NS_PRIVILEGED_ALIGN$$Limit ) - 0x1 ); /* Last address in privileged RAM. */
const uint32_t * __privileged_sram_end__ = ( uint32_t * ) ( 0x20201000 - 0x1 ); /* Last address in privileged RAM. */
; ;
/* Unprivileged RAM. */ /* Unprivileged RAM. */
const uint32_t * __unprivileged_sram_start__ = ( uint32_t * ) ( 0x20201000 ); const uint32_t * __unprivileged_sram_start__ = ( uint32_t * ) &( Image$$ER_IRAM_NS_UNPRIVILEGED$$Base );
const uint32_t * __unprivileged_sram_end__ = ( uint32_t * ) ( 0x20220000 - 0x1 ); /* Last address in un-privileged RAM. */ const uint32_t * __unprivileged_sram_end__ = ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IRAM_NS_UNPRIVILEGED_ALIGN$$Limit ) - 0x1 ); /* Last address in un-privileged RAM. */
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/** /**