Skip to content

Commit 0dcd6bd

Browse files
theotherjimmymbolivar-nordic
authored andcommitted
modules-tfm: Configure image versions with KConfig
Previously, you were required to set the image versions through the CMake variables TFM_IMAGE_VERSION_{S,NS}. For better integration with the rest of the zephyr build system, these are now KConfig variables with the same name. Signed-off-by: Jimmy Brisson <[email protected]>
1 parent b6d4788 commit 0dcd6bd

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

modules/trusted-firmware-m/CMakeLists.txt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,6 @@ if (CONFIG_BUILD_WITH_TFM)
347347
# To ensure that generated include files are created before they are used.
348348
add_dependencies(zephyr_interface tfm)
349349

350-
# Set default image versions if not defined elsewhere
351-
if (NOT DEFINED TFM_IMAGE_VERSION_S)
352-
set(TFM_IMAGE_VERSION_S 0.0.0+0)
353-
endif()
354-
355-
if (NOT DEFINED TFM_IMAGE_VERSION_NS)
356-
set(TFM_IMAGE_VERSION_NS 0.0.0+0)
357-
endif()
358-
359350
if (CONFIG_TFM_BL2)
360351
set(PREPROCESSED_FILE_S "${TFM_BINARY_DIR}/bl2/ext/mcuboot/CMakeFiles/signing_layout_s.dir/signing_layout_s.o")
361352
set(PREPROCESSED_FILE_NS "${TFM_BINARY_DIR}/bl2/ext/mcuboot/CMakeFiles/signing_layout_ns.dir/signing_layout_ns.o")
@@ -390,7 +381,7 @@ if (CONFIG_BUILD_WITH_TFM)
390381
-k ${CONFIG_TFM_KEY_FILE_${SUFFIX}}
391382
--public-key-format ${TFM_PUBLIC_KEY_FORMAT}
392383
--align 1
393-
-v ${TFM_IMAGE_VERSION_${SUFFIX}}
384+
-v ${CONFIG_TFM_IMAGE_VERSION_${SUFFIX}}
394385
${pad_args}
395386
${HEX_ADDR_ARGS_${SUFFIX}}
396387
${ADD_${SUFFIX}_IMAGE_MIN_VER}

modules/trusted-firmware-m/Kconfig.tfm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,22 @@ config TFM_BL2_NOT_SUPPORTED
173173
Hidden option to mark the BL2, the MCUBoot included in TF-M, as not supported.
174174
Platforms that don't use BL2 should select this option.
175175

176+
config TFM_IMAGE_VERSION_S
177+
string "Version of the Secure Image"
178+
default "0.0.0+0"
179+
help
180+
MCUBoot may be configured to prevent rollback prevention based on image
181+
versions of both the secure firmware and non-secure firmware. This sets
182+
the secure firmware's version for rollback prevention.
183+
184+
config TFM_IMAGE_VERSION_NS
185+
string "Version of the Non-Secure Image"
186+
default "0.0.0+0"
187+
help
188+
MCUBoot may be configured to prevent rollback prevention based on image
189+
versions of both the secure firmware and non-secure firmware. This sets
190+
the non-secure firmware's version for rollback prevention.
191+
176192
config TFM_BL2
177193
bool "Add MCUboot to TFM"
178194
depends on !TFM_BL2_NOT_SUPPORTED

samples/tfm_integration/psa_firmware/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
cmake_minimum_required(VERSION 3.13.1)
44

5-
if (NOT TFM_IMAGE_VERSION_NS)
6-
set(TFM_IMAGE_VERSION_NS 0.0.1+0)
7-
endif()
8-
95
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
106

117
project(tfm_psa_firmware)

samples/tfm_integration/psa_firmware/prj.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ CONFIG_BUILD_WITH_TFM=y
88
CONFIG_TFM_BL2=y
99
CONFIG_TFM_IPC=y
1010
CONFIG_TFM_PARTITION_FIRMWARE_UPDATE=y
11+
CONFIG_TFM_IMAGE_VERSION_S="0.0.3"
12+
CONFIG_TFM_IMAGE_VERSION_NS="0.0.1"
1113

1214
# The Zephyr CMSIS emulation assumes that ticks are ms, currently
1315
CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000

0 commit comments

Comments
 (0)