Selaa lähdekoodia

support all CM33 targets with trust zone

Julien Staub 4 vuotta sitten
vanhempi
commit
7184bc3fc0
3 muutettua tiedostoa jossa 36 lisäystä ja 18 poistoa
  1. 32 15
      cmake/FindFreeRTOS.cmake
  2. 1 3
      examples/freertos/CMakeLists.txt
  3. 3 0
      examples/freertos/FreeRTOSConfig.h

+ 32 - 15
cmake/FindFreeRTOS.cmake

@@ -1,5 +1,5 @@
 # For information about why and how of this file: https://cmake.org/cmake/help/latest/command/find_package.html
-set(FreeRTOS_PORTS ARM_CM0 ARM_CM3 ARM_CM3_MPU ARM_CM4_MPU ARM_CM4F ARM_CM7 ARM_CM7_MPU ARM_CM23_NTZ ARM_CM33_NTZ)
+set(FreeRTOS_PORTS ARM_CM0 ARM_CM3 ARM_CM3_MPU ARM_CM4_MPU ARM_CM4F ARM_CM7 ARM_CM7_MPU ARM_CM23 ARM_CM23_NTZ ARM_CM33 ARM_CM33_NTZ)
 
 if(NOT FreeRTOS_FIND_COMPONENTS)
     set(FreeRTOS_FIND_COMPONENTS ${FreeRTOS_PORTS})
@@ -125,6 +125,10 @@ macro(stm32_find_freertos FreeRTOS_NAMESPACE FREERTOS_PATH)
     endforeach()
 
     foreach(PORT ${FreeRTOS_FIND_COMPONENTS_PORTS})
+        if(${PORT} STREQUAL ARM_CM23 OR ${PORT} STREQUAL ARM_CM33)
+            set(ARMv8_NON_SECURE "::NON_SECURE")
+        endif()
+        
         find_path(FreeRTOS_${PORT}_PATH
             NAMES portmacro.h
             PATHS "${FREERTOS_PATH}" "${FREERTOS_PATH}/FreeRTOS" 
@@ -149,21 +153,34 @@ macro(stm32_find_freertos FreeRTOS_NAMESPACE FREERTOS_PATH)
             PATHS "${FreeRTOS_${PORT}_PATH}"
             NO_DEFAULT_PATH
         )
-        if(NOT (TARGET ${FreeRTOS_NAMESPACE}::${PORT}))
-            add_library(${FreeRTOS_NAMESPACE}::${PORT} INTERFACE IMPORTED)
-            target_link_libraries(${FreeRTOS_NAMESPACE}::${PORT} INTERFACE FreeRTOS)
-            target_sources(${FreeRTOS_NAMESPACE}::${PORT} INTERFACE "${FreeRTOS_${PORT}_SOURCE}")
-            target_include_directories(${FreeRTOS_NAMESPACE}::${PORT} INTERFACE "${FreeRTOS_${PORT}_PATH}")
-        endif()
+        if(NOT (TARGET ${FreeRTOS_NAMESPACE}::${PORT}${ARMv8_NON_SECURE}))
+            add_library(${FreeRTOS_NAMESPACE}::${PORT}${ARMv8_NON_SECURE} INTERFACE IMPORTED)
+            target_link_libraries(${FreeRTOS_NAMESPACE}::${PORT}${ARMv8_NON_SECURE} INTERFACE FreeRTOS)
+            target_sources(${FreeRTOS_NAMESPACE}::${PORT}${ARMv8_NON_SECURE} INTERFACE "${FreeRTOS_${PORT}_SOURCE}")
+            target_include_directories(${FreeRTOS_NAMESPACE}::${PORT}${ARMv8_NON_SECURE} INTERFACE "${FreeRTOS_${PORT}_PATH}")
+            message(trace "FindFreeRTOS: creating target ${FreeRTOS_NAMESPACE}::${PORT}${ARMv8_NON_SECURE}")
+            
+            # armv8-m needs additional file even if using "No Trust Zone" port
+            if(${PORT} STREQUAL ARM_CM23_NTZ OR ${PORT} STREQUAL ARM_CM33_NTZ OR ${PORT} STREQUAL ARM_CM23 OR ${PORT} STREQUAL ARM_CM33)
+                target_sources(${FreeRTOS_NAMESPACE}::${PORT}${ARMv8_NON_SECURE} INTERFACE "${FreeRTOS_${PORT}_PATH}/portasm.c")
+            endif()
+
+            if(${PORT} STREQUAL ARM_CM23 OR ${PORT} STREQUAL ARM_CM33)
+                # create the secure target
+                add_library(${FreeRTOS_NAMESPACE}::${PORT}::SECURE INTERFACE IMPORTED)
+                # ::SECURE doesn't link FreeRTOS like ::NON_SECURE does
+                target_sources(${FreeRTOS_NAMESPACE}::${PORT}::SECURE INTERFACE "${FreeRTOS_${PORT}_PATH}/../secure/secure_context.c"
+                                                                                "${FreeRTOS_${PORT}_PATH}/../secure/secure_context_port.c"
+                                                                                "${FreeRTOS_${PORT}_PATH}/../secure/secure_heap.c"
+                                                                                "${FreeRTOS_${PORT}_PATH}/../secure/secure_init.c")
+                message(trace "FindFreeRTOS: creating target ${FreeRTOS_NAMESPACE}::${PORT}::SECURE")
 
-        # armv8-m needs additional file even if using "No Trust Zone" port
-        if(${PORT} STREQUAL ARM_CM23_NTZ OR ${PORT} STREQUAL ARM_CM33_NTZ)
-            find_file(FreeRTOS_${PORT}_ASM
-                NAMES portasm.c
-                PATHS "${FreeRTOS_${PORT}_PATH}"
-                NO_DEFAULT_PATH
-            )
-            target_sources(${FreeRTOS_NAMESPACE}::${PORT} INTERFACE "${FreeRTOS_${PORT}_ASM}")
+                # non-secure part needs declaratation from secure includes
+                target_include_directories(${FreeRTOS_NAMESPACE}::${PORT}${ARMv8_NON_SECURE} INTERFACE "${FreeRTOS_${PORT}_PATH}/../secure")
+                # secure part needs declaratation from non-secure includes and common freeRTOS includes
+                target_include_directories(${FreeRTOS_NAMESPACE}::${PORT}::SECURE INTERFACE "${FreeRTOS_${PORT}_PATH}"
+                                                                                            "${FreeRTOS_COMMON_INCLUDE}")
+            endif()
         endif()
         
         if(FreeRTOS_${PORT}_PATH AND 

+ 1 - 3
examples/freertos/CMakeLists.txt

@@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.16)
 set(PROJ_NAME stm32-freertos)
 set(STM32_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../..)
 
-set(CMAKE_MESSAGE_LOG_LEVEL trace)
-
 # Please note: When using CMSIS, it is recommended to use the FreeRTOS version supplied in the 
 # Cube repository because more recent kernels might be incompatible to the CMSIS
 # implementation provided by STM
@@ -39,7 +37,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
 set(SUPPORTED_BOARDS F407VG H743ZI)
 option(FREERTOS_F407VG_EXAMPLE "Compile FreeRTOS example for the F407VG board" OFF)
 option(FREERTOS_H743ZI_EXAMPLE "Compile FreeRTOS example for the H743ZI board" OFF)
-option(FREERTOS_L552ZE_EXAMPLE "Compile FreeRTOS example for the F407VG board" ON)
+option(FREERTOS_L552ZE_EXAMPLE "Compile FreeRTOS example for the L552ZE board" OFF)
 
 if(NOT FREERTOS_F407VG_EXAMPLE AND NOT FREERTOS_H743ZI_EXAMPLE AND NOT FREERTOS_L552ZE_EXAMPLE)
     message(FATAL_ERROR

+ 3 - 0
examples/freertos/FreeRTOSConfig.h

@@ -46,6 +46,9 @@ extern uint32_t SystemCoreClock;
 
 #if defined STM32L5
 	#define configENABLE_TRUSTZONE                   0
+	#if configENABLE_TRUSTZONE
+		#define configMINIMAL_SECURE_STACK_SIZE          ((uint16_t)1024)
+	#endif
 	#define configRUN_FREERTOS_SECURE_ONLY           0
 	#define configENABLE_FPU                         1
 	#define configENABLE_MPU                         0