diff options
Diffstat (limited to 'FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso')
11 files changed, 759 insertions, 36 deletions
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Config/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Config/FreeRTOSConfig.h index aceab43ec..a1348de26 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Config/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Config/FreeRTOSConfig.h @@ -43,7 +43,7 @@ * https://www.FreeRTOS.org/a00110.html
*----------------------------------------------------------*/
-extern uint32_t SystemCoreClock;
+#include "clock_config.h"
/* Cortex M33 port configuration. */
#define configENABLE_MPU 1
@@ -59,7 +59,7 @@ extern uint32_t SystemCoreClock; #define configUSE_16_BIT_TICKS 0 /* Only for 8 and 16-bit hardware. */
/* Constants that describe the hardware and memory usage. */
-#define configCPU_CLOCK_HZ SystemCoreClock
+#define configCPU_CLOCK_HZ BOARD_BOOTCLOCKFROHF96M_CORE_CLOCK
#define configMINIMAL_STACK_SIZE ( ( uint16_t ) 128 )
#define configMINIMAL_SECURE_STACK_SIZE ( 1024 )
#define configMAX_TASK_NAME_LEN ( 12 )
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.cproject b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.cproject index 1b54a4f41..e5ea92f11 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.cproject +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.cproject @@ -114,6 +114,7 @@ <option id="gnu.c.compiler.option.preprocessor.undef.symbol.1876509684" name="Undefined symbols (-U)" superClass="gnu.c.compiler.option.preprocessor.undef.symbol" useByScannerDiscovery="false"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.88237135" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="../../Config"/>
+ <listOptionValue builtIn="false" value="../../Secure"/>
<listOptionValue builtIn="false" value="../../../../NXP_Code"/>
<listOptionValue builtIn="false" value="../../../../NXP_Code/board"/>
<listOptionValue builtIn="false" value="../../../../NXP_Code/source"/>
@@ -126,6 +127,8 @@ <listOptionValue builtIn="false" value="../../../../NXP_Code/component/lists"/>
<listOptionValue builtIn="false" value="../../../../../../Demo/Common/ARMv8M/mpu_demo"/>
<listOptionValue builtIn="false" value="../../../../../../Demo/Common/ARMv8M/tz_demo"/>
+ <listOptionValue builtIn="false" value="../../../../../../Demo/Common/ARMv8M/reg_tests/GCC/ARM_CM33/non_secure"/>
+ <listOptionValue builtIn="false" value="../../../../../../Demo/Common/ARMv8M/reg_tests/GCC/ARM_CM33/secure"/>
<listOptionValue builtIn="false" value="../../../../../../Source/include"/>
<listOptionValue builtIn="false" value="../../../../../../Source/portable/GCC/ARM_CM33/secure"/>
<listOptionValue builtIn="false" value="../../../../../../Source/portable/GCC/ARM_CM33/non_secure"/>
@@ -267,7 +270,7 @@ <option id="com.crt.advproject.link.cpp.inimplib.742756957" name="Input Secure Gateway Import Library" superClass="com.crt.advproject.link.cpp.inimplib"/>
</tool>
<tool id="com.crt.advproject.link.exe.debug.1811316497" name="MCU Linker" superClass="com.crt.advproject.link.exe.debug">
- <option id="com.crt.advproject.link.gcc.hdrlib.339215003" name="Library" superClass="com.crt.advproject.link.gcc.hdrlib" useByScannerDiscovery="false" value="com.crt.advproject.gcc.link.hdrlib.newlibnano.semihost" valueType="enumerated"/>
+ <option id="com.crt.advproject.link.gcc.hdrlib.339215003" name="Library" superClass="com.crt.advproject.link.gcc.hdrlib" useByScannerDiscovery="false" value="com.crt.advproject.gcc.link.hdrlib.newlibnano.nohost" valueType="enumerated"/>
<option id="com.crt.advproject.link.fpu.1049328981" name="Floating point" superClass="com.crt.advproject.link.fpu" useByScannerDiscovery="false" value="com.crt.advproject.link.fpu.fpv5sp.hard" valueType="enumerated"/>
<option id="com.crt.advproject.link.thumb.1038394022" name="Thumb mode" superClass="com.crt.advproject.link.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.link.memory.load.image.1608049889" name="Plain load image" superClass="com.crt.advproject.link.memory.load.image" useByScannerDiscovery="false" value="false;" valueType="string"/>
@@ -283,12 +286,8 @@ <option id="gnu.c.link.option.nostdlibs.2064853265" name="No startup or default libs (-nostdlib)" superClass="gnu.c.link.option.nostdlibs" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="gnu.c.link.option.strip.1473230449" name="Omit all symbol information (-s)" superClass="gnu.c.link.option.strip" useByScannerDiscovery="false"/>
<option id="gnu.c.link.option.noshared.754737421" name="No shared libraries (-static)" superClass="gnu.c.link.option.noshared" useByScannerDiscovery="false"/>
- <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.libs.2063466722" name="Libraries (-l)" superClass="gnu.c.link.option.libs" useByScannerDiscovery="false" valueType="libs">
- <listOptionValue builtIn="false" value="power_hardabi"/>
- </option>
- <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.paths.826148184" name="Library search path (-L)" superClass="gnu.c.link.option.paths" useByScannerDiscovery="false" valueType="libPaths">
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/NXP_Code/libs}""/>
- </option>
+ <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="gnu.c.link.option.libs.2063466722" name="Libraries (-l)" superClass="gnu.c.link.option.libs" useByScannerDiscovery="false" valueType="libs"/>
+ <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="gnu.c.link.option.paths.826148184" name="Library search path (-L)" superClass="gnu.c.link.option.paths" useByScannerDiscovery="false" valueType="libPaths"/>
<option id="gnu.c.link.option.ldflags.625929291" name="Linker flags" superClass="gnu.c.link.option.ldflags" useByScannerDiscovery="false"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.other.683921352" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" useByScannerDiscovery="false" valueType="stringList">
<listOptionValue builtIn="false" value="-Map="${BuildArtifactFileBaseName}.map""/>
@@ -344,11 +343,12 @@ </toolChain>
</folderInfo>
<sourceEntries>
- <entry flags="LOCAL|VALUE_WORKSPACE_PATH" kind="sourcePath" name="Config"/>
- <entry flags="LOCAL|VALUE_WORKSPACE_PATH" kind="sourcePath" name="Demos"/>
- <entry flags="LOCAL|VALUE_WORKSPACE_PATH" kind="sourcePath" name="FreeRTOS"/>
- <entry flags="LOCAL|VALUE_WORKSPACE_PATH" kind="sourcePath" name="NXP_Code"/>
- <entry flags="LOCAL|VALUE_WORKSPACE_PATH" kind="sourcePath" name="User"/>
+ <entry flags="LOCAL|VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Config"/>
+ <entry flags="LOCAL|VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Demos"/>
+ <entry flags="LOCAL|VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="FreeRTOS"/>
+ <entry flags="LOCAL|VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="NXP_Code"/>
+ <entry flags="LOCAL|VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="User"/>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="reg_tests"/>
</sourceEntries>
</configuration>
</storageModule>
@@ -405,6 +405,10 @@ </infoList>
</TargetConfig></projectStorage>
</storageModule>
- <storageModule moduleId="refreshScope"/>
+ <storageModule moduleId="refreshScope" versionNumber="2">
+ <configuration configurationName="Debug">
+ <resource resourceType="PROJECT" workspacePath="/FreeRTOSDemo_ns"/>
+ </configuration>
+ </storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>
\ No newline at end of file diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.project b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.project index 9fed40c07..5373cd7ec 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.project +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.project @@ -58,6 +58,11 @@ <locationURI>virtual:/virtual</locationURI>
</link>
<link>
+ <name>reg_tests</name>
+ <type>2</type>
+ <locationURI>DEMO_ROOT/Common/ARMv8M/reg_tests</locationURI>
+ </link>
+ <link>
<name>Demos/mpu_demo.c</name>
<type>1</type>
<locationURI>PARENT-4-PROJECT_LOC/Common/ARMv8M/mpu_demo/mpu_demo.c</locationURI>
@@ -82,10 +87,15 @@ <type>1</type>
<locationURI>PROJECT_LOC/main_ns.c</locationURI>
</link>
+ <link>
+ <name>User/res_tests.c</name>
+ <type>1</type>
+ <locationURI>PROJECT_LOC/res_tests.c</locationURI>
+ </link>
</linkedResources>
<filteredResources>
<filter>
- <id>1557021723682</id>
+ <id>1681724631111</id>
<name></name>
<type>6</type>
<matcher>
@@ -94,7 +104,7 @@ </matcher>
</filter>
<filter>
- <id>1557021723695</id>
+ <id>1681724631147</id>
<name></name>
<type>6</type>
<matcher>
@@ -103,6 +113,15 @@ </matcher>
</filter>
<filter>
+ <id>1681721788469</id>
+ <name>reg_tests</name>
+ <type>9</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-GCC</arguments>
+ </matcher>
+ </filter>
+ <filter>
<id>1554600764705</id>
<name>FreeRTOS/portable</name>
<type>9</type>
@@ -139,6 +158,15 @@ </matcher>
</filter>
<filter>
+ <id>1681721804811</id>
+ <name>reg_tests/GCC</name>
+ <type>9</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-ARM_CM33</arguments>
+ </matcher>
+ </filter>
+ <filter>
<id>1553579192808</id>
<name>FreeRTOS/portable/GCC</name>
<type>9</type>
@@ -157,6 +185,15 @@ </matcher>
</filter>
<filter>
+ <id>1681721822064</id>
+ <name>reg_tests/GCC/ARM_CM33</name>
+ <type>9</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-non_secure</arguments>
+ </matcher>
+ </filter>
+ <filter>
<id>1553579213167</id>
<name>FreeRTOS/portable/GCC/ARM_CM33</name>
<type>9</type>
@@ -166,4 +203,10 @@ </matcher>
</filter>
</filteredResources>
+ <variableList>
+ <variable>
+ <name>DEMO_ROOT</name>
+ <value>$%7BPARENT-4-PROJECT_LOC%7D</value>
+ </variable>
+ </variableList>
</projectDescription>
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/main_ns.c b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/main_ns.c index 8dd3d3c10..7967a3c68 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/main_ns.c +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/main_ns.c @@ -34,10 +34,12 @@ #include "pin_mux.h"
#include "board.h"
#include "clock_config.h"
+#include "fsl_power.h"
/* Demo includes. */
#include "tz_demo.h"
#include "mpu_demo.h"
+#include "reg_tests.h"
/*-----------------------------------------------------------*/
/**
@@ -46,6 +48,11 @@ static void prvCreateTasks( void );
/**
+ * @brief Setup hardware.
+ */
+static void prvSetupHardware( void );
+
+/**
* @brief Application-specific implementation of the SystemInit() weak
* function.
*/
@@ -66,6 +73,9 @@ void MemManage_Handler( void ) __attribute__ ( ( naked ) ); /* Non-Secure main. */
int main( void )
{
+ /* Setup hardware. */
+ prvSetupHardware();
+
/* Create tasks. */
prvCreateTasks();
@@ -90,6 +100,15 @@ static void prvCreateTasks( void ) /* Create tasks for the TZ Demo. */
vStartTZDemo();
+ /* Create tasks for reg tests. */
+ vStartRegTests();
+}
+/*-----------------------------------------------------------*/
+
+static void prvSetupHardware( void )
+{
+ /* Set BOD VBAT level to 1.65V. */
+ POWER_SetBodVbatLevel( kPOWER_BodVbatLevel1650mv, kPOWER_BodHystLevel50mv, false );
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/reg_tests.c b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/reg_tests.c new file mode 100644 index 000000000..831ec6479 --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/reg_tests.c @@ -0,0 +1,446 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* Reg test includes. */ +#include "reg_tests.h" +#include "reg_test_asm.h" +#include "secure_reg_test_asm.h" + +/* Printf includes. */ +#include "nsc_printf.h" + +/* + * Functions that implement reg test tasks. + */ +static void prvRegTest1_Task( void * pvParameters ); +static void prvRegTest2_Task( void * pvParameters ); +static void prvRegTest3_Task( void * pvParameters ); +static void prvRegTest4_Task( void * pvParameters ); +static void prvRegTest_Secure_Task( void * pvParameters ); +static void prvRegTest_NonSecureCallback_Task( void * pvParameters ); +/* + * Check task periodically checks that reg tests tasks + * are running fine. + */ +static void prvCheckTask( void * pvParameters ); +/*-----------------------------------------------------------*/ + +/* + * Priority of the check task. + */ +#define CHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) + +/* + * Frequency of check task. + */ +#define NO_ERROR_CHECK_TASK_PERIOD ( pdMS_TO_TICKS( 5000UL ) ) +#define ERROR_CHECK_TASK_PERIOD ( pdMS_TO_TICKS( 200UL ) ) + +/* + * Parameters passed to reg test tasks. + */ +#define REG_TEST_1_TASK_PARAMETER ( ( void * ) 0x12345678 ) +#define REG_TEST_2_TASK_PARAMETER ( ( void * ) 0x87654321 ) +#define REG_TEST_3_TASK_PARAMETER ( ( void * ) 0x12348765 ) +#define REG_TEST_4_TASK_PARAMETER ( ( void * ) 0x43215678 ) +#define REG_TEST_SECURE_TASK_PARAMETER ( ( void * ) 0x1234ABCD ) +#define REG_TEST_NON_SECURE_CALLBACK_TASK_PARAMETER ( ( void * ) 0xABCD1234 ) +/*-----------------------------------------------------------*/ + +/* + * The following variables are used to communicate the status of the register + * test tasks to the check task. If the variables keep incrementing, then the + * register test tasks have not discovered any errors. If a variable stops + * incrementing, then an error has been found. + */ +volatile unsigned long ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL; +volatile unsigned long ulRegTest3LoopCounter = 0UL, ulRegTest4LoopCounter = 0UL; +volatile unsigned long ulRegTestSecureLoopCounter = 0UL; +volatile unsigned long ulRegTestNonSecureCallbackLoopCounter = 0UL; + +/** + * Counter to keep a count of how may times the check task loop has detected + * error. + */ +volatile unsigned long ulCheckTaskLoops = 0UL; +/*-----------------------------------------------------------*/ + +void vStartRegTests( void ) +{ +static StackType_t xRegTest1TaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) ); +static StackType_t xRegTest2TaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) ); +static StackType_t xRegTest3TaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) ); +static StackType_t xRegTest4TaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) ); +static StackType_t xRegTestSecureTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) ); +static StackType_t xRegTestNonSecureCallbackTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) ); +static StackType_t xCheckTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) ); + +TaskParameters_t xRegTest1TaskParameters = +{ + .pvTaskCode = prvRegTest1_Task, + .pcName = "RegTest1", + .usStackDepth = configMINIMAL_STACK_SIZE, + .pvParameters = REG_TEST_1_TASK_PARAMETER, + .uxPriority = tskIDLE_PRIORITY | portPRIVILEGE_BIT, + .puxStackBuffer = xRegTest1TaskStack, + .xRegions = { + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 } + } +}; +TaskParameters_t xRegTest2TaskParameters = +{ + .pvTaskCode = prvRegTest2_Task, + .pcName = "RegTest2", + .usStackDepth = configMINIMAL_STACK_SIZE, + .pvParameters = REG_TEST_2_TASK_PARAMETER, + .uxPriority = tskIDLE_PRIORITY | portPRIVILEGE_BIT, + .puxStackBuffer = xRegTest2TaskStack, + .xRegions = { + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 } + } +}; +TaskParameters_t xRegTest3TaskParameters = +{ + .pvTaskCode = prvRegTest3_Task, + .pcName = "RegTest3", + .usStackDepth = configMINIMAL_STACK_SIZE, + .pvParameters = REG_TEST_3_TASK_PARAMETER, + .uxPriority = tskIDLE_PRIORITY | portPRIVILEGE_BIT, + .puxStackBuffer = xRegTest3TaskStack, + .xRegions = { + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 } + } +}; +TaskParameters_t xRegTest4TaskParameters = +{ + .pvTaskCode = prvRegTest4_Task, + .pcName = "RegTest4", + .usStackDepth = configMINIMAL_STACK_SIZE, + .pvParameters = REG_TEST_4_TASK_PARAMETER, + .uxPriority = tskIDLE_PRIORITY | portPRIVILEGE_BIT, + .puxStackBuffer = xRegTest4TaskStack, + .xRegions = { + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 } + } +}; +TaskParameters_t xRegTestSecureTaskParameters = +{ + .pvTaskCode = prvRegTest_Secure_Task, + .pcName = "RegTestSecure", + .usStackDepth = configMINIMAL_STACK_SIZE, + .pvParameters = REG_TEST_SECURE_TASK_PARAMETER, + .uxPriority = tskIDLE_PRIORITY | portPRIVILEGE_BIT, + .puxStackBuffer = xRegTestSecureTaskStack, + .xRegions = { + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 } + } +}; +TaskParameters_t xRegTestNonSecureCallbackTaskParameters = +{ + .pvTaskCode = prvRegTest_NonSecureCallback_Task, + .pcName = "RegTestNonSecureCallback", + .usStackDepth = configMINIMAL_STACK_SIZE, + .pvParameters = REG_TEST_NON_SECURE_CALLBACK_TASK_PARAMETER, + .uxPriority = tskIDLE_PRIORITY | portPRIVILEGE_BIT, + .puxStackBuffer = xRegTestNonSecureCallbackTaskStack, + .xRegions = { + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 } + } +}; + +TaskParameters_t xCheckTaskParameters = +{ + .pvTaskCode = prvCheckTask, + .pcName = "Check", + .usStackDepth = configMINIMAL_STACK_SIZE, + .pvParameters = NULL, + .uxPriority = ( CHECK_TASK_PRIORITY | portPRIVILEGE_BIT ), + .puxStackBuffer = xCheckTaskStack, + .xRegions = { + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 } + } +}; + + xTaskCreateRestricted( &( xRegTest1TaskParameters ), NULL ); + xTaskCreateRestricted( &( xRegTest2TaskParameters ), NULL ); + xTaskCreateRestricted( &( xRegTest3TaskParameters ), NULL ); + xTaskCreateRestricted( &( xRegTest4TaskParameters ), NULL ); + xTaskCreateRestricted( &( xRegTestSecureTaskParameters ), NULL ); + xTaskCreateRestricted( &( xRegTestNonSecureCallbackTaskParameters ), NULL ); + xTaskCreateRestricted( &( xCheckTaskParameters ), NULL ); +} +/*-----------------------------------------------------------*/ + +static void prvRegTest1_Task( void * pvParameters ) +{ + /* Although the reg tests are written in assembly, its entry + * point is written in C for convenience of checking that the + * task parameter is being passed in correctly. */ + if( pvParameters == REG_TEST_1_TASK_PARAMETER ) + { + /* Start the part of the test that is written in assembler. */ + vRegTest1Asm_NonSecure(); + } + + /* The following line will only execute if the task parameter + * is found to be incorrect. The check task will detect that + * the reg test loop counter is not being incremented and flag + * an error. */ + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +static void prvRegTest2_Task( void * pvParameters ) +{ + /* Although the reg tests are written in assembly, its entry + * point is written in C for convenience of checking that the + * task parameter is being passed in correctly. */ + if( pvParameters == REG_TEST_2_TASK_PARAMETER ) + { + /* Start the part of the test that is written in assembler. */ + vRegTest2Asm_NonSecure(); + } + + /* The following line will only execute if the task parameter + * is found to be incorrect. The check task will detect that + * the reg test loop counter is not being incremented and flag + * an error. */ + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +static void prvRegTest3_Task( void * pvParameters ) +{ + /* Although the reg tests are written in assembly, its entry + * point is written in C for convenience of checking that the + * task parameter is being passed in correctly. */ + if( pvParameters == REG_TEST_3_TASK_PARAMETER ) + { + /* Start the part of the test that is written in assembler. */ + vRegTest3Asm_NonSecure(); + } + + /* The following line will only execute if the task parameter + * is found to be incorrect. The check task will detect that + * the reg test loop counter is not being incremented and flag + * an error. */ + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +static void prvRegTest4_Task( void * pvParameters ) +{ + /* Although the reg tests are written in assembly, its entry + * point is written in C for convenience of checking that the + * task parameter is being passed in correctly. */ + if( pvParameters == REG_TEST_4_TASK_PARAMETER ) + { + /* Start the part of the test that is written in assembler. */ + vRegTest4Asm_NonSecure(); + } + + /* The following line will only execute if the task parameter + * is found to be incorrect. The check task will detect that + * the reg test loop counter is not being incremented and flag + * an error. */ + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +static void prvRegTest_Secure_Task( void * pvParameters ) +{ + /* This task is going to call secure side functions. */ + portALLOCATE_SECURE_CONTEXT( configMINIMAL_SECURE_STACK_SIZE ); + + /* Although the reg tests are written in assembly, its entry + * point is written in C for convenience of checking that the + * task parameter is being passed in correctly. */ + if( pvParameters == REG_TEST_SECURE_TASK_PARAMETER ) + { + for( ;; ) + { + /* Call the secure side function. This function populates registers + * with known values, then forces a context switch while on the + * secure side and then verifies that the contents of the registers + * are intact. This ensure that the context restoring mechanism + * works properly when the interrupted task was in the middle of a + * call to a secure side function. */ + vRegTestAsm_Secure(); + + ulRegTestSecureLoopCounter += 1; + } + } + + /* The following line will only execute if the task parameter + * is found to be incorrect. The check task will detect that + * the reg test loop counter is not being incremented and flag + * an error. */ + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +static void prvRegTest_NonSecureCallback_Task( void * pvParameters ) +{ + /* This task is going to call secure side functions. */ + portALLOCATE_SECURE_CONTEXT( configMINIMAL_SECURE_STACK_SIZE ); + + /* Although the reg tests are written in assembly, its entry + * point is written in C for convenience of checking that the + * task parameter is being passed in correctly. */ + if( pvParameters == REG_TEST_NON_SECURE_CALLBACK_TASK_PARAMETER ) + { + for( ;; ) + { + /* Call the secure side function. This function calls the provided + * non-secure callback which in-turn populates registers with + * known values, then forces a context switch while on the + * non-secure side and then verifies that the contents of the + * registers are intact. This ensure that the context restoring + * mechanism works properly when the interrupted task was in the + * middle of a non-secure callback from the secure side. */ + vRegTest_NonSecureCallback( vRegTestAsm_NonSecureCallback ); + + ulRegTestNonSecureCallbackLoopCounter += 1; + } + } + + /* The following line will only execute if the task parameter + * is found to be incorrect. The check task will detect that + * the reg test loop counter is not being incremented and flag + * an error. */ + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +static void prvCheckTask( void * pvParameters ) +{ +TickType_t xDelayPeriod = NO_ERROR_CHECK_TASK_PERIOD; +TickType_t xLastExecutionTime; +unsigned long ulErrorFound = pdFALSE; +static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0; +static unsigned long ulLastRegTest3Value = 0, ulLastRegTest4Value = 0; +static unsigned long ulLastRegTestSecureValue = 0, ulLastRegTestNonSecureCallbackValue = 0; + + /* This task is going to call secure side functions for + * printing messages. */ + portALLOCATE_SECURE_CONTEXT( configMINIMAL_SECURE_STACK_SIZE ); + + /* Just to stop compiler warnings. */ + ( void ) pvParameters; + + /* Initialize xLastExecutionTime so the first call to vTaskDelayUntil() + * works correctly. */ + xLastExecutionTime = xTaskGetTickCount(); + + /* Cycle for ever, delaying then checking all the other tasks are still + * operating without error. The onboard LED is toggled on each iteration. + * If an error is detected then the delay period is decreased from + * mainNO_ERROR_CHECK_TASK_PERIOD to mainERROR_CHECK_TASK_PERIOD. This has + * the effect of increasing the rate at which the onboard LED toggles, and + * in so doing gives visual feedback of the system status. */ + for( ;; ) + { + /* Delay until it is time to execute again. */ + vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod ); + + /* Check that the register test 1 task is still running. */ + if( ulLastRegTest1Value == ulRegTest1LoopCounter ) + { + ulErrorFound |= 1UL << 0UL; + } + ulLastRegTest1Value = ulRegTest1LoopCounter; + + /* Check that the register test 2 task is still running. */ + if( ulLastRegTest2Value == ulRegTest2LoopCounter ) + { + ulErrorFound |= 1UL << 1UL; + } + ulLastRegTest2Value = ulRegTest2LoopCounter; + + /* Check that the register test 3 task is still running. */ + if( ulLastRegTest3Value == ulRegTest3LoopCounter ) + { + ulErrorFound |= 1UL << 2UL; + } + ulLastRegTest3Value = ulRegTest3LoopCounter; + + /* Check that the register test 4 task is still running. */ + if( ulLastRegTest4Value == ulRegTest4LoopCounter ) + { + ulErrorFound |= 1UL << 3UL; + } + ulLastRegTest4Value = ulRegTest4LoopCounter; + + /* Check that the register test secure task is still running. */ + if( ulLastRegTestSecureValue == ulRegTestSecureLoopCounter ) + { + ulErrorFound |= 1UL << 4UL; + } + ulLastRegTestSecureValue = ulRegTestSecureLoopCounter; + + /* Check that the register test non-secure callback task is + * still running. */ + if( ulLastRegTestNonSecureCallbackValue == ulRegTestNonSecureCallbackLoopCounter ) + { + ulErrorFound |= 1UL << 5UL; + } + ulLastRegTestNonSecureCallbackValue = ulRegTestNonSecureCallbackLoopCounter; + + if( ulErrorFound != pdFALSE ) + { + /* An error has been detected in one of the tasks. */ + xDelayPeriod = ERROR_CHECK_TASK_PERIOD; + + NSC_Printf( "ERROR detected!\r\n" ); + + /* Increment error detection count. */ + ulCheckTaskLoops++; + } + else + { + NSC_Printf( "No errors.\r\n" ); + } + } +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/reg_tests.h b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/reg_tests.h new file mode 100644 index 000000000..0837aad72 --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/reg_tests.h @@ -0,0 +1,35 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +#ifndef REG_TESTS_H +#define REG_TESTS_H + +/** + * @brief Creates all the tasks for reg tests. + */ +void vStartRegTests( void ); + +#endif /* REG_TESTS_H */ diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Secure/.cproject b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Secure/.cproject index 29dede49e..349cc5d2a 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Secure/.cproject +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Secure/.cproject @@ -102,12 +102,12 @@ <listOptionValue builtIn="false" value="MCUXPRESSO_SDK"/>
<listOptionValue builtIn="false" value="CPU_LPC55S69JBD100"/>
<listOptionValue builtIn="false" value="CPU_LPC55S69JBD100_cm33"/>
- <listOptionValue builtIn="false" value="SDK_DEBUGCONSOLE=1"/>
<listOptionValue builtIn="false" value="CR_INTEGER_PRINTF"/>
<listOptionValue builtIn="false" value="__MCUXPRESSO"/>
<listOptionValue builtIn="false" value="__USE_CMSIS"/>
<listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="__NEWLIB__"/>
+ <listOptionValue builtIn="false" value="SDK_DEBUGCONSOLE=1"/>
</option>
<option id="gnu.c.compiler.option.preprocessor.undef.symbol.904667201" name="Undefined symbols (-U)" superClass="gnu.c.compiler.option.preprocessor.undef.symbol" useByScannerDiscovery="false"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.927386374" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
@@ -277,12 +277,8 @@ <option id="gnu.c.link.option.nostdlibs.1676046096" name="No startup or default libs (-nostdlib)" superClass="gnu.c.link.option.nostdlibs" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="gnu.c.link.option.strip.1271951104" name="Omit all symbol information (-s)" superClass="gnu.c.link.option.strip" useByScannerDiscovery="false"/>
<option id="gnu.c.link.option.noshared.257939592" name="No shared libraries (-static)" superClass="gnu.c.link.option.noshared" useByScannerDiscovery="false"/>
- <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.libs.919983000" name="Libraries (-l)" superClass="gnu.c.link.option.libs" useByScannerDiscovery="false" valueType="libs">
- <listOptionValue builtIn="false" value="power_hardabi_s"/>
- </option>
- <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.paths.2126623716" name="Library search path (-L)" superClass="gnu.c.link.option.paths" useByScannerDiscovery="false" valueType="libPaths">
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/NXP_Code/libs}""/>
- </option>
+ <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="gnu.c.link.option.libs.919983000" name="Libraries (-l)" superClass="gnu.c.link.option.libs" useByScannerDiscovery="false" valueType="libs"/>
+ <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="gnu.c.link.option.paths.2126623716" name="Library search path (-L)" superClass="gnu.c.link.option.paths" useByScannerDiscovery="false" valueType="libPaths"/>
<option id="gnu.c.link.option.ldflags.778846229" name="Linker flags" superClass="gnu.c.link.option.ldflags" useByScannerDiscovery="false"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.other.1387107219" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" useByScannerDiscovery="false" valueType="stringList">
<listOptionValue builtIn="false" value="-Map="${BuildArtifactFileBaseName}.map""/>
@@ -308,7 +304,7 @@ <option id="com.crt.advproject.link.crpenable.797389321" name="Enable automatic placement of Code Read Protection field in image" superClass="com.crt.advproject.link.crpenable" useByScannerDiscovery="false"/>
<option id="com.crt.advproject.link.flashconfigenable.908777484" name="Enable automatic placement of Flash Configuration field in image" superClass="com.crt.advproject.link.flashconfigenable" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.link.ecrp.1277431163" name="Enhanced CRP" superClass="com.crt.advproject.link.ecrp" useByScannerDiscovery="false"/>
- <option id="com.crt.advproject.link.gcc.hdrlib.2097369956" name="Library" superClass="com.crt.advproject.link.gcc.hdrlib" useByScannerDiscovery="false" value="com.crt.advproject.gcc.link.hdrlib.newlibnano.semihost" valueType="enumerated"/>
+ <option id="com.crt.advproject.link.gcc.hdrlib.2097369956" name="Library" superClass="com.crt.advproject.link.gcc.hdrlib" useByScannerDiscovery="false" value="com.crt.advproject.gcc.link.hdrlib.newlibnano.nohost" valueType="enumerated"/>
<option id="com.crt.advproject.link.gcc.nanofloat.1164185150" name="Enable printf float " superClass="com.crt.advproject.link.gcc.nanofloat" useByScannerDiscovery="false"/>
<option id="com.crt.advproject.link.gcc.nanofloat.scanf.603353586" name="Enable scanf float " superClass="com.crt.advproject.link.gcc.nanofloat.scanf" useByScannerDiscovery="false"/>
<option id="com.crt.advproject.link.toram.266119221" name="Link application to RAM" superClass="com.crt.advproject.link.toram" useByScannerDiscovery="false"/>
@@ -337,14 +333,25 @@ </tool>
</toolChain>
</folderInfo>
+ <folderInfo id="com.crt.advproject.config.exe.debug.650465968.1580633237" name="/" resourcePath="reg_tests">
+ <toolChain id="com.crt.advproject.toolchain.exe.debug.1643158192" name="NXP MCU Tools" superClass="com.crt.advproject.toolchain.exe.debug" unusedChildren="">
+ <tool id="com.crt.advproject.cpp.exe.debug.1303225074" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.exe.debug.248036726"/>
+ <tool id="com.crt.advproject.gcc.exe.debug.806639634" name="MCU C Compiler" superClass="com.crt.advproject.gcc.exe.debug.1827685058"/>
+ <tool id="com.crt.advproject.gas.exe.debug.2004350830" name="MCU Assembler" superClass="com.crt.advproject.gas.exe.debug.355931849"/>
+ <tool id="com.crt.advproject.link.cpp.exe.debug.141362876" name="MCU C++ Linker" superClass="com.crt.advproject.link.cpp.exe.debug.767850316"/>
+ <tool id="com.crt.advproject.link.exe.debug.558086384" name="MCU Linker" superClass="com.crt.advproject.link.exe.debug.1425769789"/>
+ <tool id="com.crt.advproject.tool.debug.debug.404468304" name="MCU Debugger" superClass="com.crt.advproject.tool.debug.debug.1632770985"/>
+ </toolChain>
+ </folderInfo>
<sourceEntries>
- <entry flags="LOCAL|VALUE_WORKSPACE_PATH" kind="sourcePath" name="Config"/>
- <entry flags="LOCAL|VALUE_WORKSPACE_PATH" kind="sourcePath" name="NSCFunctions"/>
- <entry flags="LOCAL|VALUE_WORKSPACE_PATH" kind="sourcePath" name="NXP_Code"/>
- <entry flags="LOCAL|VALUE_WORKSPACE_PATH" kind="sourcePath" name="SecureContext"/>
- <entry flags="LOCAL|VALUE_WORKSPACE_PATH" kind="sourcePath" name="SecureHeap"/>
- <entry flags="LOCAL|VALUE_WORKSPACE_PATH" kind="sourcePath" name="SecureInit"/>
- <entry flags="LOCAL|VALUE_WORKSPACE_PATH" kind="sourcePath" name="User"/>
+ <entry flags="LOCAL|VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Config"/>
+ <entry flags="LOCAL|VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="NSCFunctions"/>
+ <entry flags="LOCAL|VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="NXP_Code"/>
+ <entry flags="LOCAL|VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="SecureContext"/>
+ <entry flags="LOCAL|VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="SecureHeap"/>
+ <entry flags="LOCAL|VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="SecureInit"/>
+ <entry flags="LOCAL|VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="User"/>
+ <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="reg_tests"/>
</sourceEntries>
</configuration>
</storageModule>
@@ -367,7 +374,7 @@ <storageModule moduleId="com.nxp.mcuxpresso.core.datamodels">
<sdkName>SDK_2.x_LPCXpresso55S69</sdkName>
<sdkExample>FreeRTOSDemo_s</sdkExample>
- <sdkVersion>2.10.0</sdkVersion>
+ <sdkVersion>2.13.1</sdkVersion>
<sdkComponents>platform.drivers.clock.LPC55S69;platform.drivers.power_s.LPC55S69;platform.drivers.common.LPC55S69;utility.debug_console_lite.LPC55S69;platform.utilities.assert_lite.LPC55S69;platform.drivers.lpc_iocon.LPC55S69;platform.drivers.reset.LPC55S69;platform.devices.LPC55S69_CMSIS.LPC55S69;platform.devices.LPC55S69_startup.LPC55S69;platform.drivers.flexcomm_usart.LPC55S69;platform.drivers.flexcomm.LPC55S69;platform.drivers.lpc_gpio.LPC55S69;component.usart_adapter.LPC55S69;component.lists.LPC55S69;CMSIS_Include_core_cm.LPC55S69;platform.utilities.misc_utilities.LPC55S69;platform.devices.LPC55S69_system.LPC55S69;FreeRTOSDemo_s;</sdkComponents>
<boardId>lpcxpresso55s69</boardId>
<package>LPC55S69JBD100</package>
@@ -384,7 +391,7 @@ <name>LPC55S69</name>
<family>LPC55S6x</family>
<vendor>NXP</vendor>
-<memory can_program="true" id="Flash" is_ro="true" size="608" type="Flash"/>
+<memory can_program="true" id="Flash" is_ro="true" size="630" type="Flash"/>
<memory id="RAM" size="304" type="RAM"/>
<memoryInstance derived_from="Flash" driver="LPC55xx_S.cfx" edited="true" id="PROGRAM_FLASH" location="0x10000000" size="0xfe00"/>
<memoryInstance derived_from="Flash" edited="true" id="SG_veneer_table" location="0x1000fe00" size="0x200"/>
@@ -402,6 +409,10 @@ </infoList>
</TargetConfig></projectStorage>
</storageModule>
- <storageModule moduleId="refreshScope"/>
+ <storageModule moduleId="refreshScope" versionNumber="2">
+ <configuration configurationName="Debug">
+ <resource resourceType="PROJECT" workspacePath="/FreeRTOSDemo_s"/>
+ </configuration>
+ </storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>
\ No newline at end of file diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Secure/.project b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Secure/.project index fe69cfc62..b4c624902 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Secure/.project +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Secure/.project @@ -67,6 +67,11 @@ <locationURI>virtual:/virtual</locationURI>
</link>
<link>
+ <name>reg_tests</name>
+ <type>2</type>
+ <locationURI>DEMO_ROOT/Common/ARMv8M/reg_tests</locationURI>
+ </link>
+ <link>
<name>NSCFunctions/nsc_functions.c</name>
<type>1</type>
<locationURI>PARENT-4-PROJECT_LOC/Common/ARMv8M/tz_demo/nsc_functions.c</locationURI>
@@ -122,6 +127,16 @@ <locationURI>PROJECT_LOC/main_s.c</locationURI>
</link>
<link>
+ <name>User/nsc_printf.c</name>
+ <type>1</type>
+ <locationURI>PROJECT_LOC/nsc_printf.c</locationURI>
+ </link>
+ <link>
+ <name>User/nsc_printf.h</name>
+ <type>1</type>
+ <locationURI>PROJECT_LOC/nsc_printf.h</locationURI>
+ </link>
+ <link>
<name>User/tzm_config.c</name>
<type>1</type>
<locationURI>PROJECT_LOC/tzm_config.c</locationURI>
@@ -151,5 +166,38 @@ <arguments>1.0-name-matches-false-false-*.h</arguments>
</matcher>
</filter>
+ <filter>
+ <id>1681721632460</id>
+ <name>reg_tests</name>
+ <type>9</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-GCC</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1681721650651</id>
+ <name>reg_tests/GCC</name>
+ <type>9</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-ARM_CM33</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1681721666490</id>
+ <name>reg_tests/GCC/ARM_CM33</name>
+ <type>9</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-secure</arguments>
+ </matcher>
+ </filter>
</filteredResources>
+ <variableList>
+ <variable>
+ <name>DEMO_ROOT</name>
+ <value>$%7BPARENT-4-PROJECT_LOC%7D</value>
+ </variable>
+ </variableList>
</projectDescription>
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Secure/main_s.c b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Secure/main_s.c index de37dc43f..abe5b7d85 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Secure/main_s.c +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Secure/main_s.c @@ -35,6 +35,7 @@ #include "tzm_config.h"
#include "pin_mux.h"
#include "clock_config.h"
+#include "fsl_power.h"
#if ( __ARM_FEATURE_CMSE & 1 ) == 0
#error "Need ARMv8-M security extensions"
@@ -70,7 +71,8 @@ void SystemInitHook( void ); /* Secure main(). */
int main(void)
{
- PRINTF( "Booting Secure World.\r\n" );
+ /* Set BOD VBAT level to 1.65V. */
+ POWER_SetBodVbatLevel( kPOWER_BodVbatLevel1650mv, kPOWER_BodHystLevel50mv, false );
/* Attach main clock divide to FLEXCOMM0 (debug console). */
CLOCK_AttachClk( BOARD_DEBUG_UART_CLK_ATTACH );
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Secure/nsc_printf.c b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Secure/nsc_printf.c new file mode 100644 index 000000000..d3d04719f --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Secure/nsc_printf.c @@ -0,0 +1,78 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/* ARM includes. */ +#include <arm_cmse.h> + +/* Interface includes. */ +#include "nsc_printf.h" + +/* FreeRTOS includes. */ +#include "secure_port_macros.h" + +/* Device includes. */ +#include "fsl_debug_console.h" +/*-----------------------------------------------------------*/ + +/* Maximum length of the string that the non-secure code + * can print. */ +#define MAX_ALLOWED_STRING_LENGTH 0x400 +/*-----------------------------------------------------------*/ + +secureportNON_SECURE_CALLABLE void NSC_Printf( char const *str ) +{ + uint32_t isInvalidSting = 0; + size_t stringLength; + + /* Check whether the string is null terminated. */ + stringLength = strnlen( str, MAX_ALLOWED_STRING_LENGTH ); + + if( ( stringLength == MAX_ALLOWED_STRING_LENGTH ) && + ( str[ stringLength ] != '\0') ) + { + PRINTF( "[ERROR] [NSC_Printf] String too long or not null terminated!\r\n" ); + isInvalidSting = 1; + } + + if( isInvalidSting == 0 ) + { + /* Check whether the string is located in non-secure memory. */ + if( cmse_check_address_range( ( void * ) str, + stringLength, + ( CMSE_NONSECURE | CMSE_MPU_READ ) ) == NULL ) + { + PRINTF( "[ERROR] [NSC_Printf] String is not located in non-secure memory!\r\n" ); + isInvalidSting = 1; + } + } + + /* Print the string if it is a valid string. */ + if( isInvalidSting == 0 ) + { + PRINTF( str ); + } +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Secure/nsc_printf.h b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Secure/nsc_printf.h new file mode 100644 index 000000000..1362b4556 --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/Secure/nsc_printf.h @@ -0,0 +1,37 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +#ifndef NSC_PRINTF_H +#define NSC_PRINTF_H + +/** + * @brief Non-Secure callable printf function. + * + * @param str The string to print. + */ +void NSC_Printf( char const *str ); + +#endif /* NSC_PRINTF_H */ |