openSUSE:RISC-V

Jump to: navigation, search

RISC-V is the free and open RISC instruction set architecture developed by the RISC-V Foundation.

openSUSE images for RISC-V

There are some riscv64 boards supported by openSUSE. Since the RISC-V support is still under development, you may run into bugs or unstable circumstances while running openSUSE on riscv64 machines. Please report to openSUSE Bugzilla or the mailing list if you find any issues. See here for more board information.

On real hardware

Here are openSUSE Tumbleweed images for supporting RISC-V boards.

Geeko-white.png
Tumbleweed Port Images
https://download.opensuse.org/ports/riscv/tumbleweed/images/
Geeko-white.png
Tumbleweed ISO Images
https://download.opensuse.org/ports/riscv/tumbleweed/iso/

Using an emulator

The provided images can be used on normal PCs on a regular Tumbleweed installation, using either the qemu userspace CPU emulation, or the qemu system emulation.

QEMU user-space emulation

Download a rootfs from the "Port Images" link.

Geeko-white.png
Tumbleweed (Factory)
https://download.opensuse.org/ports/riscv/tumbleweed/images/openSUSE-Tumbleweed-RISC-V-JeOS.riscv64-rootfs.riscv64.tar.xz

Install qemu and systemd-machined:

 # zypper in qemu-linux-user systemd-container

Register qemu as handler for RISC-V binaries:

 # qemu-binfmt-conf.sh --credential yes

Prepare systemd-nspawn to not use private networking (see man 5 systemd.nspawn):

 # mkdir /etc/systemd/nspawn
 # cat > /etc/systemd/nspawn/riscv.nspawn << EOF
 [Network]
 Private=off
 [Exec]
 PrivateUsers=off
 EOF

Download a RISC-V container and register in machined:

 # machinectl pull-tar --verify=no \
   http://download.opensuse.org/ports/riscv/tumbleweed/images/openSUSE-Tumbleweed-RISC-V-JeOS.riscv64-rootfs.riscv64.tar.xz \
   riscv

Boot the container:

 # machinectl start riscv

Get a shell:

 # machinectl shell riscv

Have a lot of fun...

QEMU system emulation

Download an efi image from the "Port Images" link.

Geeko-white.png
Tumbleweed (Factory)
http://download.opensuse.org/ports/riscv/tumbleweed/images/openSUSE-Tumbleweed-RISC-V-JeOS-efi.riscv64.raw.xz

Install qemu-extra.

 # zypper in qemu-extra guestfs-tools

Convert the raw image to compressed qcow2.

 # qemu-img convert -f raw -O qcow2 -c openSUSE-Tumbleweed-RISC-V-JeOS-efi.riscv64.raw openSUSE-Tumbleweed-RISC-V-JeOS-efi.riscv64.qcow2

Extract /boot from the image.

 # virt-copy-out -a openSUSE-Tumbleweed-RISC-V-JeOS-efi.riscv64.qcow2 /boot .

Run qemu.

 # qemu-system-riscv64 -nographic -machine virt -m 4G \
   -device virtio-blk-device,drive=hd0 -drive file=${qcow2image},format=qcow2,id=hd0 \
   -device virtio-net-device,netdev=usernet -netdev user,id=usernet,hostfwd=tcp::22222-:22 \
   -kernel boot/u-boot.bin

Log in via SSH.

  # ssh localhost -p 22222   # root / linux

Build Service

Like aarch64 during its initial porting effort, the openSUSE Build Service does not yet have native RISC-V build workers. Using cross compilers is only feasible for software that supports it (e.g. Linux kernel, U-Boot).

Building software with a native toolchain (whether on real hardware or in a VM) allows package maintainers to avoid changing the upstream build systems of the (many) projects that do not properly support cross-compiling. For aarch64, SUSE hosts native OBS build workers, and local builds on your x86_64 laptop use a full QEMU VM to emulate a real aarch64 build worker, including its hardware.

However, it's rather inefficient to emulate the complete hardware stack when we need to build an entire distribution. Therefore, openSUSE:Factory:RISCV uses a slightly different approach for now, until native RISC-V build workers are available.

In openSUSE:Factory:RISCV/standard, OBS builds are done with a riscv64 userspace, but a kernel that is native to the build worker (i.e. x86_64). This is done by using binfmt emulation in OBS.

The build setup looks like this:

  • A native (x86_64) kernel-obs-build is installed into the VM disk image
  • qemu-linux-user is installed into the VM disk image.
  • initvm.x86_64 is copied from the host into the VM disk image and is used as init (PID 0).
  • qemu-system-kvm executes the native (x86_64) kernel using hardware virtualization. The x86_64 kernel executes initvm.x86_64, which sets up qemu-linux-user to provide riscv64 userspace emulation. Then initvm.x86_64 executes the (riscv64) systemd init, and OBS takes over from there.

When building for openSUSE:Factory:RISCV/standard on an x86_64 host, make sure build-initvm-x86_64 is installed and use --vm-type=kvm:

 osc co openSUSE:Factory:RISCV/gromox
 cd openSUSE/Factory/RISCV/gromox/
 osc build --vm-type=kvm standard riscv64

There is support for using full QEMU emulation. To do that, build against the openSUSE:Factory:RISCV/native repository, make sure qemu-extra is installed and use --vm-type=qemu:

 osc co openSUSE:Factory:RISCV/gromox
 cd openSUSE/Factory/RISCV/gromox/
 osc build --vm-type=qemu native riscv64

The native repository should also be used for native builds on RISC-V hardware, if you have it. (No --vm-type is required in that case.)