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 | |
Soby Mathew | 78bdfb1 | 2024-05-09 16:58:04 +0100 | [diff] [blame] | 4 | .. _getting_started: |
| 5 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 6 | ############# |
| 7 | Prerequisite |
| 8 | ############# |
| 9 | |
Soby Mathew | f572d3b | 2022-11-21 12:30:11 +0000 | [diff] [blame] | 10 | This document describes the software requirements for building |RMM| for |
| 11 | AArch64 target platforms. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 12 | |
Soby Mathew | f572d3b | 2022-11-21 12:30:11 +0000 | [diff] [blame] | 13 | It may possible to build |RMM| with combinations of software packages that |
| 14 | are different from those listed below, however only the software described in |
| 15 | this document can be officially supported. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 16 | |
| 17 | ########### |
| 18 | Build Host |
| 19 | ########### |
| 20 | |
| 21 | The |RMM| officially supports a limited set of build environments and setups. |
| 22 | In this context, official support means that the environments listed below |
| 23 | are actively used by team members and active developers, hence users should |
| 24 | be able to recreate the same configurations by following the instructions |
| 25 | described below. In case of problems, the |RMM| team provides support only |
| 26 | for these environments, but building in other environments can still be |
| 27 | possible. |
| 28 | |
Soby Mathew | f572d3b | 2022-11-21 12:30:11 +0000 | [diff] [blame] | 29 | We recommend at least Ubuntu 20.04 LTS (x64) for build environment. The |
| 30 | arm64/AArch64 Ubuntu and other Linux distributions should also work fine, |
| 31 | provided that the necessary tools and libraries can be installed. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 32 | |
Soby Mathew | 78bdfb1 | 2024-05-09 16:58:04 +0100 | [diff] [blame] | 33 | .. _tool_dependencies: |
| 34 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 35 | ########################## |
| 36 | Tool & Dependency overview |
| 37 | ########################## |
| 38 | |
| 39 | The 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" |
Soby Mathew | d2024c0 | 2025-05-21 13:14:33 +0100 | [diff] [blame] | 45 | "CMake", ">=3.20.0", "Firmware, Documentation" |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 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 Sobrino | 576071e | 2022-09-09 16:01:17 +0100 | [diff] [blame] | 56 | "gcovr",">=v4.2","Tools(Coverage analysis)" |
Mate Toth-Pal | 83a45bd | 2023-09-01 11:17:19 +0200 | [diff] [blame] | 57 | "CBMC",">=5.84.0","Tools(CBMC analysis)" |
Sona Mathew | 4471356 | 2024-08-11 23:18:32 -0500 | [diff] [blame] | 58 | "Cppcheck",">=2.14.0","Tools(Cppcheck)" |
Javier Almansa Sobrino | fd9d424 | 2025-05-07 15:52:51 +0100 | [diff] [blame] | 59 | "pyelftools","==0.32","Firmware (EL0 app)" |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 60 | |
| 61 | .. _getting_started_toolchain: |
| 62 | |
| 63 | ############### |
| 64 | Setup Toolchain |
| 65 | ############### |
| 66 | |
| 67 | To compile |RMM| code for an AArch64 target, at least one of the |
| 68 | supported AArch64 toolchains have to be available in the |
| 69 | build environment. |
| 70 | |
| 71 | Currently, the following compilers are supported: |
| 72 | |
| 73 | - GCC (aarch64-none-elf-) >= 10.2-2020.11 (from the `Arm Developer website`_) |
| 74 | - Clang+LLVM >= 14.0.0 (from the `LLVM Releases website`_) |
| 75 | |
| 76 | The respective compiler binary must be found in the shell's search path. |
| 77 | Be sure to add the bin/ directory if you have downloaded a binary version. |
| 78 | The toolchain to use can be set using ``RMM_TOOLCHAIN`` parameter and can |
| 79 | be set to either `llvm` or `gnu`. The default toolchain is `gnu`. |
| 80 | |
| 81 | For non-native AArch64 target build, the ``CROSS_COMPILE`` environment |
| 82 | variable must contain the right target triplet corresponding to the AArch64 |
| 83 | GCC compiler. Below is an example when RMM is to be built for AArch64 target |
| 84 | on a non-native host machine and using GCC as the toolchain. |
| 85 | |
| 86 | .. code-block:: bash |
| 87 | |
| 88 | export CROSS_COMPILE=aarch64-none-elf- |
| 89 | export PATH=<path-to-aarch64-gcc>/bin:$PATH |
| 90 | |
| 91 | Please note that AArch64 GCC must be included in the shell's search path |
| 92 | even when using Clang as the compiler as LLVM does not include some C |
| 93 | standard headers like `stdlib.h` and needs to be picked up from the |
| 94 | `include` folder of the AArch64 GCC. Below is an example when RMM is |
| 95 | to be built for AArch64 target on a non-native host machine and using |
| 96 | LLVM as the toolchain. |
| 97 | |
| 98 | .. code-block:: bash |
| 99 | |
| 100 | export CROSS_COMPILE=aarch64-none-elf- |
| 101 | export PATH=<path-to-aarch64-gcc>/bin:<path-to-clang+llvm>/bin:$PATH |
| 102 | |
| 103 | The ``CROSS_COMPILE`` variable is ignored for ``fake_host`` build and |
| 104 | the native host toolchain is used for the build. |
| 105 | |
| 106 | ####################################### |
Soby Mathew | f572d3b | 2022-11-21 12:30:11 +0000 | [diff] [blame] | 107 | Package Installation (Ubuntu-20.04 x64) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 108 | ####################################### |
| 109 | |
| 110 | If you are using the recommended Ubuntu distribution then we can install the |
| 111 | required packages with the following commands: |
| 112 | |
| 113 | 1. Install dependencies: |
| 114 | |
| 115 | .. code:: shell |
| 116 | |
Arunachalam Ganapathy | f1a13aa | 2022-11-11 15:07:12 +0000 | [diff] [blame] | 117 | 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] | 118 | sudo snap install cmake |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 119 | |
| 120 | 2. Verify cmake version: |
| 121 | |
| 122 | .. code-block:: bash |
| 123 | |
| 124 | cmake --version |
| 125 | |
| 126 | .. note:: |
| 127 | |
Soby Mathew | d2024c0 | 2025-05-21 13:14:33 +0100 | [diff] [blame] | 128 | Please download cmake 3.20 or later version from https://cmake.org/download/. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 129 | |
Arunachalam Ganapathy | f1a13aa | 2022-11-11 15:07:12 +0000 | [diff] [blame] | 130 | 3. Add CMake path into environment: |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 131 | |
| 132 | .. code-block:: bash |
| 133 | |
| 134 | export PATH=<CMake path>/bin:$PATH |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 135 | |
| 136 | ########################### |
| 137 | Install python dependencies |
| 138 | ########################### |
| 139 | |
Mate Toth-Pal | e60deeb | 2024-08-01 10:19:20 +0200 | [diff] [blame] | 140 | RMM's ``requirements.txt`` file declares additional Python dependencies. |
| 141 | Install them with ``pip3``: |
| 142 | |
| 143 | .. code-block:: bash |
| 144 | |
| 145 | pip3 install --upgrade pip |
| 146 | cd <rmm source folder> |
| 147 | pip3 install -r requirements.txt |
| 148 | |
| 149 | ############################################# |
| 150 | Install python dependencies for Documentation |
| 151 | ############################################# |
| 152 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 153 | .. note:: |
| 154 | |
Mate Toth-Pal | e60deeb | 2024-08-01 10:19:20 +0200 | [diff] [blame] | 155 | The installation of Python dependencies for documentation is an optional |
| 156 | step. This is required only if building documentation. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 157 | |
Arunachalam Ganapathy | f1a13aa | 2022-11-11 15:07:12 +0000 | [diff] [blame] | 158 | RMM's ``docs/requirements.txt`` file declares additional Python dependencies. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 159 | Install them with ``pip3``: |
| 160 | |
| 161 | .. code-block:: bash |
| 162 | |
| 163 | pip3 install --upgrade pip |
| 164 | cd <rmm source folder> |
Arunachalam Ganapathy | f1a13aa | 2022-11-11 15:07:12 +0000 | [diff] [blame] | 165 | pip3 install -r docs/requirements.txt |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 166 | |
Javier Almansa Sobrino | 576071e | 2022-09-09 16:01:17 +0100 | [diff] [blame] | 167 | ############################################ |
| 168 | Install coverage tools analysis dependencies |
| 169 | ############################################ |
| 170 | |
| 171 | .. note:: |
| 172 | |
| 173 | This is an optional step only needed if you intend to run coverage |
| 174 | analysis on the source code. |
| 175 | |
| 176 | On Ubuntu, ``gcovr`` tool can be installed in two different ways: |
| 177 | |
Soby Mathew | 78bdfb1 | 2024-05-09 16:58:04 +0100 | [diff] [blame] | 178 | Using the package manager: |
Javier Almansa Sobrino | 576071e | 2022-09-09 16:01:17 +0100 | [diff] [blame] | 179 | |
| 180 | .. code-block:: bash |
| 181 | |
| 182 | sudo apt-get install gcovr |
| 183 | |
| 184 | The second (and recommended) way is install it with ``pip3``: |
| 185 | |
| 186 | .. code-block:: bash |
| 187 | |
| 188 | pip3 install --upgrade pip |
| 189 | pip3 install gcovr |
| 190 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 191 | .. _getting_started_get_source: |
| 192 | |
| 193 | ######################### |
| 194 | Getting the RMM Source |
| 195 | ######################### |
| 196 | |
| 197 | Source code for |RMM| is maintained in a Git repository hosted on TrustedFirmware.org. |
| 198 | To clone this repository from the server, run the following in your shell: |
| 199 | |
| 200 | .. code-block:: bash |
| 201 | |
Soby Mathew | b5a2975 | 2024-11-14 14:26:11 +0000 | [diff] [blame] | 202 | git clone https://git.trustedfirmware.org/TF-RMM/tf-rmm.git |
| 203 | |
| 204 | Note that the RMM submodule dependencies will be updated during the |
| 205 | configuration phase of build. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 206 | |
| 207 | Additional steps for Contributors |
| 208 | ********************************* |
| 209 | |
| 210 | If you are planning on contributing back to RMM, your commits need to |
| 211 | include a ``Change-Id`` footer as explained in :ref:`mandated-trailers`. |
| 212 | This footer is generated by a Git hook that needs to be installed |
| 213 | inside your cloned RMM source folder. |
| 214 | |
| 215 | The `TF-RMM Gerrit page`_ under trustedfirmware.org contains a |
| 216 | *Clone with commit-msg hook* subsection under its **Download** header where |
Javier Almansa Sobrino | 6166c03 | 2022-11-10 14:24:03 +0000 | [diff] [blame] | 217 | you can copy the command to clone the repo with the required git hooks. Please |
| 218 | use the **SSH** option to clone the repository on your local machine. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 219 | |
| 220 | If needed, you can also manually install the hooks separately on an existing |
| 221 | repo: |
| 222 | |
| 223 | .. code:: shell |
| 224 | |
| 225 | curl -Lo $(git rev-parse --git-dir)/hooks/commit-msg https://review.trustedfirmware.org/tools/hooks/commit-msg |
| 226 | chmod +x $(git rev-parse --git-dir)/hooks/commit-msg |
| 227 | |
| 228 | You can read more about Git hooks in the *githooks* page of the `Git hooks |
| 229 | documentation`_. |
| 230 | |
Soby Mathew | 78bdfb1 | 2024-05-09 16:58:04 +0100 | [diff] [blame] | 231 | General contribution guidelines for contributors can be found in |
| 232 | :ref:`Contributor's Guide`. |
| 233 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 234 | ################################# |
| 235 | Install Cppcheck and dependencies |
| 236 | ################################# |
| 237 | |
| 238 | .. note:: |
| 239 | |
| 240 | The installation of Cppcheck is an optional step. This is required only |
| 241 | if using the Cppcheck static analysis. |
| 242 | |
Soby Mathew | 78bdfb1 | 2024-05-09 16:58:04 +0100 | [diff] [blame] | 243 | The recommended version of Cppcheck is indicated in :ref:`tool_dependencies`. |
Shruti Gupta | 57b8038 | 2024-04-24 11:35:18 +0100 | [diff] [blame] | 244 | See :ref:`Cppcheck Application Note` for installation steps and details |
| 245 | on how to use it within RMM build system. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 246 | |
Mate Toth-Pal | 83a45bd | 2023-09-01 11:17:19 +0200 | [diff] [blame] | 247 | ############ |
| 248 | Install CBMC |
| 249 | ############ |
| 250 | |
| 251 | .. note:: |
| 252 | |
| 253 | The installation of CBMC is an optional step. This is required only |
| 254 | if running source code analysis with CBMC. |
| 255 | |
| 256 | Follow the public documentation to install CBMC either from the official |
| 257 | website https://www.cprover.org/cbmc/ or from the official github |
| 258 | https://github.com/diffblue/cbmc |
| 259 | |
Soby Mathew | 78bdfb1 | 2024-05-09 16:58:04 +0100 | [diff] [blame] | 260 | Refer to :ref:`CBMC` Application Notes for details on installation and |
| 261 | running CBMC analysis on TF-RMM sources. |
| 262 | |
| 263 | ################## |
| 264 | Install Clang-tidy |
| 265 | ################## |
| 266 | |
| 267 | Clang-tidy is included in LLVM release package. It can also be installed via |
| 268 | package manager : |
| 269 | |
| 270 | .. code-block:: bash |
| 271 | |
| 272 | sudo apt-get install clang-tidy |
| 273 | |
| 274 | Note that the ``RMM_TOOLCHAIN`` needs to be set to `llvm` to run clang-tidy |
| 275 | build targets from RMM build system. |
| 276 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 277 | ########################### |
| 278 | Performing an Initial Build |
| 279 | ########################### |
| 280 | |
| 281 | The |RMM| sources can be compiled using multiple CMake options. |
| 282 | |
| 283 | For detailed instructions on build configurations and examples |
| 284 | see :ref:`build_options_examples`. |
| 285 | |
| 286 | A typical build command for the FVP platform using GCC toolchain |
| 287 | is shown below: |
| 288 | |
| 289 | .. code-block:: bash |
| 290 | |
| 291 | cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR} |
| 292 | cmake --build ${RMM_BUILD_DIR} |
| 293 | |
| 294 | ############### |
| 295 | Running the RMM |
| 296 | ############### |
| 297 | |
| 298 | The |RMM| is part of the CCA software stack and relies on EL3 Firmware to load |
| 299 | the binary at boot time appropriately. It needs both EL3 Firmware and |
| 300 | Non-Secure Host to be present at runtime for its functionality. The EL3 |
| 301 | Firmware must comply to `RMM-EL3 Communication Specification`_ and is |
| 302 | typically the `TF-A`_. The Non-Secure Host can be an RME aware hypervisor |
| 303 | or an appropriate Test utility running in Non-Secure world which can interact |
| 304 | with |RMM| via Realm Management Interface (RMI). |
| 305 | |
Javier Almansa Sobrino | 82edb89 | 2024-05-01 11:44:25 +0100 | [diff] [blame] | 306 | Building all of the involved stack is complicated. We recommend using the |
| 307 | `Shrinkwrap`_ tooling to bootstrap the stack. For more details on `Shrinkwrap`_ |
| 308 | and utilizing configs and overlays included in |RMM| please refer to |
| 309 | :ref:`using_shrinkwrap_with_rmm` and, specially for building a demonstrator |
| 310 | for 3-world, you can refer to :ref:`3_world_testing`. |
| 311 | |
| 312 | The |TF-A| documentation also provides some documentation to build |TF-A| and |
| 313 | other pieces of firmware for RME in `TF-A RME documentation`_. The |RMM| build |
| 314 | option in |TF-A| should point to the ``rmm.img`` binary generated by building |
| 315 | |RMM|. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 316 | |
| 317 | If |RMM| is built for the `fake_host` architecture |
Mate Toth-Pal | bbb816d | 2024-08-01 10:41:35 +0200 | [diff] [blame] | 318 | (see :ref:`RMM Fake Host Build`), then the generated `rmm_core.elf` binary can |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 319 | run natively on the Host machine. It does this by emulating parts of the system |
| 320 | as described in :ref:`RMM Fake host architecture` design. |
| 321 | |
| 322 | ----- |
| 323 | |
| 324 | .. _Arm Developer website: https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads |
| 325 | .. _LLVM Releases website: https://releases.llvm.org/ |
| 326 | .. _RMM-EL3 Communication Specification: https://trustedfirmware-a.readthedocs.io/en/latest/components/rmm-el3-comms-spec.html |
| 327 | .. _TF-A: https://www.trustedfirmware.org/projects/tf-a/ |
| 328 | .. _TF-A RME documentation: https://trustedfirmware-a.readthedocs.io/en/latest/components/realm-management-extension.html |
| 329 | .. _TF-RMM Gerrit page: https://review.trustedfirmware.org/admin/repos/TF-RMM/tf-rmm |
| 330 | .. _Git hooks documentation: https://git-scm.com/docs/githooks |
Javier Almansa Sobrino | 82edb89 | 2024-05-01 11:44:25 +0100 | [diff] [blame] | 331 | .. _Shrinkwrap: https://shrinkwrap.docs.arm.com |