blob: bbf744ec8f27326b6e764ab1c8732b6fd818967c [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 Mathewb4c6df42022-11-09 11:13:29 +000054
55.. _getting_started_toolchain:
56
57###############
58Setup Toolchain
59###############
60
61To compile |RMM| code for an AArch64 target, at least one of the
62supported AArch64 toolchains have to be available in the
63build environment.
64
65Currently, the following compilers are supported:
66
67- GCC (aarch64-none-elf-) >= 10.2-2020.11 (from the `Arm Developer website`_)
68- Clang+LLVM >= 14.0.0 (from the `LLVM Releases website`_)
69
70The respective compiler binary must be found in the shell's search path.
71Be sure to add the bin/ directory if you have downloaded a binary version.
72The toolchain to use can be set using ``RMM_TOOLCHAIN`` parameter and can
73be set to either `llvm` or `gnu`. The default toolchain is `gnu`.
74
75For non-native AArch64 target build, the ``CROSS_COMPILE`` environment
76variable must contain the right target triplet corresponding to the AArch64
77GCC compiler. Below is an example when RMM is to be built for AArch64 target
78on a non-native host machine and using GCC as the toolchain.
79
80 .. code-block:: bash
81
82 export CROSS_COMPILE=aarch64-none-elf-
83 export PATH=<path-to-aarch64-gcc>/bin:$PATH
84
85Please note that AArch64 GCC must be included in the shell's search path
86even when using Clang as the compiler as LLVM does not include some C
87standard headers like `stdlib.h` and needs to be picked up from the
88`include` folder of the AArch64 GCC. Below is an example when RMM is
89to be built for AArch64 target on a non-native host machine and using
90LLVM as the toolchain.
91
92 .. code-block:: bash
93
94 export CROSS_COMPILE=aarch64-none-elf-
95 export PATH=<path-to-aarch64-gcc>/bin:<path-to-clang+llvm>/bin:$PATH
96
97The ``CROSS_COMPILE`` variable is ignored for ``fake_host`` build and
98the native host toolchain is used for the build.
99
100#######################################
Soby Mathewf572d3b2022-11-21 12:30:11 +0000101Package Installation (Ubuntu-20.04 x64)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000102#######################################
103
104If you are using the recommended Ubuntu distribution then we can install the
105required packages with the following commands:
106
1071. Install dependencies:
108
109.. code:: shell
110
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000111 sudo apt-get install -y git build-essential python3 python3-pip make ninja-build
Soby Mathewb4c6df42022-11-09 11:13:29 +0000112 sudo snap install cmake
Soby Mathewb4c6df42022-11-09 11:13:29 +0000113
1142. Verify cmake version:
115
116.. code-block:: bash
117
118 cmake --version
119
120.. note::
121
122 Please download cmake 3.19 or later version from https://cmake.org/download/.
123
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +00001243. Add CMake path into environment:
Soby Mathewb4c6df42022-11-09 11:13:29 +0000125
126.. code-block:: bash
127
128 export PATH=<CMake path>/bin:$PATH
Soby Mathewb4c6df42022-11-09 11:13:29 +0000129
130###########################
131Install python dependencies
132###########################
133
134.. note::
135
136 The installation of Python dependencies is an optional step. This is required only
137 if building documentation.
138
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000139RMM's ``docs/requirements.txt`` file declares additional Python dependencies.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000140Install them with ``pip3``:
141
142.. code-block:: bash
143
144 pip3 install --upgrade pip
145 cd <rmm source folder>
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000146 pip3 install -r docs/requirements.txt
Soby Mathewb4c6df42022-11-09 11:13:29 +0000147
Javier Almansa Sobrino576071e2022-09-09 16:01:17 +0100148############################################
149Install coverage tools analysis dependencies
150############################################
151
152.. note::
153
154 This is an optional step only needed if you intend to run coverage
155 analysis on the source code.
156
157On Ubuntu, ``gcovr`` tool can be installed in two different ways:
158
159Using the pagckage manager:
160
161.. code-block:: bash
162
163 sudo apt-get install gcovr
164
165The second (and recommended) way is install it with ``pip3``:
166
167.. code-block:: bash
168
169 pip3 install --upgrade pip
170 pip3 install gcovr
171
Soby Mathewb4c6df42022-11-09 11:13:29 +0000172.. _getting_started_get_source:
173
174#########################
175Getting the RMM Source
176#########################
177
178Source code for |RMM| is maintained in a Git repository hosted on TrustedFirmware.org.
179To clone this repository from the server, run the following in your shell:
180
181.. code-block:: bash
182
183 git clone --recursive https://git.trustedfirmware.org/TF-RMM/tf-rmm.git
184
185Additional steps for Contributors
186*********************************
187
188If you are planning on contributing back to RMM, your commits need to
189include a ``Change-Id`` footer as explained in :ref:`mandated-trailers`.
190This footer is generated by a Git hook that needs to be installed
191inside your cloned RMM source folder.
192
193The `TF-RMM Gerrit page`_ under trustedfirmware.org contains a
194*Clone with commit-msg hook* subsection under its **Download** header where
Javier Almansa Sobrino6166c032022-11-10 14:24:03 +0000195you can copy the command to clone the repo with the required git hooks. Please
196use the **SSH** option to clone the repository on your local machine.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000197
198If needed, you can also manually install the hooks separately on an existing
199repo:
200
201.. code:: shell
202
203 curl -Lo $(git rev-parse --git-dir)/hooks/commit-msg https://review.trustedfirmware.org/tools/hooks/commit-msg
204 chmod +x $(git rev-parse --git-dir)/hooks/commit-msg
205
206You can read more about Git hooks in the *githooks* page of the `Git hooks
207documentation`_.
208
209#################################
210Install Cppcheck and dependencies
211#################################
212
213.. note::
214
215 The installation of Cppcheck is an optional step. This is required only
216 if using the Cppcheck static analysis.
217
218Follow the public documentation to install Cppcheck either from the official
219website https://cppcheck.sourceforge.io/#download or from the official github
220https://github.com/danmar/cppcheck/
221
222If you own a valid copy of a MISRA rules file:
223
224.. code-block:: bash
225
226 sudo mkdir /usr/local/share/Cppcheck/misra
227 sudo cp -a <path to the misra rules file>/<file name> /usr/local/share/Cppcheck/misra/misra.rules
228
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