blob: 040d9ce0075a905ebae8ed37e2190637b016917f [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)"
Sona Mathew44713562024-08-11 23:18:32 -050058 "Cppcheck",">=2.14.0","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
Soby Mathewb5a29752024-11-14 14:26:11 +0000188 git clone https://git.trustedfirmware.org/TF-RMM/tf-rmm.git
189
190Note that the RMM submodule dependencies will be updated during the
191configuration phase of build.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000192
193Additional steps for Contributors
194*********************************
195
196If you are planning on contributing back to RMM, your commits need to
197include a ``Change-Id`` footer as explained in :ref:`mandated-trailers`.
198This footer is generated by a Git hook that needs to be installed
199inside your cloned RMM source folder.
200
201The `TF-RMM Gerrit page`_ under trustedfirmware.org contains a
202*Clone with commit-msg hook* subsection under its **Download** header where
Javier Almansa Sobrino6166c032022-11-10 14:24:03 +0000203you can copy the command to clone the repo with the required git hooks. Please
204use the **SSH** option to clone the repository on your local machine.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000205
206If needed, you can also manually install the hooks separately on an existing
207repo:
208
209.. code:: shell
210
211 curl -Lo $(git rev-parse --git-dir)/hooks/commit-msg https://review.trustedfirmware.org/tools/hooks/commit-msg
212 chmod +x $(git rev-parse --git-dir)/hooks/commit-msg
213
214You can read more about Git hooks in the *githooks* page of the `Git hooks
215documentation`_.
216
Soby Mathew78bdfb12024-05-09 16:58:04 +0100217General contribution guidelines for contributors can be found in
218:ref:`Contributor's Guide`.
219
Soby Mathewb4c6df42022-11-09 11:13:29 +0000220#################################
221Install Cppcheck and dependencies
222#################################
223
224.. note::
225
226 The installation of Cppcheck is an optional step. This is required only
227 if using the Cppcheck static analysis.
228
Soby Mathew78bdfb12024-05-09 16:58:04 +0100229The recommended version of Cppcheck is indicated in :ref:`tool_dependencies`.
Shruti Gupta57b80382024-04-24 11:35:18 +0100230See :ref:`Cppcheck Application Note` for installation steps and details
231on how to use it within RMM build system.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000232
Mate Toth-Pal83a45bd2023-09-01 11:17:19 +0200233############
234Install CBMC
235############
236
237.. note::
238
239 The installation of CBMC is an optional step. This is required only
240 if running source code analysis with CBMC.
241
242Follow the public documentation to install CBMC either from the official
243website https://www.cprover.org/cbmc/ or from the official github
244https://github.com/diffblue/cbmc
245
Soby Mathew78bdfb12024-05-09 16:58:04 +0100246Refer to :ref:`CBMC` Application Notes for details on installation and
247running CBMC analysis on TF-RMM sources.
248
249##################
250Install Clang-tidy
251##################
252
253Clang-tidy is included in LLVM release package. It can also be installed via
254package manager :
255
256.. code-block:: bash
257
258 sudo apt-get install clang-tidy
259
260Note that the ``RMM_TOOLCHAIN`` needs to be set to `llvm` to run clang-tidy
261build targets from RMM build system.
262
Soby Mathewb4c6df42022-11-09 11:13:29 +0000263###########################
264Performing an Initial Build
265###########################
266
267The |RMM| sources can be compiled using multiple CMake options.
268
269For detailed instructions on build configurations and examples
270see :ref:`build_options_examples`.
271
272A typical build command for the FVP platform using GCC toolchain
273is shown below:
274
275.. code-block:: bash
276
277 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
278 cmake --build ${RMM_BUILD_DIR}
279
280###############
281Running the RMM
282###############
283
284The |RMM| is part of the CCA software stack and relies on EL3 Firmware to load
285the binary at boot time appropriately. It needs both EL3 Firmware and
286Non-Secure Host to be present at runtime for its functionality. The EL3
287Firmware must comply to `RMM-EL3 Communication Specification`_ and is
288typically the `TF-A`_. The Non-Secure Host can be an RME aware hypervisor
289or an appropriate Test utility running in Non-Secure world which can interact
290with |RMM| via Realm Management Interface (RMI).
291
Javier Almansa Sobrino82edb892024-05-01 11:44:25 +0100292Building all of the involved stack is complicated. We recommend using the
293`Shrinkwrap`_ tooling to bootstrap the stack. For more details on `Shrinkwrap`_
294and utilizing configs and overlays included in |RMM| please refer to
295:ref:`using_shrinkwrap_with_rmm` and, specially for building a demonstrator
296for 3-world, you can refer to :ref:`3_world_testing`.
297
298The |TF-A| documentation also provides some documentation to build |TF-A| and
299other pieces of firmware for RME in `TF-A RME documentation`_. The |RMM| build
300option in |TF-A| should point to the ``rmm.img`` binary generated by building
301|RMM|.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000302
303If |RMM| is built for the `fake_host` architecture
304(see :ref:`RMM Fake Host Build`), then the generated `rmm.elf` binary can
305run natively on the Host machine. It does this by emulating parts of the system
306as described in :ref:`RMM Fake host architecture` design.
307
308-----
309
310.. _Arm Developer website: https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads
311.. _LLVM Releases website: https://releases.llvm.org/
312.. _RMM-EL3 Communication Specification: https://trustedfirmware-a.readthedocs.io/en/latest/components/rmm-el3-comms-spec.html
313.. _TF-A: https://www.trustedfirmware.org/projects/tf-a/
314.. _TF-A RME documentation: https://trustedfirmware-a.readthedocs.io/en/latest/components/realm-management-extension.html
315.. _TF-RMM Gerrit page: https://review.trustedfirmware.org/admin/repos/TF-RMM/tf-rmm
316.. _Git hooks documentation: https://git-scm.com/docs/githooks
Javier Almansa Sobrino82edb892024-05-01 11:44:25 +0100317.. _Shrinkwrap: https://shrinkwrap.docs.arm.com