Skip to content

Commit fb92873

Browse files
authored
[OIS] TF-M and kv store improvements (project-chip#27481)
* [OIS] Add software version to Matter stack Set Matter stack software version configurable from application level. Add software version options in build script. Signed-off-by: ATmobica <artur.tynecki@arm.com> * [OIS] Remove block device storage support Remove block device KVS store from OIS platform. Remove flash block device class implementation. Remove block device support from build script, cmake and documentation. Remove OIS storage git submodule. Signed-off-by: ATmobica <artur.tynecki@arm.com> * [OIS] Set default TF-M support to examples Remove non TF-M example build option. Now, all OIS applications support TF-M by default. Remove TFM_SUPPORT flag. Remove non TF-M linker script. Documentation udpate. Signed-off-by: ATmobica <artur.tynecki@arm.com> --------- Signed-off-by: ATmobica <artur.tynecki@arm.com>
1 parent 08e04ae commit fb92873

28 files changed

+95
-1597
lines changed

.gitmodules

-5
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,6 @@
280280
url = https://git.gitlab.arm.com/iot/open-iot-sdk/sdk.git
281281
branch = main
282282
platforms = openiotsdk
283-
[submodule "open-iot-sdk-storage"]
284-
path = third_party/open-iot-sdk/storage
285-
url = https://git.gitlab.arm.com/iot/open-iot-sdk/storage.git
286-
branch = main
287-
platforms = openiotsdk
288283
[submodule "bouffalolab_sdk"]
289284
path = third_party/bouffalolab/repo
290285
url = https://github.com/bouffalolab/bl_iot_sdk_tiny.git

config/openiotsdk/CMakeLists.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ matter_add_gn_arg_bool ("chip_detail_logging" CONFIG_CHIP_DETA
6060
matter_add_gn_arg_bool ("chip_progress_logging" CONFIG_CHIP_PROGRESS_LOGGING)
6161
matter_add_gn_arg_bool ("chip_automation_logging" CONFIG_CHIP_AUTOMATION_LOGGING)
6262
matter_add_gn_arg_bool ("chip_error_logging" CONFIG_CHIP_ERROR_LOGGING)
63-
matter_add_gn_arg_bool ("chip_openiotsdk_use_tfm" TFM_SUPPORT)
64-
matter_add_gn_arg_bool ("chip_openiotsdk_use_psa_ps" CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS)
6563
matter_add_gn_arg_string("chip_crypto" "${CONFIG_CHIP_CRYPTO}")
64+
matter_add_gn_arg_string("chip_openiotsdk_software_version" "${CONFIG_CHIP_OPEN_IOT_SDK_SOFTWARE_VERSION}")
65+
matter_add_gn_arg_string("chip_openiotsdk_software_version_string" "${CONFIG_CHIP_OPEN_IOT_SDK_SOFTWARE_VERSION_STRING}")
6666
if (TARGET cmsis-rtos-api)
6767
matter_add_gn_arg_string("target_os" "cmsis-rtos")
6868
endif()
@@ -76,6 +76,7 @@ matter_generate_args_tmp_file()
7676
matter_build(chip
7777
LIB_SHELL ${CONFIG_CHIP_LIB_SHELL}
7878
LIB_TESTS ${CONFIG_CHIP_LIB_TESTS}
79+
GN_DEPENDENCIES ${CONFIG_GN_DEPENDENCIES}
7980
)
8081

8182
target_link_libraries(chip INTERFACE

config/openiotsdk/cmake/chip.cmake

+6-10
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,25 @@ set(CONFIG_CHIP_PROGRESS_LOGGING YES CACHE BOOL "Enable logging at progress leve
3131
set(CONFIG_CHIP_AUTOMATION_LOGGING YES CACHE BOOL "Enable logging at automation level")
3232
set(CONFIG_CHIP_ERROR_LOGGING YES CACHE BOOL "Enable logging at error level")
3333

34-
set(CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS NO CACHE BOOL "Enable using PSA Protected Storage")
3534
set(CONFIG_CHIP_CRYPTO "mbedtls" CACHE STRING "Matter crypto backend. Mbedtls as default")
36-
37-
if(CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS AND NOT TFM_SUPPORT)
38-
message( FATAL_ERROR "You can not use PSA Protected Storage without TF-M support" )
39-
endif()
35+
set(CONFIG_CHIP_OPEN_IOT_SDK_SOFTWARE_VERSION "0" CACHE STRING "Software version number")
36+
set(CONFIG_CHIP_OPEN_IOT_SDK_SOFTWARE_VERSION_STRING ${TFM_NS_APP_VERSION} CACHE STRING "Software version in string format x.x.x")
37+
set(CONFIG_GN_DEPENDENCIES "")
4038

4139
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
4240
set(CONFIG_CHIP_DEBUG YES)
4341
else()
4442
set(CONFIG_CHIP_DEBUG NO)
4543
endif()
4644

45+
# TF-M support requires the right order of generating targets
46+
list(APPEND CONFIG_GN_DEPENDENCIES tfm-ns-interface)
47+
4748
# Add CHIP sources
4849
add_subdirectory(${OPEN_IOT_SDK_CONFIG} ./chip_build)
4950

5051
# Additional chip target configuration
5152

52-
# TF-M support requires the right order of generating targets
53-
if(TFM_SUPPORT)
54-
add_dependencies(chip-gn tfm-ns-interface)
55-
endif()
56-
5753
if ("${CONFIG_CHIP_CRYPTO}" STREQUAL "psa")
5854
target_compile_definitions(chip
5955
INTERFACE

config/openiotsdk/cmake/sdk.cmake

+14-65
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@
2222
include(FetchContent)
2323

2424
get_filename_component(OPEN_IOT_SDK_SOURCE ${CHIP_ROOT}/third_party/open-iot-sdk/sdk REALPATH)
25-
get_filename_component(OPEN_IOT_SDK_STORAGE_SOURCE ${CHIP_ROOT}/third_party/open-iot-sdk/storage REALPATH)
2625

2726
# Open IoT SDK targets passed to CHIP build
2827
list(APPEND CONFIG_CHIP_EXTERNAL_TARGETS)
2928

3029
# Additional Open IoT SDK build configuration
31-
set(TFM_SUPPORT NO CACHE BOOL "Add Trusted Firmware-M (TF-M) support to application")
3230
set(TFM_NS_APP_VERSION "0.0.0" CACHE STRING "TF-M non-secure application version (in the x.x.x format)")
3331
set(CONFIG_CHIP_OPEN_IOT_SDK_LWIP_DEBUG NO CACHE BOOL "Enable LwIP debug logs")
3432

@@ -72,26 +70,23 @@ set(IOTSDK_FETCH_LIST
7270
mbedtls
7371
lwip
7472
cmsis-sockets-api
73+
trusted-firmware-m
7574
)
7675

7776
set(MDH_PLATFORM ARM_AN552_MPS3)
7877
set(VARIANT "FVP")
7978
set(FETCHCONTENT_QUIET OFF)
80-
if(TFM_SUPPORT)
81-
list(APPEND IOTSDK_FETCH_LIST trusted-firmware-m)
82-
set(TFM_PLATFORM ${OPEN_IOT_SDK_EXAMPLE_COMMON}/tf-m/targets/an552)
83-
set(TFM_PSA_FIRMWARE_UPDATE ON)
84-
set(MCUBOOT_IMAGE_VERSION_NS ${TFM_NS_APP_VERSION})
85-
set(TFM_CMAKE_ARGS "-DCONFIG_TFM_ENABLE_FP=ON;-DTFM_PROFILE=profile_medium;-DTFM_EXCEPTION_INFO_DUMP=ON;-DCONFIG_TFM_HALT_ON_CORE_PANIC=ON;-DTFM_ISOLATION_LEVEL=1;-DTFM_MBEDCRYPTO_PLATFORM_EXTRA_CONFIG_PATH=${OPEN_IOT_SDK_CONFIG}/mbedtls/mbedtls_config_psa.h;-DMBEDCRYPTO_BUILD_TYPE=${CMAKE_BUILD_TYPE};-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
86-
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
87-
set(TFM_CMAKE_ARGS "${TFM_CMAKE_ARGS};-DMCUBOOT_LOG_LEVEL=INFO;-DTFM_SPM_LOG_LEVEL=TFM_SPM_LOG_LEVEL_DEBUG;-DTFM_PARTITION_LOG_LEVEL=TFM_PARTITION_LOG_LEVEL_INFO")
88-
else()
89-
set(TFM_CMAKE_ARGS "${TFM_CMAKE_ARGS};-DMCUBOOT_LOG_LEVEL=ERROR;-DTFM_SPM_LOG_LEVEL=TFM_SPM_LOG_LEVEL_DEBUG;-DTFM_PARTITION_LOG_LEVEL=TFM_PARTITION_LOG_LEVEL_ERROR")
90-
endif()
91-
if(TFM_PROJECT_CONFIG_HEADER_FILE)
92-
set(TFM_CMAKE_ARGS "${TFM_CMAKE_ARGS};-DPROJECT_CONFIG_HEADER_FILE=${TFM_PROJECT_CONFIG_HEADER_FILE}")
93-
endif()
94-
set(LINKER_SCRIPT ${OPEN_IOT_SDK_CONFIG}/ld/cs300_gcc_tfm.ld)
79+
set(TFM_PLATFORM ${OPEN_IOT_SDK_EXAMPLE_COMMON}/tf-m/targets/an552)
80+
set(TFM_PSA_FIRMWARE_UPDATE ON)
81+
set(MCUBOOT_IMAGE_VERSION_NS ${TFM_NS_APP_VERSION})
82+
set(TFM_CMAKE_ARGS "-DCONFIG_TFM_ENABLE_FP=ON;-DTFM_PROFILE=profile_medium;-DTFM_EXCEPTION_INFO_DUMP=ON;-DCONFIG_TFM_HALT_ON_CORE_PANIC=ON;-DTFM_ISOLATION_LEVEL=1;-DTFM_MBEDCRYPTO_PLATFORM_EXTRA_CONFIG_PATH=${OPEN_IOT_SDK_CONFIG}/mbedtls/mbedtls_config_psa.h;-DMBEDCRYPTO_BUILD_TYPE=${CMAKE_BUILD_TYPE};-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
83+
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
84+
set(TFM_CMAKE_ARGS "${TFM_CMAKE_ARGS};-DMCUBOOT_LOG_LEVEL=INFO;-DTFM_SPM_LOG_LEVEL=TFM_SPM_LOG_LEVEL_DEBUG;-DTFM_PARTITION_LOG_LEVEL=TFM_PARTITION_LOG_LEVEL_INFO")
85+
else()
86+
set(TFM_CMAKE_ARGS "${TFM_CMAKE_ARGS};-DMCUBOOT_LOG_LEVEL=ERROR;-DTFM_SPM_LOG_LEVEL=TFM_SPM_LOG_LEVEL_DEBUG;-DTFM_PARTITION_LOG_LEVEL=TFM_PARTITION_LOG_LEVEL_ERROR")
87+
endif()
88+
if(TFM_PROJECT_CONFIG_HEADER_FILE)
89+
set(TFM_CMAKE_ARGS "${TFM_CMAKE_ARGS};-DPROJECT_CONFIG_HEADER_FILE=${TFM_PROJECT_CONFIG_HEADER_FILE}")
9590
endif()
9691

9792
# Add Open IoT SDK source
@@ -124,7 +119,7 @@ if(TARGET cmsis-rtos-api)
124119

125120
target_compile_definitions(cmsis-rtos-api
126121
PUBLIC
127-
DOMAIN_NS=$<IF:$<BOOL:${TFM_SUPPORT}>,1,0>
122+
DOMAIN_NS=1
128123
)
129124

130125
if(TARGET freertos-kernel)
@@ -142,11 +137,6 @@ if(TARGET cmsis-rtos-api)
142137
PUBLIC
143138
freertos-cmsis-rtos
144139
)
145-
146-
target_compile_definitions(cmsis-rtos-api
147-
INTERFACE
148-
CONFIG_RUN_FREERTOS_SECURE_ONLY=$<IF:$<BOOL:${TFM_SUPPORT}>,0,1>
149-
)
150140
elseif(TARGET cmsis-rtx)
151141
target_link_libraries(cmsis-rtos-api
152142
INTERFACE
@@ -191,7 +181,7 @@ endif()
191181
if(TARGET mcu-driver-hal)
192182
target_compile_definitions(mcu-driver-hal
193183
INTERFACE
194-
DOMAIN_NS=$<IF:$<BOOL:${TFM_SUPPORT}>,1,0>
184+
DOMAIN_NS=1
195185
)
196186

197187
# Fixing the optimization issue for mcu-driver-hal target in the release build.
@@ -283,24 +273,8 @@ if("mbedtls" IN_LIST IOTSDK_FETCH_LIST)
283273
)
284274
endif()
285275

286-
# Additional Open IoT SDK port components
287-
288-
# Add Open IoT SDK storage source
289-
add_subdirectory(${OPEN_IOT_SDK_STORAGE_SOURCE} ./sdk_storage_build)
290-
list(APPEND CONFIG_CHIP_EXTERNAL_TARGETS
291-
iotsdk-blockdevice
292-
iotsdk-tdbstore
293-
)
294-
295-
# Add custom storage library
296-
add_subdirectory(${OPEN_IOT_SDK_CONFIG}/storage storage_build)
297-
list(APPEND CONFIG_CHIP_EXTERNAL_TARGETS
298-
openiotsdk-storage
299-
)
300-
301276
function(sdk_post_build target)
302277
string(REPLACE "_ns" "" APP_NAME ${target})
303-
if(TFM_SUPPORT)
304278
include(ConvertElfToBin)
305279
include(SignTfmImage)
306280
ExternalProject_Get_Property(trusted-firmware-m-build BINARY_DIR)
@@ -355,29 +329,4 @@ if(TFM_SUPPORT)
355329
$<TARGET_FILE_DIR:${target}>/${target}_merged.elf
356330
VERBATIM
357331
)
358-
else()
359-
add_custom_command(
360-
TARGET
361-
${target}
362-
POST_BUILD
363-
DEPENDS
364-
$<TARGET_FILE_DIR:${target}>/${target}.elf
365-
$<TARGET_FILE_DIR:${target}>/${target}.map
366-
COMMAND
367-
# Rename output elf file
368-
${CMAKE_COMMAND} -E copy
369-
$<TARGET_FILE_DIR:${target}>/${target}.elf
370-
$<TARGET_FILE_DIR:${target}>/${APP_NAME}.elf
371-
COMMAND
372-
# Rename output map file
373-
${CMAKE_COMMAND} -E copy
374-
$<TARGET_FILE_DIR:${target}>/${target}.map
375-
$<TARGET_FILE_DIR:${target}>/${APP_NAME}.map
376-
COMMAND rm
377-
ARGS -Rf
378-
$<TARGET_FILE_DIR:${target}>/${target}.elf
379-
$<TARGET_FILE_DIR:${target}>/${target}.map
380-
VERBATIM
381-
)
382-
endif() #TFM_SUPPORT
383332
endfunction()

config/openiotsdk/ld/cs300_gcc.ld

+17-22
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@
1717

1818
MEMORY
1919
{
20-
ITCM (rx) : ORIGIN = 0x00000000, LENGTH = 32K
21-
/* Vector table is copied to RAM, so RAM address needs to be adjusted */
22-
DTCM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
23-
DATA_SRAM (rwx) : ORIGIN = 0x21000000, LENGTH = 2M
24-
QSPI_RAM (rx) : ORIGIN = 0x28000000, LENGTH = 8M
20+
FLASH (rx) : ORIGIN = ((0x28000000) + (0x60000) + (0x400)), LENGTH = ((0x200000) - (0x400) - (0x800))
21+
RAM (rwx) : ORIGIN = 0x21000000, LENGTH = 0x200000
2522
}
2623

2724
__stack_size__ = 0x1000;
@@ -31,28 +28,26 @@ GROUP(libgcc.a libc.a libm.a libnosys.a)
3128

3229
SECTIONS
3330
{
34-
.vectors :
31+
.text :
3532
{
3633
KEEP(*(.vectors))
3734
__Vectors_End = .;
3835
__Vectors_Size = __Vectors_End - __Vectors;
3936
__end__ = .;
4037

38+
*(.text*)
39+
4140
KEEP(*(.init))
4241
KEEP(*(.fini))
4342

43+
4444
/* .ctors */
4545
*crtbegin.o(.ctors)
4646
*crtbegin?.o(.ctors)
4747
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
4848
*(SORT(.ctors.*))
4949
*(.ctors)
50-
} > ITCM
5150

52-
.text :
53-
{
54-
*(.text*)
55-
5651
/* .dtors */
5752
*crtbegin.o(.dtors)
5853
*crtbegin?.o(.dtors)
@@ -63,19 +58,19 @@ SECTIONS
6358
*(.rodata*)
6459

6560
KEEP(*(.eh_frame*))
66-
} > QSPI_RAM
61+
} > FLASH
6762

6863
.ARM.extab :
6964
{
7065
*(.ARM.extab* .gnu.linkonce.armextab.*)
71-
} > QSPI_RAM
66+
} > FLASH
7267

7368
__exidx_start = .;
7469

7570
.ARM.exidx :
7671
{
7772
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
78-
} > QSPI_RAM
73+
} > FLASH
7974

8075
__exidx_end = .;
8176

@@ -92,7 +87,7 @@ SECTIONS
9287
LONG (DEFINED(__data2_start__) ? __data2_start__ : 0)
9388
LONG (DEFINED(__data2_start__) ? __data2_end__ - __data2_start__ : 0)
9489
__copy_table_end__ = .;
95-
} > QSPI_RAM
90+
} > FLASH
9691

9792
.zero.table :
9893
{
@@ -103,7 +98,7 @@ SECTIONS
10398
LONG (DEFINED(__bss2_start__) ? __bss2_start__ : 0)
10499
LONG (DEFINED(__bss2_start__) ? __bss2_end__ - __bss2_start__ : 0)
105100
__zero_table_end__ = .;
106-
} > QSPI_RAM
101+
} > FLASH
107102

108103
__etext = .;
109104

@@ -137,7 +132,7 @@ SECTIONS
137132
. = ALIGN(4);
138133
/* All data end */
139134
__data_end__ = .;
140-
} > DATA_SRAM
135+
} > RAM
141136

142137
.bss :
143138
{
@@ -147,7 +142,7 @@ SECTIONS
147142
*(COMMON)
148143
. = ALIGN(4);
149144
__bss_end__ = .;
150-
} > DATA_SRAM
145+
} > RAM
151146

152147
bss_size = __bss_end__ - __bss_start__;
153148

@@ -158,7 +153,7 @@ SECTIONS
158153
KEEP(*(.stack*))
159154
. += __stack_size__;
160155
__StackTop = .;
161-
} > DTCM
156+
} > RAM
162157
PROVIDE(__stack = __StackTop);
163158

164159
.heap (COPY):
@@ -168,10 +163,10 @@ SECTIONS
168163
__end__ = .;
169164
end = __end__;
170165
KEEP(*(.heap*))
171-
. += (ORIGIN(DATA_SRAM) + LENGTH(DATA_SRAM) - .);
166+
. += (ORIGIN(RAM) + LENGTH(RAM) - .);
172167
__HeapLimit = .;
173168
__heap_limit = .;
174-
} > DATA_SRAM
169+
} > RAM
175170

176-
ASSERT(__StackTop <= (ORIGIN(DTCM) + LENGTH(DTCM)), "RAM region overflowed")
171+
ASSERT(__HeapLimit <= (ORIGIN(RAM) + LENGTH(RAM)), "RAM region overflowed")
177172
}

0 commit comments

Comments
 (0)