Skip to content

Commit

Permalink
[OIS] Add TF-M support to Matter examples (#23951)
Browse files Browse the repository at this point in the history
* [OIS] Build scripts improvements

Remove redundant steps:
- removing old artifacts to force linking
- removing access to ARM GCC toolchain from Matter environment
  now Pigweed env contains compatible ARM GCC version.

Signed-off-by: ATmobica <[email protected]>

* [OIS] Improve OIS platform storage

Add storage library that implements custom Flash Block Device class.
OpenIoTSDKConfig uses the getter to block device object and
pass it to TDBstore.
Custom flash bd is a workaround solution for issues in MDH flash driver.
We need to use the non-secure SRAM memory instead of secure part.

Signed-off-by: ATmobica <[email protected]>

* [OIS] Extend chip_data_model Cmake

Add SCOPE option - it allows to pass the Cmake scope keyword that
defines the scope of included sources.
Data model sources will not always be added to the application target
directly.  Adding the scope option makes it more flexible.

Signed-off-by: ATmobica <[email protected]>

* [OIS] Make init ZCL Data Model and start server common

Move init ZCL Data Model and start server to openiotsdk-app target.
Implement openiotsdk_chip_run() and openiotsdk_chip_shutdown()
Add chip_add_data_model() cmake function to add specified data
model to target.
Apply changes in lock-app example.

Signed-off-by: ATmobica <[email protected]>

* [OIS] Update external version of mbedtls used by Matter

This commit updates the external version of mbedtls used by
the Matter integration with the IoT SDK, to the latest
available.

Signed-off-by: Anna Bridge <[email protected]>

* [OIS] Update SDK version

Udpate Open IoT SDK version to the latest available.
Refactoring the Cmake build system for passing the SDK targets
to the CHIP build in a more generic way.

Signed-off-by: ATmobica <[email protected]>

* [OIS] Add TF-M support in Matter examples

Extend OIS Python package requirements with imgtool.
Add custom TF-M AN552 platform implementation - flash layout
and memory usage adaptation for Matter examples.
Build lock-app and shell examples with TF-M support.
They are built as non-secure apps and merged with bootloader
and secure TF-M app.
Build script adaptation - set TF-M support and get app version.
Launch task adaptation to TF-M examples.

Signed-off-by: ATmobica <[email protected]>

* [OIS] PSA protected storage support

Add KV store class base on PSA Protected Storage.
Rename OpenIoTSDKConfig to KVBlockDeviceStore.
Build system adaptation to support various storage type.
Change KV manager and Configuration manager to support various
storage type.
Add CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS Cmake flag to enable PSA PS
support.
Initialize the KV store manager during CHIP stack setup.

Signed-off-by: ATmobica <[email protected]>

---------

Signed-off-by: ATmobica <[email protected]>
Signed-off-by: Anna Bridge <[email protected]>
Co-authored-by: Anna Bridge <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jun 30, 2023
1 parent 5c85d47 commit edc7c27
Show file tree
Hide file tree
Showing 94 changed files with 15,613 additions and 1,332 deletions.
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

0 comments on commit edc7c27

Please sign in to comment.