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" |
| 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 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)" |
Soby Mathew | 78bdfb1 | 2024-05-09 16:58:04 +0100 | [diff] [blame^] | 58 | "Cppcheck",">=2.13.4","Tools(Cppcheck)" |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 59 | |
| 60 | .. _getting_started_toolchain: |
| 61 | |
| 62 | ############### |
| 63 | Setup Toolchain |
| 64 | ############### |
| 65 | |
| 66 | To compile |RMM| code for an AArch64 target, at least one of the |
| 67 | supported AArch64 toolchains have to be available in the |
| 68 | build environment. |
| 69 | |
| 70 | Currently, 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 | |
| 75 | The respective compiler binary must be found in the shell's search path. |
| 76 | Be sure to add the bin/ directory if you have downloaded a binary version. |
| 77 | The toolchain to use can be set using ``RMM_TOOLCHAIN`` parameter and can |
| 78 | be set to either `llvm` or `gnu`. The default toolchain is `gnu`. |
| 79 | |
| 80 | For non-native AArch64 target build, the ``CROSS_COMPILE`` environment |
| 81 | variable must contain the right target triplet corresponding to the AArch64 |
| 82 | GCC compiler. Below is an example when RMM is to be built for AArch64 target |
| 83 | on 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 | |
| 90 | Please note that AArch64 GCC must be included in the shell's search path |
| 91 | even when using Clang as the compiler as LLVM does not include some C |
| 92 | standard 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 |
| 94 | to be built for AArch64 target on a non-native host machine and using |
| 95 | LLVM 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 | |
| 102 | The ``CROSS_COMPILE`` variable is ignored for ``fake_host`` build and |
| 103 | the native host toolchain is used for the build. |
| 104 | |
| 105 | ####################################### |
Soby Mathew | f572d3b | 2022-11-21 12:30:11 +0000 | [diff] [blame] | 106 | Package Installation (Ubuntu-20.04 x64) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 107 | ####################################### |
| 108 | |
| 109 | If you are using the recommended Ubuntu distribution then we can install the |
| 110 | required packages with the following commands: |
| 111 | |
| 112 | 1. Install dependencies: |
| 113 | |
| 114 | .. code:: shell |
| 115 | |
Arunachalam Ganapathy | f1a13aa | 2022-11-11 15:07:12 +0000 | [diff] [blame] | 116 | 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] | 117 | sudo snap install cmake |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 118 | |
| 119 | 2. 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 Ganapathy | f1a13aa | 2022-11-11 15:07:12 +0000 | [diff] [blame] | 129 | 3. Add CMake path into environment: |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 130 | |
| 131 | .. code-block:: bash |
| 132 | |
| 133 | export PATH=<CMake path>/bin:$PATH |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 134 | |
| 135 | ########################### |
| 136 | Install 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 Ganapathy | f1a13aa | 2022-11-11 15:07:12 +0000 | [diff] [blame] | 144 | RMM's ``docs/requirements.txt`` file declares additional Python dependencies. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 145 | Install them with ``pip3``: |
| 146 | |
| 147 | .. code-block:: bash |
| 148 | |
| 149 | pip3 install --upgrade pip |
| 150 | cd <rmm source folder> |
Arunachalam Ganapathy | f1a13aa | 2022-11-11 15:07:12 +0000 | [diff] [blame] | 151 | pip3 install -r docs/requirements.txt |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 152 | |
Javier Almansa Sobrino | 576071e | 2022-09-09 16:01:17 +0100 | [diff] [blame] | 153 | ############################################ |
| 154 | Install 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 | |
| 162 | On Ubuntu, ``gcovr`` tool can be installed in two different ways: |
| 163 | |
Soby Mathew | 78bdfb1 | 2024-05-09 16:58:04 +0100 | [diff] [blame^] | 164 | Using the package manager: |
Javier Almansa Sobrino | 576071e | 2022-09-09 16:01:17 +0100 | [diff] [blame] | 165 | |
| 166 | .. code-block:: bash |
| 167 | |
| 168 | sudo apt-get install gcovr |
| 169 | |
| 170 | The 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 Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 177 | .. _getting_started_get_source: |
| 178 | |
| 179 | ######################### |
| 180 | Getting the RMM Source |
| 181 | ######################### |
| 182 | |
| 183 | Source code for |RMM| is maintained in a Git repository hosted on TrustedFirmware.org. |
| 184 | To clone this repository from the server, run the following in your shell: |
| 185 | |
| 186 | .. code-block:: bash |
| 187 | |
| 188 | git clone --recursive https://git.trustedfirmware.org/TF-RMM/tf-rmm.git |
| 189 | |
| 190 | Additional steps for Contributors |
| 191 | ********************************* |
| 192 | |
| 193 | If you are planning on contributing back to RMM, your commits need to |
| 194 | include a ``Change-Id`` footer as explained in :ref:`mandated-trailers`. |
| 195 | This footer is generated by a Git hook that needs to be installed |
| 196 | inside your cloned RMM source folder. |
| 197 | |
| 198 | The `TF-RMM Gerrit page`_ under trustedfirmware.org contains a |
| 199 | *Clone with commit-msg hook* subsection under its **Download** header where |
Javier Almansa Sobrino | 6166c03 | 2022-11-10 14:24:03 +0000 | [diff] [blame] | 200 | you can copy the command to clone the repo with the required git hooks. Please |
| 201 | use the **SSH** option to clone the repository on your local machine. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 202 | |
| 203 | If needed, you can also manually install the hooks separately on an existing |
| 204 | repo: |
| 205 | |
| 206 | .. code:: shell |
| 207 | |
| 208 | curl -Lo $(git rev-parse --git-dir)/hooks/commit-msg https://review.trustedfirmware.org/tools/hooks/commit-msg |
| 209 | chmod +x $(git rev-parse --git-dir)/hooks/commit-msg |
| 210 | |
| 211 | You can read more about Git hooks in the *githooks* page of the `Git hooks |
| 212 | documentation`_. |
| 213 | |
Soby Mathew | 78bdfb1 | 2024-05-09 16:58:04 +0100 | [diff] [blame^] | 214 | General contribution guidelines for contributors can be found in |
| 215 | :ref:`Contributor's Guide`. |
| 216 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 217 | ################################# |
| 218 | Install Cppcheck and dependencies |
| 219 | ################################# |
| 220 | |
| 221 | .. note:: |
| 222 | |
| 223 | The installation of Cppcheck is an optional step. This is required only |
| 224 | if using the Cppcheck static analysis. |
| 225 | |
Soby Mathew | 78bdfb1 | 2024-05-09 16:58:04 +0100 | [diff] [blame^] | 226 | The recommended version of Cppcheck is indicated in :ref:`tool_dependencies`. |
Shruti Gupta | 57b8038 | 2024-04-24 11:35:18 +0100 | [diff] [blame] | 227 | See :ref:`Cppcheck Application Note` for installation steps and details |
| 228 | on how to use it within RMM build system. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 229 | |
Mate Toth-Pal | 83a45bd | 2023-09-01 11:17:19 +0200 | [diff] [blame] | 230 | ############ |
| 231 | Install CBMC |
| 232 | ############ |
| 233 | |
| 234 | .. note:: |
| 235 | |
| 236 | The installation of CBMC is an optional step. This is required only |
| 237 | if running source code analysis with CBMC. |
| 238 | |
| 239 | Follow the public documentation to install CBMC either from the official |
| 240 | website https://www.cprover.org/cbmc/ or from the official github |
| 241 | https://github.com/diffblue/cbmc |
| 242 | |
Soby Mathew | 78bdfb1 | 2024-05-09 16:58:04 +0100 | [diff] [blame^] | 243 | Refer to :ref:`CBMC` Application Notes for details on installation and |
| 244 | running CBMC analysis on TF-RMM sources. |
| 245 | |
| 246 | ################## |
| 247 | Install Clang-tidy |
| 248 | ################## |
| 249 | |
| 250 | Clang-tidy is included in LLVM release package. It can also be installed via |
| 251 | package manager : |
| 252 | |
| 253 | .. code-block:: bash |
| 254 | |
| 255 | sudo apt-get install clang-tidy |
| 256 | |
| 257 | Note that the ``RMM_TOOLCHAIN`` needs to be set to `llvm` to run clang-tidy |
| 258 | build targets from RMM build system. |
| 259 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 260 | ########################### |
| 261 | Performing an Initial Build |
| 262 | ########################### |
| 263 | |
| 264 | The |RMM| sources can be compiled using multiple CMake options. |
| 265 | |
| 266 | For detailed instructions on build configurations and examples |
| 267 | see :ref:`build_options_examples`. |
| 268 | |
| 269 | A typical build command for the FVP platform using GCC toolchain |
| 270 | is shown below: |
| 271 | |
| 272 | .. code-block:: bash |
| 273 | |
| 274 | cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR} |
| 275 | cmake --build ${RMM_BUILD_DIR} |
| 276 | |
| 277 | ############### |
| 278 | Running the RMM |
| 279 | ############### |
| 280 | |
| 281 | The |RMM| is part of the CCA software stack and relies on EL3 Firmware to load |
| 282 | the binary at boot time appropriately. It needs both EL3 Firmware and |
| 283 | Non-Secure Host to be present at runtime for its functionality. The EL3 |
| 284 | Firmware must comply to `RMM-EL3 Communication Specification`_ and is |
| 285 | typically the `TF-A`_. The Non-Secure Host can be an RME aware hypervisor |
| 286 | or an appropriate Test utility running in Non-Secure world which can interact |
| 287 | with |RMM| via Realm Management Interface (RMI). |
| 288 | |
| 289 | The `TF-A`_ project includes build and run instructions for an RME enabled |
| 290 | system on the FVP platform as part of `TF-A RME documentation`_. |
| 291 | The ``rmm.img`` binary is provided to the TF-A bootloader to be packaged |
| 292 | in FIP using ``RMM`` build option in `TF-A`_. |
| 293 | |
| 294 | If |RMM| is built for the `fake_host` architecture |
| 295 | (see :ref:`RMM Fake Host Build`), then the generated `rmm.elf` binary can |
| 296 | run natively on the Host machine. It does this by emulating parts of the system |
| 297 | as described in :ref:`RMM Fake host architecture` design. |
| 298 | |
| 299 | ----- |
| 300 | |
| 301 | .. _Arm Developer website: https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads |
| 302 | .. _LLVM Releases website: https://releases.llvm.org/ |
| 303 | .. _RMM-EL3 Communication Specification: https://trustedfirmware-a.readthedocs.io/en/latest/components/rmm-el3-comms-spec.html |
| 304 | .. _TF-A: https://www.trustedfirmware.org/projects/tf-a/ |
| 305 | .. _TF-A RME documentation: https://trustedfirmware-a.readthedocs.io/en/latest/components/realm-management-extension.html |
| 306 | .. _TF-RMM Gerrit page: https://review.trustedfirmware.org/admin/repos/TF-RMM/tf-rmm |
| 307 | .. _Git hooks documentation: https://git-scm.com/docs/githooks |