Skip to content

Commit 883394f

Browse files
committed
boards: stm32l562e_dk: Add non secure target
This commit adds a second target for the stm32l562e_dk board. The non secure target can be configured for TFM IPC application. Signed-off-by: Yestin Sun <[email protected]>
1 parent e285695 commit 883394f

File tree

7 files changed

+137
-0
lines changed

7 files changed

+137
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
if(${ZEPHYR_TOOLCHAIN_VARIANT} STREQUAL "zephyr")
4+
set(COMPILER_FULL_PATH ${ZEPHYR_SDK_INSTALL_DIR}/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc)
5+
elseif(${ZEPHYR_TOOLCHAIN_VARIANT} STREQUAL "gnuarmemb")
6+
set(COMPILER_FULL_PATH ${GNUARMEMB_TOOLCHAIN_PATH}/bin/arm-none-eabi-gcc)
7+
endif()
8+
9+
if(CONFIG_BUILD_WITH_TFM)
10+
set_property(GLOBAL APPEND PROPERTY extra_post_build_byproducts
11+
#Execute post build script postbuild.sh
12+
COMMAND ${CMAKE_BINARY_DIR}/tfm/postbuild.sh ${COMPILER_FULL_PATH}
13+
)
14+
endif()

boards/arm/stm32l562e_dk/Kconfig.defconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,16 @@ config BT_HCI_VS_EXT
3232

3333
endif # BT
3434

35+
if TRUSTED_EXECUTION_NONSECURE
36+
37+
# Get flash configuration for NS image from dts flash partition
38+
config USE_DT_CODE_PARTITION
39+
default y
40+
41+
config TFM_ISOLATION_LEVEL
42+
default 2
43+
depends on BUILD_WITH_TFM
44+
45+
endif # TRUSTED_EXECUTION_NONSECURE
46+
3547
endif # BOARD_STM32L562E_DK

boards/arm/stm32l562e_dk/board.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
if(CONFIG_BUILD_WITH_TFM)
2+
set(TFM_FLASH_BASE_ADDRESS 0x0C000000)
3+
4+
if (CONFIG_HAS_FLASH_LOAD_OFFSET)
5+
MATH(EXPR TFM_HEX_BASE_ADDRESS_NS "${TFM_FLASH_BASE_ADDRESS}+${CONFIG_FLASH_LOAD_OFFSET}")
6+
else()
7+
set(TFM_HEX_BASE_ADDRESS_NS ${TFM_TFM_FLASH_BASE_ADDRESS})
8+
endif()
9+
endif()
10+
111
set_ifndef(BOARD_DEBUG_RUNNER pyocd)
212
set_ifndef(BOARD_FLASH_RUNNER pyocd)
313

boards/arm/stm32l562e_dk/doc/index.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ The Zephyr stm32l562e_dk board configuration supports the following hardware fea
166166
+-----------+------------+-------------------------------------+
167167
| SPI | on-chip | spi |
168168
+-----------+------------+-------------------------------------+
169+
| TrustZone | on-chip | Trusted Firmware-M |
170+
+-----------+------------+-------------------------------------+
169171

170172
Other hardware features are not yet supported on this Zephyr port.
171173

@@ -254,6 +256,20 @@ You should see the following message on the console:
254256
255257
Hello World! stm32l562e_dk
256258
259+
Building Secure/Non-Secure Zephyr applications with Arm |reg| TrustZone |reg|
260+
-----------------------------------------------------------------------------
261+
262+
The TF-M integration sample :ref:`tfm_ipc` can be run on a STM32L562E-DK Discovery,
263+
using the ``stm32l562e_dk_ns`` target. When building a ``*_ns`` image with TF-M,
264+
a ``build/tfm/postbuild.sh`` bash script will be run automatically as a post-build step
265+
to make some required flash layout changes. The ``build/tfm/regression.sh`` script will
266+
need to be run to perform device initialization, and then run ``west flash --hex-file build/tfm_merged.hex``
267+
to flash the board.
268+
269+
Check the ``build/tfm`` directory to ensure that the commands required by these scripts
270+
(``readlink``, etc.) are available on your system. Please also check ``STM32_Programmer_CLI``
271+
used for initialization is available in the PATH.
272+
257273
Debugging
258274
=========
259275

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2021 Yestin Sun
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/dts-v1/;
8+
#include "stm32l562e_dk_common.dtsi"
9+
10+
/ {
11+
model = "STMicroelectronics STM32L562E-DK Discovery board";
12+
compatible = "st,stm32l562e-dk";
13+
14+
#address-cells = <1>;
15+
#size-cells = <1>;
16+
17+
chosen {
18+
zephyr,console = &usart1;
19+
zephyr,shell-uart = &usart1;
20+
zephyr,sram = &sram0;
21+
zephyr,flash = &flash0;
22+
};
23+
24+
aliases {
25+
led0 = &green_led_10;
26+
sw0 = &user_button;
27+
};
28+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
identifier: stm32l562e_dk_ns
2+
name: ST STM32L562E-DK Discovery non secure
3+
type: mcu
4+
arch: arm
5+
toolchain:
6+
- zephyr
7+
- gnuarmemb
8+
supported:
9+
- gpio
10+
- i2c
11+
- lsm6dso
12+
ram: 192
13+
flash: 512
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
CONFIG_SOC_SERIES_STM32L5X=y
4+
CONFIG_SOC_STM32L562XX=y
5+
# 110MHz system clock
6+
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=110000000
7+
8+
# enable uart driver
9+
CONFIG_SERIAL=y
10+
11+
# enable pinmux
12+
CONFIG_PINMUX=y
13+
14+
# enable GPIO
15+
CONFIG_GPIO=y
16+
17+
# clock configuration
18+
CONFIG_CLOCK_CONTROL=y
19+
# SYSCLK selection
20+
CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
21+
# PLL configuration
22+
CONFIG_CLOCK_STM32_PLL_SRC_MSI=y
23+
CONFIG_CLOCK_STM32_MSI_RANGE=6
24+
# produce 110MHz clock at PLL output
25+
CONFIG_CLOCK_STM32_PLL_M_DIVISOR=1
26+
CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER=55
27+
CONFIG_CLOCK_STM32_PLL_P_DIVISOR=7
28+
CONFIG_CLOCK_STM32_PLL_Q_DIVISOR=2
29+
CONFIG_CLOCK_STM32_PLL_R_DIVISOR=2
30+
CONFIG_CLOCK_STM32_AHB_PRESCALER=1
31+
CONFIG_CLOCK_STM32_APB1_PRESCALER=1
32+
CONFIG_CLOCK_STM32_APB2_PRESCALER=1
33+
34+
# console
35+
CONFIG_CONSOLE=y
36+
CONFIG_UART_CONSOLE=y
37+
38+
# Enable MPU
39+
CONFIG_ARM_MPU=y
40+
41+
CONFIG_ARM_TRUSTZONE_M=y
42+
CONFIG_CORTEX_M_SYSTICK=y
43+
CONFIG_RUNTIME_NMI=y
44+
CONFIG_TRUSTED_EXECUTION_NONSECURE=y

0 commit comments

Comments
 (0)