Anton Komlev | 3688278 | 2024-04-10 21:00:30 +0100 | [diff] [blame] | 1 | ######################## |
| 2 | TF-M Example Application |
| 3 | ######################## |
| 4 | |
| 5 | This **tf-m-example-ns-app** directory provides a bare metal example NS application, demonstrating how to use the |
| 6 | artifacts exported by TF-M build. |
| 7 | |
| 8 | The application outputs "Hello TF-M world" and uses a PSA service function to demonstrate |
| 9 | that a NS application can be successfully run. |
| 10 | |
| 11 | ***************** |
| 12 | The Build Process |
| 13 | ***************** |
| 14 | |
| 15 | 1. Clone the TF-M repository at anywhere, assume the root directory is ``<TF-M Source Dir>`` |
| 16 | |
| 17 | 2. Build the TF-M with the following command: |
| 18 | |
| 19 | .. code-block:: bash |
| 20 | |
| 21 | cmake -S <TF-M Source Dir> -B build/spe -DTFM_PLATFORM=arm/mps2/an521 -DTFM_PROFILE=profile_small |
| 22 | cmake --build build/spe -- install |
| 23 | |
| 24 | 3. The files necessary to build TF-M will appear in ``build/spe/api_ns``. |
| 25 | The most important elements are: |
| 26 | |
| 27 | - Bootloader: ``/bin/bl2.*`` |
| 28 | - Secure (S) side binary image: ``/bin/tfm_s.*`` |
Nik Dewally | 1ce79bb | 2024-06-17 16:33:28 +0100 | [diff] [blame] | 29 | - PSA API for Non-Secure application: ``/interface/*`` |
| 30 | - Files for building the Non-Secure application with different |
| 31 | toolchains (see :external:ref:`toolchains`): ``/cmake/toolchain_ns_*.cmake`` |
Anton Komlev | 3688278 | 2024-04-10 21:00:30 +0100 | [diff] [blame] | 32 | |
| 33 | 4. Build this example TF-M application: |
| 34 | |
| 35 | .. code-block:: bash |
| 36 | |
| 37 | cmake -S <path_to_this_example> -B build/nspe -DCONFIG_SPE_PATH=<absolute_path_to>/build/spe/api_ns |
| 38 | cmake --build build/nspe |
| 39 | |
| 40 | 5. In output you will get: |
| 41 | |
| 42 | - Non-secure (NS) application in ``build/nspe/bin/tfm_ns.*`` |
Nik Dewally | 1ce79bb | 2024-06-17 16:33:28 +0100 | [diff] [blame] | 43 | - Combined S + NS binary ``build/nspe/bin/tfm_s_ns.bin`` |
| 44 | - Combined S + NS and signed binary ``build/nspe/bin/tfm_s_ns.bin`` |
Anton Komlev | 3688278 | 2024-04-10 21:00:30 +0100 | [diff] [blame] | 45 | |
| 46 | ******************* |
| 47 | Run the Application |
| 48 | ******************* |
| 49 | The application binary shall be loaded and launched on address ``0x10080000``. |
| 50 | The application can be run using the SSE-200 fast-model using FVP_MPS2_AEMv8M provided by Arm |
| 51 | Development Studio. |
| 52 | Add ``bl2.axf`` and ``tfm_s_ns_signed.bin`` to the symbol files in the Debug Configuration menu. |
| 53 | The following output you shall find in a serial terminal: |
| 54 | |
| 55 | .. code-block:: console |
| 56 | |
| 57 | Non-Secure system starting... |
| 58 | Hello TF-M world |
| 59 | PSA Framework Version = 1.1 |
| 60 | Testing psa get random number... |
| 61 | 1: psa_generate_random() = 254 |
| 62 | 2: psa_generate_random() = 214 |
| 63 | 3: psa_generate_random() = 129 |
| 64 | 4: psa_generate_random() = 226 |
| 65 | 5: psa_generate_random() = 102 |
| 66 | End of TF-M example App |
| 67 | |
| 68 | *Copyright (c) 2023, Arm Limited. All rights reserved.* |