blob: 367b1d628b464ca5d4af8b9fc28ca72bb48705a7 [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"
45 "CMake", ">=3.15.0", "Firmware, Documentation"
46 "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)"
Soby Mathew78bdfb12024-05-09 16:58:04 +010058 "Cppcheck",">=2.13.4","Tools(Cppcheck)"
Soby Mathewb4c6df42022-11-09 11:13:29 +000059
60.. _getting_started_toolchain:
61
62###############
63Setup Toolchain
64###############
65
66To compile |RMM| code for an AArch64 target, at least one of the
67supported AArch64 toolchains have to be available in the
68build environment.
69
70Currently, the following compilers are supported:
71
72- GCC (aarch64-none-elf-) >= 10.2-2020.11 (from the `Arm Developer website`_)
73- Clang+LLVM >= 14.0.0 (from the `LLVM Releases website`_)
74
75The respective compiler binary must be found in the shell's search path.
76Be sure to add the bin/ directory if you have downloaded a binary version.
77The toolchain to use can be set using ``RMM_TOOLCHAIN`` parameter and can
78be set to either `llvm` or `gnu`. The default toolchain is `gnu`.
79
80For non-native AArch64 target build, the ``CROSS_COMPILE`` environment
81variable must contain the right target triplet corresponding to the AArch64
82GCC compiler. Below is an example when RMM is to be built for AArch64 target
83on a non-native host machine and using GCC as the toolchain.
84
85 .. code-block:: bash
86
87 export CROSS_COMPILE=aarch64-none-elf-
88 export PATH=<path-to-aarch64-gcc>/bin:$PATH
89
90Please note that AArch64 GCC must be included in the shell's search path
91even when using Clang as the compiler as LLVM does not include some C
92standard headers like `stdlib.h` and needs to be picked up from the
93`include` folder of the AArch64 GCC. Below is an example when RMM is
94to be built for AArch64 target on a non-native host machine and using
95LLVM as the toolchain.
96
97 .. code-block:: bash
98
99 export CROSS_COMPILE=aarch64-none-elf-
100 export PATH=<path-to-aarch64-gcc>/bin:<path-to-clang+llvm>/bin:$PATH
101
102The ``CROSS_COMPILE`` variable is ignored for ``fake_host`` build and
103the native host toolchain is used for the build.
104
105#######################################
Soby Mathewf572d3b2022-11-21 12:30:11 +0000106Package Installation (Ubuntu-20.04 x64)
Soby Mathewb4c6df42022-11-09 11:13:29 +0000107#######################################
108
109If you are using the recommended Ubuntu distribution then we can install the
110required packages with the following commands:
111
1121. Install dependencies:
113
114.. code:: shell
115
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000116 sudo apt-get install -y git build-essential python3 python3-pip make ninja-build
Soby Mathewb4c6df42022-11-09 11:13:29 +0000117 sudo snap install cmake
Soby Mathewb4c6df42022-11-09 11:13:29 +0000118
1192. Verify cmake version:
120
121.. code-block:: bash
122
123 cmake --version
124
125.. note::
126
127 Please download cmake 3.19 or later version from https://cmake.org/download/.
128
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +00001293. Add CMake path into environment:
Soby Mathewb4c6df42022-11-09 11:13:29 +0000130
131.. code-block:: bash
132
133 export PATH=<CMake path>/bin:$PATH
Soby Mathewb4c6df42022-11-09 11:13:29 +0000134
135###########################
136Install python dependencies
137###########################
138
139.. note::
140
141 The installation of Python dependencies is an optional step. This is required only
142 if building documentation.
143
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000144RMM's ``docs/requirements.txt`` file declares additional Python dependencies.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000145Install them with ``pip3``:
146
147.. code-block:: bash
148
149 pip3 install --upgrade pip
150 cd <rmm source folder>
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000151 pip3 install -r docs/requirements.txt
Soby Mathewb4c6df42022-11-09 11:13:29 +0000152
Javier Almansa Sobrino576071e2022-09-09 16:01:17 +0100153############################################
154Install coverage tools analysis dependencies
155############################################
156
157.. note::
158
159 This is an optional step only needed if you intend to run coverage
160 analysis on the source code.
161
162On Ubuntu, ``gcovr`` tool can be installed in two different ways:
163
Soby Mathew78bdfb12024-05-09 16:58:04 +0100164Using the package manager:
Javier Almansa Sobrino576071e2022-09-09 16:01:17 +0100165
166.. code-block:: bash
167
168 sudo apt-get install gcovr
169
170The second (and recommended) way is install it with ``pip3``:
171
172.. code-block:: bash
173
174 pip3 install --upgrade pip
175 pip3 install gcovr
176
Soby Mathewb4c6df42022-11-09 11:13:29 +0000177.. _getting_started_get_source:
178
179#########################
180Getting the RMM Source
181#########################
182
183Source code for |RMM| is maintained in a Git repository hosted on TrustedFirmware.org.
184To clone this repository from the server, run the following in your shell:
185
186.. code-block:: bash
187
188 git clone --recursive https://git.trustedfirmware.org/TF-RMM/tf-rmm.git
189
190Additional steps for Contributors
191*********************************
192
193If you are planning on contributing back to RMM, your commits need to
194include a ``Change-Id`` footer as explained in :ref:`mandated-trailers`.
195This footer is generated by a Git hook that needs to be installed
196inside your cloned RMM source folder.
197
198The `TF-RMM Gerrit page`_ under trustedfirmware.org contains a
199*Clone with commit-msg hook* subsection under its **Download** header where
Javier Almansa Sobrino6166c032022-11-10 14:24:03 +0000200you can copy the command to clone the repo with the required git hooks. Please
201use the **SSH** option to clone the repository on your local machine.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000202
203If needed, you can also manually install the hooks separately on an existing
204repo:
205
206.. code:: shell
207
208 curl -Lo $(git rev-parse --git-dir)/hooks/commit-msg https://review.trustedfirmware.org/tools/hooks/commit-msg
209 chmod +x $(git rev-parse --git-dir)/hooks/commit-msg
210
211You can read more about Git hooks in the *githooks* page of the `Git hooks
212documentation`_.
213
Soby Mathew78bdfb12024-05-09 16:58:04 +0100214General contribution guidelines for contributors can be found in
215:ref:`Contributor's Guide`.
216
Soby Mathewb4c6df42022-11-09 11:13:29 +0000217#################################
218Install Cppcheck and dependencies
219#################################
220
221.. note::
222
223 The installation of Cppcheck is an optional step. This is required only
224 if using the Cppcheck static analysis.
225
Soby Mathew78bdfb12024-05-09 16:58:04 +0100226The recommended version of Cppcheck is indicated in :ref:`tool_dependencies`.
Shruti Gupta57b80382024-04-24 11:35:18 +0100227See :ref:`Cppcheck Application Note` for installation steps and details
228on how to use it within RMM build system.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000229
Mate Toth-Pal83a45bd2023-09-01 11:17:19 +0200230############
231Install CBMC
232############
233
234.. note::
235
236 The installation of CBMC is an optional step. This is required only
237 if running source code analysis with CBMC.
238
239Follow the public documentation to install CBMC either from the official
240website https://www.cprover.org/cbmc/ or from the official github
241https://github.com/diffblue/cbmc
242
Soby Mathew78bdfb12024-05-09 16:58:04 +0100243Refer to :ref:`CBMC` Application Notes for details on installation and
244running CBMC analysis on TF-RMM sources.
245
246##################
247Install Clang-tidy
248##################
249
250Clang-tidy is included in LLVM release package. It can also be installed via
251package manager :
252
253.. code-block:: bash
254
255 sudo apt-get install clang-tidy
256
257Note that the ``RMM_TOOLCHAIN`` needs to be set to `llvm` to run clang-tidy
258build targets from RMM build system.
259
Soby Mathewb4c6df42022-11-09 11:13:29 +0000260###########################
261Performing an Initial Build
262###########################
263
264The |RMM| sources can be compiled using multiple CMake options.
265
266For detailed instructions on build configurations and examples
267see :ref:`build_options_examples`.
268
269A typical build command for the FVP platform using GCC toolchain
270is shown below:
271
272.. code-block:: bash
273
274 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
275 cmake --build ${RMM_BUILD_DIR}
276
277###############
278Running the RMM
279###############
280
281The |RMM| is part of the CCA software stack and relies on EL3 Firmware to load
282the binary at boot time appropriately. It needs both EL3 Firmware and
283Non-Secure Host to be present at runtime for its functionality. The EL3
284Firmware must comply to `RMM-EL3 Communication Specification`_ and is
285typically the `TF-A`_. The Non-Secure Host can be an RME aware hypervisor
286or an appropriate Test utility running in Non-Secure world which can interact
287with |RMM| via Realm Management Interface (RMI).
288
289The `TF-A`_ project includes build and run instructions for an RME enabled
290system on the FVP platform as part of `TF-A RME documentation`_.
291The ``rmm.img`` binary is provided to the TF-A bootloader to be packaged
292in FIP using ``RMM`` build option in `TF-A`_.
293
294If |RMM| is built for the `fake_host` architecture
295(see :ref:`RMM Fake Host Build`), then the generated `rmm.elf` binary can
296run natively on the Host machine. It does this by emulating parts of the system
297as described in :ref:`RMM Fake host architecture` design.
298
299-----
300
301.. _Arm Developer website: https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads
302.. _LLVM Releases website: https://releases.llvm.org/
303.. _RMM-EL3 Communication Specification: https://trustedfirmware-a.readthedocs.io/en/latest/components/rmm-el3-comms-spec.html
304.. _TF-A: https://www.trustedfirmware.org/projects/tf-a/
305.. _TF-A RME documentation: https://trustedfirmware-a.readthedocs.io/en/latest/components/realm-management-extension.html
306.. _TF-RMM Gerrit page: https://review.trustedfirmware.org/admin/repos/TF-RMM/tf-rmm
307.. _Git hooks documentation: https://git-scm.com/docs/githooks