xref: /openbmc/u-boot/doc/README.qemu-arm (revision 83d290c56fab2d38cd1ab4c4cc7099559c1d5046)
1d5587fa3STuomas Tynkkynen# SPDX-License-Identifier: GPL-2.0+
2d5587fa3STuomas Tynkkynen#
3*83d290c5STom 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:
42d5587fa3STuomas Tynkkynen    qemu-system-arm -machine virt,highmem=off -bios u-boot.bin
43d5587fa3STuomas Tynkkynen
44e7ba41c6STuomas Tynkkynen- For AArch64:
45e7ba41c6STuomas Tynkkynen    qemu-system-aarch64 -machine virt,highmem=off -cpu cortex-a57 -bios u-boot.bin
46e7ba41c6STuomas Tynkkynen
47d5587fa3STuomas TynkkynenThe 'highmem=off' parameter to the 'virt' machine is required for PCI to work
48e7ba41c6STuomas Tynkkynenin U-Boot. Also, for some odd reason qemu-system-aarch64 needs to be explicitly
49e7ba41c6STuomas Tynkkynentold to use a 64-bit CPU or it will boot in 32-bit mode.
50d5587fa3STuomas Tynkkynen
51d5587fa3STuomas TynkkynenAdditional peripherals that have been tested to work in both U-Boot and Linux
52d5587fa3STuomas Tynkkynencan be enabled with the following command line parameters:
53d5587fa3STuomas Tynkkynen
54d5587fa3STuomas Tynkkynen- To add a Serial ATA disk via an Intel ICH9 AHCI controller, pass e.g.:
55d5587fa3STuomas Tynkkynen    -drive if=none,file=disk.img,id=mydisk -device ich9-ahci,id=ahci -device ide-drive,drive=mydisk,bus=ahci.0
56d5587fa3STuomas Tynkkynen- To add an Intel E1000 network adapter, pass e.g.:
57d5587fa3STuomas Tynkkynen    -netdev user,id=net0 -device e1000,netdev=net0
58d5587fa3STuomas Tynkkynen- To add an EHCI-compliant USB host controller, pass e.g.:
59d5587fa3STuomas Tynkkynen    -device usb-ehci,id=ehci
60d5587fa3STuomas Tynkkynen- To add a NVMe disk, pass e.g.:
61d5587fa3STuomas Tynkkynen    -drive if=none,file=disk.img,id=mydisk -device nvme,drive=mydisk,serial=foo
62d5587fa3STuomas Tynkkynen
63d5587fa3STuomas TynkkynenThese have been tested in QEMU 2.9.0 but should work in at least 2.5.0 as well.
64