blob: b8c8f87472aed0f2f1069d5317452919fc7ff031 [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
Shruti Gupta57b80382024-04-24 11:35:18 +010035.. _tool_dependencies:
36
Soby Mathewb4c6df42022-11-09 11:13:29 +000037The following tools are required to obtain and build |RMM|:
38
39.. csv-table:: Tool dependencies
40 :header: "Name", "Version", "Component"
41
42 "C compiler", see :ref:`getting_started_toolchain` ,"Firmware"
43 "CMake", ">=3.15.0", "Firmware, Documentation"
44 "GNU Make", ">4.0", "Firmware, Documentation"
45 "Python",3.x,"Firmware, Documentation"
46 "Perl",>=5.26,"Firmware, Documentation"
47 "ninja-build",,"Firmware (using Ninja Generator)"
48 "Sphinx",">=2.4,<3.0.0","Documentation"
49 "sphinxcontrib-plantuml",,"Documentation"
50 "sphinx-rtd-theme",,"Documentation"
51 "Git",, "Firmware, Documentation"
52 "Graphviz dot",">v2.38.0","Documentation"
53 "docutils",">v2.38.0","Documentation"
Javier Almansa Sobrino576071e2022-09-09 16:01:17 +010054 "gcovr",">=v4.2","Tools(Coverage analysis)"
Mate Toth-Pal83a45bd2023-09-01 11:17:19 +020055 "CBMC",">=5.84.0","Tools(CBMC analysis)"
Shruti Gupta57b80382024-04-24 11:35:18 +010056 "CPPcheck",">=2.13.4","Tools(CPPcheck)"
Soby Mathewb4c6df42022-11-09 11:13:29 +000057
58.. _getting_started_toolchain:
59
60###############
61Setup Toolchain
62###############
63
64To compile |RMM| code for an AArch64 target, at least one of the
65supported AArch64 toolchains have to be available in the
66build environment.
67
68Currently, the following compilers are supported:
69
70- GCC (aarch64-none-elf-) >= 10.2-2020.11 (from the `Arm Developer website`_)
71- Clang+LLVM >= 14.0.0 (from the `LLVM Releases website`_)
72
73The respective compiler binary must be found in the shell's search path.
74Be sure to add the bin/ directory if you have downloaded a binary version.
75The toolchain to use can be set using ``RMM_TOOLCHAIN`` parameter and can
76be set to either `llvm` or `gnu`. The default toolchain is `gnu`.
77
78For non-native AArch64 target build, the ``CROSS_COMPILE`` environment
79variable must contain the right target triplet corresponding to the AArch64
80GCC compiler. Below is an example when RMM is to be built for AArch64 target
81on a non-native host machine and using GCC as the toolchain.
82
83 .. code-block:: bash
84
85 export CROSS_COMPILE=aarch64-none-elf-
86 export PATH=<path-to-aarch64-gcc>/bin:$PATH
87
88Please note that AArch64 GCC must be included in the shell's search path
89even when using Clang as the compiler as LLVM does not include some C
90standard headers like `stdlib.h` and needs to be picked up from the
91`include` folder of the AArch64 GCC. Below is an example when RMM is
92to be built for AArch64 target on a non-native host machine and using
93LLVM as the toolchain.
94
95 .. code-block:: bash
96
97 export CROSS_COMPILE=aarch64-none-elf-
98 export PATH=<path-to-aarch64-gcc>/bin:<path-to-clang+llvm>/bin:$PATH
99
100The ``CROSS_COMPILE`` variable is ignored for ``fake_host`` build and
101the native host toolchain is used for the build.
102
103#######################################
Soby Mathewf572d3b2022-11-21 12:30:11 +0000104Package Installation (Ubuntu-20.04 x64)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000105#######################################
106
107If you are using the recommended Ubuntu distribution then we can install the
108required packages with the following commands:
109
1101. Install dependencies:
111
112.. code:: shell
113
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000114 sudo apt-get install -y git build-essential python3 python3-pip make ninja-build
Soby Mathewb4c6df42022-11-09 11:13:29 +0000115 sudo snap install cmake
Soby Mathewb4c6df42022-11-09 11:13:29 +0000116
1172. Verify cmake version:
118
119.. code-block:: bash
120
121 cmake --version
122
123.. note::
124
125 Please download cmake 3.19 or later version from https://cmake.org/download/.
126
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +00001273. Add CMake path into environment:
Soby Mathewb4c6df42022-11-09 11:13:29 +0000128
129.. code-block:: bash
130
131 export PATH=<CMake path>/bin:$PATH
Soby Mathewb4c6df42022-11-09 11:13:29 +0000132
133###########################
134Install python dependencies
135###########################
136
137.. note::
138
139 The installation of Python dependencies is an optional step. This is required only
140 if building documentation.
141
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000142RMM's ``docs/requirements.txt`` file declares additional Python dependencies.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000143Install them with ``pip3``:
144
145.. code-block:: bash
146
147 pip3 install --upgrade pip
148 cd <rmm source folder>
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000149 pip3 install -r docs/requirements.txt
Soby Mathewb4c6df42022-11-09 11:13:29 +0000150
Javier Almansa Sobrino576071e2022-09-09 16:01:17 +0100151############################################
152Install coverage tools analysis dependencies
153############################################
154
155.. note::
156
157 This is an optional step only needed if you intend to run coverage
158 analysis on the source code.
159
160On Ubuntu, ``gcovr`` tool can be installed in two different ways:
161
162Using the pagckage manager:
163
164.. code-block:: bash
165
166 sudo apt-get install gcovr
167
168The second (and recommended) way is install it with ``pip3``:
169
170.. code-block:: bash
171
172 pip3 install --upgrade pip
173 pip3 install gcovr
174
Soby Mathewb4c6df42022-11-09 11:13:29 +0000175.. _getting_started_get_source:
176
177#########################
178Getting the RMM Source
179#########################
180
181Source code for |RMM| is maintained in a Git repository hosted on TrustedFirmware.org.
182To clone this repository from the server, run the following in your shell:
183
184.. code-block:: bash
185
186 git clone --recursive https://git.trustedfirmware.org/TF-RMM/tf-rmm.git
187
188Additional steps for Contributors
189*********************************
190
191If you are planning on contributing back to RMM, your commits need to
192include a ``Change-Id`` footer as explained in :ref:`mandated-trailers`.
193This footer is generated by a Git hook that needs to be installed
194inside your cloned RMM source folder.
195
196The `TF-RMM Gerrit page`_ under trustedfirmware.org contains a
197*Clone with commit-msg hook* subsection under its **Download** header where
Javier Almansa Sobrino6166c032022-11-10 14:24:03 +0000198you can copy the command to clone the repo with the required git hooks. Please
199use the **SSH** option to clone the repository on your local machine.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000200
201If needed, you can also manually install the hooks separately on an existing
202repo:
203
204.. code:: shell
205
206 curl -Lo $(git rev-parse --git-dir)/hooks/commit-msg https://review.trustedfirmware.org/tools/hooks/commit-msg
207 chmod +x $(git rev-parse --git-dir)/hooks/commit-msg
208
209You can read more about Git hooks in the *githooks* page of the `Git hooks
210documentation`_.
211
212#################################
213Install Cppcheck and dependencies
214#################################
215
216.. note::
217
218 The installation of Cppcheck is an optional step. This is required only
219 if using the Cppcheck static analysis.
220
Shruti Gupta57b80382024-04-24 11:35:18 +0100221The recommended version of Cppcheck is indicated :ref:`above<tool_dependencies>`.
222See :ref:`Cppcheck Application Note` for installation steps and details
223on how to use it within RMM build system.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000224
Mate Toth-Pal83a45bd2023-09-01 11:17:19 +0200225############
226Install CBMC
227############
228
229.. note::
230
231 The installation of CBMC is an optional step. This is required only
232 if running source code analysis with CBMC.
233
234Follow the public documentation to install CBMC either from the official
235website https://www.cprover.org/cbmc/ or from the official github
236https://github.com/diffblue/cbmc
237
Soby Mathewb4c6df42022-11-09 11:13:29 +0000238###########################
239Performing an Initial Build
240###########################
241
242The |RMM| sources can be compiled using multiple CMake options.
243
244For detailed instructions on build configurations and examples
245see :ref:`build_options_examples`.
246
247A typical build command for the FVP platform using GCC toolchain
248is shown below:
249
250.. code-block:: bash
251
252 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
253 cmake --build ${RMM_BUILD_DIR}
254
255###############
256Running the RMM
257###############
258
259The |RMM| is part of the CCA software stack and relies on EL3 Firmware to load
260the binary at boot time appropriately. It needs both EL3 Firmware and
261Non-Secure Host to be present at runtime for its functionality. The EL3
262Firmware must comply to `RMM-EL3 Communication Specification`_ and is
263typically the `TF-A`_. The Non-Secure Host can be an RME aware hypervisor
264or an appropriate Test utility running in Non-Secure world which can interact
265with |RMM| via Realm Management Interface (RMI).
266
267The `TF-A`_ project includes build and run instructions for an RME enabled
268system on the FVP platform as part of `TF-A RME documentation`_.
269The ``rmm.img`` binary is provided to the TF-A bootloader to be packaged
270in FIP using ``RMM`` build option in `TF-A`_.
271
272If |RMM| is built for the `fake_host` architecture
273(see :ref:`RMM Fake Host Build`), then the generated `rmm.elf` binary can
274run natively on the Host machine. It does this by emulating parts of the system
275as described in :ref:`RMM Fake host architecture` design.
276
277-----
278
279.. _Arm Developer website: https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads
280.. _LLVM Releases website: https://releases.llvm.org/
281.. _RMM-EL3 Communication Specification: https://trustedfirmware-a.readthedocs.io/en/latest/components/rmm-el3-comms-spec.html
282.. _TF-A: https://www.trustedfirmware.org/projects/tf-a/
283.. _TF-A RME documentation: https://trustedfirmware-a.readthedocs.io/en/latest/components/realm-management-extension.html
284.. _TF-RMM Gerrit page: https://review.trustedfirmware.org/admin/repos/TF-RMM/tf-rmm
285.. _Git hooks documentation: https://git-scm.com/docs/githooks