blob: 88747c9e19b5aa5f79155b86fd8a447fa548ba32 [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
4#############
5Prerequisite
6#############
7
Soby Mathewf572d3b2022-11-21 12:30:11 +00008This document describes the software requirements for building |RMM| for
9AArch64 target platforms.
Soby Mathewb4c6df42022-11-09 11:13:29 +000010
Soby Mathewf572d3b2022-11-21 12:30:11 +000011It may possible to build |RMM| with combinations of software packages that
12are different from those listed below, however only the software described in
13this document can be officially supported.
Soby Mathewb4c6df42022-11-09 11:13:29 +000014
15###########
16Build Host
17###########
18
19The |RMM| officially supports a limited set of build environments and setups.
20In this context, official support means that the environments listed below
21are actively used by team members and active developers, hence users should
22be able to recreate the same configurations by following the instructions
23described below. In case of problems, the |RMM| team provides support only
24for these environments, but building in other environments can still be
25possible.
26
Soby Mathewf572d3b2022-11-21 12:30:11 +000027We recommend at least Ubuntu 20.04 LTS (x64) for build environment. The
28arm64/AArch64 Ubuntu and other Linux distributions should also work fine,
29provided that the necessary tools and libraries can be installed.
Soby Mathewb4c6df42022-11-09 11:13:29 +000030
31##########################
32Tool & Dependency overview
33##########################
34
35The following tools are required to obtain and build |RMM|:
36
37.. csv-table:: Tool dependencies
38 :header: "Name", "Version", "Component"
39
40 "C compiler", see :ref:`getting_started_toolchain` ,"Firmware"
41 "CMake", ">=3.15.0", "Firmware, Documentation"
42 "GNU Make", ">4.0", "Firmware, Documentation"
43 "Python",3.x,"Firmware, Documentation"
44 "Perl",>=5.26,"Firmware, Documentation"
45 "ninja-build",,"Firmware (using Ninja Generator)"
46 "Sphinx",">=2.4,<3.0.0","Documentation"
47 "sphinxcontrib-plantuml",,"Documentation"
48 "sphinx-rtd-theme",,"Documentation"
49 "Git",, "Firmware, Documentation"
50 "Graphviz dot",">v2.38.0","Documentation"
51 "docutils",">v2.38.0","Documentation"
Javier Almansa Sobrino576071e2022-09-09 16:01:17 +010052 "gcovr",">=v4.2","Tools(Coverage analysis)"
Soby Mathewb4c6df42022-11-09 11:13:29 +000053
54.. _getting_started_toolchain:
55
56###############
57Setup Toolchain
58###############
59
60To compile |RMM| code for an AArch64 target, at least one of the
61supported AArch64 toolchains have to be available in the
62build environment.
63
64Currently, the following compilers are supported:
65
66- GCC (aarch64-none-elf-) >= 10.2-2020.11 (from the `Arm Developer website`_)
67- Clang+LLVM >= 14.0.0 (from the `LLVM Releases website`_)
68
69The respective compiler binary must be found in the shell's search path.
70Be sure to add the bin/ directory if you have downloaded a binary version.
71The toolchain to use can be set using ``RMM_TOOLCHAIN`` parameter and can
72be set to either `llvm` or `gnu`. The default toolchain is `gnu`.
73
74For non-native AArch64 target build, the ``CROSS_COMPILE`` environment
75variable must contain the right target triplet corresponding to the AArch64
76GCC compiler. Below is an example when RMM is to be built for AArch64 target
77on a non-native host machine and using GCC as the toolchain.
78
79 .. code-block:: bash
80
81 export CROSS_COMPILE=aarch64-none-elf-
82 export PATH=<path-to-aarch64-gcc>/bin:$PATH
83
84Please note that AArch64 GCC must be included in the shell's search path
85even when using Clang as the compiler as LLVM does not include some C
86standard headers like `stdlib.h` and needs to be picked up from the
87`include` folder of the AArch64 GCC. Below is an example when RMM is
88to be built for AArch64 target on a non-native host machine and using
89LLVM as the toolchain.
90
91 .. code-block:: bash
92
93 export CROSS_COMPILE=aarch64-none-elf-
94 export PATH=<path-to-aarch64-gcc>/bin:<path-to-clang+llvm>/bin:$PATH
95
96The ``CROSS_COMPILE`` variable is ignored for ``fake_host`` build and
97the native host toolchain is used for the build.
98
99#######################################
Soby Mathewf572d3b2022-11-21 12:30:11 +0000100Package Installation (Ubuntu-20.04 x64)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000101#######################################
102
103If you are using the recommended Ubuntu distribution then we can install the
104required packages with the following commands:
105
1061. Install dependencies:
107
108.. code:: shell
109
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000110 sudo apt-get install -y git build-essential python3 python3-pip make ninja-build
Soby Mathewb4c6df42022-11-09 11:13:29 +0000111 sudo snap install cmake
Soby Mathewb4c6df42022-11-09 11:13:29 +0000112
1132. Verify cmake version:
114
115.. code-block:: bash
116
117 cmake --version
118
119.. note::
120
121 Please download cmake 3.19 or later version from https://cmake.org/download/.
122
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +00001233. Add CMake path into environment:
Soby Mathewb4c6df42022-11-09 11:13:29 +0000124
125.. code-block:: bash
126
127 export PATH=<CMake path>/bin:$PATH
Soby Mathewb4c6df42022-11-09 11:13:29 +0000128
129###########################
130Install python dependencies
131###########################
132
133.. note::
134
135 The installation of Python dependencies is an optional step. This is required only
136 if building documentation.
137
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000138RMM's ``docs/requirements.txt`` file declares additional Python dependencies.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000139Install them with ``pip3``:
140
141.. code-block:: bash
142
143 pip3 install --upgrade pip
144 cd <rmm source folder>
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000145 pip3 install -r docs/requirements.txt
Soby Mathewb4c6df42022-11-09 11:13:29 +0000146
Javier Almansa Sobrino576071e2022-09-09 16:01:17 +0100147############################################
148Install coverage tools analysis dependencies
149############################################
150
151.. note::
152
153 This is an optional step only needed if you intend to run coverage
154 analysis on the source code.
155
156On Ubuntu, ``gcovr`` tool can be installed in two different ways:
157
158Using the pagckage manager:
159
160.. code-block:: bash
161
162 sudo apt-get install gcovr
163
164The second (and recommended) way is install it with ``pip3``:
165
166.. code-block:: bash
167
168 pip3 install --upgrade pip
169 pip3 install gcovr
170
Soby Mathewb4c6df42022-11-09 11:13:29 +0000171.. _getting_started_get_source:
172
173#########################
174Getting the RMM Source
175#########################
176
177Source code for |RMM| is maintained in a Git repository hosted on TrustedFirmware.org.
178To clone this repository from the server, run the following in your shell:
179
180.. code-block:: bash
181
182 git clone --recursive https://git.trustedfirmware.org/TF-RMM/tf-rmm.git
183
184Additional steps for Contributors
185*********************************
186
187If you are planning on contributing back to RMM, your commits need to
188include a ``Change-Id`` footer as explained in :ref:`mandated-trailers`.
189This footer is generated by a Git hook that needs to be installed
190inside your cloned RMM source folder.
191
192The `TF-RMM Gerrit page`_ under trustedfirmware.org contains a
193*Clone with commit-msg hook* subsection under its **Download** header where
Javier Almansa Sobrino6166c032022-11-10 14:24:03 +0000194you can copy the command to clone the repo with the required git hooks. Please
195use the **SSH** option to clone the repository on your local machine.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000196
197If needed, you can also manually install the hooks separately on an existing
198repo:
199
200.. code:: shell
201
202 curl -Lo $(git rev-parse --git-dir)/hooks/commit-msg https://review.trustedfirmware.org/tools/hooks/commit-msg
203 chmod +x $(git rev-parse --git-dir)/hooks/commit-msg
204
205You can read more about Git hooks in the *githooks* page of the `Git hooks
206documentation`_.
207
208#################################
209Install Cppcheck and dependencies
210#################################
211
212.. note::
213
214 The installation of Cppcheck is an optional step. This is required only
215 if using the Cppcheck static analysis.
216
217Follow the public documentation to install Cppcheck either from the official
218website https://cppcheck.sourceforge.io/#download or from the official github
219https://github.com/danmar/cppcheck/
220
221If you own a valid copy of a MISRA rules file:
222
223.. code-block:: bash
224
225 sudo mkdir /usr/local/share/Cppcheck/misra
226 sudo cp -a <path to the misra rules file>/<file name> /usr/local/share/Cppcheck/misra/misra.rules
227
228###########################
229Performing an Initial Build
230###########################
231
232The |RMM| sources can be compiled using multiple CMake options.
233
234For detailed instructions on build configurations and examples
235see :ref:`build_options_examples`.
236
237A typical build command for the FVP platform using GCC toolchain
238is shown below:
239
240.. code-block:: bash
241
242 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
243 cmake --build ${RMM_BUILD_DIR}
244
245###############
246Running the RMM
247###############
248
249The |RMM| is part of the CCA software stack and relies on EL3 Firmware to load
250the binary at boot time appropriately. It needs both EL3 Firmware and
251Non-Secure Host to be present at runtime for its functionality. The EL3
252Firmware must comply to `RMM-EL3 Communication Specification`_ and is
253typically the `TF-A`_. The Non-Secure Host can be an RME aware hypervisor
254or an appropriate Test utility running in Non-Secure world which can interact
255with |RMM| via Realm Management Interface (RMI).
256
257The `TF-A`_ project includes build and run instructions for an RME enabled
258system on the FVP platform as part of `TF-A RME documentation`_.
259The ``rmm.img`` binary is provided to the TF-A bootloader to be packaged
260in FIP using ``RMM`` build option in `TF-A`_.
261
262If |RMM| is built for the `fake_host` architecture
263(see :ref:`RMM Fake Host Build`), then the generated `rmm.elf` binary can
264run natively on the Host machine. It does this by emulating parts of the system
265as described in :ref:`RMM Fake host architecture` design.
266
267-----
268
269.. _Arm Developer website: https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads
270.. _LLVM Releases website: https://releases.llvm.org/
271.. _RMM-EL3 Communication Specification: https://trustedfirmware-a.readthedocs.io/en/latest/components/rmm-el3-comms-spec.html
272.. _TF-A: https://www.trustedfirmware.org/projects/tf-a/
273.. _TF-A RME documentation: https://trustedfirmware-a.readthedocs.io/en/latest/components/realm-management-extension.html
274.. _TF-RMM Gerrit page: https://review.trustedfirmware.org/admin/repos/TF-RMM/tf-rmm
275.. _Git hooks documentation: https://git-scm.com/docs/githooks