# RISC-V cheat sheet

**URL:** https://collective.flashbots.net/t/risc-v-cheat-sheet/3820
**Category:** References
**Tags:** notes
**Created:** [September 4, 2024, 10:06pm UTC](https://collective.flashbots.net/t/risc-v-cheat-sheet/3820 "2024-09-04T22:06:36Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![guayabyte](https://collective.flashbots.net/user_avatar/collective.flashbots.net/guayabyte/32/4_2.png) [@guayabyte](https://collective.flashbots.net/u/guayabyte)
#### Post date: [September 4, 2024, 10:06pm UTC](https://collective.flashbots.net/t/risc-v-cheat-sheet/3820/1 "2024-09-04T22:06:36Z")

</div>

Tested in Ubuntu 24.04.

# Qemu

Install:

```auto
$ sudo apt install qemu-system-misc u-boot-qemu

```

List 32-bits supported boards:

```auto
$ qemu-system-riscv32 --machine help

```

List 64-bits supported boards:

```auto
$ qemu-system-riscv64 --machine help

```

Download the Ubuntu preinstalled server image:

```auto
$ wget --continue https://cdimage.ubuntu.com/releases/24.04/release/ubuntu-24.04.2-preinstalled-server-riscv64.img.xz

```

Decompress the image:

```auto
$ xz --decompress --keep ubuntu-24.04.2-preinstalled-server-riscv64.img.xz

```

Resize the image:

```auto
$ qemu-img resize -f raw ubuntu-24.04.2-preinstalled-server-riscv64.img +5G

```

Run on the generic virtual platform `virt`:

```auto
$ qemu-system-riscv64 \
    -machine virt \
    -nographic \
    -m 2048 \
    -smp 4 \
    -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf \
    -device virtio-net-device,netdev=eth0 \
    -netdev user,id=eth0 \
    -device virtio-rng-pci \
    -drive file=ubuntu-24.04.2-preinstalled-server-riscv64.img,format=raw,if=virtio

```

Log in with user and password `ubuntu`.

Upgrade all the packages:

```auto
$ sudo apt update
$ sudo apt dist-upgrade

```

# References

- [RISC-V System emulator — QEMU documentation](https://www.qemu.org/docs/master/system/target-riscv.html#choosing-a-board-model)
- [Running 64- and 32-bit RISC-V Linux on QEMU — RISC-V - Getting Started Guide](https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html)
- [https://wiki.ubuntu.com/RISC-V/QEMU](https://wiki.ubuntu.com/RISC-V/QEMU)
