boards: stm32l5: Update TFM related flashing instructions
Following the work done to add TFM support on b_u585i_iot02a,
update other STM32 TFM enabled boards to benefit from the
progress made on TFM flashing instructions.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
diff --git a/boards/arm/nucleo_l552ze_q/CMakeLists.txt b/boards/arm/nucleo_l552ze_q/CMakeLists.txt
index 8400973..d170d28 100644
--- a/boards/arm/nucleo_l552ze_q/CMakeLists.txt
+++ b/boards/arm/nucleo_l552ze_q/CMakeLists.txt
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
+# Define the toolchain to be used (by eg CI)
if(${ZEPHYR_TOOLCHAIN_VARIANT} STREQUAL "zephyr")
set(COMPILER_FULL_PATH ${ZEPHYR_SDK_INSTALL_DIR}/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc)
elseif(${ZEPHYR_TOOLCHAIN_VARIANT} STREQUAL "gnuarmemb")
diff --git a/boards/arm/nucleo_l552ze_q/board.cmake b/boards/arm/nucleo_l552ze_q/board.cmake
index c1f04ce..fb1f2e4 100644
--- a/boards/arm/nucleo_l552ze_q/board.cmake
+++ b/boards/arm/nucleo_l552ze_q/board.cmake
@@ -1,6 +1,10 @@
+# SPDX-License-Identifier: Apache-2.0
if(CONFIG_BUILD_WITH_TFM)
set(FLASH_BASE_ADDRESS_S 0x0C000000)
+ # Flash merged TF-M + Zephyr binary
+ set_property(TARGET runners_yaml_props_target PROPERTY hex_file "${CMAKE_BINARY_DIR}/tfm_merged.hex")
+
if (CONFIG_HAS_FLASH_LOAD_OFFSET)
MATH(EXPR TFM_HEX_BASE_ADDRESS_NS "${FLASH_BASE_ADDRESS_S}+${CONFIG_FLASH_LOAD_OFFSET}")
else()
diff --git a/boards/arm/nucleo_l552ze_q/doc/nucleol552ze_q.rst b/boards/arm/nucleo_l552ze_q/doc/nucleol552ze_q.rst
index 1369219..3a31ecf 100644
--- a/boards/arm/nucleo_l552ze_q/doc/nucleol552ze_q.rst
+++ b/boards/arm/nucleo_l552ze_q/doc/nucleol552ze_q.rst
@@ -180,6 +180,44 @@
- :zephyr_file:`boards/arm/nucleo_l552ze_q/nucleo_l552ze_q_ns_defconfig`
- :zephyr_file:`boards/arm/nucleo_l552ze_q/nucleo_l552ze_q_ns.dts`
+Zephyr board options
+====================
+
+The STM32L552e is an SoC with Cortex-M33 architecture. Zephyr provides support
+for building for both Secure and Non-Secure firmware.
+
+The BOARD options are summarized below:
+
++----------------------+-----------------------------------------------+
+| BOARD | Description |
++======================+===============================================+
+| nucleo_l552ze_q | For building Secure (or Secure-only) firmware |
++----------------------+-----------------------------------------------+
+| nucleo_l552ze_q_ns | For building Non-Secure firmware |
++----------------------+-----------------------------------------------+
+
+Here are the instructions to build Zephyr with a non-secure configuration,
+using `tfm_ipc_` sample:
+
+ .. code-block:: bash
+
+ $ west build -b nucleo_l552ze_q_ns samples/tfm_integration/tfm_ipc/
+
+Once done, before flashing, you need to first run a generated script that
+will set platform option bytes config and erase platform (among others,
+option bit TZEN will be set).
+
+ .. code-block:: bash
+
+ $ ./build/tfm/regression.sh
+ $ west flash
+
+Please note that, after having run a TFM sample on the board, you will need to
+run `./build/tfm/regression.sh` once more to clean up the board from secure
+options and get back the platform back to a "normal" state and be able to run
+usual, non-TFM, binaries.
+Also note that, even then, TZEN will remain set, and you will need to use
+STM32CubeProgrammer_ to disable it fully, if required.
Connections and IOs
===================
@@ -346,3 +384,6 @@
.. _STM32L552 reference manual:
http://www.st.com/resource/en/reference_manual/DM00346336.pdf
+
+.. _STM32CubeProgrammer:
+ https://www.st.com/en/development-tools/stm32cubeprog.html
diff --git a/boards/arm/stm32l562e_dk/CMakeLists.txt b/boards/arm/stm32l562e_dk/CMakeLists.txt
index 4d67c64..dde7380 100644
--- a/boards/arm/stm32l562e_dk/CMakeLists.txt
+++ b/boards/arm/stm32l562e_dk/CMakeLists.txt
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
+# Define the toolchain to be used (by eg CI)
if(${ZEPHYR_TOOLCHAIN_VARIANT} STREQUAL "zephyr")
set(COMPILER_FULL_PATH ${ZEPHYR_SDK_INSTALL_DIR}/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc)
elseif(${ZEPHYR_TOOLCHAIN_VARIANT} STREQUAL "gnuarmemb")
diff --git a/boards/arm/stm32l562e_dk/board.cmake b/boards/arm/stm32l562e_dk/board.cmake
index ddc46d4..08e5d44 100644
--- a/boards/arm/stm32l562e_dk/board.cmake
+++ b/boards/arm/stm32l562e_dk/board.cmake
@@ -1,6 +1,10 @@
+# SPDX-License-Identifier: Apache-2.0
if(CONFIG_BUILD_WITH_TFM)
set(TFM_FLASH_BASE_ADDRESS 0x0C000000)
+ # Flash merged TF-M + Zephyr binary
+ set_property(TARGET runners_yaml_props_target PROPERTY hex_file "${CMAKE_BINARY_DIR}/tfm_merged.hex")
+
if (CONFIG_HAS_FLASH_LOAD_OFFSET)
MATH(EXPR TFM_HEX_BASE_ADDRESS_NS "${TFM_FLASH_BASE_ADDRESS}+${CONFIG_FLASH_LOAD_OFFSET}")
else()
diff --git a/boards/arm/stm32l562e_dk/doc/index.rst b/boards/arm/stm32l562e_dk/doc/index.rst
index 863f3be..7c4050f 100644
--- a/boards/arm/stm32l562e_dk/doc/index.rst
+++ b/boards/arm/stm32l562e_dk/doc/index.rst
@@ -206,6 +206,44 @@
- :zephyr_file:`boards/arm/stm32l562e_dk/stm32l562e_dk_ns_defconfig`
- :zephyr_file:`boards/arm/stm32l562e_dk/stm32l562e_dk_ns.dts`
+Zephyr board options
+====================
+
+The STM32L562e is an SoC with Cortex-M33 architecture. Zephyr provides support
+for building for both Secure and Non-Secure firmware.
+
+The BOARD options are summarized below:
+
++----------------------+-----------------------------------------------+
+| BOARD | Description |
++======================+===============================================+
+| stm32l562e_dk | For building Secure (or Secure-only) firmware |
++----------------------+-----------------------------------------------+
+| stm32l562e_dk_ns | For building Non-Secure firmware |
++----------------------+-----------------------------------------------+
+
+Here are the instructions to build Zephyr with a non-secure configuration,
+using `tfm_ipc_` sample:
+
+ .. code-block:: bash
+
+ $ west build -b stm32l562e_dk_ns samples/tfm_integration/tfm_ipc/
+
+Once done, before flashing, you need to first run a generated script that
+will set platform option bytes config and erase platform (among others,
+option bit TZEN will be set).
+
+ .. code-block:: bash
+
+ $ ./build/tfm/regression.sh
+ $ west flash
+
+Please note that, after having run a TFM sample on the board, you will need to
+run `./build/tfm/regression.sh` once more to clean up the board from secure
+options and get back the platform back to a "normal" state and be able to run
+usual, non-TFM, binaries.
+Also note that, even then, TZEN will remain set, and you will need to use
+STM32CubeProgrammer_ to disable it fully, if required.
Connections and IOs
===================
@@ -344,3 +382,6 @@
.. _STM32L562 reference manual:
http://www.st.com/resource/en/reference_manual/DM00346336.pdf
+
+.. _STM32CubeProgrammer:
+ https://www.st.com/en/development-tools/stm32cubeprog.html
diff --git a/samples/tfm_integration/tfm_ipc/README.rst b/samples/tfm_integration/tfm_ipc/README.rst
index c7f7f34..3f519b3 100644
--- a/samples/tfm_integration/tfm_ipc/README.rst
+++ b/samples/tfm_integration/tfm_ipc/README.rst
@@ -135,7 +135,7 @@
.. code-block:: bash
$ ./build/tfm/regression.sh
- $ west flash --hex-file build/tfm_merged.hex
+ $ west flash
.. 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`` (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.