David Vincze | aa40361 | 2024-12-02 10:00:09 +0000 | [diff] [blame] | 1 | ################################### |
| 2 | Run TF-M regression tests with eRPC |
| 3 | ################################### |
| 4 | |
| 5 | This document aims to show the steps of building and running the NS regression |
| 6 | test suites based on TF-M's eRPC framework and to serve as an example |
| 7 | which can be followed for other tests and basically for any application |
| 8 | that wants to interface with TF-M through the PSA client APIs using eRPC. |
| 9 | |
| 10 | The description assumes that the basic steps and requirements [1]_ of building |
| 11 | the TF-M regression test code are known. |
| 12 | |
| 13 | *************************** |
| 14 | eRPC specific build options |
| 15 | *************************** |
| 16 | |
| 17 | When using the eRPC framework it is required to provide a few additional |
| 18 | parameters to specify which kind of transportation should be used for a given |
| 19 | target. These parameters depending on the transport of choice are listed below |
| 20 | and should be passed as CMake command line parameters. |
| 21 | |
| 22 | +----------------+--------------------------------------------------------------------------+ |
| 23 | | Parameter | Description | |
| 24 | +================+==========================================================================+ |
| 25 | | ERPC_TRANSPORT | Selected method of transportation. It can be either ``TCP`` or ``UART``. | |
| 26 | +----------------+--------------------------------------------------------------------------+ |
| 27 | | ERPC_HOST | Hostname/IP address of eRPC server to connect to (for TCP only). | |
| 28 | +----------------+--------------------------------------------------------------------------+ |
| 29 | | ERPC_PORT | Port number of eRPC server to connect to (for TCP only). | |
| 30 | +----------------+--------------------------------------------------------------------------+ |
| 31 | | PORT_NAME | Serial port to use for communication with eRPC server (for UART only). | |
| 32 | +----------------+--------------------------------------------------------------------------+ |
| 33 | |
| 34 | As it was already mentioned in the |
| 35 | :doc:`TF-M eRPC Test Framework <tfm_test_suites_addition>` documentation, |
| 36 | it is recommended to assign a separate UART device to the eRPC |
| 37 | communication to avoid collision with other data (e.g. log messages) being sent |
| 38 | on UART. In the simplest configuration if there is only one serial device |
| 39 | available on the target (due to any limitation) all types of log messages from |
| 40 | the device must be disabled. When the build type is set to either |
| 41 | ``MinSizeRel`` (default) or ``Release`` all logging in TF-M |
| 42 | (BLx, SPM, Secure Partitions) is disabled automatically. Otherwise, one must |
| 43 | disable logging manually by setting the following build options |
| 44 | (if available on the given target): |
| 45 | |
| 46 | +-------------------------+-------------------------------------+ |
| 47 | | Parameter | Value | |
| 48 | +=========================+=====================================+ |
| 49 | | TFM_BL1_LOG_LEVEL | ``LOG_LEVEL_NONE`` | |
| 50 | +-------------------------+-------------------------------------+ |
| 51 | | MCUBOOT_LOG_LEVEL | ``OFF`` | |
| 52 | +-------------------------+-------------------------------------+ |
Jackson Cooper-Driver | a60f992 | 2025-03-13 16:15:24 +0000 | [diff] [blame^] | 53 | | TFM_SPM_LOG_LEVEL | ``LOG_LEVEL_NONE`` | |
David Vincze | aa40361 | 2024-12-02 10:00:09 +0000 | [diff] [blame] | 54 | +-------------------------+-------------------------------------+ |
Jackson Cooper-Driver | e7c8f8e | 2025-03-04 10:28:59 +0000 | [diff] [blame] | 55 | | TFM_PARTITION_LOG_LEVEL | ``LOG_LEVEL_NONE`` | |
David Vincze | aa40361 | 2024-12-02 10:00:09 +0000 | [diff] [blame] | 56 | +-------------------------+-------------------------------------+ |
| 57 | |
| 58 | Execute tests on TC3 FVP with TCP Transport |
| 59 | =========================================== |
| 60 | |
| 61 | On TC3 we are using the same UART device for eRPC communication as for logging. |
| 62 | In this case we are setting the build type to ``Release`` and therefore we do |
| 63 | not need to manually disable any logs. |
| 64 | |
| 65 | Build instructions for TC3 |
| 66 | -------------------------- |
| 67 | |
| 68 | Build TF-M (target SPE image): |
| 69 | |
| 70 | .. code-block:: bash |
| 71 | |
| 72 | cd <TF-M tests base folder> |
| 73 | cmake -S tests_reg/spe -B <TF-M build dir> \ |
| 74 | -DTFM_PLATFORM=arm/rse/tc/tc3 \ |
| 75 | -DCONFIG_TFM_SOURCE_PATH=<TF-M source dir absolute path> \ |
| 76 | -DCMAKE_BUILD_TYPE=Release \ |
| 77 | -DTFM_TOOLCHAIN_FILE=<TF-M source dir absolute path>/toolchain_GNUARM.cmake \ |
| 78 | -DMCUBOOT_IMAGE_NUMBER=2 \ |
| 79 | -DRSE_LOAD_NS_IMAGE=ON \ |
| 80 | -DTEST_NS=ON |
| 81 | cmake --build <TF-M build dir> -- install |
| 82 | |
| 83 | Build eRPC server application (target NSPE image): |
| 84 | |
| 85 | .. code-block:: bash |
| 86 | |
| 87 | cd <TF-M tests base folder> |
| 88 | cmake -S erpc/server/app -B <NS build dir> \ |
| 89 | -DCONFIG_SPE_PATH=<TF-M build dir>/api_ns \ |
| 90 | -DCMAKE_BUILD_TYPE=Release |
| 91 | cmake --build <NS build dir> |
| 92 | |
| 93 | Build test application and eRPC client (host image): |
| 94 | |
| 95 | .. code-block:: bash |
| 96 | |
| 97 | cd <TF-M tests base folder>/erpc/tfm_reg_tests |
| 98 | cmake -S . -B <Test app build dir> \ |
| 99 | -DCONFIG_SPE_PATH=<TF-M build dir>/api_ns \ |
| 100 | -DERPC_REPO_PATH=<NS build dir>/lib/ext/erpc-src \ |
| 101 | -DERPC_TRANSPORT=TCP \ |
| 102 | -DERPC_HOST="0.0.0.0" \ |
| 103 | -DERPC_PORT=5005 |
| 104 | cmake --build <Test app build dir> |
| 105 | |
| 106 | Run the code on the TC3 FVP model |
| 107 | --------------------------------- |
| 108 | |
| 109 | The basic steps of creating the required images (e.g ROM and flash images) |
| 110 | for the Total Compute TC3 platform are covered in the `RSE documentation |
| 111 | <https://trustedfirmware-m.readthedocs.io/en/latest/platform/arm/rse/readme.html>`_. |
| 112 | To run the tests, the latest available TC3 FVP (Fixed Virtual Platform) model |
| 113 | can be downloaded from the `Arm Developer Hub |
| 114 | <https://developer.arm.com/Tools%20and%20Software/Fixed%20Virtual%20Platforms/Total%20Compute%20FVPs>`_. |
| 115 | |
| 116 | .. code-block:: bash |
| 117 | |
| 118 | <PATH to FVP model folder>FVP_TC3 \ |
| 119 | -C css.terminal_uart_ap.start_port=5000 \ |
| 120 | -C css.terminal_uart1_ap.start_port=5001 \ |
| 121 | -C css.sms.scp.terminal_uart.start_port=5002 \ |
| 122 | -C css.sms.rse_terminal_uart.start_port=5003 \ |
| 123 | -C soc.terminal_s0.start_port=5004 \ |
| 124 | -C soc.terminal_s1.start_port=5005 \ |
| 125 | -C soc.terminal_s1.start_telnet=0 \ |
| 126 | -C soc.terminal_s1.quiet=1 \ |
| 127 | -C soc.terminal_s1.mode=raw \ |
| 128 | -C soc.pl011_uart1.unbuffered_output=1 \ |
| 129 | -C soc.pl011_uart1.enable_dc4=0 \ |
| 130 | -C displayController=2 \ |
| 131 | -C css.sms.rse.sic.SIC_AUTH_ENABLE=1 \ |
| 132 | -C css.sms.rse.sic.SIC_DECRYPT_ENABLE=1 \ |
| 133 | -C css.sms.rse.VMADDRWIDTH=16 \ |
| 134 | -C css.sms.rse.intchecker.ICBC_RESET_VALUE=0x0000011B \ |
| 135 | -C css.sms.rse.rom.raw_image=<rse_rom.bin> \ |
| 136 | -C board.flashloader0.fname=<host_flash_fip.bin> \ |
| 137 | --data css.sms.rse.sram0=<encrypted_cm_provisioning_bundle_0.bin>@0x400 \ |
| 138 | --data css.sms.rse.sram1=<encrypted_dm_provisioning_bundle_0.bin>@0x0 |
| 139 | |
| 140 | Execute tests on AN521 FVP with TCP Transport |
| 141 | ============================================= |
| 142 | |
| 143 | On this platform several UART devices are available, therefore we can assign |
| 144 | an unused one exclusively to the eRPC communication while we can keep all |
| 145 | logging enabled. |
| 146 | |
| 147 | Build instructions for AN521 |
| 148 | ---------------------------- |
| 149 | |
| 150 | Build TF-M (device SPE image): |
| 151 | |
| 152 | .. code-block:: bash |
| 153 | |
| 154 | cd <TF-M tests base folder> |
| 155 | cmake -S tests_reg/spe -B <TF-M build dir> \ |
| 156 | -DTFM_PLATFORM=arm/mps2/an521 \ |
| 157 | -DCONFIG_TFM_SOURCE_PATH=<TF-M source dir absolute path> \ |
| 158 | -DCMAKE_BUILD_TYPE=Debug \ |
| 159 | -DTFM_TOOLCHAIN_FILE=<TF-M source dir absolute path>/toolchain_GNUARM.cmake \ |
| 160 | -DTEST_NS=ON |
| 161 | cmake --build <TF-M build dir> -- install |
| 162 | |
| 163 | Build eRPC server application (device NSPE image): |
| 164 | |
| 165 | .. code-block:: bash |
| 166 | |
| 167 | cd <TF-M tests base folder> |
| 168 | cmake -S erpc/server/app -B <NS build dir> \ |
| 169 | -DCONFIG_SPE_PATH=<TF-M build dir>/api_ns \ |
| 170 | -DCMAKE_BUILD_TYPE=Debug |
| 171 | cmake --build <NS build dir> |
| 172 | |
| 173 | |
| 174 | Build test application and eRPC client (host image): |
| 175 | |
| 176 | .. code-block:: bash |
| 177 | |
| 178 | cd <TF-M tests base folder>/erpc/tfm_reg_tests |
| 179 | cmake -S . -B <Test app build dir> \ |
| 180 | -DCONFIG_SPE_PATH=<TF-M build dir>/api_ns \ |
| 181 | -DERPC_REPO_PATH=<NS build dir>/lib/ext/erpc-src \ |
| 182 | -DERPC_TRANSPORT=TCP \ |
| 183 | -DERPC_HOST="0.0.0.0" \ |
| 184 | -DERPC_PORT=5001 |
| 185 | cmake --build <Test app build dir> |
| 186 | |
| 187 | Run the code on the AN521 FVP model |
| 188 | ----------------------------------- |
| 189 | |
| 190 | To run the test application we are using the FVP_MPS2_AEMv8M model provided |
| 191 | by `Arm Development Studio`_ or the FVP can be downloaded from the |
| 192 | `Developer Hub <https://developer.arm.com/Tools%20and%20Software/Fixed%20Virtual%20Platforms/Arm%20Architecture%20FVPs>`_. |
| 193 | |
| 194 | .. code-block:: bash |
| 195 | |
| 196 | <PATH to FVP model folder>/FVP_MPS2_AEMv8M \ |
| 197 | --parameter fvp_mps2.platform_type=2 \ |
| 198 | --parameter cpu0.baseline=0 \ |
| 199 | --parameter cpu0.INITVTOR_S=0x10000000 \ |
| 200 | --parameter cpu0.semihosting-enable=0 \ |
| 201 | --parameter fvp_mps2.DISABLE_GATING=0 \ |
| 202 | --parameter fvp_mps2.telnetterminal0.start_telnet=1 \ |
| 203 | --parameter fvp_mps2.telnetterminal1.start_telnet=0 \ |
| 204 | --parameter fvp_mps2.telnetterminal2.start_telnet=0 \ |
| 205 | --parameter fvp_mps2.telnetterminal0.quiet=0 \ |
| 206 | --parameter fvp_mps2.telnetterminal1.quiet=1 \ |
| 207 | --parameter fvp_mps2.telnetterminal2.quiet=1 \ |
| 208 | --parameter fvp_mps2.telnetterminal0.start_port=5000 \ |
| 209 | --parameter fvp_mps2.telnetterminal1.start_port=5001 \ |
| 210 | --parameter fvp_mps2.telnetterminal1.mode=raw \ |
| 211 | --parameter fvp_mps2.UART1.unbuffered_output=1 \ |
| 212 | --application cpu0=<TF-M build dir>/bin/bl2.axf \ |
| 213 | --data cpu0=<NS build dir>/tfm_s_ns_signed.bin@0x10080000 \ |
| 214 | -M 1 |
| 215 | |
| 216 | References |
| 217 | ---------- |
| 218 | |
| 219 | .. [1] :doc:`Building TF-M Tests <TF-M:building/tests_build_instruction>` |
| 220 | |
| 221 | .. _Arm Development Studio: https://developer.arm.com/tools-and-software/embedded/arm-development-studio |
| 222 | |
| 223 | -------------- |
| 224 | |
| 225 | *SPDX-License-Identifier: BSD-3-Clause* |
| 226 | *SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors* |