xref: /openbmc/u-boot/doc/README.qemu-riscv (revision 94228a9188803473206544c8f33649ea72bf1ee1)
1*510e379cSBin Meng# SPDX-License-Identifier: GPL-2.0+
2*510e379cSBin Meng#
3*510e379cSBin Meng# Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
4*510e379cSBin Meng
5*510e379cSBin MengU-Boot on QEMU's 'virt' machine on RISC-V
6*510e379cSBin Meng=========================================
7*510e379cSBin Meng
8*510e379cSBin MengQEMU for RISC-V supports a special 'virt' machine designed for emulation and
9*510e379cSBin Mengvirtualization purposes. This document describes how to run U-Boot under it.
10*510e379cSBin MengBoth 32-bit 64-bit targets are supported.
11*510e379cSBin Meng
12*510e379cSBin MengThe QEMU virt machine models a generic RISC-V virtual machine with support for
13*510e379cSBin Mengthe VirtIO standard networking and block storage devices. It has CLINT, PLIC,
14*510e379cSBin Meng16550A UART devices in addition to VirtIO and it also uses device-tree to pass
15*510e379cSBin Mengconfiguration information to guest software. It implements RISC-V privileged
16*510e379cSBin Mengarchitecture spec v1.10.
17*510e379cSBin Meng
18*510e379cSBin MengBuilding U-Boot
19*510e379cSBin Meng---------------
20*510e379cSBin MengSet the CROSS_COMPILE environment variable as usual, and run:
21*510e379cSBin Meng
22*510e379cSBin Meng- For 32-bit RISC-V:
23*510e379cSBin Meng    make qemu-riscv32_defconfig
24*510e379cSBin Meng    make
25*510e379cSBin Meng
26*510e379cSBin Meng- For 64-bit RISC-V:
27*510e379cSBin Meng    make qemu-riscv64_defconfig
28*510e379cSBin Meng    make
29*510e379cSBin Meng
30*510e379cSBin MengRunning U-Boot
31*510e379cSBin Meng--------------
32*510e379cSBin MengThe minimal QEMU command line to get U-Boot up and running is:
33*510e379cSBin Meng
34*510e379cSBin Meng- For 32-bit RISC-V:
35*510e379cSBin Meng    qemu-system-riscv32 -nographic -machine virt -kernel u-boot
36*510e379cSBin Meng
37*510e379cSBin Meng- For 64-bit RISC-V:
38*510e379cSBin Meng    qemu-system-riscv64 -nographic -machine virt -kernel u-boot
39*510e379cSBin Meng
40*510e379cSBin MengThe commands above create targets with 128MiB memory by default.
41*510e379cSBin MengA freely configurable amount of RAM can be created via the '-m'
42*510e379cSBin Mengparameter. For example, '-m 2G' creates 2GiB memory for the target,
43*510e379cSBin Mengand the memory node in the embedded DTB created by QEMU reflects
44*510e379cSBin Mengthe new setting.
45*510e379cSBin Meng
46*510e379cSBin MengThese have been tested in QEMU 3.0.0.
47