blob: 827c66f0e08d40c3f010ae77b51a8d3f26f92822 [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"
51 "JRE",">=10.0","Documentation"
52 "plantuml",,"Documentation"
53
54.. _getting_started_toolchain:
55
56###############
57Setup Toolchain
58###############
59
60To compile |RMM| code for an AArch64 target, at least one of the
61supported AArch64 toolchains have to be available in the
62build environment.
63
64Currently, the following compilers are supported:
65
66- GCC (aarch64-none-elf-) >= 10.2-2020.11 (from the `Arm Developer website`_)
67- Clang+LLVM >= 14.0.0 (from the `LLVM Releases website`_)
68
69The respective compiler binary must be found in the shell's search path.
70Be sure to add the bin/ directory if you have downloaded a binary version.
71The toolchain to use can be set using ``RMM_TOOLCHAIN`` parameter and can
72be set to either `llvm` or `gnu`. The default toolchain is `gnu`.
73
74For non-native AArch64 target build, the ``CROSS_COMPILE`` environment
75variable must contain the right target triplet corresponding to the AArch64
76GCC compiler. Below is an example when RMM is to be built for AArch64 target
77on a non-native host machine and using GCC as the toolchain.
78
79 .. code-block:: bash
80
81 export CROSS_COMPILE=aarch64-none-elf-
82 export PATH=<path-to-aarch64-gcc>/bin:$PATH
83
84Please note that AArch64 GCC must be included in the shell's search path
85even when using Clang as the compiler as LLVM does not include some C
86standard headers like `stdlib.h` and needs to be picked up from the
87`include` folder of the AArch64 GCC. Below is an example when RMM is
88to be built for AArch64 target on a non-native host machine and using
89LLVM as the toolchain.
90
91 .. code-block:: bash
92
93 export CROSS_COMPILE=aarch64-none-elf-
94 export PATH=<path-to-aarch64-gcc>/bin:<path-to-clang+llvm>/bin:$PATH
95
96The ``CROSS_COMPILE`` variable is ignored for ``fake_host`` build and
97the native host toolchain is used for the build.
98
99#######################################
100Package Installation (Ubuntu-18.04 x64)
101#######################################
102
103If you are using the recommended Ubuntu distribution then we can install the
104required packages with the following commands:
105
1061. Install dependencies:
107
108.. code:: shell
109
110 sudo apt-get install -y git build-essential python3 python3-pip make ninja-build default-jre
111 sudo snap install cmake
112 wget https://github.com/plantuml/plantuml/releases/download/v1.2022.7/plantuml-1.2022.7.jar -P <plantuml install path>
113
114.. note::
115
116 platUML and JRE are only required for documentation build.
117
1182. Verify cmake version:
119
120.. code-block:: bash
121
122 cmake --version
123
124.. note::
125
126 Please download cmake 3.19 or later version from https://cmake.org/download/.
127
1283. Add CMake and platUML path into environment:
129
130.. code-block:: bash
131
132 export PATH=<CMake path>/bin:$PATH
133 export PLANTUML_JAR_PATH=<plantuml install path>/plantuml.jar
134
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
144RMM's ``tools/requirements.txt`` file declares additional Python dependencies.
145Install them with ``pip3``:
146
147.. code-block:: bash
148
149 pip3 install --upgrade pip
150 cd <rmm source folder>
151 pip3 install -r tools/requirements.txt
152
153.. _getting_started_get_source:
154
155#########################
156Getting the RMM Source
157#########################
158
159Source code for |RMM| is maintained in a Git repository hosted on TrustedFirmware.org.
160To clone this repository from the server, run the following in your shell:
161
162.. code-block:: bash
163
164 git clone --recursive https://git.trustedfirmware.org/TF-RMM/tf-rmm.git
165
166Additional steps for Contributors
167*********************************
168
169If you are planning on contributing back to RMM, your commits need to
170include a ``Change-Id`` footer as explained in :ref:`mandated-trailers`.
171This footer is generated by a Git hook that needs to be installed
172inside your cloned RMM source folder.
173
174The `TF-RMM Gerrit page`_ under trustedfirmware.org contains a
175*Clone with commit-msg hook* subsection under its **Download** header where
176you can copy the command to clone the repo with the required git hooks.
177
178If needed, you can also manually install the hooks separately on an existing
179repo:
180
181.. code:: shell
182
183 curl -Lo $(git rev-parse --git-dir)/hooks/commit-msg https://review.trustedfirmware.org/tools/hooks/commit-msg
184 chmod +x $(git rev-parse --git-dir)/hooks/commit-msg
185
186You can read more about Git hooks in the *githooks* page of the `Git hooks
187documentation`_.
188
189#################################
190Install Cppcheck and dependencies
191#################################
192
193.. note::
194
195 The installation of Cppcheck is an optional step. This is required only
196 if using the Cppcheck static analysis.
197
198Follow the public documentation to install Cppcheck either from the official
199website https://cppcheck.sourceforge.io/#download or from the official github
200https://github.com/danmar/cppcheck/
201
202If you own a valid copy of a MISRA rules file:
203
204.. code-block:: bash
205
206 sudo mkdir /usr/local/share/Cppcheck/misra
207 sudo cp -a <path to the misra rules file>/<file name> /usr/local/share/Cppcheck/misra/misra.rules
208
209###########################
210Performing an Initial Build
211###########################
212
213The |RMM| sources can be compiled using multiple CMake options.
214
215For detailed instructions on build configurations and examples
216see :ref:`build_options_examples`.
217
218A typical build command for the FVP platform using GCC toolchain
219is shown below:
220
221.. code-block:: bash
222
223 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
224 cmake --build ${RMM_BUILD_DIR}
225
226###############
227Running the RMM
228###############
229
230The |RMM| is part of the CCA software stack and relies on EL3 Firmware to load
231the binary at boot time appropriately. It needs both EL3 Firmware and
232Non-Secure Host to be present at runtime for its functionality. The EL3
233Firmware must comply to `RMM-EL3 Communication Specification`_ and is
234typically the `TF-A`_. The Non-Secure Host can be an RME aware hypervisor
235or an appropriate Test utility running in Non-Secure world which can interact
236with |RMM| via Realm Management Interface (RMI).
237
238The `TF-A`_ project includes build and run instructions for an RME enabled
239system on the FVP platform as part of `TF-A RME documentation`_.
240The ``rmm.img`` binary is provided to the TF-A bootloader to be packaged
241in FIP using ``RMM`` build option in `TF-A`_.
242
243If |RMM| is built for the `fake_host` architecture
244(see :ref:`RMM Fake Host Build`), then the generated `rmm.elf` binary can
245run natively on the Host machine. It does this by emulating parts of the system
246as described in :ref:`RMM Fake host architecture` design.
247
248-----
249
250.. _Arm Developer website: https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads
251.. _LLVM Releases website: https://releases.llvm.org/
252.. _RMM-EL3 Communication Specification: https://trustedfirmware-a.readthedocs.io/en/latest/components/rmm-el3-comms-spec.html
253.. _TF-A: https://www.trustedfirmware.org/projects/tf-a/
254.. _TF-A RME documentation: https://trustedfirmware-a.readthedocs.io/en/latest/components/realm-management-extension.html
255.. _TF-RMM Gerrit page: https://review.trustedfirmware.org/admin/repos/TF-RMM/tf-rmm
256.. _Git hooks documentation: https://git-scm.com/docs/githooks