From 46cab056bc6418cf880ac17fda000c8635723885 Mon Sep 17 00:00:00 2001 From: Yestin Sun Date: Tue, 5 Jan 2021 15:27:12 -0800 Subject: [PATCH] boards: stm32l562e_dk: Enable TF-M IPC application This commit enables the TF-M IPC sample application on stm32l562e_dk board. It provides device tree flash partition as an overlay in order to configure and flash the bl2, secure/non secure firmwares. Signed-off-by: Yestin Sun --- modules/trusted-firmware-m/Kconfig | 1 + samples/tfm_integration/tfm_ipc/README.rst | 21 ++++--- .../tfm_ipc/boards/stm32l562e_dk_ns.overlay | 55 +++++++++++++++++++ samples/tfm_integration/tfm_ipc/sample.yaml | 2 +- 4 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 samples/tfm_integration/tfm_ipc/boards/stm32l562e_dk_ns.overlay diff --git a/modules/trusted-firmware-m/Kconfig b/modules/trusted-firmware-m/Kconfig index 097cf138ed0..6530b401268 100644 --- a/modules/trusted-firmware-m/Kconfig +++ b/modules/trusted-firmware-m/Kconfig @@ -14,6 +14,7 @@ config TFM_BOARD default "nxp/lpcxpresso55s69" if BOARD_LPCXPRESSO55S69_CPU0 default "mps2/an521" if BOARD_MPS2_AN521 default "stm/nucleo_l552ze_q" if BOARD_NUCLEO_L552ZE_Q + default "stm/stm32l562e_dk" if BOARD_STM32L562E_DK default "musca_b1" if BOARD_MUSCA_B1 default "musca_s1" if BOARD_MUSCA_S1 help diff --git a/samples/tfm_integration/tfm_ipc/README.rst b/samples/tfm_integration/tfm_ipc/README.rst index b76255b3af0..848c63d3fe8 100644 --- a/samples/tfm_integration/tfm_ipc/README.rst +++ b/samples/tfm_integration/tfm_ipc/README.rst @@ -103,33 +103,38 @@ Or, post build: $ ninja run -On ST Nucleo L552ZE Q: -====================== +On ST Nucleo L552ZE Q or STM32L562E-DK Discovery: +================================================= This sample was tested on Ubuntu 18.04 with Zephyr SDK 0.11.3. Build Zephyr with a non-secure configuration: + Example, for building non-secure configuration for Nucleo L552ZE Q + .. code-block:: bash $ west build -b nucleo_l552ze_q_ns samples/tfm_integration/tfm_ipc/ -Two scripts are avalaible in the ``build/tfm`` folder: + Example, for building non-secure configuration for STM32L562E-DK Discovery + + .. code-block:: bash + + $ west build -b stm32l562e_dk_ns samples/tfm_integration/tfm_ipc/ + +The script to initialize the device is avalaible in the ``build/tfm`` folder: - ``regression.sh``: Sets platform option bytes config and erase platform. - - ``TFM_UPDATE.sh``: Writes bl2, secure, and non secure image in target. Run them in the following order to flash the board: .. code-block:: bash $ ./build/tfm/regression.sh - $ ./build/tfm/TFM_UPDATE.sh - -Reset the board. + $ west flash --hex-file build/tfm_merged.hex .. note:: - Note that ``arm-none-eabi-gcc`` should be available in the PATH variable and that ``STM32_Programmer_CLI`` is required to run ``regression.sh`` and ``TFM_UPDATE.sh`` (see https://www.st.com/en/development-tools/stm32cubeprog.html). If you are still having trouble running these scripts, check the Programming and Debugging section of the :ref:`nucleo_l552ze_q_board` documentation. + Note that ``arm-none-eabi-gcc`` should be available in the PATH variable and that ``STM32_Programmer_CLI`` is required to run ``regression.sh`` (see https://www.st.com/en/development-tools/stm32cubeprog.html). If you are still having trouble running these scripts, check the Programming and Debugging section of the :ref:`nucleo_l552ze_q_board` or :ref:`stm32l562e_dk_board` documentation. On LPCxpresso55S69: =================== diff --git a/samples/tfm_integration/tfm_ipc/boards/stm32l562e_dk_ns.overlay b/samples/tfm_integration/tfm_ipc/boards/stm32l562e_dk_ns.overlay new file mode 100644 index 00000000000..b36ca6bfeb9 --- /dev/null +++ b/samples/tfm_integration/tfm_ipc/boards/stm32l562e_dk_ns.overlay @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2021 Yestin Sun + * + * SPDX-License-Identifier: Apache-2.0 + */ + + /* This partition table should be used along with TFM configuration: + * - TFM_PSA_API=ON (IPC) + * - ISOLATION_LEVEL 2 + * - TEST_S=ON (REGRESSION) + * - TEST_NS=OFF (By default) + * + * In this configuration, TFM binary includes tests. As a consequence, + * its size is bloated and it is not possible to set secondary partitions + * for secured or non secured images. + */ + +/ { + chosen { + zephyr,code-partition = &slot1_partition; + }; +}; + +&flash0 { + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x00000000 0x00013000>; + read-only; + }; + /* Secure image primary slot */ + slot0_partition: partition@00013000 { + label = "image-0"; + reg = <0x00013000 0x00038000>; + }; + /* Non-secure image primary slot */ + slot1_partition: partition@0004B000 { + label = "image-1"; + reg = <0x0004B000 0x0002A000>; + }; + /* + * The flash starting at 0x7F000 and ending at + * 0x80000 is reserved for the application. + */ + storage_partition: partition@7F000 { + label = "storage"; + reg = <0x0007F000 0x00001000>; + }; + }; +}; diff --git a/samples/tfm_integration/tfm_ipc/sample.yaml b/samples/tfm_integration/tfm_ipc/sample.yaml index 96c8f46f0dc..7814f173fb9 100644 --- a/samples/tfm_integration/tfm_ipc/sample.yaml +++ b/samples/tfm_integration/tfm_ipc/sample.yaml @@ -7,7 +7,7 @@ tests: tags: introduction tfm platform_allow: mps2_an521_nonsecure lpcxpresso55s69_ns nrf5340dk_nrf5340_cpuappns nrf9160dk_nrf9160ns nucleo_l552ze_q_ns - v2m_musca_s1_nonsecure + stm32l562e_dk_ns v2m_musca_s1_nonsecure harness: console harness_config: type: multi_line