1 .. SPDX-License-Identifier: GPL-2.0+
2 .. Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
7 QEMU for RISC-V supports a special 'virt' machine designed for emulation and
8 virtualization purposes. This document describes how to run U-Boot under it.
9 Both 32-bit and 64-bit targets are supported, running in either machine or
12 The QEMU virt machine models a generic RISC-V virtual machine with support for
13 the VirtIO standard networking and block storage devices. It has CLINT, PLIC,
14 16550A UART devices in addition to VirtIO and it also uses device-tree to pass
15 configuration information to guest software. It implements RISC-V privileged
16 architecture spec v1.10.
20 Set the CROSS_COMPILE environment variable as usual, and run:
24 make qemu-riscv32_defconfig
29 make qemu-riscv64_defconfig
32 This will compile U-Boot for machine mode. To build supervisor mode binaries,
33 use the configurations qemu-riscv32_smode_defconfig and
34 qemu-riscv64_smode_defconfig instead. Note that U-Boot running in supervisor
35 mode requires a supervisor binary interface (SBI), such as RISC-V OpenSBI.
39 The minimal QEMU command line to get U-Boot up and running is:
43 qemu-system-riscv32 -nographic -machine virt -kernel u-boot
47 qemu-system-riscv64 -nographic -machine virt -kernel u-boot
49 The commands above create targets with 128MiB memory by default.
50 A freely configurable amount of RAM can be created via the '-m'
51 parameter. For example, '-m 2G' creates 2GiB memory for the target,
52 and the memory node in the embedded DTB created by QEMU reflects
55 For instructions on how to run U-Boot in supervisor mode on QEMU
56 with OpenSBI, see the documentation available with OpenSBI:
57 https://github.com/riscv/opensbi/blob/master/docs/platform/qemu_virt.md
59 These have been tested in QEMU 3.0.0.
63 In the default SPL configuration, U-Boot SPL starts in machine mode. U-Boot
64 proper and OpenSBI (FW_DYNAMIC firmware) are bundled as FIT image and made
65 available to U-Boot SPL. Both are then loaded by U-Boot SPL and the location
66 of U-Boot proper is passed to OpenSBI. After initialization, U-Boot proper is
67 started in supervisor mode by OpenSBI.
69 OpenSBI must be compiled before compiling U-Boot. Version 0.4 and higher is
70 supported by U-Boot. Clone the OpenSBI repository and run the following command.
72 .. code-block:: console
74 git clone https://github.com/riscv/opensbi.git
76 make PLATFORM=qemu/virt
78 See the OpenSBI documentation for full details:
79 https://github.com/riscv/opensbi/blob/master/docs/platform/qemu_virt.md
81 To make the FW_DYNAMIC binary (build/platform/qemu/virt/firmware/fw_dynamic.bin)
82 available to U-Boot, either copy it into the U-Boot root directory or specify
83 its location with the OPENSBI environment variable. Afterwards, compile U-Boot
84 with the following commands.
88 make qemu-riscv32_spl_defconfig
93 make qemu-riscv64_spl_defconfig
96 The minimal QEMU commands to run U-Boot SPL in both 32-bit and 64-bit
101 qemu-system-riscv32 -nographic -machine virt -kernel spl/u-boot-spl \
102 -device loader,file=u-boot.itb,addr=0x80200000
104 - For 64-bit RISC-V::
106 qemu-system-riscv64 -nographic -machine virt -kernel spl/u-boot-spl \
107 -device loader,file=u-boot.itb,addr=0x80200000