blob: f001b75ca9c74c7678b7c8fa7a98ca9e0d422ead [file] [log] [blame]
Soby Mathewb4c6df42022-11-09 11:13:29 +00001.. SPDX-License-Identifier: BSD-3-Clause
2.. SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
3
Soby Mathew78bdfb12024-05-09 16:58:04 +01004.. _getting_started:
5
Soby Mathewb4c6df42022-11-09 11:13:29 +00006#############
7Prerequisite
8#############
9
Soby Mathewf572d3b2022-11-21 12:30:11 +000010This document describes the software requirements for building |RMM| for
11AArch64 target platforms.
Soby Mathewb4c6df42022-11-09 11:13:29 +000012
Soby Mathewf572d3b2022-11-21 12:30:11 +000013It may possible to build |RMM| with combinations of software packages that
14are different from those listed below, however only the software described in
15this document can be officially supported.
Soby Mathewb4c6df42022-11-09 11:13:29 +000016
17###########
18Build Host
19###########
20
21The |RMM| officially supports a limited set of build environments and setups.
22In this context, official support means that the environments listed below
23are actively used by team members and active developers, hence users should
24be able to recreate the same configurations by following the instructions
25described below. In case of problems, the |RMM| team provides support only
26for these environments, but building in other environments can still be
27possible.
28
Soby Mathewf572d3b2022-11-21 12:30:11 +000029We recommend at least Ubuntu 20.04 LTS (x64) for build environment. The
30arm64/AArch64 Ubuntu and other Linux distributions should also work fine,
31provided that the necessary tools and libraries can be installed.
Soby Mathewb4c6df42022-11-09 11:13:29 +000032
Soby Mathew78bdfb12024-05-09 16:58:04 +010033.. _tool_dependencies:
34
Soby Mathewb4c6df42022-11-09 11:13:29 +000035##########################
36Tool & Dependency overview
37##########################
38
39The following tools are required to obtain and build |RMM|:
40
41.. csv-table:: Tool dependencies
42 :header: "Name", "Version", "Component"
43
44 "C compiler", see :ref:`getting_started_toolchain` ,"Firmware"
Soby Mathewd2024c02025-05-21 13:14:33 +010045 "CMake", ">=3.20.0", "Firmware, Documentation"
Soby Mathewb4c6df42022-11-09 11:13:29 +000046 "GNU Make", ">4.0", "Firmware, Documentation"
47 "Python",3.x,"Firmware, Documentation"
48 "Perl",>=5.26,"Firmware, Documentation"
49 "ninja-build",,"Firmware (using Ninja Generator)"
50 "Sphinx",">=2.4,<3.0.0","Documentation"
51 "sphinxcontrib-plantuml",,"Documentation"
52 "sphinx-rtd-theme",,"Documentation"
53 "Git",, "Firmware, Documentation"
54 "Graphviz dot",">v2.38.0","Documentation"
55 "docutils",">v2.38.0","Documentation"
Javier Almansa Sobrino576071e2022-09-09 16:01:17 +010056 "gcovr",">=v4.2","Tools(Coverage analysis)"
Mate Toth-Pal83a45bd2023-09-01 11:17:19 +020057 "CBMC",">=5.84.0","Tools(CBMC analysis)"
Sona Mathew44713562024-08-11 23:18:32 -050058 "Cppcheck",">=2.14.0","Tools(Cppcheck)"
Javier Almansa Sobrinofd9d4242025-05-07 15:52:51 +010059 "pyelftools","==0.32","Firmware (EL0 app)"
Soby Mathewb4c6df42022-11-09 11:13:29 +000060
61.. _getting_started_toolchain:
62
63###############
64Setup Toolchain
65###############
66
67To compile |RMM| code for an AArch64 target, at least one of the
68supported AArch64 toolchains have to be available in the
69build environment.
70
71Currently, the following compilers are supported:
72
73- GCC (aarch64-none-elf-) >= 10.2-2020.11 (from the `Arm Developer website`_)
74- Clang+LLVM >= 14.0.0 (from the `LLVM Releases website`_)
75
76The respective compiler binary must be found in the shell's search path.
77Be sure to add the bin/ directory if you have downloaded a binary version.
78The toolchain to use can be set using ``RMM_TOOLCHAIN`` parameter and can
79be set to either `llvm` or `gnu`. The default toolchain is `gnu`.
80
81For non-native AArch64 target build, the ``CROSS_COMPILE`` environment
82variable must contain the right target triplet corresponding to the AArch64
83GCC compiler. Below is an example when RMM is to be built for AArch64 target
84on a non-native host machine and using GCC as the toolchain.
85
86 .. code-block:: bash
87
88 export CROSS_COMPILE=aarch64-none-elf-
89 export PATH=<path-to-aarch64-gcc>/bin:$PATH
90
91Please note that AArch64 GCC must be included in the shell's search path
92even when using Clang as the compiler as LLVM does not include some C
93standard headers like `stdlib.h` and needs to be picked up from the
94`include` folder of the AArch64 GCC. Below is an example when RMM is
95to be built for AArch64 target on a non-native host machine and using
96LLVM as the toolchain.
97
98 .. code-block:: bash
99
100 export CROSS_COMPILE=aarch64-none-elf-
101 export PATH=<path-to-aarch64-gcc>/bin:<path-to-clang+llvm>/bin:$PATH
102
103The ``CROSS_COMPILE`` variable is ignored for ``fake_host`` build and
104the native host toolchain is used for the build.
105
106#######################################
Soby Mathewf572d3b2022-11-21 12:30:11 +0000107Package Installation (Ubuntu-20.04 x64)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000108#######################################
109
110If you are using the recommended Ubuntu distribution then we can install the
111required packages with the following commands:
112
1131. Install dependencies:
114
115.. code:: shell
116
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000117 sudo apt-get install -y git build-essential python3 python3-pip make ninja-build
Soby Mathewb4c6df42022-11-09 11:13:29 +0000118 sudo snap install cmake
Soby Mathewb4c6df42022-11-09 11:13:29 +0000119
1202. Verify cmake version:
121
122.. code-block:: bash
123
124 cmake --version
125
126.. note::
127
Soby Mathewd2024c02025-05-21 13:14:33 +0100128 Please download cmake 3.20 or later version from https://cmake.org/download/.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000129
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +00001303. Add CMake path into environment:
Soby Mathewb4c6df42022-11-09 11:13:29 +0000131
132.. code-block:: bash
133
134 export PATH=<CMake path>/bin:$PATH
Soby Mathewb4c6df42022-11-09 11:13:29 +0000135
136###########################
137Install python dependencies
138###########################
139
Mate Toth-Pale60deeb2024-08-01 10:19:20 +0200140RMM's ``requirements.txt`` file declares additional Python dependencies.
141Install them with ``pip3``:
142
143.. code-block:: bash
144
145 pip3 install --upgrade pip
146 cd <rmm source folder>
147 pip3 install -r requirements.txt
148
149#############################################
150Install python dependencies for Documentation
151#############################################
152
Soby Mathewb4c6df42022-11-09 11:13:29 +0000153.. note::
154
Mate Toth-Pale60deeb2024-08-01 10:19:20 +0200155 The installation of Python dependencies for documentation is an optional
156 step. This is required only if building documentation.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000157
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000158RMM's ``docs/requirements.txt`` file declares additional Python dependencies.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000159Install them with ``pip3``:
160
161.. code-block:: bash
162
163 pip3 install --upgrade pip
164 cd <rmm source folder>
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000165 pip3 install -r docs/requirements.txt
Soby Mathewb4c6df42022-11-09 11:13:29 +0000166
Javier Almansa Sobrino576071e2022-09-09 16:01:17 +0100167############################################
168Install coverage tools analysis dependencies
169############################################
170
171.. note::
172
173 This is an optional step only needed if you intend to run coverage
174 analysis on the source code.
175
176On Ubuntu, ``gcovr`` tool can be installed in two different ways:
177
Soby Mathew78bdfb12024-05-09 16:58:04 +0100178Using the package manager:
Javier Almansa Sobrino576071e2022-09-09 16:01:17 +0100179
180.. code-block:: bash
181
182 sudo apt-get install gcovr
183
184The second (and recommended) way is install it with ``pip3``:
185
186.. code-block:: bash
187
188 pip3 install --upgrade pip
189 pip3 install gcovr
190
Soby Mathewb4c6df42022-11-09 11:13:29 +0000191.. _getting_started_get_source:
192
193#########################
194Getting the RMM Source
195#########################
196
197Source code for |RMM| is maintained in a Git repository hosted on TrustedFirmware.org.
198To clone this repository from the server, run the following in your shell:
199
200.. code-block:: bash
201
Soby Mathewb5a29752024-11-14 14:26:11 +0000202 git clone https://git.trustedfirmware.org/TF-RMM/tf-rmm.git
203
204Note that the RMM submodule dependencies will be updated during the
205configuration phase of build.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000206
207Additional steps for Contributors
208*********************************
209
210If you are planning on contributing back to RMM, your commits need to
211include a ``Change-Id`` footer as explained in :ref:`mandated-trailers`.
212This footer is generated by a Git hook that needs to be installed
213inside your cloned RMM source folder.
214
215The `TF-RMM Gerrit page`_ under trustedfirmware.org contains a
216*Clone with commit-msg hook* subsection under its **Download** header where
Javier Almansa Sobrino6166c032022-11-10 14:24:03 +0000217you can copy the command to clone the repo with the required git hooks. Please
218use the **SSH** option to clone the repository on your local machine.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000219
220If needed, you can also manually install the hooks separately on an existing
221repo:
222
223.. code:: shell
224
225 curl -Lo $(git rev-parse --git-dir)/hooks/commit-msg https://review.trustedfirmware.org/tools/hooks/commit-msg
226 chmod +x $(git rev-parse --git-dir)/hooks/commit-msg
227
228You can read more about Git hooks in the *githooks* page of the `Git hooks
229documentation`_.
230
Soby Mathew78bdfb12024-05-09 16:58:04 +0100231General contribution guidelines for contributors can be found in
232:ref:`Contributor's Guide`.
233
Soby Mathewb4c6df42022-11-09 11:13:29 +0000234#################################
235Install Cppcheck and dependencies
236#################################
237
238.. note::
239
240 The installation of Cppcheck is an optional step. This is required only
241 if using the Cppcheck static analysis.
242
Soby Mathew78bdfb12024-05-09 16:58:04 +0100243The recommended version of Cppcheck is indicated in :ref:`tool_dependencies`.
Shruti Gupta57b80382024-04-24 11:35:18 +0100244See :ref:`Cppcheck Application Note` for installation steps and details
245on how to use it within RMM build system.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000246
Mate Toth-Pal83a45bd2023-09-01 11:17:19 +0200247############
248Install CBMC
249############
250
251.. note::
252
253 The installation of CBMC is an optional step. This is required only
254 if running source code analysis with CBMC.
255
256Follow the public documentation to install CBMC either from the official
257website https://www.cprover.org/cbmc/ or from the official github
258https://github.com/diffblue/cbmc
259
Soby Mathew78bdfb12024-05-09 16:58:04 +0100260Refer to :ref:`CBMC` Application Notes for details on installation and
261running CBMC analysis on TF-RMM sources.
262
263##################
264Install Clang-tidy
265##################
266
267Clang-tidy is included in LLVM release package. It can also be installed via
268package manager :
269
270.. code-block:: bash
271
272 sudo apt-get install clang-tidy
273
274Note that the ``RMM_TOOLCHAIN`` needs to be set to `llvm` to run clang-tidy
275build targets from RMM build system.
276
Soby Mathewb4c6df42022-11-09 11:13:29 +0000277###########################
278Performing an Initial Build
279###########################
280
281The |RMM| sources can be compiled using multiple CMake options.
282
283For detailed instructions on build configurations and examples
284see :ref:`build_options_examples`.
285
286A typical build command for the FVP platform using GCC toolchain
287is shown below:
288
289.. code-block:: bash
290
291 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
292 cmake --build ${RMM_BUILD_DIR}
293
294###############
295Running the RMM
296###############
297
298The |RMM| is part of the CCA software stack and relies on EL3 Firmware to load
299the binary at boot time appropriately. It needs both EL3 Firmware and
300Non-Secure Host to be present at runtime for its functionality. The EL3
301Firmware must comply to `RMM-EL3 Communication Specification`_ and is
302typically the `TF-A`_. The Non-Secure Host can be an RME aware hypervisor
303or an appropriate Test utility running in Non-Secure world which can interact
304with |RMM| via Realm Management Interface (RMI).
305
Javier Almansa Sobrino82edb892024-05-01 11:44:25 +0100306Building all of the involved stack is complicated. We recommend using the
307`Shrinkwrap`_ tooling to bootstrap the stack. For more details on `Shrinkwrap`_
308and utilizing configs and overlays included in |RMM| please refer to
309:ref:`using_shrinkwrap_with_rmm` and, specially for building a demonstrator
310for 3-world, you can refer to :ref:`3_world_testing`.
311
312The |TF-A| documentation also provides some documentation to build |TF-A| and
313other pieces of firmware for RME in `TF-A RME documentation`_. The |RMM| build
314option in |TF-A| should point to the ``rmm.img`` binary generated by building
315|RMM|.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000316
317If |RMM| is built for the `fake_host` architecture
Mate Toth-Palbbb816d2024-08-01 10:41:35 +0200318(see :ref:`RMM Fake Host Build`), then the generated `rmm_core.elf` binary can
Soby Mathewb4c6df42022-11-09 11:13:29 +0000319run natively on the Host machine. It does this by emulating parts of the system
320as described in :ref:`RMM Fake host architecture` design.
321
322-----
323
324.. _Arm Developer website: https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads
325.. _LLVM Releases website: https://releases.llvm.org/
326.. _RMM-EL3 Communication Specification: https://trustedfirmware-a.readthedocs.io/en/latest/components/rmm-el3-comms-spec.html
327.. _TF-A: https://www.trustedfirmware.org/projects/tf-a/
328.. _TF-A RME documentation: https://trustedfirmware-a.readthedocs.io/en/latest/components/realm-management-extension.html
329.. _TF-RMM Gerrit page: https://review.trustedfirmware.org/admin/repos/TF-RMM/tf-rmm
330.. _Git hooks documentation: https://git-scm.com/docs/githooks
Javier Almansa Sobrino82edb892024-05-01 11:44:25 +0100331.. _Shrinkwrap: https://shrinkwrap.docs.arm.com