Skip to content

Commit ed9a156

Browse files
gergkvaggarg
authored andcommitted
build: Switch to TF-M provided NS toolchain
Removed the previous toolchain dependency and the NS toolchain exported by TF-M is used instead. The cross compilation flags are set up by this toolchain file (e.g. -mcpu). The compilation options are set by FRI, these options are the previously used options from the removed toolchain and the options used in TF-M merged. Signed-off-by: Gergely Kovacs <[email protected]>
1 parent c15b7c7 commit ed9a156

File tree

10 files changed

+115
-26
lines changed

10 files changed

+115
-26
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@
4040
[submodule "mbedtls"]
4141
path = components/security/mbedtls/library
4242
url = https://github.com/Mbed-TLS/mbedtls.git
43-
[submodule "open_iot_sdk_toolchain"]
44-
path = components/tools/open_iot_sdk_toolchain/library
45-
url = https://git.gitlab.arm.com/iot/open-iot-sdk/toolchain.git
4643
[submodule "tinycbor"]
4744
path = components/aws_iot/tinycbor/library
4845
url = https://github.com/intel/tinycbor.git

applications/blinky/TfmInitialCache.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
include(${ROOT}/cmake/TfmInitialCacheCommon.cmake)
66

77
set(MCUBOOT_IMAGE_VERSION_NS 0.0.1 CACHE STRING "MCUBOOT_IMAGE_VERSION_NS" FORCE)
8+
set(MCUBOOT_IMAGE_NUMBER 2 CACHE STRING "MCUBOOT_IMAGE_NUMBER" FORCE)
9+
set(DEFAULT_MCUBOOT_FLASH_MAP ON CACHE STRING "DEFAULT_MCUBOOT_FLASH_MAP" FORCE)
810
set(PROJECT_CONFIG_HEADER_FILE ${ROOT}/applications/blinky/configs/tfm_config/project_config.h CACHE FILEPATH "PROJECT_CONFIG_HEADER_FILE" FORCE)

cmake/CompilerFlagsARMCLANG.cmake

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2025 Arm Limited and/or its affiliates
2+
3+
# SPDX-License-Identifier: MIT
4+
5+
macro(set_compiler_and_linker_flags)
6+
# Clear toolchain options for all languages similar to IOTSDK as FRI uses
7+
# different initialization options (such as for optimization and debug symbols)
8+
# These variables only hold -O, -g and -DNDEBUG options originally
9+
set(CMAKE_ASM_FLAGS_DEBUG "-O1 -g" CACHE STRING "" FORCE)
10+
set(CMAKE_ASM_FLAGS_RELWITHDEBINFO "-O1 -g" CACHE STRING "" FORCE)
11+
set(CMAKE_ASM_FLAGS_RELEASE "-O1" CACHE STRING "" FORCE)
12+
set(CMAKE_C_FLAGS_DEBUG "-O1 -g" CACHE STRING "" FORCE)
13+
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O1 -g" CACHE STRING "" FORCE)
14+
set(CMAKE_C_FLAGS_RELEASE "-O1" CACHE STRING "" FORCE)
15+
set(CMAKE_CXX_FLAGS_DEBUG "-O1 -g" CACHE STRING "" FORCE)
16+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O1 -g" CACHE STRING "" FORCE)
17+
set(CMAKE_CXX_FLAGS_RELEASE "-O1" CACHE STRING "" FORCE)
18+
19+
# Customization of TF-M NS toolchain provided default options
20+
# TF-M options that are never added because the TFM_DEBUG_SYMBOLS and
21+
# CONFIG_TFM_WARNINGS_ARE_ERRORS variables are not defined during NS build:
22+
# $<$<AND:$<COMPILE_LANGUAGE:C>,$<BOOL:${TFM_DEBUG_SYMBOLS}>>:-g>
23+
# $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<BOOL:${TFM_DEBUG_SYMBOLS}>>:-g>
24+
# $<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<BOOL:${CONFIG_TFM_WARNINGS_ARE_ERRORS}>>:-Werror>
25+
get_property(compile_options DIRECTORY PROPERTY COMPILE_OPTIONS)
26+
# TensorFlow Lite Micro is built with the toolchain default -f[no-]short-enums
27+
# and -f[no-]short-wchar options
28+
list(REMOVE_ITEM compile_options $<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-fshort-enums>)
29+
list(REMOVE_ITEM compile_options $<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-fshort-wchar>)
30+
# This option causes error when linking with TensorFlow Lite Micro
31+
list(REMOVE_ITEM compile_options $<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-nostdlib>)
32+
# These options are used to align with previously used Open IOT SDK toolchain flags
33+
list(APPEND compile_options $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>)
34+
list(APPEND compile_options $<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>)
35+
list(APPEND compile_options -mthumb)
36+
list(REMOVE_ITEM compile_options $<$<COMPILE_LANGUAGE:ASM>:-masm=armasm>)
37+
list(APPEND compile_options $<$<COMPILE_LANGUAGE:ASM>:-masm=auto>)
38+
list(APPEND compile_options $<$<COMPILE_LANGUAGE:ASM>:--target=arm-arm-none-eabi>)
39+
set_property(DIRECTORY PROPERTY COMPILE_OPTIONS ${compile_options})
40+
41+
endmacro()

cmake/CompilerFlagsGNUARM.cmake

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2025 Arm Limited and/or its affiliates
2+
3+
# SPDX-License-Identifier: MIT
4+
5+
macro(set_compiler_and_linker_flags)
6+
# Clear toolchain options for all languages similar to IOTSDK as FRI uses
7+
# different initialization options (such as for optimization and debug symbols)
8+
# These variables only hold -O, -g and -DNDEBUG options originally
9+
set(CMAKE_ASM_FLAGS_DEBUG "-Og -g3" CACHE STRING "" FORCE)
10+
set(CMAKE_ASM_FLAGS_RELWITHDEBINFO "-Og -g3" CACHE STRING "" FORCE)
11+
set(CMAKE_ASM_FLAGS_RELEASE "-Og" CACHE STRING "" FORCE)
12+
set(CMAKE_C_FLAGS_DEBUG "-Og -g3" CACHE STRING "" FORCE)
13+
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Og -g3" CACHE STRING "" FORCE)
14+
set(CMAKE_C_FLAGS_RELEASE "-Og" CACHE STRING "" FORCE)
15+
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g3" CACHE STRING "" FORCE)
16+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Og -g3" CACHE STRING "" FORCE)
17+
set(CMAKE_CXX_FLAGS_RELEASE "-Og" CACHE STRING "" FORCE)
18+
19+
# Customization of TF-M NS toolchain provided default options
20+
# TF-M options that are never added because the TFM_DEBUG_SYMBOLS and
21+
# CONFIG_TFM_WARNINGS_ARE_ERRORS variables are not defined during NS build:
22+
# $<$<AND:$<COMPILE_LANGUAGE:C>,$<BOOL:${TFM_DEBUG_SYMBOLS}>>:-g>
23+
# $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<BOOL:${TFM_DEBUG_SYMBOLS}>>:-g>
24+
# $<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<BOOL:${CONFIG_TFM_WARNINGS_ARE_ERRORS}>>:-Werror>
25+
get_property(compile_options DIRECTORY PROPERTY COMPILE_OPTIONS)
26+
list(REMOVE_ITEM compile_options "-specs=nano.specs")
27+
# TensorFlow Lite Micro is built with the toolchain default -f[no-]short-enums
28+
# and -f[no-]short-wchar options
29+
list(REMOVE_ITEM compile_options "-fshort-enums")
30+
# These options are used to align with previously used Open IOT SDK toolchain flags
31+
list(APPEND compile_options "-fomit-frame-pointer")
32+
list(APPEND compile_options $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>)
33+
list(APPEND compile_options $<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>)
34+
set_property(DIRECTORY PROPERTY COMPILE_OPTIONS ${compile_options})
35+
36+
get_property(link_options DIRECTORY PROPERTY LINK_OPTIONS)
37+
# These options are used to align with previously used Open IOT SDK toolchain flags
38+
list(REMOVE_ITEM link_options "-specs=nano.specs")
39+
set_property(DIRECTORY PROPERTY LINK_OPTIONS ${link_options})
40+
41+
endmacro()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2025 Arm Limited and/or its affiliates
2+
3+
# SPDX-License-Identifier: MIT
4+
5+
list(APPEND CMAKE_MODULE_PATH ${CONFIG_SPE_PATH}/cmake)
6+
7+
# A platform specific MCPU and architecture flags for NS side
8+
include(${CONFIG_SPE_PATH}/platform/cpuarch.cmake)
9+
# Include common configs exported from TF-M
10+
include(${CONFIG_SPE_PATH}/cmake/spe_config.cmake)
11+
12+
if(NOT DEFINED TFM_TOOLCHAIN_FILE)
13+
if(${TOOLCHAIN} STREQUAL "GNU")
14+
set(TFM_TOOLCHAIN_FILE ${CONFIG_SPE_PATH}/cmake/toolchain_ns_GNUARM.cmake)
15+
elseif(${TOOLCHAIN} STREQUAL "ARMCLANG")
16+
set(TFM_TOOLCHAIN_FILE ${CONFIG_SPE_PATH}/cmake/toolchain_ns_ARMCLANG.cmake)
17+
endif()
18+
endif()
19+
20+
if(${TOOLCHAIN} STREQUAL "GNU")
21+
include(${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/cmake/CompilerFlagsGNUARM.cmake)
22+
elseif(${TOOLCHAIN} STREQUAL "ARMCLANG")
23+
include(${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/cmake/CompilerFlagsARMCLANG.cmake)
24+
else()
25+
message(FATAL_ERROR "Unsupported toolchain: ${TOOLCHAIN}")
26+
endif()
27+
28+
include(${TFM_TOOLCHAIN_FILE})
Submodule library updated from c9352b5 to 96cc044

components/tools/CMakeLists.txt

Lines changed: 1 addition & 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

@@ -7,6 +7,5 @@ if(BUILD_TESTING AND NOT CMAKE_CROSSCOMPILING)
77
add_subdirectory(googletest)
88
else()
99
add_subdirectory(freertos_libraries_integration_tests)
10-
add_subdirectory(open_iot_sdk_toolchain)
1110
add_subdirectory(unity)
1211
endif()

components/tools/open_iot_sdk_toolchain/CMakeLists.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
This file was deleted.

manifest.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies:
2525
license: "BSD-3-Clause"
2626
tpip-category: "category-2"
2727
security-risk: "high"
28-
version: "c9352b59f2a501b5af3f648b3fc91065993c002f"
28+
version: "96cc044555f57b755ca3605788798b71f2c1a180"
2929
repository:
3030
type: "git"
3131
url: "https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git"
@@ -138,15 +138,6 @@ dependencies:
138138
type: "git"
139139
url: "https://github.com/intel/tinycbor"
140140
path: "components/aws_iot/tinycbor/library"
141-
- name: "toolchains"
142-
license: "Apache-2.0"
143-
tpip-category: "category-2"
144-
security-risk: "low"
145-
version: "f77e1ba2bb830f6950a88c34849cf3df9af4ad32"
146-
repository:
147-
type: "git"
148-
url: "https://git.gitlab.arm.com/iot/open-iot-sdk/toolchain.git"
149-
path: "components/tools/open_iot_sdk_toolchain/library"
150141
- name: "FreeRTOS-Libraries-Integration-Tests"
151142
license: "MIT"
152143
tpip-category: "category-2"

0 commit comments

Comments
 (0)