From: gaurav-aws Date: Tue, 17 Dec 2019 01:45:53 +0000 (+0000) Subject: Use linker script variables for MPU setup for Nuvoton M2351 Keil Project X-Git-Tag: V10.3.0~61 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=059d65bb93ebd642f835a72c322b93f947ce64ab;p=freertos Use linker script variables for MPU setup for Nuvoton M2351 Keil Project 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 uVision project for Nuvoton Numaker-PFM-M2351 to use the variables exported from the linker script. This ensures that the MPU setup never goes out of sync with linker script. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2762 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects/Keil/NonSecure/FreeRTOSDemo_ns.sct b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects/Keil/NonSecure/FreeRTOSDemo_ns.sct index 961bae92c..3273dd507 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects/Keil/NonSecure/FreeRTOSDemo_ns.sct +++ b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects/Keil/NonSecure/FreeRTOSDemo_ns.sct @@ -1,59 +1,70 @@ - -; Privileged Code: -; Start : 0x10040000 -; End : 0x10047000 - 1 -; Size : 28 Kbytes +; NOTE: 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. +; +; Flash Layout +; +; --------------------- +; | Privileged Code | +; --------------------- +; | System Calls | +; --------------------- +; | Unprivileged Code | +; --------------------- +; +; RAM Layout ; -; Privileged Data: -; Start : 0x30008000 -; End : 0x30009000 - 1 -; Size : 4 Kbytes -LR_IROM_NS_PRIVILEGED 0x10040000 0x00007000 ; load region size_region +; --------------------- +; | Privileged Data | +; --------------------- +; | Unprivileged Data | +; --------------------- + +LR_APP 0x10040000 ; load region { - ER_IROM_NS_PRIVILEGED +0 ; load address = execution address + ER_IROM_NS_PRIVILEGED +0 ALIGN 32 { *.o(RESET, +First) *(InRoot$$Sections) ; All sections that must be in a root region *(privileged_functions) } - ER_IRAM_NS_PRIVILEGED 0x30008000 0x00001000 + ER_IROM_NS_PRIVILEGED_ALIGN +0 ALIGN 32 EMPTY 0x0 { - *(privileged_data) } -} -; System Calls: -; Start : 0x10047000 -; End : 0x10048000 - 1 -; Size : 4 Kbytes -LR_IROM_NS_SYSTEM_CALLS 0x10047000 0x00001000 ; load region size_region -{ - ER_IROM_NS_SYSTEM_CALLS +0 ; load address = execution address + ER_IROM_NS_FREERTOS_SYSTEM_CALLS +0 ALIGN 32 { - *(freertos_system_calls) + *(freertos_system_calls) } -} -; Unprivileged Code: -; Start : 0x10048000 -; End : 0x10080000 - 1 -; Size : 224 Kbytes -; -; Unprivileged Data: -; Start : 0x30009000 -; End : 0x30018000 - 1 -; Size : 60 Kbytes -LR_IROM_NS_UNPRIVILEGED 0x10048000 0x00038000 ; load region size_region -{ - ER_IROM_NS_UNPRIVILEGED +0 ; load address = execution address + ER_IROM_NS_FREERTOS_SYSTEM_CALLS_ALIGN +0 ALIGN 32 EMPTY 0x0 + { + } + + ER_IROM_NS_UNPRIVILEGED +0 ALIGN 32 { - *(+RO) + *(+RO) } - ER_IRAM_NS_UNPRIVILEGED 0x30009000 0x0000F000 + ER_IROM_NS_UNPRIVILEGED_ALIGN +0 ALIGN 32 EMPTY 0x0 + { + } + + ER_IRAM_NS_PRIVILEGED 0x30008000 ALIGN 32 + { + *(privileged_data) + } + + ER_IRAM_NS_PRIVILEGED_ALIGN +0 ALIGN 32 EMPTY 0x0 + { + } + + ER_IRAM_NS_UNPRIVILEGED +0 ALIGN 32 { *(+RW, +ZI) } -} + ER_IRAM_NS_UNPRIVILEGED_ALIGN +0 ALIGN 32 EMPTY 0x0 + { + } +} diff --git a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects/Keil/NonSecure/main_ns.c b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects/Keil/NonSecure/main_ns.c index 973777d93..68d74acc0 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects/Keil/NonSecure/main_ns.c +++ b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects/Keil/NonSecure/main_ns.c @@ -37,28 +37,40 @@ #include "tz_demo.h" #include "mpu_demo.h" -/* Externs needed by the MPU setup code. These must match the memory map as - * specified in Scatter-Loading description file (FreeRTOSDemo_ns.sct). */ +/* Externs needed by the MPU setup code. These are defined in Scatter-Loading + * 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. */ -const uint32_t * __privileged_functions_start__ = ( uint32_t * ) ( 0x10040000 ); -const uint32_t * __privileged_functions_end__ = ( uint32_t * ) ( 0x10047000 - 0x1 ); /* Last address in privileged Flash region. */ +const uint32_t * __privileged_functions_start__ = ( uint32_t * ) &( Image$$ER_IROM_NS_PRIVILEGED$$Base ); +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. Note that the section containing system calls - * is unprivileged so that unprivileged tasks can make system calls.*/ -const uint32_t * __syscalls_flash_start__ = ( uint32_t * ) ( 0x10047000 ); -const uint32_t * __syscalls_flash_end__ = ( uint32_t * ) ( 0x10048000 - 0x1 ); /* Last address in Flash region containing system calls. */ +/* Flash containing system calls. */ +const uint32_t * __syscalls_flash_start__ = ( uint32_t * ) &( Image$$ER_IROM_NS_FREERTOS_SYSTEM_CALLS$$Base ); +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. */ -const uint32_t * __unprivileged_flash_start__ = ( uint32_t * ) ( 0x10048000 ); -const uint32_t * __unprivileged_flash_end__ = ( uint32_t * ) ( 0x10080000 - 0x1 ); /* Last address in un-privileged Flash region. */ +/* Unprivileged flash. Note that the section containing system calls is + * unprivileged so that unprivileged tasks can make system calls. */ +const uint32_t * __unprivileged_flash_start__ = ( uint32_t * ) &( Image$$ER_IROM_NS_UNPRIVILEGED$$Base ); +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. */ -/* Privileged RAM. It contains kernel data. */ -const uint32_t * __privileged_sram_start__ = ( uint32_t * ) ( 0x30008000 ); -const uint32_t * __privileged_sram_end__ = ( uint32_t * ) ( 0x30009000 - 0x1 ); /* Last address in privileged RAM. */ +/* RAM with 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_end__ = ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IRAM_NS_PRIVILEGED_ALIGN$$Limit ) - 0x1 ); /* Last address in privileged RAM. */ /* Unprivileged RAM. */ -const uint32_t * __unprivileged_sram_start__ = ( uint32_t * ) ( 0x30009000 ); -const uint32_t * __unprivileged_sram_end__ = ( uint32_t * ) ( 0x30018000 - 0x1 ); /* Last address in un-privileged RAM. */ +const uint32_t * __unprivileged_sram_start__ = ( uint32_t * ) &( Image$$ER_IRAM_NS_UNPRIVILEGED$$Base ); +const uint32_t * __unprivileged_sram_end__ = ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IRAM_NS_UNPRIVILEGED_ALIGN$$Limit ) - 0x1 ); /* Last address in un-privileged RAM. */ /*-----------------------------------------------------------*/ /** diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/FreeRTOSDemo_ns.sct b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/FreeRTOSDemo_ns.sct index e523fa16a..bf9373b06 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/FreeRTOSDemo_ns.sct +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/FreeRTOSDemo_ns.sct @@ -1,10 +1,7 @@ -; ************************************************************* -; *** Scatter-Loading Description File generated by uVision *** -; ************************************************************* - +; NOTE: 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. +; ; Flash 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 Code | @@ -13,8 +10,16 @@ ; --------------------- ; | Unprivileged Code | ; --------------------- +; +; RAM Layout +; +; --------------------- +; | Privileged Data | +; --------------------- +; | Unprivileged Data | +; --------------------- -LR_CODE 0x00200000 ; load region +LR_APP 0x00200000 ; load region { ER_IROM_NS_PRIVILEGED +0 ALIGN 32 { @@ -44,20 +49,7 @@ LR_CODE 0x00200000 ; load region 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) diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/main_ns.c b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/main_ns.c index 42ac4f49a..fb6aeaa6b 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/main_ns.c +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/main_ns.c @@ -63,7 +63,7 @@ const uint32_t * __unprivileged_flash_end__ = ( uint32_t * ) ( ( uint32_t ) &( /* RAM with 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_end__ = ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IRAM_NS_PRIVILEGED_ALIGN$$Limit ) - 0x1 ); /* Last address in privileged RAM. */ -; + /* Unprivileged RAM. */ const uint32_t * __unprivileged_sram_start__ = ( uint32_t * ) &( Image$$ER_IRAM_NS_UNPRIVILEGED$$Base ); const uint32_t * __unprivileged_sram_end__ = ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IRAM_NS_UNPRIVILEGED_ALIGN$$Limit ) - 0x1 ); /* Last address in un-privileged RAM. */