blob: 87c003de235756821f4aa65e108a1712653732c7 [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)"
Mate Toth-Pal83a45bd2023-09-01 11:17:19 +020053 "CBMC",">=5.84.0","Tools(CBMC analysis)"
Soby Mathew7faa95e2023-11-22 17:04:10 +000054 "CPPcheck",">=1.90","Tools(CPPcheck)"
Soby Mathewb4c6df42022-11-09 11:13:29 +000055
56.. _getting_started_toolchain:
57
58###############
59Setup Toolchain
60###############
61
62To compile |RMM| code for an AArch64 target, at least one of the
63supported AArch64 toolchains have to be available in the
64build environment.
65
66Currently, the following compilers are supported:
67
68- GCC (aarch64-none-elf-) >= 10.2-2020.11 (from the `Arm Developer website`_)
69- Clang+LLVM >= 14.0.0 (from the `LLVM Releases website`_)
70
71The respective compiler binary must be found in the shell's search path.
72Be sure to add the bin/ directory if you have downloaded a binary version.
73The toolchain to use can be set using ``RMM_TOOLCHAIN`` parameter and can
74be set to either `llvm` or `gnu`. The default toolchain is `gnu`.
75
76For non-native AArch64 target build, the ``CROSS_COMPILE`` environment
77variable must contain the right target triplet corresponding to the AArch64
78GCC compiler. Below is an example when RMM is to be built for AArch64 target
79on a non-native host machine and using GCC as the toolchain.
80
81 .. code-block:: bash
82
83 export CROSS_COMPILE=aarch64-none-elf-
84 export PATH=<path-to-aarch64-gcc>/bin:$PATH
85
86Please note that AArch64 GCC must be included in the shell's search path
87even when using Clang as the compiler as LLVM does not include some C
88standard headers like `stdlib.h` and needs to be picked up from the
89`include` folder of the AArch64 GCC. Below is an example when RMM is
90to be built for AArch64 target on a non-native host machine and using
91LLVM as the toolchain.
92
93 .. code-block:: bash
94
95 export CROSS_COMPILE=aarch64-none-elf-
96 export PATH=<path-to-aarch64-gcc>/bin:<path-to-clang+llvm>/bin:$PATH
97
98The ``CROSS_COMPILE`` variable is ignored for ``fake_host`` build and
99the native host toolchain is used for the build.
100
101#######################################
Soby Mathewf572d3b2022-11-21 12:30:11 +0000102Package Installation (Ubuntu-20.04 x64)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000103#######################################
104
105If you are using the recommended Ubuntu distribution then we can install the
106required packages with the following commands:
107
1081. Install dependencies:
109
110.. code:: shell
111
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000112 sudo apt-get install -y git build-essential python3 python3-pip make ninja-build
Soby Mathewb4c6df42022-11-09 11:13:29 +0000113 sudo snap install cmake
Soby Mathewb4c6df42022-11-09 11:13:29 +0000114
1152. Verify cmake version:
116
117.. code-block:: bash
118
119 cmake --version
120
121.. note::
122
123 Please download cmake 3.19 or later version from https://cmake.org/download/.
124
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +00001253. Add CMake path into environment:
Soby Mathewb4c6df42022-11-09 11:13:29 +0000126
127.. code-block:: bash
128
129 export PATH=<CMake path>/bin:$PATH
Soby Mathewb4c6df42022-11-09 11:13:29 +0000130
131###########################
132Install python dependencies
133###########################
134
135.. note::
136
137 The installation of Python dependencies is an optional step. This is required only
138 if building documentation.
139
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000140RMM's ``docs/requirements.txt`` file declares additional Python dependencies.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000141Install them with ``pip3``:
142
143.. code-block:: bash
144
145 pip3 install --upgrade pip
146 cd <rmm source folder>
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000147 pip3 install -r docs/requirements.txt
Soby Mathewb4c6df42022-11-09 11:13:29 +0000148
Javier Almansa Sobrino576071e2022-09-09 16:01:17 +0100149############################################
150Install coverage tools analysis dependencies
151############################################
152
153.. note::
154
155 This is an optional step only needed if you intend to run coverage
156 analysis on the source code.
157
158On Ubuntu, ``gcovr`` tool can be installed in two different ways:
159
160Using the pagckage manager:
161
162.. code-block:: bash
163
164 sudo apt-get install gcovr
165
166The second (and recommended) way is install it with ``pip3``:
167
168.. code-block:: bash
169
170 pip3 install --upgrade pip
171 pip3 install gcovr
172
Soby Mathewb4c6df42022-11-09 11:13:29 +0000173.. _getting_started_get_source:
174
175#########################
176Getting the RMM Source
177#########################
178
179Source code for |RMM| is maintained in a Git repository hosted on TrustedFirmware.org.
180To clone this repository from the server, run the following in your shell:
181
182.. code-block:: bash
183
184 git clone --recursive https://git.trustedfirmware.org/TF-RMM/tf-rmm.git
185
186Additional steps for Contributors
187*********************************
188
189If you are planning on contributing back to RMM, your commits need to
190include a ``Change-Id`` footer as explained in :ref:`mandated-trailers`.
191This footer is generated by a Git hook that needs to be installed
192inside your cloned RMM source folder.
193
194The `TF-RMM Gerrit page`_ under trustedfirmware.org contains a
195*Clone with commit-msg hook* subsection under its **Download** header where
Javier Almansa Sobrino6166c032022-11-10 14:24:03 +0000196you can copy the command to clone the repo with the required git hooks. Please
197use the **SSH** option to clone the repository on your local machine.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000198
199If needed, you can also manually install the hooks separately on an existing
200repo:
201
202.. code:: shell
203
204 curl -Lo $(git rev-parse --git-dir)/hooks/commit-msg https://review.trustedfirmware.org/tools/hooks/commit-msg
205 chmod +x $(git rev-parse --git-dir)/hooks/commit-msg
206
207You can read more about Git hooks in the *githooks* page of the `Git hooks
208documentation`_.
209
210#################################
211Install Cppcheck and dependencies
212#################################
213
214.. note::
215
216 The installation of Cppcheck is an optional step. This is required only
217 if using the Cppcheck static analysis.
218
219Follow the public documentation to install Cppcheck either from the official
Soby Mathew7faa95e2023-11-22 17:04:10 +0000220website https://cppcheck.sourceforge.io/ or from the official github
Soby Mathewb4c6df42022-11-09 11:13:29 +0000221https://github.com/danmar/cppcheck/
222
223If you own a valid copy of a MISRA rules file:
224
225.. code-block:: bash
226
Soby Mathew7faa95e2023-11-22 17:04:10 +0000227 cp -a <path to the misra rules file>/<file name> ${RMM_SOURCE_DIR}/tools/cppcheck/misra.rules
Soby Mathewb4c6df42022-11-09 11:13:29 +0000228
Mate Toth-Pal83a45bd2023-09-01 11:17:19 +0200229############
230Install CBMC
231############
232
233.. note::
234
235 The installation of CBMC is an optional step. This is required only
236 if running source code analysis with CBMC.
237
238Follow the public documentation to install CBMC either from the official
239website https://www.cprover.org/cbmc/ or from the official github
240https://github.com/diffblue/cbmc
241
Soby Mathewb4c6df42022-11-09 11:13:29 +0000242###########################
243Performing an Initial Build
244###########################
245
246The |RMM| sources can be compiled using multiple CMake options.
247
248For detailed instructions on build configurations and examples
249see :ref:`build_options_examples`.
250
251A typical build command for the FVP platform using GCC toolchain
252is shown below:
253
254.. code-block:: bash
255
256 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
257 cmake --build ${RMM_BUILD_DIR}
258
259###############
260Running the RMM
261###############
262
263The |RMM| is part of the CCA software stack and relies on EL3 Firmware to load
264the binary at boot time appropriately. It needs both EL3 Firmware and
265Non-Secure Host to be present at runtime for its functionality. The EL3
266Firmware must comply to `RMM-EL3 Communication Specification`_ and is
267typically the `TF-A`_. The Non-Secure Host can be an RME aware hypervisor
268or an appropriate Test utility running in Non-Secure world which can interact
269with |RMM| via Realm Management Interface (RMI).
270
271The `TF-A`_ project includes build and run instructions for an RME enabled
272system on the FVP platform as part of `TF-A RME documentation`_.
273The ``rmm.img`` binary is provided to the TF-A bootloader to be packaged
274in FIP using ``RMM`` build option in `TF-A`_.
275
276If |RMM| is built for the `fake_host` architecture
277(see :ref:`RMM Fake Host Build`), then the generated `rmm.elf` binary can
278run natively on the Host machine. It does this by emulating parts of the system
279as described in :ref:`RMM Fake host architecture` design.
280
281-----
282
283.. _Arm Developer website: https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads
284.. _LLVM Releases website: https://releases.llvm.org/
285.. _RMM-EL3 Communication Specification: https://trustedfirmware-a.readthedocs.io/en/latest/components/rmm-el3-comms-spec.html
286.. _TF-A: https://www.trustedfirmware.org/projects/tf-a/
287.. _TF-A RME documentation: https://trustedfirmware-a.readthedocs.io/en/latest/components/realm-management-extension.html
288.. _TF-RMM Gerrit page: https://review.trustedfirmware.org/admin/repos/TF-RMM/tf-rmm
289.. _Git hooks documentation: https://git-scm.com/docs/githooks