blob: a8b3fd231fe402fe85fea1e3bc574068940d997b [file] [log] [blame]
Anton Komlev36882782024-04-10 21:00:30 +01001########################
2TF-M Example Application
3########################
4
5This **tf-m-example-ns-app** directory provides a bare metal example NS application, demonstrating how to use the
6artifacts exported by TF-M build.
7
8The application outputs "Hello TF-M world" and uses a PSA service function to demonstrate
9that a NS application can be successfully run.
10
11*****************
12The Build Process
13*****************
14
151. Clone the TF-M repository at anywhere, assume the root directory is ``<TF-M Source Dir>``
16
172. 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
243. 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 Dewally1ce79bb2024-06-17 16:33:28 +010029 - 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 Komlev36882782024-04-10 21:00:30 +010032
334. 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
405. In output you will get:
41
42 - Non-secure (NS) application in ``build/nspe/bin/tfm_ns.*``
Nik Dewally1ce79bb2024-06-17 16:33:28 +010043 - 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 Komlev36882782024-04-10 21:00:30 +010045
46*******************
47Run the Application
48*******************
49The application binary shall be loaded and launched on address ``0x10080000``.
50The application can be run using the SSE-200 fast-model using FVP_MPS2_AEMv8M provided by Arm
51Development Studio.
52Add ``bl2.axf`` and ``tfm_s_ns_signed.bin`` to the symbol files in the Debug Configuration menu.
53The 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.*