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