blob: c7f9026331d76960c9cd57f72348902bc73127ea [file] [log] [blame]
Gyorgy Szingdb9783c2019-04-17 21:08:48 +02001#############################
2Trusted Firmware M user guide
3#############################
4How to compile and run TF-M and example test application for CoreLink
5SSE-200 subsystem on the MPS2 board and on the Fast Model(FVP).
6
7Follow :doc:`build instruction <tfm_build_instruction>` to build the binaries.
8Follow :doc:`secure boot <tfm_secure_boot>` to build the binaries with or
9without BL2 bootloader.
10
11****************************************************************
12Execute TF-M example and regression tests on MPS2 boards and FVP
13****************************************************************
14The BL2 bootloader and TF-M example application and tests run correctly on
15SMM-SSE-200 for MPS2 (AN521) and on the Fixed Virtual Platform model
16FVP_MPS2_AEMv8M version 11.2.23.
17
18To run the example code on FVP_MPS2_AEMv8M
19==========================================
20Using FVP_MPS2_AEMv8M provided by DS-5 v5.27.1.
21
22.. Note::
23 FVP reference guide can be found
24 `here <https://developer.arm.com/docs/100966/latest>`__
25
26Example application and regression tests without BL2 bootloader
27---------------------------------------------------------------
28Add ``tfm_s.axf`` and ``tfm_ns.axf`` to symbol files in Debug Configuration
29menu.
30
31.. code-block:: bash
32
33 <DS5_PATH>/sw/models/bin/FVP_MPS2_AEMv8M \
34 --parameter fvp_mps2.platform_type=2 \
35 --parameter cpu0.baseline=0 \
36 --parameter cpu0.INITVTOR_S=0x10000000 \
37 --parameter cpu0.semihosting-enable=0 \
38 --parameter fvp_mps2.DISABLE_GATING=0 \
39 --parameter fvp_mps2.telnetterminal0.start_telnet=1 \
40 --parameter fvp_mps2.telnetterminal1.start_telnet=0 \
41 --parameter fvp_mps2.telnetterminal2.start_telnet=0 \
42 --parameter fvp_mps2.telnetterminal0.quiet=0 \
43 --parameter fvp_mps2.telnetterminal1.quiet=1 \
44 --parameter fvp_mps2.telnetterminal2.quiet=1 \
45 --application cpu0=<build_dir>/install/outputs/fvp/tfm_s.axf \
46 --data cpu0=<build_dir>/install/outputs/fvp/tfm_ns.bin@0x00100000
47
48Example application and regression tests with BL2 bootloader
49------------------------------------------------------------
50To test TF-M with bootloader, one must apply the following changes:
51
52- Add ``mcuboot.axf`` to symbol files in DS-5 in Debug Configuration
53 menu.
54- Replace the last two lines of the previous command with this:
55
56.. code-block:: bash
57
58 --application cpu0=<build_dir>/install/outputs/fvp/mcuboot.axf \
59 --data cpu0=<build_dir>/install/outputs/fvp/tfm_s_ns_signed.bin@0x10080000
60
61Test software upgrade with BL2 bootloader
62^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63BL2 bootloader is mandatory to test software update. Furthermore two TF-M blob
64must be built. Outputs of example application and regression test can be used to
65test it. Load output of example application to slot 0 (0x10080000) and output of
66regression test to slot 1 (0x10180000). Add the following line to the end of
67the previous chapter:
68
69.. code-block:: bash
70
71 --data cpu0=<build_dir>/install/outputs/fvp/tfm_s_ns_signed.bin@0x10180000
72
73To run the example code on SSE 200 FPGA on MPS2 board
74=====================================================
75FPGA image is available to download
76`here <https://developer.arm.com/products/system-design/development-boards/cortex-m-prototyping-systems/mps2>`__
77
78To run BL2 bootloader and TF-M example application and tests in the MPS2 board,
79it is required to have SMM-SSE-200 for MPS2 (AN521) image in the MPS2 board SD
80card. The image should be located in
81``<MPS2 device name>/MB/HBI0263<board revision letter>/AN521``
82
83The MPS2 board tested is HBI0263C referred also as MPS2+.
84
85.. Warning::
86
87 If you change the exe names, MPS2 expects file names in 8.3 format.
88
89Example application
90-------------------
91#. Copy ``mcuboot.bin`` and ``tfm_sign.bin`` files from
92 ``<build_dir>/install/outputs/AN521/`` to
93 ``<MPS2 device name>/SOFTWARE/``
94#. Open ``<MPS2 device name>/MB/HBI0263C/AN521/images.txt``
95#. Update the ``AN521/images.txt`` file as follows::
96
97 TITLE: Versatile Express Images Configuration File
98 [IMAGES]
99 TOTALIMAGES: 2 ;Number of Images (Max: 32)
100 IMAGE0ADDRESS: 0x10000000
101 IMAGE0FILE: \Software\mcuboot.bin ; BL2 bootloader
102 IMAGE1ADDRESS: 0x10080000
103 IMAGE1FILE: \Software\tfm_sign.bin ; TF-M example application binary blob
104
105#. Close ``<MPS2 device name>/MB/HBI0263C/AN521/images.txt``
106#. Unmount/eject the ``<MPS2 device name>`` unit
107#. Reset the board to execute the TF-M example application
108#. After completing the procedure you should be able to visualize on the serial
109 port (baud 115200 8n1) the following messages::
110
111 [INF] Starting bootloader
112 [INF] Image 0: magic=good, copy_done=0xff, image_ok=0xff
113 [INF] Scratch: magic=bad, copy_done=0x5, image_ok=0xcf
114 [INF] Boot source: slot 0
115 [INF] Swap type: none
116 [INF] Bootloader chainload address offset: 0x80000
117 [INF] Jumping to the first image slot
118 [Sec Thread] Secure image initializing!
119
120Regression tests
121----------------
122After completing the procedure you should be able to visualize on the serial
123port (baud 115200 8n1) the following messages::
124
125 [INF] Starting bootloader
126 [INF] Image 0: magic=good, copy_done=0xff, image_ok=0xff
127 [INF] Scratch: magic=bad, copy_done=0x5, image_ok=0xcf
128 [INF] Boot source: slot 0
129 [INF] Swap type: none
130 [INF] Bootloader chainload address offset: 0x80000
131 [INF] Jumping to the first image slot
132 [Sec Thread] Secure image initializing!
133
134 #### Execute test suites for the secure storage service ####
135 Running Test Suite SST secure interface tests (TFM_SST_TEST_2XXX)...
136
137 > Executing 'TFM_SST_TEST_2001'
138 Description: 'Create interface'
139 TEST PASSED!
140 > Executing 'TFM_SST_TEST_2002'
141 Description: 'Get handle interface (DEPRECATED)'
142 This test is DEPRECATED and the test execution was SKIPPED
143 TEST PASSED!
144 > Executing 'TFM_SST_TEST_2003'
145 Description: 'Get handle with null handle pointer (DEPRECATED)'
146 This test is DEPRECATED and the test execution was SKIPPED
147 TEST PASSED!
148 > Executing 'TFM_SST_TEST_2004'
149 Description: 'Write interface'
150 TEST PASSED!
151 > Executing 'TFM_SST_TEST_2005'
152 Description: 'Read interface'
153 ....
154
155.. Note::
156
157 SST reliability tests take a few minutes to run on the MPS2.
158
159Example application without BL2 bootloader
160------------------------------------------
161#. Copy ``tfm_s.bin`` and ``tfm_ns.bin`` files from
162 ``<build_dir>/install/outputs/AN521/`` to
163 ``<MPS2 device name>/SOFTWARE/``
164#. Open ``<MPS2 device name>/MB/HBI0263C/AN521/images.txt``
165#. Update the ``AN521/images.txt`` file as follows::
166
167 TITLE: Versatile Express Images Configuration File
168 [IMAGES]
169 TOTALIMAGES: 2 ;Number of Images (Max: 32)
170 IMAGE0ADDRESS: 0x10000000
171 IMAGE0FILE: \Software\tfm_s.bin ; Secure code
172 IMAGE1ADDRESS: 0x00100000
173 IMAGE1FILE: \Software\tfm_ns.bin ; Non-secure code
174
175#. Close ``<MPS2 device name>/MB/HBI0263C/AN521/images.txt``
176#. Unmount/eject the ``<MPS2 device name>`` unit
177#. Reset the board to execute the TF-M example application
178#. After completing the procedure you should be able to visualize on the serial
179 port (baud 115200 8n1) the following messages::
180
181 [Sec Thread] Secure image initializing!
182
183Regression tests without BL2 bootloader
184---------------------------------------
185After completing the procedure you should be able to visualize on the serial
186port (baud 115200 8n1) the following messages::
187
188 [Sec Thread] Secure image initializing!
189
190 #### Execute test suites for the secure storage service ####
191 Running Test Suite SST secure interface tests (TFM_SST_TEST_2XXX)...
192
193 > Executing 'TFM_SST_TEST_2001'
194 Description: 'Create interface'
195 TEST PASSED!
196 > Executing 'TFM_SST_TEST_2002'
197 Description: 'Get handle interface (DEPRECATED)'
198 This test is DEPRECATED and the test execution was SKIPPED
199 TEST PASSED!
200 > Executing 'TFM_SST_TEST_2003'
201 Description: 'Get handle with null handle pointer (DEPRECATED)'
202 This test is DEPRECATED and the test execution was SKIPPED
203 TEST PASSED!
204 > Executing 'TFM_SST_TEST_2004'
205 Description: 'Write interface'
206 TEST PASSED!
207 > Executing 'TFM_SST_TEST_2005'
208 Description: 'Read interface'
209 ....
210
211*******************************************************************
212Execute TF-M example and regression tests on Musca test chip boards
213*******************************************************************
214.. Note::
215
216 Before executing any images on Musca-B1 board, please check the
217 :doc:`target platform readme </platform/ext/target/musca_b1/readme>`
218 to have the correct setup.
219
220Example application with BL2 bootloader
221=======================================
222
223#. Create a unified hex file comprising of both mcuboot and tfm_sign
224 binary
225
226- For Musca-A1
227
228 - Windows::
229
230 srec_cat.exe bl2\ext\mcuboot\mcuboot.bin -Binary -offset 0x200000 tfm_sign.bin -Binary -offset 0x220000 -o tfm.hex -Intel
231
232 - Linux::
233
234 srec_cat bl2/ext/mcuboot/mcuboot.bin -Binary -offset 0x200000 tfm_sign.bin -Binary -offset 0x220000 -o tfm.hex -Intel
235
236- For Musca-B1
237
238 - Windows::
239
240 srec_cat.exe bl2\ext\mcuboot\mcuboot.bin -Binary -offset 0xA000000 tfm_sign.bin -Binary -offset 0xA020000 -o tfm.hex -Intel
241
242 - Linux::
243
244 srec_cat bl2/ext/mcuboot/mcuboot.bin -Binary -offset 0xA000000 tfm_sign.bin -Binary -offset 0xA020000 -o tfm.hex -Intel
245
246#. Plug the Musca board into your computer. The board should appear as a USB
247 drive
248#. Copy ``tfm.hex`` to the USB drive
249#. Reset the board to execute the TF-M example application
250#. After completing the procedure you should be able to see on the UART0
251 (baud 115200 8n1) the following messages::
252
253 [INF] Starting bootloader
254 [INF] Image 0: magic=good, copy_done=0xff, image_ok=0xff
255 [INF] Scratch: magic=bad, copy_done=0x5, image_ok=0xd9
256 [INF] Boot source: slot 0
257 [INF] Swap type: none
258 [INF] Bootloader chainload address offset: 0x20000
259 [INF] Jumping to the first image slot
260 [Sec Thread] Secure image initializing!
261
262Regression tests with BL2 bootloader
263====================================
264After completing the procedure you should see the following messages on the
265UART0 (baud 115200 8n1)::
266
267 [INF] Starting bootloader
268 [INF] Image 0: magic=good, copy_done=0xff, image_ok=0xff
269 [INF] Scratch: magic=bad, copy_done=0x5, image_ok=0x9
270 [INF] Boot source: slot 0
271 [INF] Swap type: none
272 [INF] Bootloader chainload address offset: 0x20000
273 [INF] Jumping to the first image slot
274 [Sec Thread] Secure image initializing!
275
276 #### Execute test suites for the secure storage service ####
277 Running Test Suite SST secure interface tests (TFM_SST_TEST_2XXX)...
278 > Executing 'TFM_SST_TEST_2001'
279 Description: 'Create interface'
280 TEST PASSED!
281 > Executing 'TFM_SST_TEST_2002'
282 Description: 'Get handle interface (DEPRECATED)'
283 This test is DEPRECATED and the test execution was SKIPPED
284 TEST PASSED!
285 > Executing 'TFM_SST_TEST_2003'
286 Description: 'Get handle with null handle pointer (DEPRECATED)'
287 This test is DEPRECATED and the test execution was SKIPPED
288 TEST PASSED!
289 > Executing 'TFM_SST_TEST_2004'
290 Description: 'Get attributes interface'
291 TEST PASSED!
292 > Executing 'TFM_SST_TEST_2005'
293 Description: 'Get attributes with null attributes struct pointer'
294 ....
295
296Example application or regression tests on Musca-B1 without BL2 bootloader
297==========================================================================
298
299Follow the above procedures, but create a unified hex file out of ``tfm_s.bin``
300and ``tfm_ns.bin``:
301
302- Windows::
303
304 srec_cat.exe app\secure_fw\tfm_s.bin -Binary -offset 0xA000000 app\tfm_ns.bin -Binary -offset 0xA060000 -o tfm.hex -Intel
305
306- Linux::
307
308 srec_cat app/secure_fw/tfm_s.bin -Binary -offset 0xA000000 app/tfm_ns.bin -Binary -offset 0xA060000 -o tfm.hex -Intel
309
310Firmware upgrade and image validation with BL2 bootloader
311=========================================================
312High level operation of BL2 bootloader and instructions for testing firmware
313upgrade is described in :doc:`secure boot <tfm_secure_boot>`.
314
315--------------
316
317*Copyright (c) 2017-2019, Arm Limited. All rights reserved.*