Verified Commit eb49eeda authored by Vincent Coubard's avatar Vincent Coubard
Browse files

Update build files to use CMSIS RTOS


- The OS can be selected by setting the variable RTOS to either RTX or
FREERTOS.
- A new library has been added to expose FreeRTOS memory allocation
functions on CMSIS RTOS.
Signed-off-by: Vincent Coubard's avatarVincent Coubard <vincent.coubard@arm.com>
parent 4014c3fa
......@@ -71,7 +71,12 @@ FetchContent_Declare(
)
# Declare the Open IoT SDK configuration flags
set(IOTSDK_FREERTOS ON)
if(${RTOS} STREQUAL "FREERTOS")
set(IOTSDK_FREERTOS ON)
elseif(${RTOS} STREQUAL "RTX")
set(IOTSDK_CMSIS_RTX ON)
endif()
set(IOTSDK_TFM ON)
set(IOTSDK_ML ON)
set(IOTSDK_CMSIS_RTOS_API ON)
......@@ -139,14 +144,16 @@ include(TfmSignImage)
# Test management
include(CTest)
# Patch the FreeRTOS target to match config requirements
target_include_directories(freertos-kernel
INTERFACE
${PRJ_DIR}/bsp/aws_configs
${PRJ_DIR}/bsp/freertos-config
${PRJ_DIR}/bsp/freertos-platform
${PRJ_DIR}/kws/include
)
if(TARGET freertos-kernel)
# Patch the FreeRTOS target to match config requirements
target_include_directories(freertos-kernel
INTERFACE
${PRJ_DIR}/bsp/aws_configs
${PRJ_DIR}/bsp/freertos-config
${PRJ_DIR}/bsp/freertos-platform
${PRJ_DIR}/kws/include
)
endif()
# Patch the ethernet-lan91c111 target to enable multicast
if(TARGET ethernet-lan91c111)
......@@ -156,6 +163,25 @@ if(TARGET ethernet-lan91c111)
)
endif()
# Declare RTOS interface target
add_library(cmsis-rtos-implementation INTERFACE)
if(TARGET freertos-kernel)
target_link_libraries(cmsis-rtos-implementation
INTERFACE
freertos-cmsis-rtos
freertos-kernel-heap-3
)
elseif(TARGET cmsis-rtx)
target_link_libraries(cmsis-rtos-implementation
INTERFACE
cmsis-rtx
cmsis-rtos-api
cmsis-rtx-freertos-alloc-wrapper
)
endif()
# CMSIS 5 require projects to provide configuration macros via RTE_Components.h
# and CMSIS_device_header. The macro CMSIS_device_header is not automatically set
# based on CMAKE_SYSTEM_PROCESSOR in the place where cmsis-core is first defined,
......
......@@ -11,8 +11,7 @@ target_link_libraries(blinky
mcu-driver-bootstrap
mdh-reference-platforms-for-arm
freertos-cmsis-rtos
freertos-kernel-heap-2
cmsis-rtos-implementation
tfm-ns-interface-cmsis-rtos
......
......@@ -161,6 +161,16 @@ target_link_libraries(${LIB_NAME}
bsp_serial
)
# OS alloc wrapper
if (TARGET cmsis-rtx)
add_library(cmsis-rtx-freertos-alloc-wrapper STATIC)
target_sources(cmsis-rtx-freertos-alloc-wrapper
PRIVATE
cmsis-config/rtx-alloc.c
)
endif()
# Add Startup library
add_library(startup
$<$<STREQUAL:${TS_TARGET},Corstone-300>:${TFM_PLATFORM}/device/source/startup_an547_ns.c>
......
/*
* Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdlib.h>
void *pvPortMalloc(size_t size)
{
return malloc(size);
}
void vPortFree(void *p)
{
free(p);
}
......@@ -53,11 +53,11 @@ target_include_directories(coreMQTT-config
)
target_link_libraries(coreMQTT-config
INTERFACE
freertos-kernel
cmsis-rtos-api
)
target_link_libraries(coreHTTP-config
INTERFACE
freertos-kernel
cmsis-rtos-api
)
add_executable(kws
"${PRJ_DIR}/bsp/aws_libraries/abstractions/secure_sockets/lwip/iot_secure_sockets.c"
......@@ -150,10 +150,8 @@ target_link_libraries(kws
AWS-extra
startup
tfm-ns-interface-cmsis-rtos
freertos-kernel-heap-4
cmsis-rtos-implementation
mcu-driver-hal
cmsis-rtos-api
freertos-cmsis-rtos
lib-bsp
)
......
......@@ -52,6 +52,7 @@ target_include_directories(AWS-extra
"${TFM_PLATFORM_TARGET_DIR}/arm/mps3/an547/services/src"
"${TFM_PLATFORM_TARGET_DIR}/arm/mps3/common"
"${tf-m_SOURCE_DIR}/interface/include"
"${PRJ_DIR}/lib/AWS/ota_for_aws"
)
target_sources(AWS-extra
......@@ -109,12 +110,13 @@ target_link_libraries(AWS-extra
PKCS11
ota_for_aws
backoffAlgorithm
freertos-kernel-heap-4
freertos-kernel
tfm-ns-interface
lwip-sockets
lwipcore
lwipopts
iotsdk-ip-network-api
cmsis-sockets-api
mcu-driver-bootstrap
mcu-driver-hal
cmsis-rtos-api
)
......@@ -32,11 +32,12 @@ target_include_directories(PKCS11
"${PRJ_DIR}/bsp/aws_libraries/c_sdk/standard/https/src/pkcs11/corePKCS11/source/include"
"${PRJ_DIR}/bsp/aws_libraries/freertos_plus/standard/crypto/include"
"${PRJ_DIR}/bsp/aws_libraries/abstractions/pkcs11/corePKCS11/source/include"
"${PRJ_DIR}/bsp/aws_configs"
)
target_link_libraries(PKCS11
PUBLIC
freertos-kernel
cmsis-rtos-api
tfm-ns-interface
mbedtls
)
......@@ -31,7 +31,7 @@ target_include_directories(coreMQTT-Agent
target_link_libraries(coreMQTT-Agent
PUBLIC
freertos-kernel
cmsis-rtos-api
coreJSON
tinycbor
)
......@@ -49,7 +49,7 @@ function build_with_cmake {
set -ex
# Note: A bug in CMake force us to set the toolchain here
cmake -G Ninja -S . -B $BUILD_PATH --toolchain=toolchains/toolchain-armclang.cmake -DCMAKE_SYSTEM_PROCESSOR=$TARGET_PROCESSOR -DAWS_CONFIG_CREDENTIALS_PATH=$CREDENTIALS_PATH -DTS_TARGET=$TARGET
cmake -G Ninja -S . -B $BUILD_PATH --toolchain=toolchains/toolchain-armclang.cmake -DCMAKE_SYSTEM_PROCESSOR=$TARGET_PROCESSOR -DAWS_CONFIG_CREDENTIALS_PATH=$CREDENTIALS_PATH -DTS_TARGET=$TARGET -DRTOS=$RTOS
cmake --build $BUILD_PATH --target $EXAMPLE
)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment