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.*`` |
| 29 | - PSA API for Non-Secure application ``/interface/*`` |
| 30 | |
| 31 | 4. Build this example TF-M application: |
| 32 | |
| 33 | .. code-block:: bash |
| 34 | |
| 35 | cmake -S <path_to_this_example> -B build/nspe -DCONFIG_SPE_PATH=<absolute_path_to>/build/spe/api_ns |
| 36 | cmake --build build/nspe |
| 37 | |
| 38 | 5. In output you will get: |
| 39 | |
| 40 | - Non-secure (NS) application in ``build/nspe/bin/tfm_ns.*`` |
| 41 | - Combined S + NS bianry ``build/nspe/bin/tfm_s_ns.bin`` |
| 42 | - Combined S + NS and signed bianry ``build/nspe/bin/tfm_s_ns.bin`` |
| 43 | |
| 44 | ******************* |
| 45 | Run the Application |
| 46 | ******************* |
| 47 | The application binary shall be loaded and launched on address ``0x10080000``. |
| 48 | The application can be run using the SSE-200 fast-model using FVP_MPS2_AEMv8M provided by Arm |
| 49 | Development Studio. |
| 50 | Add ``bl2.axf`` and ``tfm_s_ns_signed.bin`` to the symbol files in the Debug Configuration menu. |
| 51 | The following output you shall find in a serial terminal: |
| 52 | |
| 53 | .. code-block:: console |
| 54 | |
| 55 | Non-Secure system starting... |
| 56 | Hello TF-M world |
| 57 | PSA Framework Version = 1.1 |
| 58 | Testing psa get random number... |
| 59 | 1: psa_generate_random() = 254 |
| 60 | 2: psa_generate_random() = 214 |
| 61 | 3: psa_generate_random() = 129 |
| 62 | 4: psa_generate_random() = 226 |
| 63 | 5: psa_generate_random() = 102 |
| 64 | End of TF-M example App |
| 65 | |
| 66 | *Copyright (c) 2023, Arm Limited. All rights reserved.* |