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