Skip to content

Commit 8d3a884

Browse files
gergkvaggarg
authored andcommitted
build: Object detection application with split-build
The TF-M toolchain adds a __ARM_ARCH_8_1M_MAIN__ define which caused a build error in arm_2d. It is fixed in the new release. Signed-off-by: Gergely Kovacs <[email protected]>
1 parent 2d2582d commit 8d3a884

File tree

8 files changed

+62
-57
lines changed

8 files changed

+62
-57
lines changed

applications/object_detection/CMakeLists.txt

Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
cmake_minimum_required(VERSION 3.21.0 FATAL_ERROR)
66

7+
# NS target name the TF-M api_ns CMakeLists.txt uses
8+
set(NS_TARGET_NAME object-detection)
79
set(ML_INFERENCE_ENGINE "ETHOS" CACHE STRING "Machine Learning inference engine (ETHOS)")
810
set(AUDIO_SOURCE "ROM" CACHE STRING "Source of audio data (ROM | VSI)")
911
set(APPLICATION_PATH "${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/applications/object_detection" CACHE STRING "Path to the application folder")
@@ -22,10 +24,8 @@ set(AWS_OTA_SIGNATURE_TYPE "RSA-3072" CACHE STRING "Supported algorithms for si
2224
# Because of this, if only PATCH version is changed then the OTA will be rejected
2325
# due to same firmware version.
2426
# We will therefore change the build version from TF-M.
25-
set(MCUBOOT_IMAGE_VERSION_NS "0.0.1+10")
27+
# MCUBOOT_IMAGE_VERSION_NS is passed to the TF-M build in TfmInitialCache.cmake
2628
set(MCUBOOT_IMAGE_VERSION_NS_UPDATE "0.0.1+20")
27-
set(MCUBOOT_IMAGE_NUMBER 2 CACHE STRING "Total number of firmware images")
28-
set(DEFAULT_MCUBOOT_FLASH_MAP ON)
2929

3030
if (${ML_INFERENCE_ENGINE} STREQUAL "ETHOS")
3131
set(ETHOS_U_NPU_ENABLED ON)
@@ -36,31 +36,15 @@ endif()
3636
set(ML_USE_CASE "object_detection")
3737
set(ML_MODEL "GenerateObjectDetectionModel")
3838
set(ML_USE_CASE_RESOURCES_FILE "${CMAKE_CURRENT_LIST_DIR}/resources/use_case_resources.json")
39-
set(TFM_PLATFORM_UPGRADE_STRATEGY "SWAP_USING_SCRATCH")
40-
set(TFM_PLATFORM_CONFIRM_IMAGE ON)
41-
42-
# Trusted Firmware-M setup
43-
set(TFM_CMAKE_APP_ARGS
44-
-DPROJECT_CONFIG_HEADER_FILE=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/applications/object_detection/configs/tfm_config/project_config.h
45-
-DMCUBOOT_CONFIRM_IMAGE=${TFM_PLATFORM_CONFIRM_IMAGE}
46-
-DMCUBOOT_UPGRADE_STRATEGY=${TFM_PLATFORM_UPGRADE_STRATEGY}
47-
-DMCUBOOT_IMAGE_VERSION_NS=${MCUBOOT_IMAGE_VERSION_NS}
48-
-DCONFIG_TFM_HALT_ON_CORE_PANIC=ON
49-
-DMCUBOOT_DATA_SHARING=ON
50-
-DPLATFORM_HAS_FIRMWARE_UPDATE_SUPPORT=ON
51-
-DTFM_PARTITION_FIRMWARE_UPDATE=ON
52-
-DTFM_PARTITION_LOG_LEVEL=TFM_PARTITION_LOG_LEVEL_INFO
53-
)
5439

55-
project(object-detection LANGUAGES C CXX)
40+
# Toolchain file has to be included before the very first project() call
41+
include(${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/components/security/trusted_firmware-m/integration/cmake/TfmNsToolchain.cmake)
5642

57-
# Set global optimization level to reduce code size while keeping the debug experience.
58-
if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
59-
add_compile_options(-Og)
60-
elseif(${CMAKE_C_COMPILER_ID} STREQUAL "ARMClang")
61-
add_compile_options(-O1)
62-
endif()
6343

44+
project(object-detection LANGUAGES C CXX)
45+
46+
set_compiler_and_linker_flags()
47+
include(${CONFIG_SPE_PATH}/config/cp_check.cmake)
6448

6549
add_subdirectory(${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR} ${CMAKE_BINARY_DIR}/iot_reference_arm_corstone3xx)
6650

@@ -81,6 +65,7 @@ add_executable(object-detection
8165
blink_task.c
8266
main.c
8367
ml_interface.cc
68+
${CONFIG_SPE_PATH}/interface/src/os_wrapper/tfm_ns_interface_rtos.c
8469
)
8570

8671
target_include_directories(object-detection
@@ -106,10 +91,6 @@ target_compile_definitions(arm-corstone-platform-bsp
10691
RTE_USART1=1
10792
)
10893

109-
# Trusted Firmware-M must be built before the application, because
110-
# the application depends on the NS interface and the BL2 signing scripts,
111-
# both of which are generated as parts of the Trusted Firmware-M build process.
112-
add_dependencies(object-detection trusted_firmware-m-build)
11394
# The provision data must be built before the application because
11495
# it provides credentials to connect to AWS.
11596
add_dependencies(object-detection provisioning_data_bin)
@@ -132,36 +113,39 @@ target_link_libraries(object-detection
132113
mbedtls
133114
ota-update
134115
provisioning-lib
135-
tfm-ns-interface
116+
tfm_api_ns
136117
toolchain-override
137118
object_detection_api
138119
object_detection_model
139120
helpers-logging
121+
# FRI always uses TrustZone
122+
tfm_api_ns_tz
140123
)
141124

142125
include(${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/bsp/cmake/SetLinkerOptions.cmake)
143126
set_linker_script(object-detection)
144127

145128
list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/tools/cmake)
146129
include(ConvertElfToBin)
147-
include(ExternalProject)
148-
ExternalProject_Get_Property(trusted_firmware-m-build BINARY_DIR)
149130

150131
extract_sections_from_axf(
151132
object-detection
152133
SECTIONS_NAMES "ddr.bin"
153134
OUTPUT_BIN_NAME "ns_image"
154135
)
155136

156-
# The non-secure application image should be padded while being signed
157-
# Hence, passing "TRUE" as the input parameter to the pad option of sign function.
158-
iot_reference_arm_corstone3xx_tf_m_sign_image(
159-
object-detection
160-
"ns_image"
161-
object-detection_signed
162-
${MCUBOOT_IMAGE_VERSION_NS}
163-
"${BINARY_DIR}/api_ns/image_signing/layout_files/signing_layout_ns.o"
164-
TRUE
137+
# Copy the binary flash content to the location expected by default signing
138+
# Signing is implemented in the exported TF-M NS CMakeLists.txt (in the
139+
# ${CONFIG_SPE_PATH} directory)
140+
add_custom_target(object-detection_bin
141+
SOURCES ${CMAKE_BINARY_DIR}/object-detection.bin
142+
DEPENDS object-detection
143+
)
144+
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/object-detection.bin
145+
DEPENDS object-detection
146+
COMMAND ${CMAKE_COMMAND}
147+
-E copy ${SECTORS_BIN_DIR}/ns_image.bin
148+
${CMAKE_BINARY_DIR}/object-detection.bin
165149
)
166150

167151
# The update image is not padded to fill the whole slot (no --pad), because
@@ -173,7 +157,7 @@ iot_reference_arm_corstone3xx_tf_m_sign_image(
173157
"ns_image"
174158
object-detection-update_signed
175159
${MCUBOOT_IMAGE_VERSION_NS_UPDATE}
176-
"${BINARY_DIR}/api_ns/image_signing/layout_files/signing_layout_ns.o"
160+
"${CONFIG_SPE_PATH}/image_signing/layout_files/signing_layout_ns.o"
177161
FALSE
178162
)
179163

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2025 Arm Limited and/or its affiliates
2+
3+
# SPDX-License-Identifier: MIT
4+
5+
include(${ROOT}/cmake/TfmInitialCacheCommon.cmake)
6+
7+
set(TFM_MBEDCRYPTO_CONFIG_CLIENT_PATH "${ROOT}/applications/object_detection/configs/mbedtls_config/aws_mbedtls_config.h" CACHE FILEPATH "TFM_MBEDCRYPTO_CONFIG_CLIENT_PATH" FORCE)
8+
set(PROJECT_CONFIG_HEADER_FILE ${ROOT}/applications/object_detection/configs/tfm_config/project_config.h CACHE FILEPATH "PROJECT_CONFIG_HEADER_FILE" FORCE)
9+
set(MCUBOOT_IMAGE_NUMBER 2 CACHE STRING "MCUBOOT_IMAGE_NUMBER" FORCE)
10+
set(DEFAULT_MCUBOOT_FLASH_MAP ON CACHE BOOL "DEFAULT_MCUBOOT_FLASH_MAP" FORCE)
11+
set(MCUBOOT_UPGRADE_STRATEGY "SWAP_USING_SCRATCH" CACHE STRING "MCUBOOT_UPGRADE_STRATEGY" FORCE)
12+
set(MCUBOOT_IMAGE_VERSION_NS "0.0.1+10" CACHE STRING "MCUBOOT_IMAGE_VERSION_NS" FORCE)
13+
set(CONFIG_TFM_HALT_ON_CORE_PANIC ON CACHE BOOL "CONFIG_TFM_HALT_ON_CORE_PANIC" FORCE)
14+
set(MCUBOOT_DATA_SHARING ON CACHE BOOL "MCUBOOT_DATA_SHARING" FORCE)
15+
set(PLATFORM_HAS_FIRMWARE_UPDATE_SUPPORT ON CACHE BOOL "PLATFORM_HAS_FIRMWARE_UPDATE_SUPPORT" FORCE)
16+
set(TFM_PARTITION_FIRMWARE_UPDATE ON CACHE BOOL "TFM_PARTITION_FIRMWARE_UPDATE" FORCE)
17+
set(TFM_PARTITION_LOG_LEVEL TFM_PARTITION_LOG_LEVEL_INFO CACHE STRING "TFM_PARTITION_LOG_LEVEL" FORCE)
18+
set(CONFIG_TFM_ENABLE_MVE ON CACHE STRING "CONFIG_TFM_ENABLE_MVE" FORCE)
19+
set(CONFIG_TFM_ENABLE_MVE_FP ON CACHE STRING "CONFIG_TFM_ENABLE_MVE_FP" FORCE)

applications/object_detection/configs/freertos_config/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023-2024, Arm Limited and/or its affiliates
1+
# Copyright 2023-2025, Arm Limited and/or its affiliates
22
33
# SPDX-License-Identifier: MIT
44

@@ -14,6 +14,6 @@ target_compile_definitions(freertos_config
1414

1515
target_link_libraries(freertos_config
1616
INTERFACE
17-
tfm-ns-interface
17+
tfm_api_ns
1818
app-config
1919
)

applications/object_detection/configs/mbedtls_config/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023-2024, Arm Limited and/or its affiliates
1+
# Copyright 2023-2025, Arm Limited and/or its affiliates
22
33
# SPDX-License-Identifier: MIT
44

@@ -7,11 +7,6 @@ target_include_directories(mbedtls-config
77
.
88
)
99

10-
target_compile_definitions(mbedtls-config
11-
INTERFACE
12-
MBEDTLS_CONFIG_FILE="aws_mbedtls_config.h"
13-
)
14-
1510
target_link_libraries(mbedtls-config
1611
INTERFACE
1712
freertos_kernel

applications/object_detection/configs/mbedtls_config/aws_mbedtls_config.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/*
1212
* Copyright The Mbed TLS Contributors
1313
* SPDX-License-Identifier: Apache-2.0
14-
* Copyright 2024 Arm Limited and/or its affiliates
14+
* Copyright 2024-2025 Arm Limited and/or its affiliates
1515
1616
*
1717
* Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -27,6 +27,11 @@
2727
* limitations under the License.
2828
*/
2929

30+
#ifndef DOMAIN_NS
31+
/* Set if this config file is currently used for TF-M secure clients */
32+
#define PSA_CRYPTO_TFM_SECURE_CONFIG
33+
#endif /* DOMAIN_NS == 1 */
34+
3035
/**
3136
* This is an optional version symbol that enables compatibility handling of
3237
* config files.
@@ -1158,7 +1163,7 @@ void mbedtls_platform_free( void * ptr );
11581163
* \warning This interface is experimental and may change or be removed
11591164
* without notice.
11601165
*/
1161-
#ifdef PSA_CRYPTO_IMPLEMENTATION_TFM
1166+
#if defined( PSA_CRYPTO_IMPLEMENTATION_TFM ) || defined( PSA_CRYPTO_TFM_SECURE_CONFIG )
11621167
#define MBEDTLS_PSA_CRYPTO_CLIENT
11631168
#endif
11641169

@@ -1758,7 +1763,9 @@ void mbedtls_platform_free( void * ptr );
17581763
* This feature is still experimental and is not ready for production since
17591764
* it is not completed.
17601765
*/
1761-
/*#define MBEDTLS_PSA_CRYPTO_CONFIG */
1766+
#ifdef PSA_CRYPTO_TFM_SECURE_CONFIG
1767+
#define MBEDTLS_PSA_CRYPTO_CONFIG
1768+
#endif
17621769

17631770
/**
17641771
* \def MBEDTLS_VERSION_FEATURES

components/graphics/arm-2d/integration/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 Arm Limited and/or its affiliates
1+
# Copyright 2024-2025 Arm Limited and/or its affiliates
22
33
# SPDX-License-Identifier: MIT
44

@@ -11,7 +11,7 @@ target_include_directories(arm-2d
1111
)
1212

1313
target_sources(arm-2d
14-
PUBLIC
14+
PRIVATE
1515
${arm-2d_SOURCE_DIR}/Library/Source/arm_2d.c
1616
${arm-2d_SOURCE_DIR}/Library/Source/__arm_2d_tile.c
1717
${arm-2d_SOURCE_DIR}/Library/Source/arm_2d_draw.c

components/graphics/arm-2d/library

Submodule library updated 807 files

manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ dependencies:
196196
license: "Apache-2.0"
197197
tpip-category: "category-2"
198198
security-risk: "low"
199-
version: "v1.1.5"
199+
version: "v1.2.1"
200200
repository:
201201
type: "git"
202202
url: "https://github.com/ARM-software/Arm-2D.git"

0 commit comments

Comments
 (0)