RISC-V

Differences between revisions 22 and 23
Revision 22 as of 2022-02-09 16:35:45
Size: 4923
Editor: mvo
Comment: Make the uboot impish requirement bold to ensure people know before trying it on focal
Revision 23 as of 2022-05-17 07:58:52
Size: 4530
Editor: alexghiti
Comment:
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
 * Ubuntu 20.04.3 LTS Release Image https://cdimage.ubuntu.com/releases/20.04.3/release/  * Ubuntu 20.04.4 LTS Release Image https://cdimage.ubuntu.com/releases/20.04.4/release/
Line 9: Line 9:
 * Ubuntu 21.04 Release Image https://cdimage.ubuntu.com/releases/21.04/ use riscv64+unmatched.img.xz  * Ubuntu 22.04 Release Image https://cdimage.ubuntu.com/releases/22.04/release/ use riscv64+unmatched.img.xz
Line 12: Line 12:

=== SiFive HiFive Unleashed & QEMU ===

 * Ubuntu 20.04.3 LTS Release Image https://cdimage.ubuntu.com/releases/20.04.3/release/

 * Ubuntu 21.04 Release Image https://cdimage.ubuntu.com/releases/21.04/ use riscv64+unleashed.img.xz

One can boot riscv64 & riscv64+unleashed images on any system with qemu-system, or on bare-metal SiFive HiFive Unleashed board.
Line 31: Line 23:
'''Impish's (21.10) version of u-boot-qemu is required at the moment to boot Impish images.'''
Line 38: Line 29:
xz -dk focal-preinstalled-server-riscv64.img.xz xz -dk ubuntu-22.04-preinstalled-server-riscv64+unmatched.img.xz
Line 44: Line 35:
qemu-img resize -f raw focal-preinstalled-server-riscv64.img +5G qemu-img resize -f raw ubuntu-22.04-preinstalled-server-riscv64+unmatched.img +5G
Line 57: Line 48:
-drive file=focal-preinstalled-server-riscv64.img,format=raw,if=virtio -drive file=ubuntu-22.04-preinstalled-server-riscv64+unmatched.img,format=raw,if=virtio
Line 81: Line 72:
xz -dk focal-preinstalled-server-riscv64+unmatched.img.xz
dd if=focal-preinstalled-server-riscv64+unmatched.img of=/dev/disk/by-id/<TAB><TAB>complete-to-sdcard-device
xz -dk ubuntu-22.04-preinstalled-server-riscv64+unmatched.img.xz
dd if=ubuntu-22.04-preinstalled-server-riscv64+unmatched.img of=/dev/disk/by-id/<TAB><TAB>complete-to-sdcard-device

Ubuntu provides the riscv64 architecture for the RISC-V platform since the release of Ubuntu 20.04 LTS.

Images

SiFive HiFive Unmatched & QEMU

One can boot riscv64+unmatched image on any system with qemu-system, or on bare-metal SiFive HiFive Unmatched board.

Forums

You can discuss Ubuntu on RISC-V over at the Ubuntu Server forums.

Booting with qemu

Prerequisites:

  • apt install qemu-system-misc opensbi u-boot-qemu qemu-utils

After installing the above prerequisites, one can use any of the above images to boot virtual machine.

First unpack the image

xz -dk ubuntu-22.04-preinstalled-server-riscv64+unmatched.img.xz

Optionally, if you want larger disk, you can expand the disk (filesystem will be automatically resized too).

qemu-img resize -f raw ubuntu-22.04-preinstalled-server-riscv64+unmatched.img +5G

Next use OpenSBI bootloader & u-boot-qemu to boot the virtual machine

Working example with all the options is:

qemu-system-riscv64 \
-machine virt -nographic -m 2048 -smp 4 \
-bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf \
-kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf \
-device virtio-net-device,netdev=eth0 -netdev user,id=eth0 \
-drive file=ubuntu-22.04-preinstalled-server-riscv64+unmatched.img,format=raw,if=virtio

The important options to use are:

  • Machine type virt aka -machine virt

  • Bios is OpenSBI -bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf

  • "kernel" is qemu smode uboot -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf

One can use pass through networking, adjust memory (-m) & cpu counts (-smp) as needed.

Switch to the serial console, wait for cloud-init to complete, then login using ubuntu:ubuntu. See the cloud-init section below to further customise the first boot behaviour with cloud-init.

Booting on SiFive HiFive Unmatched board

The above image has U-Boot SPL loader as well as SiFive U-Boot to boot on the board.

Set jumpers to boot from the microSD by setting MSEL=1011 (MSEL2 to the outside of the board, the rest to the inside).

You can then use "Gnome Disks" app to restore img.xz image onto the microSD card, plug it into the board and boot.

You can also use cmdline to extract the image and dd it.

xz -dk ubuntu-22.04-preinstalled-server-riscv64+unmatched.img.xz
dd if=ubuntu-22.04-preinstalled-server-riscv64+unmatched.img of=/dev/disk/by-id/<TAB><TAB>complete-to-sdcard-device

Monitor serial console, wait for cloud-init to complete, then login using ubuntu:ubuntu. See the cloud-init section below to further customise the first boot behaviour with cloud-init.

Booting on SiFive HiFive Unleashed board

The above image has U-Boot SPL loader as well as SiFive U-Boot to boot on the board.

Set jumpers to boot from the microSD by setting MSEL=1011 (MSEL2 to the outside of the board, the rest to the inside).

You can then use "Gnome Disks" app to restore img.xz image onto the microSD card, plug it into the board and boot.

You can also use cmdline to extract the image and dd it.

xz -dk focal-preinstalled-server-riscv64+unleashed.img.xz
dd if=focal-preinstalled-server-riscv64+unleashed.img of=/dev/disk/by-id/<TAB><TAB>complete-to-sdcard-device

Monitor serial console, wait for cloud-init to complete, then login using ubuntu:ubuntu. See the cloud-init section below to further customise the first boot behaviour with cloud-init.

cloud-init integration

The image has a fallback cloud-init datasource that configures sudo user ubuntu with password ubuntu and DHCP networking. You will be asked to change the password on first login.

The image has CIDATA partition which can be used as a valid datasource to adjust cloud-config metadata. If you wish to customize user password, networking information, add ssh keys, etc. Please mount CIDATA partition rename meta-data and user-data files and adjust them to taste. You can use network-info to configure networking if something more sophisticated than just DHCP is desired.

For example ssh keys, disabling interactive login, and so on. See https://cloudinit.readthedocs.io/en/latest

RISC-V (last edited 2023-11-13 18:51:48 by lengau)