Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OIS] Add TF-M support to Matter examples #23951

Merged
merged 8 commits into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,13 @@
"armToolchainPath": "${env:ARM_GCC_TOOLCHAIN_PATH}/bin",
"servertype": "external",
"gdbTarget": "${input:openiotsdkRemoteHost}:31627", //GDBserver port on FVP
"overrideLaunchCommands": ["-enable-pretty-printing"],
"overrideLaunchCommands": [
"-enable-pretty-printing",
"add-symbol-file ./build/bl2.elf 0x10000000",
"add-symbol-file ./build/tfm_s.elf 0x38000400",
"add-symbol-file ./build/chip-openiotsdk-${input:openiotsdkApp}-example_ns.elf 0x28060400",
"break main_ns.cpp:main"
],
"runToEntryPoint": "main",
"preLaunchTask": "Debug Open IoT SDK example",
"showDevDebugOutput": "parsed"
Expand Down
34 changes: 7 additions & 27 deletions config/openiotsdk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,10 @@ endif()
set(GN_ROOT_TARGET ${CHIP_ROOT}/config/openiotsdk/chip-gn)

# Prepare compiler flags
# All Open IoT SDK targets
list(APPEND ALL_SDK_TARGETS)

foreach(source_dir ${SDK_SOURCES_BINARY_DIRS})
get_all_cmake_targets(SDK_TARGETS ${source_dir})
list(APPEND ALL_SDK_TARGETS ${SDK_TARGETS})
endforeach()

# Exclude unnecessary targets
list(FILTER ALL_SDK_TARGETS EXCLUDE REGEX "^.*linker.*|.*example.*|.*apps.*|.*doc.*|dist|lib$")

foreach(target ${ALL_SDK_TARGETS})
get_target_common_compile_flags(SDK_TARGET_CFLAGS ${target})
list(APPEND CHIP_CFLAGS ${SDK_TARGET_CFLAGS})
# Get compiler flags from external targets
foreach(target ${EXTERNAL_TARGETS})
get_target_common_compile_flags(EXTERNAL_TARGET_CFLAGS ${target})
list(APPEND CHIP_CFLAGS ${EXTERNAL_TARGET_CFLAGS})
endforeach()

# Remove duplicated flags
Expand Down Expand Up @@ -200,6 +190,8 @@ chip_gn_arg_bool ("chip_detail_logging" CONFIG_CHIP_DETAIL_LOG
chip_gn_arg_bool ("chip_progress_logging" CONFIG_CHIP_PROGRESS_LOGGING)
chip_gn_arg_bool ("chip_automation_logging" CONFIG_CHIP_AUTOMATION_LOGGING)
chip_gn_arg_bool ("chip_error_logging" CONFIG_CHIP_ERROR_LOGGING)
chip_gn_arg_bool ("chip_openiotsdk_use_tfm" TFM_SUPPORT)
chip_gn_arg_bool ("chip_openiotsdk_use_psa_ps" CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS)
if (TARGET cmsis-rtos-api)
chip_gn_arg_string("target_os" "cmsis-rtos")
endif()
Expand Down Expand Up @@ -249,22 +241,10 @@ target_include_directories(openiotsdk-chip INTERFACE
target_link_directories(openiotsdk-chip INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/lib)
target_link_libraries(openiotsdk-chip INTERFACE -Wl,--start-group ${CHIP_LIBRARIES} -Wl,--end-group)
target_link_libraries(openiotsdk-chip INTERFACE
$<$<TARGET_EXISTS:mcu-driver-hal>:mcu-driver-hal>
$<$<TARGET_EXISTS:mcu-driver-bootstrap>:mcu-driver-bootstrap>
$<$<TARGET_EXISTS:mdh-reference-platforms-for-arm>:mdh-reference-platforms-for-arm>
$<$<TARGET_EXISTS:mbedtls>:mbedtls>
$<$<TARGET_EXISTS:lwipcore>:lwipcore>
$<$<TARGET_EXISTS:iotsdk-ip-network-api>:iotsdk-ip-network-api>
$<$<TARGET_EXISTS:iotsdk-tdbstore>:iotsdk-tdbstore>
$<$<TARGET_EXISTS:iotsdk-blockdevice>:iotsdk-blockdevice>
$<$<TARGET_EXISTS:iotsdk-serial-retarget>:$<TARGET_OBJECTS:iotsdk-serial-retarget>>
${EXTERNAL_TARGETS}
)
add_dependencies(openiotsdk-chip chip-gn)

target_include_directories(openiotsdk-chip INTERFACE
${CHIP_ROOT}/config/openiotsdk/mbedtls
)

if (NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
target_compile_definitions(openiotsdk-chip INTERFACE
NDEBUG
Expand Down
35 changes: 35 additions & 0 deletions config/openiotsdk/cmake/chip.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
# CMake for CHIP library configuration
#

get_filename_component(GEN_DIR ${CHIP_ROOT}/zzz_generated/ REALPATH)

# Default CHIP build configuration
set(CONFIG_CHIP_PROJECT_CONFIG "main/include/CHIPProjectConfig.h" CACHE STRING "")
set(CONFIG_CHIP_LIB_TESTS NO CACHE BOOL "")
Expand All @@ -29,5 +31,38 @@ set(CONFIG_CHIP_PROGRESS_LOGGING YES CACHE BOOL "Enable logging at progress leve
set(CONFIG_CHIP_AUTOMATION_LOGGING YES CACHE BOOL "Enable logging at automation level")
set(CONFIG_CHIP_ERROR_LOGGING YES CACHE BOOL "Enable logging at error level")

set(CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS NO CACHE BOOL "Enable using PSA Protected Storage")

if(CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS AND NOT TFM_SUPPORT)
message( FATAL_ERROR "You can not use PSA Protected Storage without TF-M support" )
endif()

# Add CHIP sources
add_subdirectory(${OPEN_IOT_SDK_CONFIG} ./chip_build)

# Additional openiotsdk-chip target configuration

# TF-M support requires the right order of generating targets
if(TFM_SUPPORT)
add_dependencies(chip-gn tfm-ns-interface)
endif()

function(chip_add_data_model target scope model_name)
target_include_directories(${target}
PUBLIC
${GEN_DIR}/app-common
${GEN_DIR}/${model_name}-app
)

target_compile_definitions(${target}
PUBLIC
USE_CHIP_DATA_MODEL
)

include(${CHIP_ROOT}/src/app/chip_data_model.cmake)
chip_configure_data_model(${target}
SCOPE ${scope}
INCLUDE_SERVER
ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../${model_name}-common/${model_name}-app.zap
)
endfunction()
Loading