From 14a34fc9e5a7338cc118627ba2213edcf64a221b Mon Sep 17 00:00:00 2001 From: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Date: Mon, 24 Apr 2023 16:48:39 +0530 Subject: Add non trustzone (NTZ) projects for M2351 (#1003) Signed-off-by: Gaurav Aggarwal --- .../.gitignore | 1 + .../Projects_NTZ/IAR/Config/FreeRTOSConfig.h | 173 +++ .../Projects_NTZ/IAR/FreeRTOSDemo.ewd | 1554 ++++++++++++++++++++ .../Projects_NTZ/IAR/FreeRTOSDemo.ewp | 1198 +++++++++++++++ .../Projects_NTZ/IAR/FreeRTOSDemo.eww | 19 + .../Projects_NTZ/IAR/FreeRTOSDemo.icf | 118 ++ .../Projects_NTZ/IAR/fault_handler.s | 46 + .../Projects_NTZ/IAR/main.c | 200 +++ .../Projects_NTZ/Keil/Config/FreeRTOSConfig.h | 168 +++ .../Projects_NTZ/Keil/FreeRTOSDemo.sct | 70 + .../Projects_NTZ/Keil/FreeRTOSDemo.uvoptx | 547 +++++++ .../Projects_NTZ/Keil/FreeRTOSDemo.uvprojx | 615 ++++++++ .../Projects_NTZ/Keil/FreeRTOSDemo_debug.ini | 3 + .../Projects_NTZ/Keil/main.c | 265 ++++ .../RegTests/reg_tests.c | 144 +- 15 files changed, 5066 insertions(+), 55 deletions(-) create mode 100644 FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/Config/FreeRTOSConfig.h create mode 100644 FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/FreeRTOSDemo.ewd create mode 100644 FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/FreeRTOSDemo.ewp create mode 100644 FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/FreeRTOSDemo.eww create mode 100644 FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/FreeRTOSDemo.icf create mode 100644 FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/fault_handler.s create mode 100644 FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/main.c create mode 100644 FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/Config/FreeRTOSConfig.h create mode 100644 FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/FreeRTOSDemo.sct create mode 100644 FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/FreeRTOSDemo.uvoptx create mode 100644 FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/FreeRTOSDemo.uvprojx create mode 100644 FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/FreeRTOSDemo_debug.ini create mode 100644 FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/main.c diff --git a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/.gitignore b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/.gitignore index 30de058bd..6a8df8dc1 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/.gitignore +++ b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/.gitignore @@ -2,6 +2,7 @@ *.uvgui* settings/ Nu_Link_Driver.ini +EventRecorderStub.scvd *.ewt *.dep diff --git a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/Config/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/Config/FreeRTOSConfig.h new file mode 100644 index 000000000..3234ed684 --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/Config/FreeRTOSConfig.h @@ -0,0 +1,173 @@ +/* + * 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 + * + */ + +/****************************************************************************** + See http://www.freertos.org/a00110.html for an explanation of the + definitions contained in this file. +******************************************************************************/ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + * https://www.FreeRTOS.org/a00110.html + *----------------------------------------------------------*/ + +/* The #ifdef guards against the file being included from IAR assembly files. */ +#ifndef __IASMARM__ + + extern uint32_t SystemCoreClock; + +#endif /* __IASMARM__ */ + +/* Cortex M33 port configuration. */ +#define configENABLE_MPU 1 +#define configENABLE_FPU 0 +#define configENABLE_TRUSTZONE 0 +#define configRUN_FREERTOS_SECURE_ONLY 1 + +/* Constants related to the behaviour or the scheduler. */ +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 +#define configUSE_PREEMPTION 1 +#define configUSE_TIME_SLICING 1 +#define configMAX_PRIORITIES ( 5 ) +#define configIDLE_SHOULD_YIELD 1 +#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 configMINIMAL_STACK_SIZE ( ( uint16_t ) 128 ) +#define configMINIMAL_SECURE_STACK_SIZE ( 1024 ) +#define configMAX_TASK_NAME_LEN ( 12 ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 20 * 1024 ) ) + +/* Constants that build features in or out. */ +#define configUSE_MUTEXES 1 +#define configUSE_TICKLESS_IDLE 1 +#define configUSE_APPLICATION_TASK_TAG 0 +#define configUSE_NEWLIB_REENTRANT 0 +#define configUSE_COUNTING_SEMAPHORES 1 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configUSE_QUEUE_SETS 0 +#define configUSE_TASK_NOTIFICATIONS 1 +#define configUSE_TRACE_FACILITY 1 + +/* Constants that define which hook (callback) functions should be used. */ +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configUSE_MALLOC_FAILED_HOOK 0 + +/* Constants provided for debugging and optimisation assistance. */ +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); } +#define configQUEUE_REGISTRY_SIZE 0 + +/* Software timer definitions. */ +#define configUSE_TIMERS 1 +#define configTIMER_TASK_PRIORITY ( 3 ) +#define configTIMER_QUEUE_LENGTH 5 +#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE ) + +/* Set the following definitions to 1 to include the API function, or zero + * to exclude the API function. NOTE: Setting an INCLUDE_ parameter to 0 is + * only necessary if the linker does not automatically remove functions that are + * not referenced anyway. */ +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 0 +#define INCLUDE_xTaskGetIdleTaskHandle 0 +#define INCLUDE_eTaskGetState 1 +#define INCLUDE_xTaskResumeFromISR 0 +#define INCLUDE_xTaskGetCurrentTaskHandle 1 +#define INCLUDE_xTaskGetSchedulerState 0 +#define INCLUDE_xSemaphoreGetMutexHolder 0 +#define INCLUDE_xTimerPendFunctionCall 1 + +/* This demo makes use of one or more example stats formatting functions. These + * format the raw data provided by the uxTaskGetSystemState() function in to + * human readable ASCII form. See the notes in the implementation of vTaskList() + * within FreeRTOS/Source/tasks.c for limitations. */ +#define configUSE_STATS_FORMATTING_FUNCTIONS 1 + +/* Dimensions a buffer that can be used by the FreeRTOS+CLI command interpreter. + * See the FreeRTOS+CLI documentation for more information: + * https://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_CLI/ */ +#define configCOMMAND_INT_MAX_OUTPUT_SIZE 2048 + +/* Interrupt priority configuration follows...................... */ + +/* Use the system definition, if there is one. */ +#ifdef __NVIC_PRIO_BITS + #define configPRIO_BITS __NVIC_PRIO_BITS +#else + #define configPRIO_BITS 3 /* 8 priority levels. */ +#endif + +/* The lowest interrupt priority that can be used in a call to a "set priority" + * function. */ +#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0x07 + +/* The highest interrupt priority that can be used by any interrupt service + * routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT + * CALL INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A + * HIGHER PRIORITY THAN THIS! (higher priorities are lower numeric values). */ +#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 + +/* Interrupt priorities used by the kernel port layer itself. These are generic + * to all Cortex-M ports, and do not rely on any particular library functions. */ +#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << ( 8 - configPRIO_BITS ) ) + +/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! + * See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ +#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << ( 8 - configPRIO_BITS ) ) + +/* The #ifdef guards against the file being included from IAR assembly files. */ +#ifndef __IASMARM__ + + /* Constants related to the generation of run time stats. */ + #define configGENERATE_RUN_TIME_STATS 0 + #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() + #define portGET_RUN_TIME_COUNTER_VALUE() 0 + #define configTICK_RATE_HZ ( ( TickType_t ) 100 ) + +#endif /* __IASMARM__ */ + +/* Enable static allocation. */ +#define configSUPPORT_STATIC_ALLOCATION 1 + +#endif /* FREERTOS_CONFIG_H */ diff --git a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/FreeRTOSDemo.ewd b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/FreeRTOSDemo.ewd new file mode 100644 index 000000000..8491b4e1a --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/FreeRTOSDemo.ewd @@ -0,0 +1,1554 @@ + + + 3 + + Release + + ARM + + 0 + + C-SPY + 2 + + 32 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ARMSIM_ID + 2 + + 1 + 1 + 0 + + + + + + + + CADI_ID + 2 + + 0 + 1 + 0 + + + + + + + + + CMSISDAP_ID + 2 + + 4 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GDBSERVER_ID + 2 + + 0 + 1 + 0 + + + + + + + + + + + IJET_ID + 2 + + 9 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JLINK_ID + 2 + + 16 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LMIFTDI_ID + 2 + + 3 + 1 + 0 + + + + + + + + + + + + + NULINK_ID + 2 + + 0 + 1 + 0 + + + + + + + PEMICRO_ID + 2 + + 3 + 1 + 0 + + + + + + + + STLINK_ID + 2 + + 8 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + THIRDPARTY_ID + 2 + + 0 + 1 + 0 + + + + + + + + TIFET_ID + 2 + + 1 + 1 + 0 + + + + + + + + + + + + + + + + + + + XDS100_ID + 2 + + 9 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\FreeRtos\FreeRtosArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\Mbed\MbedArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\Mbed\MbedArmPlugin2.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm9.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm9BE.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin + 0 + + + $TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin + 0 + + + $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\TargetAccessServer\TargetAccessServer.ENU.ewplugin + 0 + + + $EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin + 0 + + + + diff --git a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/FreeRTOSDemo.ewp b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/FreeRTOSDemo.ewp new file mode 100644 index 000000000..3546df42b --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/FreeRTOSDemo.ewp @@ -0,0 +1,1198 @@ + + + 3 + + Release + + ARM + + 0 + + General + 3 + + 35 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 37 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 11 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 0 + + + + + + + + + CUSTOM + 3 + + + + 1 + inputOutputBased + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 27 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 0 + + + + + + + + Config + + $PROJ_DIR$\Config\FreeRTOSConfig.h + + + + Demos + + $PROJ_DIR$\..\..\..\Common\ARMv8M\mpu_demo\mpu_demo.c + + + $PROJ_DIR$\..\..\..\Common\ARMv8M\mpu_demo\mpu_demo.h + + + $PROJ_DIR$\..\..\..\Common\ARMv8M\reg_tests\IAR\ARM_CM23\non_secure\reg_test_asm.h + + + $PROJ_DIR$\..\..\..\Common\ARMv8M\reg_tests\IAR\ARM_CM23\non_secure\reg_test_asm.s + + + + Device + + $PROJ_DIR$\..\..\Nuvoton_Code\Device\Nuvoton\M2351\Source\IAR\startup_M2351.s + + + $PROJ_DIR$\..\..\Nuvoton_Code\Device\Nuvoton\M2351\Source\system_M2351.c + + + + Drivers + + $PROJ_DIR$\..\..\Nuvoton_Code\StdDriver\src\clk.c + + + $PROJ_DIR$\..\..\Nuvoton_Code\StdDriver\src\gpio.c + + + $PROJ_DIR$\..\..\Nuvoton_Code\StdDriver\src\retarget.c + + + + FreeRTOS + + portable + + Common + + $PROJ_DIR$\..\..\..\..\Source\portable\Common\mpu_wrappers.c + + + + IAR + + ARM_CM23_NTZ + + $PROJ_DIR$\..\..\..\..\Source\portable\IAR\ARM_CM23_NTZ\non_secure\port.c + + + $PROJ_DIR$\..\..\..\..\Source\portable\IAR\ARM_CM23_NTZ\non_secure\portasm.h + + + $PROJ_DIR$\..\..\..\..\Source\portable\IAR\ARM_CM23_NTZ\non_secure\portasm.s + + + $PROJ_DIR$\..\..\..\..\Source\portable\IAR\ARM_CM23_NTZ\non_secure\portmacro.h + + + $PROJ_DIR$\..\..\..\..\Source\portable\IAR\ARM_CM23_NTZ\non_secure\portmacrocommon.h + + + + + MemMang + + $PROJ_DIR$\..\..\..\..\Source\portable\MemMang\heap_4.c + + + + + $PROJ_DIR$\..\..\..\..\Source\event_groups.c + + + $PROJ_DIR$\..\..\..\..\Source\list.c + + + $PROJ_DIR$\..\..\..\..\Source\queue.c + + + $PROJ_DIR$\..\..\..\..\Source\stream_buffer.c + + + $PROJ_DIR$\..\..\..\..\Source\tasks.c + + + $PROJ_DIR$\..\..\..\..\Source\timers.c + + + + User + + $PROJ_DIR$\fault_handler.s + + + $PROJ_DIR$\main.c + + + $PROJ_DIR$\..\..\RegTests\reg_tests.c + + + $PROJ_DIR$\..\..\RegTests\reg_tests.h + + + diff --git a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/FreeRTOSDemo.eww b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/FreeRTOSDemo.eww new file mode 100644 index 000000000..558ec71aa --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/FreeRTOSDemo.eww @@ -0,0 +1,19 @@ + + + + + $WS_DIR$\FreeRTOSDemo.ewp + + + + + all + + FreeRTOSDemo + Release + + + + + + diff --git a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/FreeRTOSDemo.icf b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/FreeRTOSDemo.icf new file mode 100644 index 000000000..8c23e43f4 --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/FreeRTOSDemo.icf @@ -0,0 +1,118 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/ +/*-Editor annotation file-*/ +/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v2_1.xml" */ + +/*-Specials-*/ +define symbol __ICFEDIT_intvec_start__ = 0x00000000; + +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_IROM1_start__ = 0x00000000; +define symbol __ICFEDIT_region_IROM1_end__ = 0x0007FFFF; +define symbol __ICFEDIT_region_IROM2_start__ = 0x0; +define symbol __ICFEDIT_region_IROM2_end__ = 0x0; +define symbol __ICFEDIT_region_EROM1_start__ = 0x0; +define symbol __ICFEDIT_region_EROM1_end__ = 0x0; +define symbol __ICFEDIT_region_EROM2_start__ = 0x0; +define symbol __ICFEDIT_region_EROM2_end__ = 0x0; +define symbol __ICFEDIT_region_EROM3_start__ = 0x0; +define symbol __ICFEDIT_region_EROM3_end__ = 0x0; +define symbol __ICFEDIT_region_IRAM1_start__ = 0x20000000; +define symbol __ICFEDIT_region_IRAM1_end__ = 0x20017FFF; +define symbol __ICFEDIT_region_IRAM2_start__ = 0x0; +define symbol __ICFEDIT_region_IRAM2_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM1_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM1_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM2_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM2_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM3_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM3_end__ = 0x0; + +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = 0x800; +define symbol __ICFEDIT_size_proc_s_stack__ = 0x0; +define symbol __ICFEDIT_size_main_ns_stack__ = 0x0; +define symbol __ICFEDIT_size_proc_ns_stack__ = 0x0; +define symbol __ICFEDIT_size_heap__ = 0x0; + +/**** End of ICF editor section. ###ICF###*/ + +/* Flash Organization + * 1. Privileged Code: + * Start : 0x00000000 + * End : 0x00006FFF + * Size : 28 Kbytes + * 2. System calls: + * Start : 0x00007000 + * End : 0x00007FFF + * Size : 4 Kbytes + * 3. Unprivileged Code: + * Start : 0x00008000 + * End : 0x0007FFFF + * Size : 480 Kbytes + */ +define symbol __region_ROM_Privileged_start__ = 0x00000000; +define symbol __region_ROM_Privileged_end__ = 0x00006FFF; +define symbol __region_ROM_SystemCalls_start__ = 0x00007000; +define symbol __region_ROM_SystemCalls_end__ = 0x00007FFF; +define symbol __region_ROM_Unprivileged_start__ = 0x00008000; +define symbol __region_ROM_Unprivileged_end__ = 0x0007FFFF; + +/* RAM Organization + * 1. Privileged Data: + * Start : 0x20000000 + * End : 0x20007FFF + * Size : 32 Kbytes + * 2. Unprivileged Data: + * Start : 0x20008000 + * End : 0x20017FFF + * Size : 64 Kbytes + */ +define symbol __region_RAM_Privileged_start__ = 0x20000000; +define symbol __region_RAM_Privileged_end__ = 0x20007FFF; +define symbol __region_RAM_Unprivileged_start__ = 0x20008000; +define symbol __region_RAM_Unprivileged_end__ = 0x20017FFF; + +/* Memory Regions. */ +define memory mem with size = 4G; +define region ROM_Privileged_region = mem:[from __region_ROM_Privileged_start__ to __region_ROM_Privileged_end__]; +define region ROM_SystemCalls_region = mem:[from __region_ROM_SystemCalls_start__ to __region_ROM_SystemCalls_end__]; +define region ROM_Unprivileged_region = mem:[from __region_ROM_Unprivileged_start__ to __region_ROM_Unprivileged_end__]; +define region RAM_Privileged_region = mem:[from __region_RAM_Privileged_start__ to __region_RAM_Privileged_end__]; +define region RAM_Unprivileged_region = mem:[from __region_RAM_Unprivileged_start__ to __region_RAM_Unprivileged_end__]; + +/* Stack and Heap. */ +define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; +define block PROC_STACK_S with alignment = 8, size = __ICFEDIT_size_proc_s_stack__ { }; +define block MAIN_STACK_NS with alignment = 8, size = __ICFEDIT_size_main_ns_stack__ { }; +define block PROC_STACK_NS with alignment = 8, size = __ICFEDIT_size_proc_ns_stack__ { }; +define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; + +/* Initialization. */ +do not initialize { section .noinit }; +initialize by copy { readwrite }; +if( isdefinedsymbol(__USE_DLIB_PERTHREAD) ) +{ + /* Required in a multi-threaded application. */ + initialize by copy with packing = none { section __DLIB_PERTHREAD }; +} + +/* Exported symbols. */ +define exported symbol __privileged_functions_start__ = __region_ROM_Privileged_start__; +define exported symbol __privileged_functions_end__ = __region_ROM_Privileged_end__; +define exported symbol __syscalls_flash_start__ = __region_ROM_SystemCalls_start__; +define exported symbol __syscalls_flash_end__ = __region_ROM_SystemCalls_end__; +define exported symbol __unprivileged_flash_start__ = __region_ROM_Unprivileged_start__; +define exported symbol __unprivileged_flash_end__ = __region_ROM_Unprivileged_end__; +define exported symbol __privileged_sram_start__ = __region_RAM_Privileged_start__; +define exported symbol __privileged_sram_end__ = __region_RAM_Privileged_end__; + +/* Placements. */ +place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; + +place in ROM_Privileged_region { readonly section privileged_functions }; +place in ROM_SystemCalls_region { readonly section freertos_system_calls }; +place in ROM_Unprivileged_region { readonly }; + +place in RAM_Privileged_region { readwrite section privileged_data }; +place in RAM_Unprivileged_region { readwrite, + block CSTACK, block PROC_STACK_S, block MAIN_STACK_NS, block PROC_STACK_NS, block HEAP }; diff --git a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/fault_handler.s b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/fault_handler.s new file mode 100644 index 000000000..29150ef59 --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/fault_handler.s @@ -0,0 +1,46 @@ +/* + * 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 + * + */ + + EXTERN vHandleMemoryFault + PUBLIC HardFault_Handler + + SECTION .text:CODE:NOROOT(2) + THUMB +/*-----------------------------------------------------------*/ + +HardFault_Handler: + movs r0, #4 + mov r1, lr + tst r0, r1 + beq stacking_used_msp + mrs r0, psp + b vHandleMemoryFault + stacking_used_msp: + mrs r0, msp + b vHandleMemoryFault +/*-----------------------------------------------------------*/ + + END diff --git a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/main.c b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/main.c new file mode 100644 index 000000000..09311b036 --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/IAR/main.c @@ -0,0 +1,200 @@ +/* + * 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 + * + */ + +/* Device includes. */ +#include +#include "NuMicro.h" + +/* FreeRTOS includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* Demo includes. */ +#include "mpu_demo.h" +#include "reg_tests.h" + +/** + * @brief Sets up the hardware - clocks and UARTs. + */ +static void prvSetupHardware( void ); + +/** + * @brief Create all demo tasks. + */ +static void prvCreateTasks( void ); +/*-----------------------------------------------------------*/ + +int main( void ) +{ + /* Initialize the hardware. */ + prvSetupHardware(); + + /* Print banner. */ + printf( "\r\n" ); + printf( "+---------------------------------------------+\r\n" ); + printf( "| Application is running ... |\r\n" ); + printf( "+---------------------------------------------+\r\n" ); + + /* Create tasks. */ + prvCreateTasks(); + + /* Start scheduler. */ + vTaskStartScheduler(); + + /* Will not get here if the scheduler starts successfully. If you do end up + here then there wasn't enough heap memory available to start either the idle + task or the timer/daemon task. https://www.freertos.org/a00111.html */ + + for( ; ; ) + { + } +} +/*-----------------------------------------------------------*/ + +static void prvSetupHardware( void ) +{ + /* Unlock protected registers. */ + SYS_UnlockReg(); + + /* Init System Clock. */ + /* Enable PLL */ + CLK->PLLCTL = CLK_PLLCTL_64MHz_HIRC; + /* Wait for PLL to be stable. */ + while( ( CLK->STATUS & CLK_STATUS_PLLSTB_Msk ) == 0 ); + + /* Set HCLK divider to 1. */ + CLK->CLKDIV0 = ( CLK->CLKDIV0 & ( ~CLK_CLKDIV0_HCLKDIV_Msk ) ); + + /* Switch HCLK clock source to PLL. */ + CLK->CLKSEL0 = ( CLK->CLKSEL0 & ( ~CLK_CLKSEL0_HCLKSEL_Msk ) ) | CLK_CLKSEL0_HCLKSEL_PLL; + + /* Initialize UART0 - It is used for debug output from the non-secure side. */ + /* Enable UART0 clock. */ + CLK->APBCLK0 |= CLK_APBCLK0_UART0CKEN_Msk; + + /* Select UART0 clock source. */ + CLK->CLKSEL1 = ( CLK->CLKSEL1 & ( ~CLK_CLKSEL1_UART0SEL_Msk ) ) | CLK_CLKSEL1_UART0SEL_HIRC; + + /* Set multi-function pins for UART0 RXD and TXD. */ + SYS->GPB_MFPH = ( SYS->GPB_MFPH & ( ~UART0_RXD_PB12_Msk ) ) | UART0_RXD_PB12; + SYS->GPB_MFPH = ( SYS->GPB_MFPH & ( ~UART0_TXD_PB13_Msk ) ) | UART0_TXD_PB13; + + /* Initialize UART1 - It is used for debug output from the secure side. */ + /* Enable UART1 clock. */ + CLK->APBCLK0 |= CLK_APBCLK0_UART1CKEN_Msk; + + /* Select UART1 clock source. */ + CLK->CLKSEL1 = ( CLK->CLKSEL1 & ( ~CLK_CLKSEL1_UART1SEL_Msk ) ) | CLK_CLKSEL1_UART1SEL_HIRC; + + /* Set multi-function pins for UART1 RXD and TXD. */ + SYS->GPA_MFPL = ( SYS->GPA_MFPL & ( ~UART1_RXD_PA2_Msk ) ) | UART1_RXD_PA2; + SYS->GPA_MFPL = ( SYS->GPA_MFPL & ( ~UART1_TXD_PA3_Msk ) ) | UART1_TXD_PA3; + + /* Update System Core Clock. */ + PllClock = 64000000; /* PLL. */ + SystemCoreClock = 64000000 / 1; /* HCLK. */ + CyclesPerUs = 64000000 / 1000000; /* For SYS_SysTickDelay(). */ + + /* Initialize the debug port. */ + DEBUG_PORT->BAUD = UART_BAUD_MODE2 | UART_BAUD_MODE2_DIVIDER(__HIRC, 115200); + DEBUG_PORT->LINE = UART_WORD_LEN_8 | UART_PARITY_NONE | UART_STOP_BIT_1; + + /* Lock protected registers. */ + SYS_LockReg(); +} +/*-----------------------------------------------------------*/ + +static void prvCreateTasks( void ) +{ + /* Create tasks for the MPU Demo. */ + vStartMPUDemo(); + + /* Create tasks for register tests. */ + vStartRegTests(); +} +/*-----------------------------------------------------------*/ + +/* Stack overflow hook. */ +void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName ) +{ + /* Force an assert. */ + configASSERT( pcTaskName == 0 ); +} +/*-----------------------------------------------------------*/ + +/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an + * implementation of vApplicationGetIdleTaskMemory() to provide the memory that + * is used by the Idle task. */ +void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, + StackType_t ** ppxIdleTaskStackBuffer, + uint32_t * pulIdleTaskStackSize ) +{ + /* If the buffers to be provided to the Idle task are declared inside this + * function then they must be declared static - otherwise they will be + * allocated on the stack and so not exists after this function exits. */ + static StaticTask_t xIdleTaskTCB; + static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) ); + + /* Pass out a pointer to the StaticTask_t structure in which the Idle + * task's state will be stored. */ + *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; + + /* Pass out the array that will be used as the Idle task's stack. */ + *ppxIdleTaskStackBuffer = uxIdleTaskStack; + + /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. + * Note that, as the array is necessarily of type StackType_t, + * configMINIMAL_STACK_SIZE is specified in words, not bytes. */ + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; +} +/*-----------------------------------------------------------*/ + +/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the + * application must provide an implementation of vApplicationGetTimerTaskMemory() + * to provide the memory that is used by the Timer service task. */ +void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, + StackType_t ** ppxTimerTaskStackBuffer, + uint32_t * pulTimerTaskStackSize ) +{ + /* If the buffers to be provided to the Timer task are declared inside this + * function then they must be declared static - otherwise they will be + * allocated on the stack and so not exists after this function exits. */ + static StaticTask_t xTimerTaskTCB; + static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ] __attribute__( ( aligned( 32 ) ) ); + + /* Pass out a pointer to the StaticTask_t structure in which the Timer + * task's state will be stored. */ + *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; + + /* Pass out the array that will be used as the Timer task's stack. */ + *ppxTimerTaskStackBuffer = uxTimerTaskStack; + + /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. + * Note that, as the array is necessarily of type StackType_t, + * configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */ + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/Config/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/Config/FreeRTOSConfig.h new file mode 100644 index 000000000..c8c02affe --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/Config/FreeRTOSConfig.h @@ -0,0 +1,168 @@ +/* + * 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 + * + */ + +/****************************************************************************** + See http://www.freertos.org/a00110.html for an explanation of the + definitions contained in this file. +******************************************************************************/ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + * https://www.FreeRTOS.org/a00110.html + *----------------------------------------------------------*/ + +extern uint32_t SystemCoreClock; + +/* Cortex M23 port configuration. */ +#define configENABLE_MPU 1 +#define configENABLE_FPU 0 +#define configENABLE_TRUSTZONE 0 +#define configRUN_FREERTOS_SECURE_ONLY 1 + +/* Constants related to the behaviour or the scheduler. */ +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 +#define configUSE_PREEMPTION 1 +#define configUSE_TIME_SLICING 1 +#define configMAX_PRIORITIES ( 5 ) +#define configIDLE_SHOULD_YIELD 1 +#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 configMINIMAL_STACK_SIZE ( ( uint16_t ) 128 ) +#define configMINIMAL_SECURE_STACK_SIZE ( 1024 ) +#define configMAX_TASK_NAME_LEN ( 12 ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 50 * 1024 ) ) + +/* Constants that build features in or out. */ +#define configUSE_MUTEXES 1 +#define configUSE_TICKLESS_IDLE 1 +#define configUSE_APPLICATION_TASK_TAG 0 +#define configUSE_NEWLIB_REENTRANT 0 +#define configUSE_COUNTING_SEMAPHORES 1 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configUSE_QUEUE_SETS 0 +#define configUSE_TASK_NOTIFICATIONS 1 +#define configUSE_TRACE_FACILITY 1 + +/* Constants that define which hook (callback) functions should be used. */ +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configUSE_MALLOC_FAILED_HOOK 0 + +/* Constants provided for debugging and optimisation assistance. */ +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); } +#define configQUEUE_REGISTRY_SIZE 0 + +/* Software timer definitions. */ +#define configUSE_TIMERS 1 +#define configTIMER_TASK_PRIORITY ( 3 ) +#define configTIMER_QUEUE_LENGTH 5 +#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE ) + +/* Set the following definitions to 1 to include the API function, or zero + * to exclude the API function. NOTE: Setting an INCLUDE_ parameter to 0 is + * only necessary if the linker does not automatically remove functions that are + * not referenced anyway. */ +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 0 +#define INCLUDE_xTaskGetIdleTaskHandle 0 +#define INCLUDE_eTaskGetState 1 +#define INCLUDE_xTaskResumeFromISR 0 +#define INCLUDE_xTaskGetCurrentTaskHandle 1 +#define INCLUDE_xTaskGetSchedulerState 0 +#define INCLUDE_xSemaphoreGetMutexHolder 0 +#define INCLUDE_xTimerPendFunctionCall 1 + +/* This demo makes use of one or more example stats formatting functions. These + * format the raw data provided by the uxTaskGetSystemState() function in to + * human readable ASCII form. See the notes in the implementation of vTaskList() + * within FreeRTOS/Source/tasks.c for limitations. */ +#define configUSE_STATS_FORMATTING_FUNCTIONS 1 + +/* Dimensions a buffer that can be used by the FreeRTOS+CLI command interpreter. + * See the FreeRTOS+CLI documentation for more information: + * https://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_CLI/ */ +#define configCOMMAND_INT_MAX_OUTPUT_SIZE 2048 + +/* Interrupt priority configuration follows...................... */ + +/* Use the system definition, if there is one. */ +#ifdef __NVIC_PRIO_BITS + #define configPRIO_BITS __NVIC_PRIO_BITS +#else + #define configPRIO_BITS 3 /* 8 priority levels. */ +#endif + +/* The lowest interrupt priority that can be used in a call to a "set priority" + * function. */ +#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0x07 + +/* The highest interrupt priority that can be used by any interrupt service + * routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT + * CALL INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A + * HIGHER PRIORITY THAN THIS! (higher priorities are lower numeric values). */ +#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 + +/* Interrupt priorities used by the kernel port layer itself. These are generic + * to all Cortex-M ports, and do not rely on any particular library functions. */ +#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << ( 8 - configPRIO_BITS ) ) + +/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! + * See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ +#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << ( 8 - configPRIO_BITS ) ) + +/* The #ifdef guards against the file being included from IAR assembly files. */ +#ifndef __IASMARM__ + + /* Constants related to the generation of run time stats. */ + #define configGENERATE_RUN_TIME_STATS 0 + #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() + #define portGET_RUN_TIME_COUNTER_VALUE() 0 + #define configTICK_RATE_HZ ( ( TickType_t ) 100 ) + +#endif /* __IASMARM__ */ + +/* Enable static allocation. */ +#define configSUPPORT_STATIC_ALLOCATION 1 + +#endif /* FREERTOS_CONFIG_H */ diff --git a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/FreeRTOSDemo.sct b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/FreeRTOSDemo.sct new file mode 100644 index 000000000..ba6201290 --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/FreeRTOSDemo.sct @@ -0,0 +1,70 @@ +; 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 | +; --------------------- +; | Unprivileged Data | +; --------------------- + +LR_APP 0x00000000 ; load region +{ + ER_IROM_PRIVILEGED +0 ALIGN 32 + { + *.o(RESET, +First) + *(InRoot$$Sections) ; All sections that must be in a root region + *(privileged_functions) + } + + ER_IROM_PRIVILEGED_ALIGN +0 ALIGN 32 EMPTY 0x0 + { + } + + ER_IROM_FREERTOS_SYSTEM_CALLS +0 ALIGN 32 + { + *(freertos_system_calls) + } + + ER_IROM_FREERTOS_SYSTEM_CALLS_ALIGN +0 ALIGN 32 EMPTY 0x0 + { + } + + ER_IROM_UNPRIVILEGED +0 ALIGN 32 + { + *(+RO) + } + + ER_IROM_UNPRIVILEGED_ALIGN +0 ALIGN 32 EMPTY 0x0 + { + } + + ER_IRAM_PRIVILEGED 0x20000000 ALIGN 32 + { + *(privileged_data) + } + + ER_IRAM_PRIVILEGED_ALIGN +0 ALIGN 32 EMPTY 0x0 + { + } + + ER_IRAM_UNPRIVILEGED +0 ALIGN 32 + { + *(+RW, +ZI) + } + + ER_IRAM_UNPRIVILEGED_ALIGN +0 ALIGN 32 EMPTY 0x0 + { + } +} diff --git a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/FreeRTOSDemo.uvoptx b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/FreeRTOSDemo.uvoptx new file mode 100644 index 000000000..6c5549d78 --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/FreeRTOSDemo.uvoptx @@ -0,0 +1,547 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc; *.md + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + FreeRTOSDemo + 0x4 + ARM-ADS + + 12000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\Listings\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 6 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 7 + + + + + + + + + + .\FreeRTOSDemo_debug.ini + NULink\Nu_Link.dll + + + + 0 + DLGTARM + (6010=-1,-1,-1,-1,0)(6018=-1,-1,-1,-1,0)(6019=-1,-1,-1,-1,0)(6008=-1,-1,-1,-1,0)(6009=-1,-1,-1,-1,0)(6014=-1,-1,-1,-1,0)(6015=-1,-1,-1,-1,0)(6003=535,89,1117,625,1)(6000=-1,-1,-1,-1,0) + + + 0 + ARMDBGFLAGS + + + + 0 + Nu_Link + + + + 0 + UL2V8M + UL2V8M(-S0 -C0 -P0 -FD20000000 -FC1000) + + + + + 0 + + + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + + + + + Config + 0 + 0 + 0 + 0 + + 1 + 1 + 5 + 0 + 0 + 0 + .\Config\FreeRTOSConfig.h + FreeRTOSConfig.h + 0 + 0 + + + + + Device + 0 + 0 + 0 + 0 + + 2 + 2 + 1 + 0 + 0 + 0 + ..\..\Nuvoton_Code\Device\Nuvoton\M2351\Source\system_M2351.c + system_M2351.c + 0 + 0 + + + 2 + 3 + 2 + 0 + 0 + 0 + ..\..\Nuvoton_Code\Device\Nuvoton\M2351\Source\ARM\startup_M2351.s + startup_M2351.s + 0 + 0 + + + + + Drivers + 0 + 0 + 0 + 0 + + 3 + 4 + 1 + 0 + 0 + 0 + ..\..\Nuvoton_Code\StdDriver\src\clk.c + clk.c + 0 + 0 + + + 3 + 5 + 1 + 0 + 0 + 0 + ..\..\Nuvoton_Code\StdDriver\src\gpio.c + gpio.c + 0 + 0 + + + 3 + 6 + 1 + 0 + 0 + 0 + ..\..\Nuvoton_Code\StdDriver\src\retarget.c + retarget.c + 0 + 0 + + + + + FreeRTOS + 0 + 0 + 0 + 0 + + 4 + 7 + 1 + 0 + 0 + 0 + ..\..\..\..\Source\event_groups.c + event_groups.c + 0 + 0 + + + 4 + 8 + 1 + 0 + 0 + 0 + ..\..\..\..\Source\list.c + list.c + 0 + 0 + + + 4 + 9 + 1 + 0 + 0 + 0 + ..\..\..\..\Source\queue.c + queue.c + 0 + 0 + + + 4 + 10 + 1 + 0 + 0 + 0 + ..\..\..\..\Source\stream_buffer.c + stream_buffer.c + 0 + 0 + + + 4 + 11 + 1 + 0 + 0 + 0 + ..\..\..\..\Source\tasks.c + tasks.c + 0 + 0 + + + 4 + 12 + 1 + 0 + 0 + 0 + ..\..\..\..\Source\timers.c + timers.c + 0 + 0 + + + 4 + 13 + 1 + 0 + 0 + 0 + ..\..\..\..\Source\portable\GCC\ARM_CM23_NTZ\non_secure\port.c + port.c + 0 + 0 + + + 4 + 14 + 1 + 0 + 0 + 0 + ..\..\..\..\Source\portable\GCC\ARM_CM23_NTZ\non_secure\portasm.c + portasm.c + 0 + 0 + + + 4 + 15 + 5 + 0 + 0 + 0 + ..\..\..\..\Source\portable\GCC\ARM_CM23_NTZ\non_secure\portasm.h + portasm.h + 0 + 0 + + + 4 + 16 + 5 + 0 + 0 + 0 + ..\..\..\..\Source\portable\GCC\ARM_CM23_NTZ\non_secure\portmacro.h + portmacro.h + 0 + 0 + + + 4 + 17 + 5 + 0 + 0 + 0 + ..\..\..\..\Source\portable\GCC\ARM_CM23_NTZ\non_secure\portmacrocommon.h + portmacrocommon.h + 0 + 0 + + + 4 + 18 + 1 + 0 + 0 + 0 + ..\..\..\..\Source\portable\MemMang\heap_4.c + heap_4.c + 0 + 0 + + + 4 + 19 + 1 + 0 + 0 + 0 + ..\..\..\..\Source\portable\Common\mpu_wrappers.c + mpu_wrappers.c + 0 + 0 + + + + + Demo + 0 + 0 + 0 + 0 + + 5 + 20 + 1 + 0 + 0 + 0 + ..\..\..\Common\ARMv8M\mpu_demo\mpu_demo.c + mpu_demo.c + 0 + 0 + + + 5 + 21 + 5 + 0 + 0 + 0 + ..\..\..\Common\ARMv8M\mpu_demo\mpu_demo.h + mpu_demo.h + 0 + 0 + + + 5 + 22 + 1 + 0 + 0 + 0 + ..\..\..\Common\ARMv8M\reg_tests\GCC\ARM_CM23\non_secure\reg_test_asm.c + reg_test_asm.c + 0 + 0 + + + 5 + 23 + 5 + 0 + 0 + 0 + ..\..\..\Common\ARMv8M\reg_tests\GCC\ARM_CM23\non_secure\reg_test_asm.h + reg_test_asm.h + 0 + 0 + + + + + User + 0 + 0 + 0 + 0 + + 6 + 24 + 1 + 0 + 0 + 0 + .\main.c + main.c + 0 + 0 + + + 6 + 25 + 1 + 0 + 0 + 0 + ..\..\RegTests\reg_tests.c + reg_tests.c + 0 + 0 + + + 6 + 26 + 5 + 0 + 0 + 0 + ..\..\RegTests\reg_tests.h + reg_tests.h + 0 + 0 + + + +
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/FreeRTOSDemo.uvprojx b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/FreeRTOSDemo.uvprojx new file mode 100644 index 000000000..6f68fa4b8 --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/FreeRTOSDemo.uvprojx @@ -0,0 +1,615 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + FreeRTOSDemo + 0x4 + ARM-ADS + 6190000::V6.19::ARMCLANG + 1 + + + M2351KIAAEES + Nuvoton + Nuvoton.NuMicro_DFP.1.3.19 + https://github.com/OpenNuvoton/cmsis-packs/raw/master/Nuvoton_DFP/ + IRAM(0x20000000,0x18000) IROM(0x00000000,0x00080000) CPUTYPE("ARMV8MBL") TZ CLOCK(12000000) ESEL ELITTLE + + + UL2V8M(-S0 -C0 -P0 -FD20000000 -FC1000) + 0 + + + + + + + + + + + $$Device:M2351KIAAEES$SVD\Nuvoton\M2351_v1.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\Objects\ + FreeRTOSDemo + 1 + 0 + 0 + 1 + 1 + .\Listings\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 1 + 1 + fromelf --bin ".\Objects\@L.axf" --output ".\Objects\@L.bin" + fromelf --text -c ".\Objects\@L.axf" --output ".\Objects\@L.txt" + 0 + 0 + 0 + 0 + + 1 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + + + + SARMV8M.DLL + -MPU + TCM.DLL + -pV8MBL + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4102 + + 1 + BIN\UL2V8M.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + "ARMV8MBL" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 8 + 1 + 1 + 0 + 2 + 3 + 3 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x18000 + + + 1 + 0x0 + 0x80000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x80000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x18000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 5 + 0 + 0 + 0 + 0 + 0 + 0 + + -mfloat-abi=soft -Wno-documentation -Wno-reserved-id-macro + DEBUG_PORT = UART0 + + .\Config;..\Keil;..\..\RegTests;..\..\Nuvoton_Code\StdDriver\inc;..\..\Nuvoton_Code\CMSIS\Include;..\..\Nuvoton_Code\Device\Nuvoton\M2351\Include;..\..\..\..\Source\include;..\..\..\..\Source\portable\GCC\ARM_CM23_NTZ\non_secure;..\..\..\Common\ARMv8M\mpu_demo;..\..\..\Common\ARMv8M\reg_tests\GCC\ARM_CM23\non_secure + + + + 1 + 0 + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 4 + + + + + + + + + 0 + 0 + 0 + 0 + 1 + 0 + + + + .\FreeRTOSDemo.sct + + + + + + + + + + + Config + + + FreeRTOSConfig.h + 5 + .\Config\FreeRTOSConfig.h + + + + + Device + + + system_M2351.c + 1 + ..\..\Nuvoton_Code\Device\Nuvoton\M2351\Source\system_M2351.c + + + startup_M2351.s + 2 + ..\..\Nuvoton_Code\Device\Nuvoton\M2351\Source\ARM\startup_M2351.s + + + + + Drivers + + + clk.c + 1 + ..\..\Nuvoton_Code\StdDriver\src\clk.c + + + gpio.c + 1 + ..\..\Nuvoton_Code\StdDriver\src\gpio.c + + + retarget.c + 1 + ..\..\Nuvoton_Code\StdDriver\src\retarget.c + + + + + FreeRTOS + + + event_groups.c + 1 + ..\..\..\..\Source\event_groups.c + + + list.c + 1 + ..\..\..\..\Source\list.c + + + queue.c + 1 + ..\..\..\..\Source\queue.c + + + stream_buffer.c + 1 + ..\..\..\..\Source\stream_buffer.c + + + tasks.c + 1 + ..\..\..\..\Source\tasks.c + + + timers.c + 1 + ..\..\..\..\Source\timers.c + + + port.c + 1 + ..\..\..\..\Source\portable\GCC\ARM_CM23_NTZ\non_secure\port.c + + + portasm.c + 1 + ..\..\..\..\Source\portable\GCC\ARM_CM23_NTZ\non_secure\portasm.c + + + portasm.h + 5 + ..\..\..\..\Source\portable\GCC\ARM_CM23_NTZ\non_secure\portasm.h + + + portmacro.h + 5 + ..\..\..\..\Source\portable\GCC\ARM_CM23_NTZ\non_secure\portmacro.h + + + portmacrocommon.h + 5 + ..\..\..\..\Source\portable\GCC\ARM_CM23_NTZ\non_secure\portmacrocommon.h + + + heap_4.c + 1 + ..\..\..\..\Source\portable\MemMang\heap_4.c + + + mpu_wrappers.c + 1 + ..\..\..\..\Source\portable\Common\mpu_wrappers.c + + + + + Demo + + + mpu_demo.c + 1 + ..\..\..\Common\ARMv8M\mpu_demo\mpu_demo.c + + + mpu_demo.h + 5 + ..\..\..\Common\ARMv8M\mpu_demo\mpu_demo.h + + + reg_test_asm.c + 1 + ..\..\..\Common\ARMv8M\reg_tests\GCC\ARM_CM23\non_secure\reg_test_asm.c + + + reg_test_asm.h + 5 + ..\..\..\Common\ARMv8M\reg_tests\GCC\ARM_CM23\non_secure\reg_test_asm.h + + + + + User + + + main.c + 1 + .\main.c + + + reg_tests.c + 1 + ..\..\RegTests\reg_tests.c + + + reg_tests.h + 5 + ..\..\RegTests\reg_tests.h + + + + + + + + + + + + + RTE\Device\ARMv8MBL\partition_ARMv8MBL.h + + + + + + RTE\Device\ARMv8MBL\startup_ARMv8MBL.s + + + + + + RTE\Device\ARMv8MBL\system_ARMv8MBL.c + + + + + + RTE\Device\CMSDK_ARMv8MBL\partition_ARMv8MBL.h + + + + + + RTE\Device\CMSDK_ARMv8MBL\partition_CMSDK_ARMv8MBL.h + + + + + + RTE\Device\CMSDK_ARMv8MBL\startup_CMSDK_ARMv8MBL.s + + + + + + RTE\Device\CMSDK_ARMv8MBL\system_CMSDK_ARMv8MBL.c + + + + + + RTE\Device\MPS2_ARMv8MBL\partition_ARMv8MBL.h + + + + + + RTE\Device\MPS2_ARMv8MBL\startup_ARMv8MBL.s + + + + + + RTE\Device\MPS2_ARMv8MBL\system_ARMv8MBL.c + + + + + + + +
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/FreeRTOSDemo_debug.ini b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/FreeRTOSDemo_debug.ini new file mode 100644 index 000000000..9d688e977 --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/FreeRTOSDemo_debug.ini @@ -0,0 +1,3 @@ +LOAD ".\\Objects\\FreeRTOSDemo.axf" incremental +RESET +g, \\FreeRTOSDemo\main\main diff --git a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/main.c b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/main.c new file mode 100644 index 000000000..471ef6c48 --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Projects_NTZ/Keil/main.c @@ -0,0 +1,265 @@ +/* + * 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 + * + */ + +/* Device includes. */ +#include +#include "NuMicro.h" + +/* FreeRTOS includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* Demo includes. */ +#include "mpu_demo.h" +#include "reg_tests.h" + +/* Externs needed by the MPU setup code. These are defined in Scatter-Loading + * description file (FreeRTOSDemo.sct). */ +extern uint32_t Image$$ER_IROM_PRIVILEGED$$Base; +extern uint32_t Image$$ER_IROM_PRIVILEGED_ALIGN$$Limit; +extern uint32_t Image$$ER_IROM_FREERTOS_SYSTEM_CALLS$$Base; +extern uint32_t Image$$ER_IROM_FREERTOS_SYSTEM_CALLS_ALIGN$$Limit; +extern uint32_t Image$$ER_IROM_UNPRIVILEGED$$Base; +extern uint32_t Image$$ER_IROM_UNPRIVILEGED_ALIGN$$Limit; + +extern uint32_t Image$$ER_IRAM_PRIVILEGED$$Base; +extern uint32_t Image$$ER_IRAM_PRIVILEGED_ALIGN$$Limit; +extern uint32_t Image$$ER_IRAM_UNPRIVILEGED$$Base; +extern uint32_t Image$$ER_IRAM_UNPRIVILEGED_ALIGN$$Limit; + +/* Privileged flash. */ +const uint32_t * __privileged_functions_start__ = ( uint32_t * ) &( Image$$ER_IROM_PRIVILEGED$$Base ); +const uint32_t * __privileged_functions_end__ = ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IROM_PRIVILEGED_ALIGN$$Limit ) - 0x1 ); /* Last address in privileged Flash region. */ + +/* Flash containing system calls. */ +const uint32_t * __syscalls_flash_start__ = ( uint32_t * ) &( Image$$ER_IROM_FREERTOS_SYSTEM_CALLS$$Base ); +const uint32_t * __syscalls_flash_end__ = ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IROM_FREERTOS_SYSTEM_CALLS_ALIGN$$Limit ) - 0x1 ); /* Last address in Flash region containing system calls. */ + +/* 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_UNPRIVILEGED$$Base ); +const uint32_t * __unprivileged_flash_end__ = ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IROM_UNPRIVILEGED_ALIGN$$Limit ) - 0x1 ); /* Last address in un-privileged Flash region. */ + +/* RAM with priviledged access only. This contains kernel data. */ +const uint32_t * __privileged_sram_start__ = ( uint32_t * ) &( Image$$ER_IRAM_PRIVILEGED$$Base ); +const uint32_t * __privileged_sram_end__ = ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IRAM_PRIVILEGED_ALIGN$$Limit ) - 0x1 ); /* Last address in privileged RAM. */ + +/* Unprivileged RAM. */ +const uint32_t * __unprivileged_sram_start__ = ( uint32_t * ) &( Image$$ER_IRAM_UNPRIVILEGED$$Base ); +const uint32_t * __unprivileged_sram_end__ = ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IRAM_UNPRIVILEGED_ALIGN$$Limit ) - 0x1 ); /* Last address in un-privileged RAM. */ +/*-----------------------------------------------------------*/ + +/** + * @brief Sets up the hardware - clocks and UARTs. + */ +static void prvSetupHardware( void ); + +/** + * @brief Create all demo tasks. + */ +static void prvCreateTasks( void ); + +/** + * @brief The hard fault handler. + * + * It calls a function called vHandleMemoryFault. + */ +void HardFault_Handler( void ) __attribute__ ( ( naked ) ); +/*-----------------------------------------------------------*/ + +int main( void ) +{ + /* Initialize the hardware. */ + prvSetupHardware(); + + /* Print banner. */ + printf( "\r\n" ); + printf( "+---------------------------------------------+\r\n" ); + printf( "| Application is running ... |\r\n" ); + printf( "+---------------------------------------------+\r\n" ); + + /* Create tasks. */ + prvCreateTasks(); + + /* Start scheduler. */ + vTaskStartScheduler(); + + /* Will not get here if the scheduler starts successfully. If you do end up + here then there wasn't enough heap memory available to start either the idle + task or the timer/daemon task. https://www.freertos.org/a00111.html */ + + for( ; ; ) + { + } +} +/*-----------------------------------------------------------*/ + +static void prvSetupHardware( void ) +{ + /* Unlock protected registers. */ + SYS_UnlockReg(); + + /* Init System Clock. */ + /* Enable PLL */ + CLK->PLLCTL = CLK_PLLCTL_64MHz_HIRC; + /* Wait for PLL to be stable. */ + while( ( CLK->STATUS & CLK_STATUS_PLLSTB_Msk ) == 0 ); + + /* Set HCLK divider to 1. */ + CLK->CLKDIV0 = ( CLK->CLKDIV0 & ( ~CLK_CLKDIV0_HCLKDIV_Msk ) ); + + /* Switch HCLK clock source to PLL. */ + CLK->CLKSEL0 = ( CLK->CLKSEL0 & ( ~CLK_CLKSEL0_HCLKSEL_Msk ) ) | CLK_CLKSEL0_HCLKSEL_PLL; + + /* Initialize UART0 - It is used for debug output from the non-secure side. */ + /* Enable UART0 clock. */ + CLK->APBCLK0 |= CLK_APBCLK0_UART0CKEN_Msk; + + /* Select UART0 clock source. */ + CLK->CLKSEL1 = ( CLK->CLKSEL1 & ( ~CLK_CLKSEL1_UART0SEL_Msk ) ) | CLK_CLKSEL1_UART0SEL_HIRC; + + /* Set multi-function pins for UART0 RXD and TXD. */ + SYS->GPB_MFPH = ( SYS->GPB_MFPH & ( ~UART0_RXD_PB12_Msk ) ) | UART0_RXD_PB12; + SYS->GPB_MFPH = ( SYS->GPB_MFPH & ( ~UART0_TXD_PB13_Msk ) ) | UART0_TXD_PB13; + + /* Initialize UART1 - It is used for debug output from the secure side. */ + /* Enable UART1 clock. */ + CLK->APBCLK0 |= CLK_APBCLK0_UART1CKEN_Msk; + + /* Select UART1 clock source. */ + CLK->CLKSEL1 = ( CLK->CLKSEL1 & ( ~CLK_CLKSEL1_UART1SEL_Msk ) ) | CLK_CLKSEL1_UART1SEL_HIRC; + + /* Set multi-function pins for UART1 RXD and TXD. */ + SYS->GPA_MFPL = ( SYS->GPA_MFPL & ( ~UART1_RXD_PA2_Msk ) ) | UART1_RXD_PA2; + SYS->GPA_MFPL = ( SYS->GPA_MFPL & ( ~UART1_TXD_PA3_Msk ) ) | UART1_TXD_PA3; + + /* Update System Core Clock. */ + PllClock = 64000000; /* PLL. */ + SystemCoreClock = 64000000 / 1; /* HCLK. */ + CyclesPerUs = 64000000 / 1000000; /* For SYS_SysTickDelay(). */ + + /* Initialize the debug port. */ + DEBUG_PORT->BAUD = UART_BAUD_MODE2 | UART_BAUD_MODE2_DIVIDER(__HIRC, 115200); + DEBUG_PORT->LINE = UART_WORD_LEN_8 | UART_PARITY_NONE | UART_STOP_BIT_1; + + /* Lock protected registers. */ + SYS_LockReg(); +} +/*-----------------------------------------------------------*/ + +static void prvCreateTasks( void ) +{ + /* Create tasks for the MPU Demo. */ + vStartMPUDemo(); + + /* Create tasks for register tests. */ + vStartRegTests(); +} +/*-----------------------------------------------------------*/ + +/* Stack overflow hook. */ +void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName ) +{ + /* Force an assert. */ + configASSERT( pcTaskName == 0 ); +} +/*-----------------------------------------------------------*/ + +/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an + * implementation of vApplicationGetIdleTaskMemory() to provide the memory that + * is used by the Idle task. */ +void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, + StackType_t ** ppxIdleTaskStackBuffer, + uint32_t * pulIdleTaskStackSize ) +{ + /* If the buffers to be provided to the Idle task are declared inside this + * function then they must be declared static - otherwise they will be + * allocated on the stack and so not exists after this function exits. */ + static StaticTask_t xIdleTaskTCB; + static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) ); + + /* Pass out a pointer to the StaticTask_t structure in which the Idle + * task's state will be stored. */ + *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; + + /* Pass out the array that will be used as the Idle task's stack. */ + *ppxIdleTaskStackBuffer = uxIdleTaskStack; + + /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. + * Note that, as the array is necessarily of type StackType_t, + * configMINIMAL_STACK_SIZE is specified in words, not bytes. */ + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; +} +/*-----------------------------------------------------------*/ + +/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the + * application must provide an implementation of vApplicationGetTimerTaskMemory() + * to provide the memory that is used by the Timer service task. */ +void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, + StackType_t ** ppxTimerTaskStackBuffer, + uint32_t * pulTimerTaskStackSize ) +{ + /* If the buffers to be provided to the Timer task are declared inside this + * function then they must be declared static - otherwise they will be + * allocated on the stack and so not exists after this function exits. */ + static StaticTask_t xTimerTaskTCB; + static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ] __attribute__( ( aligned( 32 ) ) ); + + /* Pass out a pointer to the StaticTask_t structure in which the Timer + * task's state will be stored. */ + *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; + + /* Pass out the array that will be used as the Timer task's stack. */ + *ppxTimerTaskStackBuffer = uxTimerTaskStack; + + /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. + * Note that, as the array is necessarily of type StackType_t, + * configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */ + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; +} +/*-----------------------------------------------------------*/ + +void HardFault_Handler( void ) +{ + __asm volatile + ( + " movs r0, #4 \n" + " mov r1, lr \n" + " tst r0, r1 \n" + " beq msp_used_for_stacking \n" + " mrs r0, psp \n" + " ldr r2, handler_address_const \n" + " bx r2 \n" + "msp_used_for_stacking: \n" + " mrs r0, msp \n" + " ldr r2, handler_address_const \n" + " bx r2 \n" + " \n" + " .align 4 \n" + " handler_address_const: .word vHandleMemoryFault \n" + ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/RegTests/reg_tests.c b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/RegTests/reg_tests.c index 9cda7f753..7ae69babd 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/RegTests/reg_tests.c +++ b/FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/RegTests/reg_tests.c @@ -31,7 +31,9 @@ /* Reg test includes. */ #include "reg_tests.h" #include "reg_test_asm.h" -#include "secure_reg_test_asm.h" +#if( configENABLE_TRUSTZONE == 1 ) + #include "secure_reg_test_asm.h" +#endif /* Device includes. */ #include "NuMicro.h" @@ -41,9 +43,10 @@ */ static void prvRegTest1_Task( void * pvParameters ); static void prvRegTest2_Task( void * pvParameters ); -static void prvRegTest_Secure_Task( void * pvParameters ); -static void prvRegTest_NonSecureCallback_Task( void * pvParameters ); - +#if( configENABLE_TRUSTZONE == 1 ) + static void prvRegTest_Secure_Task( void * pvParameters ); + static void prvRegTest_NonSecureCallback_Task( void * pvParameters ); +#endif /* * Check task periodically checks that reg tests tasks * are running fine. @@ -54,8 +57,13 @@ static void prvCheckTask( void * pvParameters ); /* * On board LEDs. */ -#define YELLOW_LED PA11_NS -#define GREEN_LED PA10_NS +#if( configENABLE_TRUSTZONE == 1 ) + #define YELLOW_LED PA11_NS + #define GREEN_LED PA10_NS +#else + #define YELLOW_LED PA11 + #define GREEN_LED PA10 +#endif /* * Priority of the check task. @@ -84,8 +92,10 @@ static void prvCheckTask( void * pvParameters ); * incrementing, then an error has been found. */ volatile unsigned long ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL; -volatile unsigned long ulRegTestSecureLoopCounter = 0UL; -volatile unsigned long ulRegTestNonSecureCallbackLoopCounter = 0UL; +#if( configENABLE_TRUSTZONE == 1 ) + volatile unsigned long ulRegTestSecureLoopCounter = 0UL; + volatile unsigned long ulRegTestNonSecureCallbackLoopCounter = 0UL; +#endif /** * Counter to keep a count of how may times the check task loop has detected @@ -98,9 +108,11 @@ 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 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 ) ) ); +#if( configENABLE_TRUSTZONE == 1 ) + static StackType_t xRegTestSecureTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) ); + static StackType_t xRegTestNonSecureCallbackTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) ); +#endif TaskParameters_t xRegTest1TaskParameters = { @@ -130,35 +142,6 @@ TaskParameters_t xRegTest2TaskParameters = { 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, @@ -174,8 +157,43 @@ TaskParameters_t xCheckTaskParameters = } }; +#if( configENABLE_TRUSTZONE == 1 ) + 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 } + } + }; +#endif /* configENABLE_TRUSTZONE */ + /* Configure pins in output mode to drive external LEDs. */ - GPIO_SetMode( PA_NS, BIT10 | BIT11, GPIO_MODE_OUTPUT ); + #if( configENABLE_TRUSTZONE == 1 ) + GPIO_SetMode( PA_NS, BIT10 | BIT11, GPIO_MODE_OUTPUT ); + #else + GPIO_SetMode( PA, BIT10 | BIT11, GPIO_MODE_OUTPUT ); + #endif /* Start with both LEDs off. */ YELLOW_LED = 1; @@ -183,9 +201,11 @@ TaskParameters_t xCheckTaskParameters = xTaskCreateRestricted( &( xRegTest1TaskParameters ), NULL ); xTaskCreateRestricted( &( xRegTest2TaskParameters ), NULL ); - xTaskCreateRestricted( &( xRegTestSecureTaskParameters ), NULL ); - xTaskCreateRestricted( &( xRegTestNonSecureCallbackTaskParameters ), NULL ); xTaskCreateRestricted( &( xCheckTaskParameters ), NULL ); + #if( configENABLE_TRUSTZONE == 1 ) + xTaskCreateRestricted( &( xRegTestSecureTaskParameters ), NULL ); + xTaskCreateRestricted( &( xRegTestNonSecureCallbackTaskParameters ), NULL ); + #endif } /*-----------------------------------------------------------*/ @@ -227,6 +247,8 @@ static void prvRegTest2_Task( void * pvParameters ) } /*-----------------------------------------------------------*/ +#if( configENABLE_TRUSTZONE == 1 ) + static void prvRegTest_Secure_Task( void * pvParameters ) { /* This task is going to call secure side functions. */ @@ -257,8 +279,12 @@ static void prvRegTest_Secure_Task( void * pvParameters ) * an error. */ vTaskDelete( NULL ); } + +#endif /*-----------------------------------------------------------*/ +#if( configENABLE_TRUSTZONE == 1 ) + static void prvRegTest_NonSecureCallback_Task( void * pvParameters ) { /* This task is going to call secure side functions. */ @@ -290,6 +316,8 @@ static void prvRegTest_NonSecureCallback_Task( void * pvParameters ) * an error. */ vTaskDelete( NULL ); } + +#endif /*-----------------------------------------------------------*/ static void prvCheckTask( void * pvParameters ) @@ -298,7 +326,9 @@ 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 ulLastRegTestSecureValue = 0, ulLastRegTestNonSecureCallbackValue = 0; +#if( configENABLE_TRUSTZONE == 1 ) + static unsigned long ulLastRegTestSecureValue = 0, ulLastRegTestNonSecureCallbackValue = 0; +#endif /* Just to stop compiler warnings. */ ( void ) pvParameters; @@ -332,20 +362,24 @@ static unsigned long ulLastRegTestSecureValue = 0, ulLastRegTestNonSecureCallbac } ulLastRegTest2Value = ulRegTest2LoopCounter; - /* Check that the register test secure task is still running. */ - if( ulLastRegTestSecureValue == ulRegTestSecureLoopCounter ) - { - ulErrorFound |= 1UL << 2UL; - } - ulLastRegTestSecureValue = ulRegTestSecureLoopCounter; - - /* Check that the register test non-secure callback task is - * still running. */ - if( ulLastRegTestNonSecureCallbackValue == ulRegTestNonSecureCallbackLoopCounter ) + #if( configENABLE_TRUSTZONE == 1 ) { - ulErrorFound |= 1UL << 3UL; + /* Check that the register test secure task is still running. */ + if( ulLastRegTestSecureValue == ulRegTestSecureLoopCounter ) + { + ulErrorFound |= 1UL << 2UL; + } + ulLastRegTestSecureValue = ulRegTestSecureLoopCounter; + + /* Check that the register test non-secure callback task is + * still running. */ + if( ulLastRegTestNonSecureCallbackValue == ulRegTestNonSecureCallbackLoopCounter ) + { + ulErrorFound |= 1UL << 3UL; + } + ulLastRegTestNonSecureCallbackValue = ulRegTestNonSecureCallbackLoopCounter; } - ulLastRegTestNonSecureCallbackValue = ulRegTestNonSecureCallbackLoopCounter; + #endif /* configENABLE_TRUSTZONE */ /* Toggle the green LED to give an indication of the system status. * If the LED toggles every NO_ERROR_CHECK_TASK_PERIOD milliseconds -- cgit v1.2.1