1d6d98968SBin Meng.. _RISC-V-System-emulator: 2d6d98968SBin Meng 3d6d98968SBin MengRISC-V System emulator 4d6d98968SBin Meng====================== 5d6d98968SBin Meng 6d6d98968SBin MengQEMU can emulate both 32-bit and 64-bit RISC-V CPUs. Use the 7d6d98968SBin Meng``qemu-system-riscv64`` executable to simulate a 64-bit RISC-V machine, 8d6d98968SBin Meng``qemu-system-riscv32`` executable to simulate a 32-bit RISC-V machine. 9d6d98968SBin Meng 10d6d98968SBin MengQEMU has generally good support for RISC-V guests. It has support for 11d6d98968SBin Mengseveral different machines. The reason we support so many is that 12d6d98968SBin MengRISC-V hardware is much more widely varying than x86 hardware. RISC-V 13d6d98968SBin MengCPUs are generally built into "system-on-chip" (SoC) designs created by 14d6d98968SBin Mengmany different companies with different devices, and these SoCs are 15d6d98968SBin Mengthen built into machines which can vary still further even if they use 16d6d98968SBin Mengthe same SoC. 17d6d98968SBin Meng 18d6d98968SBin MengFor most boards the CPU type is fixed (matching what the hardware has), 19d6d98968SBin Mengso typically you don't need to specify the CPU type by hand, except for 20d6d98968SBin Mengspecial cases like the ``virt`` board. 21d6d98968SBin Meng 22d6d98968SBin MengChoosing a board model 23d6d98968SBin Meng---------------------- 24d6d98968SBin Meng 25d6d98968SBin MengFor QEMU's RISC-V system emulation, you must specify which board 26d6d98968SBin Mengmodel you want to use with the ``-M`` or ``--machine`` option; 27d6d98968SBin Mengthere is no default. 28d6d98968SBin Meng 29d6d98968SBin MengBecause RISC-V systems differ so much and in fundamental ways, typically 30d6d98968SBin Mengoperating system or firmware images intended to run on one machine 31d6d98968SBin Mengwill not run at all on any other. This is often surprising for new 32d6d98968SBin Mengusers who are used to the x86 world where every system looks like a 33d6d98968SBin Mengstandard PC. (Once the kernel has booted, most user space software 34d6d98968SBin Mengcares much less about the detail of the hardware.) 35d6d98968SBin Meng 36d6d98968SBin MengIf you already have a system image or a kernel that works on hardware 37d6d98968SBin Mengand you want to boot with QEMU, check whether QEMU lists that machine 38d6d98968SBin Mengin its ``-machine help`` output. If it is listed, then you can probably 39d6d98968SBin Menguse that board model. If it is not listed, then unfortunately your image 40d6d98968SBin Mengwill almost certainly not boot on QEMU. (You might be able to 41d6d98968SBin Mengextract the file system and use that with a different kernel which 42d6d98968SBin Mengboots on a system that QEMU does emulate.) 43d6d98968SBin Meng 44d6d98968SBin MengIf you don't care about reproducing the idiosyncrasies of a particular 45d6d98968SBin Mengbit of hardware, such as small amount of RAM, no PCI or other hard 46d6d98968SBin Mengdisk, etc., and just want to run Linux, the best option is to use the 47d6d98968SBin Meng``virt`` board. This is a platform which doesn't correspond to any 48d6d98968SBin Mengreal hardware and is designed for use in virtual machines. You'll 49d6d98968SBin Mengneed to compile Linux with a suitable configuration for running on 50d6d98968SBin Mengthe ``virt`` board. ``virt`` supports PCI, virtio, recent CPUs and 51d6d98968SBin Menglarge amounts of RAM. It also supports 64-bit CPUs. 52d6d98968SBin Meng 53d6d98968SBin MengBoard-specific documentation 54d6d98968SBin Meng---------------------------- 55d6d98968SBin Meng 56d6d98968SBin MengUnfortunately many of the RISC-V boards QEMU supports are currently 57d6d98968SBin Mengundocumented; you can get a complete list by running 58d6d98968SBin Meng``qemu-system-riscv64 --machine help``, or 59d6d98968SBin Meng``qemu-system-riscv32 --machine help``. 60d6d98968SBin Meng 6101153d2bSBin Meng.. 6201153d2bSBin Meng This table of contents should be kept sorted alphabetically 6301153d2bSBin Meng by the title text of each file, which isn't the same ordering 6401153d2bSBin Meng as an alphabetical sort by filename. 6501153d2bSBin Meng 6601153d2bSBin Meng.. toctree:: 6701153d2bSBin Meng :maxdepth: 1 6801153d2bSBin Meng 69d4e28f0eSBin Meng riscv/microchip-icicle-kit 700924a423SVijai Kumar K riscv/shakti-c 7101153d2bSBin Meng riscv/sifive_u 7285198f18SBin Meng riscv/virt 7301153d2bSBin Meng 746debd840SAlistair FrancisRISC-V CPU firmware 75d6d98968SBin Meng------------------- 766debd840SAlistair Francis 776debd840SAlistair FrancisWhen using the ``sifive_u`` or ``virt`` machine there are three different 786debd840SAlistair Francisfirmware boot options: 79*542c8776SDaniel Henrique Barboza 80*542c8776SDaniel Henrique Barboza* ``-bios default`` 81*542c8776SDaniel Henrique Barboza 82*542c8776SDaniel Henrique BarbozaThis is the default behaviour if no ``-bios`` option is included. This option 83*542c8776SDaniel Henrique Barbozawill load the default OpenSBI firmware automatically. The firmware is included 84*542c8776SDaniel Henrique Barbozawith the QEMU release and no user interaction is required. All a user needs to 85*542c8776SDaniel Henrique Barbozado is specify the kernel they want to boot with the ``-kernel`` option 86*542c8776SDaniel Henrique Barboza 87*542c8776SDaniel Henrique Barboza* ``-bios none`` 88*542c8776SDaniel Henrique Barboza 89*542c8776SDaniel Henrique BarbozaQEMU will not automatically load any firmware. It is up to the user to load all 90*542c8776SDaniel Henrique Barbozathe images they need. 91*542c8776SDaniel Henrique Barboza 92*542c8776SDaniel Henrique Barboza* ``-bios <file>`` 93*542c8776SDaniel Henrique Barboza 94*542c8776SDaniel Henrique BarbozaTells QEMU to load the specified file as the firmware. 95