RISC-V

Differences between revisions 8 and 9
Revision 8 as of 2020-11-25 18:51:54
Size: 1821
Editor: xnox
Comment:
Revision 9 as of 2021-02-01 11:33:11
Size: 2678
Editor: xnox
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:

== Images ==

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

 * Ubuntu Focal (20.04) Dailies https://cdimage.ubuntu.com/ubuntu-server/focal/daily-preinstalled/current/

 * Ubuntu Hirsute (21.04) Dailies https://cdimage.ubuntu.com/ubuntu-server/daily-preinstalled/current/
Line 25: Line 33:
Adjust to taste as needed. The image has a fallback cloud-init datasource that configures sudo user `ubuntu` with password `ubuntu`. Alternatively, you can provide a config drive (or tweak the first partitions `/var/lib/cloud/seed/nocloud/*` files) to setup anything else using cloud-init. For example ssh keys, disabling interactive login, and so on. See https://cloudinit.readthedocs.io/en/latest
Line 29: Line 35:
The above image has U-Boot SPL loader as well as SiFive U-Boot to boot on the board. Possibly one needs to set jumpers to boot from sd-card. The above image has U-Boot SPL loader as well as SiFive U-Boot to boot on the board.
Line 31: Line 37:
The image is qcow2 however, so convert it to raw first before flashing 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.
Line 34: Line 44:
qemu-img convert -O raw livecd.ubuntu-cpc.img livecd.ubuntu-cpc.raw
dd if=livecd.ubuntu-cpc.raw of=/dev/disk/by-id/
xz -dk focal-preinstalled-server-riscv64.img.xz
dd if=focal-preinstalled-server-riscv64.img of=/dev/disk/by-id/<TAB><TAB>complete-to-sdcard-device
Line 37: Line 47:

== 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

Ubuntu provides riscv64 architecture for the RISC-V platform since Focal release.

Images

One can boot it on any system with qemu-system, or on bare-metal board such as those built by SiFive.

Booting with qemu

qemu-system-riscv64 is available from qemu-system-misc package (apt install qemu-system-misc)

  • Machine type virt aka -machine virt

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

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

  • And just the cloud image from http://cloud-images.ubuntu.com/

Working example with all the options is:

qemu-system-riscv64 \
-machine virt -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 \
-device virtio-blk-device,drive=vda -drive file=livecd.ubuntu-cpc.img,id=vda 

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.img.xz
dd if=focal-preinstalled-server-riscv64.img of=/dev/disk/by-id/<TAB><TAB>complete-to-sdcard-device

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)