Javier Almansa Sobrino | 82edb89 | 2024-05-01 11:44:25 +0100 | [diff] [blame] | 1 | .. SPDX-License-Identifier: BSD-3-Clause |
| 2 | .. SPDX-FileCopyrightText: Copyright TF-RMM Contributors. |
| 3 | |
| 4 | .. _using_shrinkwrap_with_rmm: |
| 5 | |
| 6 | Building with Shrinkwrap |
| 7 | ************************ |
| 8 | |
| 9 | This document explains how to build and run |RMM| in |FVP|, including all |
| 10 | necessary firmware images, by using `Shrinkwrap`_. |
| 11 | |
| 12 | Introduction |
| 13 | ____________ |
| 14 | |
| 15 | `Shrinkwrap`_ is a tool that helps to simplify the process of building and |
| 16 | running firmware on Arm |FVP| by providing an intuitive command line interface |
| 17 | frontend and (by default) a container-based backend. |
| 18 | |
| 19 | Shrinkwrap works by using *configs*, which are defined in YAML and can be easily |
| 20 | extended using a built-in layering system. |
| 21 | |
| 22 | For instructions on how to setup Shrinkwrap on your local machine as well as for |
| 23 | further information, you can refer to the `Quick Start Guide`_. In particular, |
| 24 | for development with RME enabled Linux in Normal World, please refer to the |
| 25 | `3 world configuration`_. In case that the Secure World also needs to be |
| 26 | included, please refer to the `4 world configuration`_ |
| 27 | |
| 28 | Setup local RMM with Shrinkwrap |
| 29 | _______________________________ |
| 30 | |
| 31 | This section assumes that you have your local |RMM| repository cloned |
| 32 | and that it is used for your development. In order to help using |
| 33 | Shrinkwrap with your development workflow, the project provides some |
| 34 | configs and overlays. |
| 35 | |
| 36 | Also, from now on, it is assumed that your current directory (pointed by |
| 37 | ``${PWD}``) is the root of your |RMM| development repository. |
| 38 | |
| 39 | In order to use the configs defined in |RMM|, it is essential to configure |
Soby Mathew | 1c8a2e8 | 2024-11-07 06:10:56 +0000 | [diff] [blame] | 40 | the ``${SHRINKWRAP_CONFIG}`` environment variable to point to |
Javier Almansa Sobrino | 82edb89 | 2024-05-01 11:44:25 +0100 | [diff] [blame] | 41 | ``${PWD}/tools/shrinkwrap/configs`` directory so the tool can locate the |
| 42 | config yaml files. |
| 43 | |
| 44 | .. code-block:: shell |
| 45 | |
| 46 | export SHRINKWRAP_CONFIG=${PWD}/tools/shrinkwrap/configs |
| 47 | |
| 48 | It is also recommended to override the default ``${SHRINKWRAP_BUILD}`` and |
| 49 | ``${SHRINKWRAP_PACKAGE}`` environment variables to a known workspace directory, |
| 50 | as shown below: |
| 51 | |
| 52 | .. code-block:: shell |
| 53 | |
| 54 | export WORKSPACE=${HOME}/workspace |
| 55 | export SHRINKWRAP_BUILD=${WORKSPACE} |
| 56 | export SHRINKWRAP_PACKAGE=${SHRINKWRAP_BUILD}/package |
| 57 | |
| 58 | When building, Shrinkwrap will store the sources inside |
| 59 | ``${SHRINKWRAP_BUILD}/source/<CONFIG_NAME>`` and the build artifacts and |
| 60 | packages will be stored inside ``${SHRINKWRAP_BUILD}/build/<CONFIG_NAME>`` and |
| 61 | ``${SHRINKWRAP_PACKAGE}/<CONFIG_NAME>`` directories respectively. |
| 62 | |
| 63 | .. note:: |
| 64 | |
| 65 | By default, if ${SHRINKWRAP_BUILD} and ${SHRINKWRAP_PACKAGE} are not |
| 66 | specified, Shrinkwrap will use the ``${HOME}/.shrinkwrap`` as default |
| 67 | value for ${SHRINKWRAP_BUILD}. It is only necessary to overwrite the |
| 68 | environment variables in the case it is needed to build in a different |
| 69 | location. |
| 70 | |
| 71 | .. _3_world_testing: |
| 72 | |
| 73 | 3-World testing |
| 74 | _______________ |
| 75 | |
| 76 | |RMM| provides a number of overlays that can be used in conjunction with some |
| 77 | of the configs provided by Shrinkwrap. One of the overlays, specifically |
| 78 | ``rmm.yaml``, can be used along with the ``cca-3world.yaml`` to |
| 79 | build a 3 World demonstrator using the ``master`` branch of |TF-A| and the |
| 80 | local |RMM| repository. |
| 81 | |
| 82 | As an example, the following command line would build the 3-World demonstrator. |
| 83 | It assumes that Shrinkwrap is called from within the ``<RMM_ROOT>`` directory: |
| 84 | |
| 85 | .. code-block:: shell |
| 86 | |
| 87 | shrinkwrap build cca-3world.yaml --overlay=buildroot.yaml --overlay=rmm.yaml --btvar=GUEST_ROOTFS='${artifact:BUILDROOT}' --btvar=RMM_SRC=${PWD} --no-sync=rmm |
| 88 | |
| 89 | You can find further instructions on how to build and package the filesystem |
| 90 | and required binaries in the `3 world configuration`_ documentation. |
| 91 | |
| 92 | To run the demonstrator, use the following command: |
| 93 | |
| 94 | .. code-block:: shell |
| 95 | |
Javier Almansa Sobrino | 27e4427 | 2024-10-02 16:06:18 +0100 | [diff] [blame] | 96 | shrinkwrap run cca-3world.yaml --rtvar=ROOTFS=${SHRINKWRAP_PACKAGE}/cca-3world/rootfs.ext2 |
Javier Almansa Sobrino | 82edb89 | 2024-05-01 11:44:25 +0100 | [diff] [blame] | 97 | |
| 98 | Testing RMM with TFTF |
| 99 | _____________________ |
| 100 | |
| 101 | |RMM| provides a config that brings together a software stack to test |RMM| |
| 102 | and Arm RME extension utilizing `TF-A-Tests`_. The main Test payload in |
| 103 | TF-A-Tests is the |TFTF| binary. In this config, |TF-A| is in Root World, |RMM| |
| 104 | is in Realm EL2 and |TFTF| is in Normal World. |
| 105 | |
| 106 | In order to build the config, you need to run the following command: |
| 107 | |
| 108 | .. code-block:: shell |
| 109 | |
| 110 | shrinkwrap build --btvar=RMM_SRC=${PWD} rmm-tftf.yaml --no-sync=rmm |
| 111 | |
| 112 | and you can run it through |
| 113 | |
| 114 | .. code-block:: shell |
| 115 | |
| 116 | shrinkwrap run rmm-tftf.yaml |
| 117 | |
| 118 | For further documentation about this configuration, you can check the docs through |
| 119 | |
| 120 | .. code-block:: shell |
| 121 | |
| 122 | shrinkwrap inspect rmm-tftf.yaml |
| 123 | |
| 124 | The build and run commands can also be found in the documentation of the config |
| 125 | yaml file. When invoking the ``build`` command, Shrinkwrap will store the |
| 126 | external repositories inside the ``${SHRINKWRAP_BUILD}/sources/<CONFIG_NAME>`` |
| 127 | directory. |
| 128 | |
| 129 | Overlays |
| 130 | ________ |
| 131 | |
| 132 | Overlays can be used to extend the functionality of a config by overwriting |
| 133 | both build and runtime settings. They can be used on any configuration and they |
| 134 | can be combined in any way needed. |
| 135 | |
| 136 | In order to use an overlay, they need to be specified on the command line, through |
| 137 | the ``--overlay`` keyword, as follows: |
| 138 | |
| 139 | .. code-block:: shell |
| 140 | |
| 141 | shrinkwrap build rmm-tftf.yaml --btvar=RMM_SRC=${PWD} --overlay=<OVERLAY_FILE_NAME> --no-sync=rmm |
| 142 | |
| 143 | The path to the overlay can be relative to where Shrinkwrap is called from and you |
| 144 | can use as many ``--overlay`` statements as needed. |
| 145 | |
| 146 | Overlays are stored in the ``<RMM_ROOT_DIR>/tools/shrinkwrap/configs/`` directory, |
| 147 | alongside with the configuration files. |
| 148 | |
| 149 | The available Overlays are sumarized in the next table |
| 150 | |
| 151 | .. csv-table:: |
| 152 | :header: "Overlay", "Description" |
| 153 | :widths: 2 8 |
| 154 | |
| 155 | model-enable-lpa2.yaml,Overlay used to enable ``FEAT_LPA2`` on the |FVP| model at run time. In addition this overlay also sets the ``PA_SIZE`` on the model to 52 |
| 156 | model-wait-debugger.yaml,Overlay to configure the |FVP| model to listen for Iris connections on port 7100 and make it wait until a debugger is connected before starting execution |
| 157 | rmm-debug.yaml,Overlay to build |RMM| (as well as |TF-A|) in debug mode |
| 158 | clean.yaml,Overlay used to avoid an exception with ``Shrinkwrap clean`` in which a path with a valid format needs to be specified for |RMM| |
| 159 | |
| 160 | Example of use |
| 161 | ~~~~~~~~~~~~~~ |
| 162 | |
| 163 | Below is an example on how to use one of the available overlays with the |
| 164 | existing configuration. The example specifies ``--runtime=null`` to use the |
| 165 | native toolchain (without the Docker container) to build the artifacts and |
| 166 | ``--no-sync-all`` to prevent Shrinkwrap from updating/cleaning any of the |
| 167 | repositories: |
| 168 | |
| 169 | .. code-block:: shell |
| 170 | |
| 171 | shrinkwrap --runtime=null build rmm-tftf.yaml --overlay=model-enable-lpa2.yaml --btvar=RMM_SRC=${PWD} --no-sync-all |
| 172 | |
| 173 | Then you run your tests with |
| 174 | |
| 175 | .. code-block:: shell |
| 176 | |
| 177 | shrinkwrap --runtime=null run rmm-tftf.yaml |
| 178 | |
| 179 | .. note:: |
| 180 | |
| 181 | Note that ``runtime=null`` is specified for the run, as it must match |
| 182 | the same setting as used on the build stage. Also, with this setting, |
| 183 | the appropriate FVP (FVP_Base_RevC-2xAEMvA) needs to be present in the |
| 184 | system ${PATH}. |
| 185 | |
| 186 | ----- |
| 187 | |
| 188 | .. _Shrinkwrap: https://shrinkwrap.docs.arm.com |
| 189 | .. _Quick Start Guide: https://shrinkwrap.docs.arm.com/en/latest/userguide/quickstart.html#quick-start-guide |
| 190 | .. _3 world configuration: https://shrinkwrap.docs.arm.com/en/latest/userguide/configstore/cca-3world.html |
| 191 | .. _4 world configuration: https://shrinkwrap.docs.arm.com/en/latest/userguide/configstore/cca-4world.html |
| 192 | .. _TF-A-Tests: https://trustedfirmware-a-tests.readthedocs.io/en/latest/index.html |
| 193 | .. _btvar: https://shrinkwrap.docs.arm.com/en/latest/userguide/configmodel.html#defined-macros |
| 194 | .. _rtvar: https://shrinkwrap.docs.arm.com/en/latest/userguide/configmodel.html#defined-macros |