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 | |
| 8 | This document describes the software requirements for building |RMM| for AArch64 target platforms. |
| 9 | |
| 10 | It may possible to build |RMM| with combinations of software packages that are different from |
| 11 | those listed below, however only the software described in this document can be officially supported. |
| 12 | |
| 13 | ########### |
| 14 | Build Host |
| 15 | ########### |
| 16 | |
| 17 | The |RMM| officially supports a limited set of build environments and setups. |
| 18 | In this context, official support means that the environments listed below |
| 19 | are actively used by team members and active developers, hence users should |
| 20 | be able to recreate the same configurations by following the instructions |
| 21 | described below. In case of problems, the |RMM| team provides support only |
| 22 | for these environments, but building in other environments can still be |
| 23 | possible. |
| 24 | |
| 25 | A relatively recent Linux distribution is recommended for building RMM. We |
| 26 | have performed tests using Ubuntu 18.04 LTS (64-bit) but other distributions |
| 27 | should also work fine as a base, provided that the necessary tools and |
| 28 | libraries can be installed. |
| 29 | |
| 30 | ########################## |
| 31 | Tool & Dependency overview |
| 32 | ########################## |
| 33 | |
| 34 | The 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 Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 51 | |
| 52 | .. _getting_started_toolchain: |
| 53 | |
| 54 | ############### |
| 55 | Setup Toolchain |
| 56 | ############### |
| 57 | |
| 58 | To compile |RMM| code for an AArch64 target, at least one of the |
| 59 | supported AArch64 toolchains have to be available in the |
| 60 | build environment. |
| 61 | |
| 62 | Currently, 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 | |
| 67 | The respective compiler binary must be found in the shell's search path. |
| 68 | Be sure to add the bin/ directory if you have downloaded a binary version. |
| 69 | The toolchain to use can be set using ``RMM_TOOLCHAIN`` parameter and can |
| 70 | be set to either `llvm` or `gnu`. The default toolchain is `gnu`. |
| 71 | |
| 72 | For non-native AArch64 target build, the ``CROSS_COMPILE`` environment |
| 73 | variable must contain the right target triplet corresponding to the AArch64 |
| 74 | GCC compiler. Below is an example when RMM is to be built for AArch64 target |
| 75 | on 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 | |
| 82 | Please note that AArch64 GCC must be included in the shell's search path |
| 83 | even when using Clang as the compiler as LLVM does not include some C |
| 84 | standard 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 |
| 86 | to be built for AArch64 target on a non-native host machine and using |
| 87 | LLVM 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 | |
| 94 | The ``CROSS_COMPILE`` variable is ignored for ``fake_host`` build and |
| 95 | the native host toolchain is used for the build. |
| 96 | |
| 97 | ####################################### |
| 98 | Package Installation (Ubuntu-18.04 x64) |
| 99 | ####################################### |
| 100 | |
| 101 | If you are using the recommended Ubuntu distribution then we can install the |
| 102 | required packages with the following commands: |
| 103 | |
| 104 | 1. Install dependencies: |
| 105 | |
| 106 | .. code:: shell |
| 107 | |
Arunachalam Ganapathy | f1a13aa | 2022-11-11 15:07:12 +0000 | [diff] [blame^] | 108 | 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] | 109 | sudo snap install cmake |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 110 | |
| 111 | 2. 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 Ganapathy | f1a13aa | 2022-11-11 15:07:12 +0000 | [diff] [blame^] | 121 | 3. Add CMake path into environment: |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 122 | |
| 123 | .. code-block:: bash |
| 124 | |
| 125 | export PATH=<CMake path>/bin:$PATH |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 126 | |
| 127 | ########################### |
| 128 | Install 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 Ganapathy | f1a13aa | 2022-11-11 15:07:12 +0000 | [diff] [blame^] | 136 | RMM's ``docs/requirements.txt`` file declares additional Python dependencies. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 137 | Install them with ``pip3``: |
| 138 | |
| 139 | .. code-block:: bash |
| 140 | |
| 141 | pip3 install --upgrade pip |
| 142 | cd <rmm source folder> |
Arunachalam Ganapathy | f1a13aa | 2022-11-11 15:07:12 +0000 | [diff] [blame^] | 143 | pip3 install -r docs/requirements.txt |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 144 | |
| 145 | .. _getting_started_get_source: |
| 146 | |
| 147 | ######################### |
| 148 | Getting the RMM Source |
| 149 | ######################### |
| 150 | |
| 151 | Source code for |RMM| is maintained in a Git repository hosted on TrustedFirmware.org. |
| 152 | To 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 | |
| 158 | Additional steps for Contributors |
| 159 | ********************************* |
| 160 | |
| 161 | If you are planning on contributing back to RMM, your commits need to |
| 162 | include a ``Change-Id`` footer as explained in :ref:`mandated-trailers`. |
| 163 | This footer is generated by a Git hook that needs to be installed |
| 164 | inside your cloned RMM source folder. |
| 165 | |
| 166 | The `TF-RMM Gerrit page`_ under trustedfirmware.org contains a |
| 167 | *Clone with commit-msg hook* subsection under its **Download** header where |
Javier Almansa Sobrino | 6166c03 | 2022-11-10 14:24:03 +0000 | [diff] [blame] | 168 | you can copy the command to clone the repo with the required git hooks. Please |
| 169 | use the **SSH** option to clone the repository on your local machine. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 170 | |
| 171 | If needed, you can also manually install the hooks separately on an existing |
| 172 | repo: |
| 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 | |
| 179 | You can read more about Git hooks in the *githooks* page of the `Git hooks |
| 180 | documentation`_. |
| 181 | |
| 182 | ################################# |
| 183 | Install 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 | |
| 191 | Follow the public documentation to install Cppcheck either from the official |
| 192 | website https://cppcheck.sourceforge.io/#download or from the official github |
| 193 | https://github.com/danmar/cppcheck/ |
| 194 | |
| 195 | If 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 | ########################### |
| 203 | Performing an Initial Build |
| 204 | ########################### |
| 205 | |
| 206 | The |RMM| sources can be compiled using multiple CMake options. |
| 207 | |
| 208 | For detailed instructions on build configurations and examples |
| 209 | see :ref:`build_options_examples`. |
| 210 | |
| 211 | A typical build command for the FVP platform using GCC toolchain |
| 212 | is 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 | ############### |
| 220 | Running the RMM |
| 221 | ############### |
| 222 | |
| 223 | The |RMM| is part of the CCA software stack and relies on EL3 Firmware to load |
| 224 | the binary at boot time appropriately. It needs both EL3 Firmware and |
| 225 | Non-Secure Host to be present at runtime for its functionality. The EL3 |
| 226 | Firmware must comply to `RMM-EL3 Communication Specification`_ and is |
| 227 | typically the `TF-A`_. The Non-Secure Host can be an RME aware hypervisor |
| 228 | or an appropriate Test utility running in Non-Secure world which can interact |
| 229 | with |RMM| via Realm Management Interface (RMI). |
| 230 | |
| 231 | The `TF-A`_ project includes build and run instructions for an RME enabled |
| 232 | system on the FVP platform as part of `TF-A RME documentation`_. |
| 233 | The ``rmm.img`` binary is provided to the TF-A bootloader to be packaged |
| 234 | in FIP using ``RMM`` build option in `TF-A`_. |
| 235 | |
| 236 | If |RMM| is built for the `fake_host` architecture |
| 237 | (see :ref:`RMM Fake Host Build`), then the generated `rmm.elf` binary can |
| 238 | run natively on the Host machine. It does this by emulating parts of the system |
| 239 | as 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 |