1d5587fa3STuomas Tynkkynen# 2d5587fa3STuomas Tynkkynen# Copyright (C) 2017, Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi> 3d5587fa3STuomas Tynkkynen# 4d5587fa3STuomas Tynkkynen# SPDX-License-Identifier: GPL-2.0+ 5d5587fa3STuomas Tynkkynen# 6d5587fa3STuomas Tynkkynen 7*e7ba41c6STuomas TynkkynenU-Boot on QEMU's 'virt' machine on ARM & AArch64 8*e7ba41c6STuomas Tynkkynen================================================ 9d5587fa3STuomas Tynkkynen 10d5587fa3STuomas TynkkynenQEMU for ARM supports a special 'virt' machine designed for emulation and 11d5587fa3STuomas Tynkkynenvirtualization purposes. This document describes how to run U-Boot under it. 12*e7ba41c6STuomas TynkkynenBoth 32-bit ARM and AArch64 are supported. 13d5587fa3STuomas Tynkkynen 14d5587fa3STuomas TynkkynenThe 'virt' platform provides the following as the basic functionality: 15d5587fa3STuomas Tynkkynen 16d5587fa3STuomas Tynkkynen - A freely configurable amount of CPU cores 17d5587fa3STuomas Tynkkynen - U-Boot loaded and executing in the emulated flash at address 0x0 18d5587fa3STuomas Tynkkynen - A generated device tree blob placed at the start of RAM 19d5587fa3STuomas Tynkkynen - A freely configurable amount of RAM, described by the DTB 20d5587fa3STuomas Tynkkynen - A PL011 serial port, discoverable via the DTB 21*e7ba41c6STuomas Tynkkynen - An ARMv7/ARMv8 architected timer 22d5587fa3STuomas Tynkkynen - PSCI for rebooting the system 23d5587fa3STuomas Tynkkynen - A generic ECAM-based PCI host controller, discoverable via the DTB 24d5587fa3STuomas Tynkkynen 25d5587fa3STuomas TynkkynenAdditionally, a number of optional peripherals can be added to the PCI bus. 26d5587fa3STuomas Tynkkynen 27d5587fa3STuomas TynkkynenBuilding U-Boot 28d5587fa3STuomas Tynkkynen--------------- 29*e7ba41c6STuomas TynkkynenSet the CROSS_COMPILE environment variable as usual, and run: 30d5587fa3STuomas Tynkkynen 31*e7ba41c6STuomas Tynkkynen- For ARM: 32d5587fa3STuomas Tynkkynen make qemu_arm_defconfig 33d5587fa3STuomas Tynkkynen make 34d5587fa3STuomas Tynkkynen 35*e7ba41c6STuomas Tynkkynen- For AArch64: 36*e7ba41c6STuomas Tynkkynen make qemu_arm64_defconfig 37*e7ba41c6STuomas Tynkkynen make 38*e7ba41c6STuomas Tynkkynen 39d5587fa3STuomas TynkkynenRunning U-Boot 40d5587fa3STuomas Tynkkynen-------------- 41d5587fa3STuomas TynkkynenThe minimal QEMU command line to get U-Boot up and running is: 42d5587fa3STuomas Tynkkynen 43*e7ba41c6STuomas Tynkkynen- For ARM: 44d5587fa3STuomas Tynkkynen qemu-system-arm -machine virt,highmem=off -bios u-boot.bin 45d5587fa3STuomas Tynkkynen 46*e7ba41c6STuomas Tynkkynen- For AArch64: 47*e7ba41c6STuomas Tynkkynen qemu-system-aarch64 -machine virt,highmem=off -cpu cortex-a57 -bios u-boot.bin 48*e7ba41c6STuomas Tynkkynen 49d5587fa3STuomas TynkkynenThe 'highmem=off' parameter to the 'virt' machine is required for PCI to work 50*e7ba41c6STuomas Tynkkynenin U-Boot. Also, for some odd reason qemu-system-aarch64 needs to be explicitly 51*e7ba41c6STuomas Tynkkynentold to use a 64-bit CPU or it will boot in 32-bit mode. 52d5587fa3STuomas Tynkkynen 53d5587fa3STuomas TynkkynenAdditional peripherals that have been tested to work in both U-Boot and Linux 54d5587fa3STuomas Tynkkynencan be enabled with the following command line parameters: 55d5587fa3STuomas Tynkkynen 56d5587fa3STuomas Tynkkynen- To add a Serial ATA disk via an Intel ICH9 AHCI controller, pass e.g.: 57d5587fa3STuomas Tynkkynen -drive if=none,file=disk.img,id=mydisk -device ich9-ahci,id=ahci -device ide-drive,drive=mydisk,bus=ahci.0 58d5587fa3STuomas Tynkkynen- To add an Intel E1000 network adapter, pass e.g.: 59d5587fa3STuomas Tynkkynen -netdev user,id=net0 -device e1000,netdev=net0 60d5587fa3STuomas Tynkkynen- To add an EHCI-compliant USB host controller, pass e.g.: 61d5587fa3STuomas Tynkkynen -device usb-ehci,id=ehci 62d5587fa3STuomas Tynkkynen- To add a NVMe disk, pass e.g.: 63d5587fa3STuomas Tynkkynen -drive if=none,file=disk.img,id=mydisk -device nvme,drive=mydisk,serial=foo 64d5587fa3STuomas Tynkkynen 65d5587fa3STuomas TynkkynenThese have been tested in QEMU 2.9.0 but should work in at least 2.5.0 as well. 66