Skip to content

Commit 97f406c

Browse files
committed
soc: cyw20829: add support of Secure LCS
Enable support of SECURE LCS stage. In this stage, the protection state is set to “secure”. A secured device will boot only when the authentication of its flash boot and application code succeeds Signed-off-by: Sreeram Tatapudi <[email protected]>
1 parent d4cef82 commit 97f406c

File tree

4 files changed

+101
-3
lines changed

4 files changed

+101
-3
lines changed

boards/infineon/cyw920829m2evk_02/board.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ endif()
1818
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
1919
board_runner_args(jlink "--device=CYW20829_tm")
2020
include (${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
21+
22+
set_property(TARGET runners_yaml_props_target PROPERTY hex_file zephyr_merged.hex)

soc/infineon/cat1b/cyw20829/CMakeLists.txt

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,78 @@ math(EXPR flash_addr_offset
3030
OUTPUT_FORMAT HEXADECIMAL
3131
)
3232
set(gen_app_header_args --flash_addr_offset ${flash_addr_offset})
33+
set(app_signed_enc_path ${ZEPHYR_BINARY_DIR}/${KERNEL_NAME})
34+
35+
if(CONFIG_INFINEON_SECURE_LCS OR CONFIG_BOOTLOADER_MCUBOOT)
36+
# Check cysecuretools
37+
find_program(CYSECURETOOLS cysecuretools)
38+
if(NOT CYSECURETOOLS)
39+
message(FATAL_ERROR "Can't find cysecuretools. To fix, install cysecuretools with pip3.")
40+
else()
41+
message("-- Found cysecuretools: ${CYSECURETOOLS}")
42+
endif()
43+
endif()
44+
45+
if(CONFIG_INFINEON_SECURE_LCS)
46+
set(default_policy)
47+
set(default_policy_name)
48+
49+
# Cysecuretools policy.
50+
if(NOT CONFIG_INFINEON_SECURE_POLICY)
51+
# Get default cysecuretools policy
52+
if(CONFIG_INFINEON_SECURE_LCS)
53+
message(INFO "CONFIG_INFINEON_SECURE_POLICY was not defined.")
54+
set(default_policy_name policy_secure.json)
55+
else()
56+
set(default_policy_name policy_no_secure.json)
57+
endif()
58+
endif()
59+
60+
find_file(
61+
default_policy
62+
NAMES
63+
${CONFIG_INFINEON_SECURE_POLICY}
64+
${default_policy_name}
65+
PATHS
66+
${APPLICATION_SOURCE_DIR}
67+
${ZEPHYR_BASE}
68+
NO_DEFAULT_PATH
69+
)
70+
71+
if(NOT default_policy)
72+
message(FATAL_ERROR "Can't find policy:${CONFIG_INFINEON_SECURE_POLICY}"
73+
"/${default_policy_name}"
74+
"Checked locations: ${APPLICATION_SOURCE_DIR}, ${ZEPHYR_BASE}")
75+
endif()
76+
77+
set(cysecuretools_policy ${default_policy} CACHE PATH "cysecuretools policy")
78+
message("-- Using cysecuretools policy: ${cysecuretools_policy}")
79+
endif()
80+
81+
if(CONFIG_INFINEON_SECURE_LCS)
82+
#
83+
# Addition postbuild action for SECURE LCS
84+
#
85+
set(gen_app_header_args ${gen_app_header_args} --secure_lcs True)
86+
set(app_signed_enc_path ${ZEPHYR_BINARY_DIR}/${KERNEL_NAME}.signed)
87+
88+
if(CONFIG_INFINEON_SMIF_ENCRYPTION)
89+
set(gen_app_header_args ${gen_app_header_args} --smif-config ${ZEPHYR_BINARY_DIR}/nonce-output.bin)
90+
set(enc_option --encrypt --nonce-output nonce-output.bin)
91+
set(app_signed_enc_path ${ZEPHYR_BINARY_DIR}/${KERNEL_NAME}.signed.encrypted)
92+
endif()
93+
94+
set(bin2hex_option bin2hex --image ${app_signed_enc_path}.bin --output ${app_signed_enc_path}.hex --offset 0x60000030)
95+
96+
# Sign Zephyr L1 app in SECURE LCS
97+
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
98+
COMMAND ${CYSECURETOOLS} -q -t cyw20829
99+
-p ${cysecuretools_policy} sign-image --image-format bootrom_next_app
100+
-i ${ZEPHYR_BINARY_DIR}/${KERNEL_BIN_NAME} -k 0 -o ${app_signed_enc_path}.bin
101+
--slot-size ${CONFIG_FLASH_LOAD_SIZE} --app-addr 0x08000030
102+
${enc_option} ${bin2hex_option}
103+
)
104+
endif()
33105

34106
# Generate platform specific header (TOC2, l1_desc, etc)
35107
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND
@@ -39,9 +111,13 @@ set_property(GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND
39111
--bootstrap-dst-addr ${bootstrap_dst_addr}
40112
)
41113

114+
set(MERGED_FILE ${CMAKE_BINARY_DIR}/zephyr/zephyr_merged.hex)
115+
42116
# Merge platform specific header and zephyr image to a single binary.
43117
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
44118
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/build/mergehex.py
45-
-o ${ZEPHYR_BINARY_DIR}/${KERNEL_NAME}.hex
46-
${app_temp_path}.hex ${ZEPHYR_BINARY_DIR}/app_header.hex
119+
-o ${MERGED_FILE}
120+
${app_signed_enc_path}.hex ${ZEPHYR_BINARY_DIR}/app_header.hex
47121
)
122+
123+
set_property(GLOBAL APPEND PROPERTY extra_post_build_byproducts ${MERGED_FILE})

soc/infineon/cat1b/cyw20829/Kconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,23 @@ config SOC_SERIES_CYW20829
1616
select BUILD_OUTPUT_HEX
1717
select BUILD_OUTPUT_BIN
1818
select SOC_EARLY_INIT_HOOK
19+
20+
config INFINEON_SECURE_LCS
21+
bool "Secure LCS stage support"
22+
help
23+
Enable support of SECURE LCS stage. In this stage, the protection
24+
state is set to “secure”. A secured device will boot only when the
25+
authentication of its flash boot and application code succeeds.
26+
27+
config INFINEON_SECURE_POLICY
28+
string "Path to policy JSON file"
29+
help
30+
Policy is a text file in JSON format that contains a set of properties
31+
for the device configuration (e.g., enabling/disabling debug access ports,
32+
SMIF configuration, keys information, etc).
33+
34+
config INFINEON_SMIF_ENCRYPTION
35+
bool "SMIF encryption support"
36+
depends on INFINEON_SECURE_LCS
37+
help
38+
Enables SMIF encryption.

tests/application_development/vector_table_relocation/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#if (defined(CONFIG_ARM_MPU) && !defined(CONFIG_CPU_HAS_NXP_SYSMPU))
2929
#include <cmsis_core.h>
30-
void disable_mpu_rasr_xn(void)
30+
static void disable_mpu_rasr_xn(void)
3131
{
3232
uint32_t index;
3333
/* Kept the max index as 8(irrespective of soc) because the sram

0 commit comments

Comments
 (0)