blob: 72889e4c91eca7f59faad32d8b427a6203a58f20 [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
8This document describes the software requirements for building |RMM| for AArch64 target platforms.
9
10It may possible to build |RMM| with combinations of software packages that are different from
11those listed below, however only the software described in this document can be officially supported.
12
13###########
14Build Host
15###########
16
17The |RMM| officially supports a limited set of build environments and setups.
18In this context, official support means that the environments listed below
19are actively used by team members and active developers, hence users should
20be able to recreate the same configurations by following the instructions
21described below. In case of problems, the |RMM| team provides support only
22for these environments, but building in other environments can still be
23possible.
24
25A relatively recent Linux distribution is recommended for building RMM. We
26have performed tests using Ubuntu 18.04 LTS (64-bit) but other distributions
27should also work fine as a base, provided that the necessary tools and
28libraries can be installed.
29
30##########################
31Tool & Dependency overview
32##########################
33
34The following tools are required to obtain and build |RMM|:
35
36.. csv-table:: Tool dependencies
37 :header: "Name", "Version", "Component"
38
39 "C compiler", see :ref:`getting_started_toolchain` ,"Firmware"
40 "CMake", ">=3.15.0", "Firmware, Documentation"
41 "GNU Make", ">4.0", "Firmware, Documentation"
42 "Python",3.x,"Firmware, Documentation"
43 "Perl",>=5.26,"Firmware, Documentation"
44 "ninja-build",,"Firmware (using Ninja Generator)"
45 "Sphinx",">=2.4,<3.0.0","Documentation"
46 "sphinxcontrib-plantuml",,"Documentation"
47 "sphinx-rtd-theme",,"Documentation"
48 "Git",, "Firmware, Documentation"
49 "Graphviz dot",">v2.38.0","Documentation"
50 "docutils",">v2.38.0","Documentation"
Soby Mathewb4c6df42022-11-09 11:13:29 +000051
52.. _getting_started_toolchain:
53
54###############
55Setup Toolchain
56###############
57
58To compile |RMM| code for an AArch64 target, at least one of the
59supported AArch64 toolchains have to be available in the
60build environment.
61
62Currently, the following compilers are supported:
63
64- GCC (aarch64-none-elf-) >= 10.2-2020.11 (from the `Arm Developer website`_)
65- Clang+LLVM >= 14.0.0 (from the `LLVM Releases website`_)
66
67The respective compiler binary must be found in the shell's search path.
68Be sure to add the bin/ directory if you have downloaded a binary version.
69The toolchain to use can be set using ``RMM_TOOLCHAIN`` parameter and can
70be set to either `llvm` or `gnu`. The default toolchain is `gnu`.
71
72For non-native AArch64 target build, the ``CROSS_COMPILE`` environment
73variable must contain the right target triplet corresponding to the AArch64
74GCC compiler. Below is an example when RMM is to be built for AArch64 target
75on a non-native host machine and using GCC as the toolchain.
76
77 .. code-block:: bash
78
79 export CROSS_COMPILE=aarch64-none-elf-
80 export PATH=<path-to-aarch64-gcc>/bin:$PATH
81
82Please note that AArch64 GCC must be included in the shell's search path
83even when using Clang as the compiler as LLVM does not include some C
84standard headers like `stdlib.h` and needs to be picked up from the
85`include` folder of the AArch64 GCC. Below is an example when RMM is
86to be built for AArch64 target on a non-native host machine and using
87LLVM as the toolchain.
88
89 .. code-block:: bash
90
91 export CROSS_COMPILE=aarch64-none-elf-
92 export PATH=<path-to-aarch64-gcc>/bin:<path-to-clang+llvm>/bin:$PATH
93
94The ``CROSS_COMPILE`` variable is ignored for ``fake_host`` build and
95the native host toolchain is used for the build.
96
97#######################################
98Package Installation (Ubuntu-18.04 x64)
99#######################################
100
101If you are using the recommended Ubuntu distribution then we can install the
102required packages with the following commands:
103
1041. Install dependencies:
105
106.. code:: shell
107
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000108 sudo apt-get install -y git build-essential python3 python3-pip make ninja-build
Soby Mathewb4c6df42022-11-09 11:13:29 +0000109 sudo snap install cmake
Soby Mathewb4c6df42022-11-09 11:13:29 +0000110
1112. Verify cmake version:
112
113.. code-block:: bash
114
115 cmake --version
116
117.. note::
118
119 Please download cmake 3.19 or later version from https://cmake.org/download/.
120
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +00001213. Add CMake path into environment:
Soby Mathewb4c6df42022-11-09 11:13:29 +0000122
123.. code-block:: bash
124
125 export PATH=<CMake path>/bin:$PATH
Soby Mathewb4c6df42022-11-09 11:13:29 +0000126
127###########################
128Install python dependencies
129###########################
130
131.. note::
132
133 The installation of Python dependencies is an optional step. This is required only
134 if building documentation.
135
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000136RMM's ``docs/requirements.txt`` file declares additional Python dependencies.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000137Install them with ``pip3``:
138
139.. code-block:: bash
140
141 pip3 install --upgrade pip
142 cd <rmm source folder>
Arunachalam Ganapathyf1a13aa2022-11-11 15:07:12 +0000143 pip3 install -r docs/requirements.txt
Soby Mathewb4c6df42022-11-09 11:13:29 +0000144
145.. _getting_started_get_source:
146
147#########################
148Getting the RMM Source
149#########################
150
151Source code for |RMM| is maintained in a Git repository hosted on TrustedFirmware.org.
152To clone this repository from the server, run the following in your shell:
153
154.. code-block:: bash
155
156 git clone --recursive https://git.trustedfirmware.org/TF-RMM/tf-rmm.git
157
158Additional steps for Contributors
159*********************************
160
161If you are planning on contributing back to RMM, your commits need to
162include a ``Change-Id`` footer as explained in :ref:`mandated-trailers`.
163This footer is generated by a Git hook that needs to be installed
164inside your cloned RMM source folder.
165
166The `TF-RMM Gerrit page`_ under trustedfirmware.org contains a
167*Clone with commit-msg hook* subsection under its **Download** header where
Javier Almansa Sobrino6166c032022-11-10 14:24:03 +0000168you can copy the command to clone the repo with the required git hooks. Please
169use the **SSH** option to clone the repository on your local machine.
Soby Mathewb4c6df42022-11-09 11:13:29 +0000170
171If needed, you can also manually install the hooks separately on an existing
172repo:
173
174.. code:: shell
175
176 curl -Lo $(git rev-parse --git-dir)/hooks/commit-msg https://review.trustedfirmware.org/tools/hooks/commit-msg
177 chmod +x $(git rev-parse --git-dir)/hooks/commit-msg
178
179You can read more about Git hooks in the *githooks* page of the `Git hooks
180documentation`_.
181
182#################################
183Install Cppcheck and dependencies
184#################################
185
186.. note::
187
188 The installation of Cppcheck is an optional step. This is required only
189 if using the Cppcheck static analysis.
190
191Follow the public documentation to install Cppcheck either from the official
192website https://cppcheck.sourceforge.io/#download or from the official github
193https://github.com/danmar/cppcheck/
194
195If you own a valid copy of a MISRA rules file:
196
197.. code-block:: bash
198
199 sudo mkdir /usr/local/share/Cppcheck/misra
200 sudo cp -a <path to the misra rules file>/<file name> /usr/local/share/Cppcheck/misra/misra.rules
201
202###########################
203Performing an Initial Build
204###########################
205
206The |RMM| sources can be compiled using multiple CMake options.
207
208For detailed instructions on build configurations and examples
209see :ref:`build_options_examples`.
210
211A typical build command for the FVP platform using GCC toolchain
212is shown below:
213
214.. code-block:: bash
215
216 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
217 cmake --build ${RMM_BUILD_DIR}
218
219###############
220Running the RMM
221###############
222
223The |RMM| is part of the CCA software stack and relies on EL3 Firmware to load
224the binary at boot time appropriately. It needs both EL3 Firmware and
225Non-Secure Host to be present at runtime for its functionality. The EL3
226Firmware must comply to `RMM-EL3 Communication Specification`_ and is
227typically the `TF-A`_. The Non-Secure Host can be an RME aware hypervisor
228or an appropriate Test utility running in Non-Secure world which can interact
229with |RMM| via Realm Management Interface (RMI).
230
231The `TF-A`_ project includes build and run instructions for an RME enabled
232system on the FVP platform as part of `TF-A RME documentation`_.
233The ``rmm.img`` binary is provided to the TF-A bootloader to be packaged
234in FIP using ``RMM`` build option in `TF-A`_.
235
236If |RMM| is built for the `fake_host` architecture
237(see :ref:`RMM Fake Host Build`), then the generated `rmm.elf` binary can
238run natively on the Host machine. It does this by emulating parts of the system
239as described in :ref:`RMM Fake host architecture` design.
240
241-----
242
243.. _Arm Developer website: https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads
244.. _LLVM Releases website: https://releases.llvm.org/
245.. _RMM-EL3 Communication Specification: https://trustedfirmware-a.readthedocs.io/en/latest/components/rmm-el3-comms-spec.html
246.. _TF-A: https://www.trustedfirmware.org/projects/tf-a/
247.. _TF-A RME documentation: https://trustedfirmware-a.readthedocs.io/en/latest/components/realm-management-extension.html
248.. _TF-RMM Gerrit page: https://review.trustedfirmware.org/admin/repos/TF-RMM/tf-rmm
249.. _Git hooks documentation: https://git-scm.com/docs/githooks