|
| 1 | +--- |
| 2 | +title: Boot Linux on FVP |
| 3 | +weight: 5 |
| 4 | + |
| 5 | +### FIXED, DO NOT MODIFY |
| 6 | +layout: learningpathall |
| 7 | +--- |
| 8 | + |
| 9 | +## Introduction |
| 10 | + |
| 11 | +During this step, we set up everything for the FVP to run and then boot the Linux system |
| 12 | +using the kernel and the root file system that we prepared earlier. |
| 13 | + |
| 14 | +Arm [Fixed Virtual Platform (FVP)][1] is a model that allows you to access functionality |
| 15 | +of Armv8.x or v9.x hardware. We use the Armv-A Base Rev C Architecture Envelope Model (AEM). |
| 16 | + |
| 17 | +In addition to the model itself, you also need the device tree and the firmware. To simplify |
| 18 | +building these components, we use a tool called [Shrinkwrap][2]. |
| 19 | + |
| 20 | +This tool comes with a detailed [user guide][3] that covers all of its features and |
| 21 | +configuration options. Here, we provide a short quick-start guide. |
| 22 | + |
| 23 | +We also rely on a Docker container to facilitate the building of the firmware and |
| 24 | +running the FVP. This helps avoid installing all the dependencies on your host system. |
| 25 | +Shrinkwrap can be used without Docker but it requires extra steps to ensure that all |
| 26 | +dependencies are of the right version and are installed correctly. |
| 27 | + |
| 28 | +## Install Shrinkwrap |
| 29 | + |
| 30 | +First, we install prerequisites in a Python virtual environment using Python 3.x: |
| 31 | + |
| 32 | +```bash |
| 33 | +python -m venv ~/workspace/venv |
| 34 | +source ~/workspace/venv/bin/activate |
| 35 | +pip install -U pip setuptools wheel |
| 36 | +pip install pyyaml termcolor tuxmake |
| 37 | +``` |
| 38 | + |
| 39 | +Shrinkwrap can be used directly from the source, which can be checked out from its Git |
| 40 | +repository. Run this command in the workspace directory: |
| 41 | + |
| 42 | +```bash |
| 43 | +git clone https://git.gitlab.arm.com/tooling/shrinkwrap.git |
| 44 | +export PATH=${PATH}:$(pwd)/shrinkwrap/shrinkwrap |
| 45 | +``` |
| 46 | + |
| 47 | +Putting Shrinkwrap's main executable on your `PATH` is all you need to install the tool. |
| 48 | +To check that it works, ensure that the Python virtual environment we created earlier |
| 49 | +is activated, then run this command: |
| 50 | + |
| 51 | +```bash |
| 52 | +shrinkwrap --version |
| 53 | +``` |
| 54 | + |
| 55 | +## Build firmware for FVP |
| 56 | + |
| 57 | +Before proceeding, ensure that Docker is installed and usable. Follow the installation |
| 58 | +instructions for your distro [here][4]. |
| 59 | + |
| 60 | +Now, we use the Shrinkwrap tool to build the firmware, the third essential ingredient in our |
| 61 | +setup. The following step needs to be done once although you will need to repeat it if you |
| 62 | +want to rebuild the firmware: |
| 63 | + |
| 64 | +```bash |
| 65 | +shrinkwrap build --overlay=arch/v9.4.yaml ns-edk2.yaml |
| 66 | +``` |
| 67 | + |
| 68 | +This command uses the `arch/v9.4.yaml` config that enables Armv9.4 hardware features. |
| 69 | +This config is included with the Shrinkwrap installation. We also use the `ns-edk2.yaml` |
| 70 | +config. This configuration file is also a part of the Shrinkwrap tool. It defines the |
| 71 | +settings for building and running the firmware using EDK2 on Arm FVPs. The build |
| 72 | +process takes some time. During this step, Shrinkwrap downloads the required Docker |
| 73 | +image and starts a container to clone all the required firmware repositories and build |
| 74 | +the components including the device tree for the FVP. |
| 75 | + |
| 76 | +## Overlay config |
| 77 | + |
| 78 | +At this point, we have everything required to boot our system. Shrinkwrap uses so called overlay |
| 79 | +configuration files. The following file instructs Shrinkwrap to connect all the pieces together |
| 80 | +and locate the kernel image, and rootfs. It can also be used to tweak any of the FVP |
| 81 | +parameters. Save this file as `~/workspace/aarch64.yaml`: |
| 82 | + |
| 83 | +```yaml |
| 84 | +run: |
| 85 | + rtvars: |
| 86 | + ROOTFS: |
| 87 | + value: /home/user/workspace/rootfs.img |
| 88 | + CMDLINE: |
| 89 | + value: ip=dhcp kpti=off root=/dev/vda2 console=ttyAMA0 |
| 90 | + KERNEL: |
| 91 | + value: /home/user/workspace/linux-build/arch/arm64/boot/Image |
| 92 | + params: |
| 93 | + -C bp.hostbridge.userNetworking: 1 |
| 94 | + -C bp.hostbridge.userNetPorts: 8022=22,8123=8123 |
| 95 | + -C bp.smsc_91c111.enabled: 1 |
| 96 | + -C bp.virtio_net.enabled: 0 |
| 97 | + -C cluster0.NUM_CORES: 1 |
| 98 | + -C cluster1.NUM_CORES: 0 |
| 99 | + -C pctl.CPU-affinities: 0.0.0.0 |
| 100 | +``` |
| 101 | +
|
| 102 | +The most important parts in this configuration file are: |
| 103 | +
|
| 104 | + * Paths to the rootfs image and the kernel image. |
| 105 | + * The kernel command line, which contains `root=/dev/vda2`, specifying where to locate |
| 106 | + the filesystem to be mounted at `/`. |
| 107 | + * The port mapping `8022=22`, which is used for SSH access into the guest system. |
| 108 | + You can add more ports as needed. |
| 109 | + |
| 110 | +The FVP has many parameters that can be tweaked in this config by adding a `-C param: value` |
| 111 | +line to the `params` section. Refer to the [Fast Models Fixed Virtual Platforms Reference Guide][5] |
| 112 | +for more details. |
| 113 | + |
| 114 | +## Run FVP with Shrinkwrap |
| 115 | + |
| 116 | +To run the FVP using Docker, execute the following command: |
| 117 | + |
| 118 | +```bash |
| 119 | +shrinkwrap run ns-edk2.yaml --overlay ~/workspace/aarch64.yaml |
| 120 | +``` |
| 121 | + |
| 122 | +At first, Shrinkwrap starts a Docker container and runs the FVP in it. At the beginning |
| 123 | +of the output, you may see a line containing the IP address that you need to use for SSH |
| 124 | +access into the guest system: |
| 125 | + |
| 126 | +``` |
| 127 | +Press '^]' to quit shrinkwrap. |
| 128 | +All other keys are passed through. |
| 129 | +Environment ip address: 172.17.0.2. |
| 130 | +``` |
| 131 | + |
| 132 | +It also tells you how to stop the FVP execution: press `Ctrl+]` (more on this later). |
| 133 | + |
| 134 | +Booting the Linux on the FVP takes some time. Look out for the system log messages about |
| 135 | +growing the root partition to utilize the empty disk space we created earlier. |
| 136 | + |
| 137 | +``` |
| 138 | +=> Growing root partition |
| 139 | +CHANGED: partition=2 ... old: size=1316864 ... new: size=5511135 |
| 140 | +``` |
| 141 | +
|
| 142 | +After a couple of minutes, you should be able to SSH in a different terminal into the |
| 143 | +guest OS running on the FVP using the IP address reported by the Shrinkwrap tool and the |
| 144 | +port number specified earlier in our overlay config: |
| 145 | +
|
| 146 | +```bash |
| 147 | + |
| 148 | +``` |
| 149 | + |
| 150 | +The default password is `voidlinux`. |
| 151 | + |
| 152 | +When you have logged in, check the properties of your guest system, for example: |
| 153 | + |
| 154 | +```bash |
| 155 | +uname -a |
| 156 | +cat /proc/cpuinfo |
| 157 | +``` |
| 158 | + |
| 159 | +We will do more setup during the next step. This additional setup is optional but it |
| 160 | +helps prepare our guest system for running Glibc tests and doing other complex tasks. |
| 161 | + |
| 162 | +## Powering down |
| 163 | + |
| 164 | +You can always press `Ctrl+]` to stop Shrinkwrap in the terminal where Shrinkwrap is |
| 165 | +running. However, this abruptly aborts execution of the FVP. This may leave the filesystem |
| 166 | +in your rootfs image, used by the guest system, in a broken state, resulting in errors |
| 167 | +during the next boot. To avoid this, it is advisable to shut down the guest system gracefully |
| 168 | +from the root console of your guest system, for example: |
| 169 | + |
| 170 | +```bash |
| 171 | +ssh [email protected] -p 8022 poweroff |
| 172 | +``` |
| 173 | + |
| 174 | +[1]: https://developer.arm.com/downloads/-/arm-ecosystem-fvps |
| 175 | +[2]: https://gitlab.arm.com/tooling/shrinkwrap |
| 176 | +[3]: https://shrinkwrap.docs.arm.com/en/latest/ |
| 177 | +[4]: https://docs.docker.com/engine/install/ |
| 178 | +[5]: https://developer.arm.com/documentation/100966/latest/Getting-Started-with-Fixed-Virtual-Platforms/Configuring-the-model |
0 commit comments