|
|
(22 intermediate revisions by 3 users not shown) |
Line 1: |
Line 1: |
| This page describes the steps necessary to get Fedora for RISC-V running, either on emulated or real hardware. | | This page explains how to get Fedora running on either physical or virtual RISC-V hardware. |
|
| |
|
| = Obtain a disk image = | | = Disclaimer = |
|
| |
|
| == Tested images ==
| | riscv64 is currently '''not''' an officially supported Fedora architecture. |
|
| |
|
| These images have undergone some testing and thus are more likely to work without issues. If you are not sure which image to choose, go with one of these.
| | Most packages are built from unmodified Fedora sources, but in several cases architecture-specific patches are necessary. There is an ongoing effort to reduce (and eventually eliminate) this delta. Check out the [https://abologna.gitlab.io/fedora-riscv-tracker/ tracker] to see the current status. |
|
| |
|
| === Download using virt-builder ===
| | Hardware support is limited to what mainline Linux provides, and that usually doesn't include the SoC's integrated GPU. Fedora RISC-V is primarily intended to be used as a headless build host / server environment for now. |
|
| |
|
| This is the recommended way to obtain disk images.
| | = Generic instructions = |
|
| |
|
| To install <code>virt-builder</code>, run <code>dnf install libguestfs-tools-c</code>.
| | The following installation steps are applicable to most hardware. |
|
| |
|
| Before you can start using <code>virt-builder</code> for this task, a one-time setup is necessary:
| | If your machine is listed in the [[#Machine-specific instructions|machine-specific instructions]] section below, make sure you check out the corresponding page first, as it might contain important information that (partially or completely) supersedes what's written here. |
|
| |
|
| <pre>
| | == Requirements == |
| $ mkdir -p ~/.config/virt-builder/repos.d/
| |
| $ cat <<EOF >~/.config/virt-builder/repos.d/fedora-riscv.conf
| |
| [fedora-riscv]
| |
| uri=https://dl.fedoraproject.org/pub/alt/risc-v/repo/virt-builder-images/images/index
| |
| EOF
| |
| </pre>
| |
| | |
| With that out of the way, you can get a list of available RISC-V templates with:
| |
| | |
| <pre>
| |
| $ virt-builder --list | grep riscv64
| |
| fedora-rawhide-developer-20191123.n.0 riscv64 Fedora® Rawhide Developer 20191123.n.0
| |
| fedora-rawhide-minimal-20191123.n.1 riscv64 Fedora® Rawhide Minimal 20191123.n.1
| |
| </pre>
| |
| | |
| Then tell <code>virt-builder</code> to build a custom disk image based on one of the templates:
| |
| | |
| <pre>
| |
| $ virt-builder \
| |
| --arch riscv64 \
| |
| --size 20G \
| |
| --format raw \
| |
| --output Fedora-Developer-Rawhide-20191123.n.0-sda.raw \
| |
| fedora-rawhide-developer-20191123.n.0
| |
| [ 3.6] Downloading: https://dl.fedoraproject.org/pub/alt/risc-v/repo/virt-builder-images/images/Fedora-Developer-Rawhide-20191123.n.0-sda.raw.xz
| |
| [ 6.1] Planning how to build this image
| |
| [ 6.1] Uncompressing
| |
| [ 32.8] Opening the new disk
| |
| [ 38.4] Setting a random seed
| |
| [ 38.4] Setting the machine ID in /etc/machine-id
| |
| [ 38.4] Setting passwords
| |
| virt-builder: Setting random password of root to 5PegnZtGMP47bXnw
| |
| [ 39.9] Finishing off
| |
| Output file: Fedora-Developer-Rawhide-20191123.n.0-sda.raw
| |
| Output size: 20.0G
| |
| Output format: raw
| |
| Total usable space: 19.7G
| |
| Free space: 14.7G (75%)
| |
| </pre>
| |
| | |
| <code>virt-builder</code> has reasonable defaults, such as generating a random root password for you, but if you want more control you can pass additional arguments to customize the image further: for example, using <code>--format qcow2</code> will cause the output image to be in QCOW2 format. See <code>virt-builder --help</code> for more information.
| |
| | |
| In addition to the disk image, a firmware image (which has to be downloaded separately) is needed as well. To find out the download URL, use:
| |
| | |
| <pre>
| |
| $ virt-builder --arch riscv64 --notes fedora-rawhide-developer-20191123.n.0 | grep fw_payload
| |
| https://dl.fedoraproject.org/pub/alt/risc-v/repo/virt-builder-images/images/Fedora-Developer-Rawhide-20191123.n.0-fw_payload-uboot-qemu-virt-smode.elf
| |
| https://dl.fedoraproject.org/pub/alt/risc-v/repo/virt-builder-images/images/Fedora-Developer-Rawhide-20191123.n.0-fw_payload-uboot-qemu-virt-smode.elf.CHECKSUM
| |
| </pre>
| |
| | |
| Then download it using your favorite HTTP client, for example:
| |
| | |
| <pre>
| |
| $ wget https://dl.fedoraproject.org/pub/alt/risc-v/repo/virt-builder-images/images/Fedora-Developer-Rawhide-20191123.n.0-fw_payload-uboot-qemu-virt-smode.elf
| |
| </pre>
| |
| | |
| === Download manually === | |
| | |
| If using <code>virt-builder</code> is not an option, you can download disk images manually from: https://dl.fedoraproject.org/pub/alt/risc-v/repo/virt-builder-images/images/
| |
| | |
| Download <code>Fedora-Developer-Rawhide-*.raw.xz</code> as well as the matching <code>Fedora-Developer-Rawhide-*-fw_payload-uboot-qemu-virt-smode.elf</code>.
| |
| | |
| == Nightly builds ==
| |
| | |
| You can find them here: http://fedora.riscv.rocks/koji/tasks?state=closed&view=flat&method=createAppliance&order=-id
| |
| | |
| Select the most recent (top) build and download <code>Fedora-Developer-Rawhide-*.raw.xz</code>.
| |
| | |
| These disk images differ from the ones above in that:
| |
| * the firmware is inside the disk image, in the <code>/boot</code> directory;
| |
| * they are completely untested.
| |
| | |
| = Prepare the disk image =
| |
| | |
| These steps are only necessary if you haven't used <code>virt-builder</code>.
| |
| | |
| == Uncompress the image ==
| |
| | |
| Whether you have downloaded a tested image or a nightly build, you'll need to uncompress it before it can be used:
| |
| | |
| <pre>
| |
| $ unxz Fedora-Developer-Rawhide-*.raw.xz
| |
| </pre>
| |
| | |
| == Optional: expand the disk image ==
| |
| | |
| You might want to expand the disk image before setting up the VM. Here is one example:
| |
| | |
| <pre>
| |
| $ truncate -r Fedora-Developer-Rawhide-*.raw expanded.raw
| |
| $ truncate -s 40G expanded.raw
| |
| $ virt-resize -v -x --expand /dev/sda4 Fedora-Developer-Rawhide-*.raw expanded.raw
| |
| $ virt-filesystems --long -h --all -a expanded.raw
| |
| $ virt-df -h -a expanded.raw
| |
| </pre>
| |
| | |
| The resulting disk image will work with QEMU as well as TinyEMU. Make sure you use <code>expanded.raw</code> instead of <code>Fedora-Developer-Rawhide-*.raw</code> when booting the guest.
| |
| | |
| == Optional: create an overlay ==
| |
| | |
| You can also create <code>qcow2</code> disk image with <code>raw</code> Fedora disk as backing one. This way Fedora <code>raw</code> is unmodified and all changes are written to <code>qcow2</code> layer. You will need to install <code>libguestfs-tools-c</code>.
| |
| | |
| <pre>
| |
| $ qemu-img create -f qcow2 -F raw -b Fedora-Developer-Rawhide-*.raw overlay.qcow2 20G
| |
| $ virt-resize -v -x --expand /dev/sda4 Fedora-Developer-Rawhide-*.raw overlay.qcow2
| |
| $ virt-filesystems --long -h --all -a overlay.qcow2
| |
| </pre>
| |
| | |
| The resulting disk image will only work with QEMU. Make sure you use <code>overlay.qcow2</code> instead of <code>Fedora-Developer-Rawhide-*.raw</code> when booting the guest.
| |
| | |
| == Optional: set the hostname before booting ==
| |
| | |
| If you want to change hostname before the first boot, install <code>libguestfs-tools-c</code> and then run:
| |
| | |
| <pre>
| |
| $ virt-customize -a Fedora-Developer-Rawhide-*.raw --hostname fedora-riscv-mymagicbox
| |
| </pre>
| |
| | |
| == Nightly builds only: extracting firmware (OpenSBI) ==
| |
|
| |
|
| Fedora/RISC-V does not support BLS (Boot Loader Specification - [https://fedoraproject.org/wiki/Changes/BootLoaderSpecByDefault more details]).
| | === Serial console access === |
|
| |
|
| Disk images contain a <code>/boot</code> directory from where you can copy out the firmware.
| | While <code>ssh</code> is likely going to be the primary way you'll interact with the machine, it's useful to have serial console access as a fallback. Moreover, it is '''required''' for the initial setup. |
|
| |
|
| This is '''only''' necessary for nightly builds, since for tested images these files are provided as separate downloads alongside the image.
| | The process of connecting the USB to serial adapter is machine-specific and can't be documented in a generic fashion. |
|
| |
|
| Example session:
| | First of all, make sure your user is in the <code>dialout</code> group: |
|
| |
|
| <pre> | | <pre> |
| $ guestfish \ | | $ sudo usermod -a -G dialout $(whoami) |
| add Fedora-Developer-Rawhide-*.raw : \
| |
| run : \
| |
| mount /dev/sda1 / : \
| |
| ls /opensbi/unstable
| |
| fw_jump.elf
| |
| fw_payload-5.2.0-0.rc7.git0.1.0.riscv64.fc31.riscv64.elf
| |
| fw_payload-uboot-qemu-virt-smode.elf
| |
| $ guestfish \ | |
| add Fedora-Developer-Rawhide-*.raw : run : mount /dev/sda1 / : \
| |
| download /opensbi/unstable/fw_payload-uboot-qemu-virt-smode.elf fw_payload-uboot-qemu-virt-smode.elf
| |
| </pre> | | </pre> |
|
| |
|
| You can also use <code>guestmount</code> or QEMU/NBD to mount disk image. Examples:
| | This is necessary to access the serial console. Log out and back in for the change to take effect. |
| <pre>
| |
| $ mkdir a
| |
| $ guestmount -a $PWD/Fedora-Developer-Rawhide-*.raw -m /dev/sda1 $PWD/a
| |
| $ cp a/opensbi/unstable/fw_payload-uboot-qemu-virt-smode.elf .
| |
| $ guestunmount $PWD/a
| |
| </pre>
| |
|
| |
|
| <pre> | | Now plug the USB to serial adapter into your computer. If you only have one such adapters connected, it should show up as <code>/dev/ttyUSB0</code>. |
| $ sudo modprobe nbd max_part=8
| |
| $ sudo qemu-nbd -f raw --connect=/dev/nbd1 $PWD/Fedora-Developer-Rawhide-*.raw
| |
| $ sudo fdisk -l /dev/nbd1
| |
| Disk /dev/nbd1: 7.5 GiB, 8053063680 bytes, 15728640 sectors
| |
| Units: sectors of 1 * 512 = 512 bytes
| |
| Sector size (logical/physical): 512 bytes / 512 bytes
| |
| I/O size (minimum/optimal): 512 bytes / 512 bytes
| |
| Disklabel type: gpt
| |
| Disk identifier: F0F4268F-1B73-46FF-BABA-D87F075DCCA5
| |
|
| |
|
| Device Start End Sectors Size Type
| | Create a configuration file for <code>minicom</code>, with the name you like, for example <code>~/.minirc.RISCV</code>. The contents should look like this: |
| /dev/nbd1p1 2048 15001599 14999552 7.2G Linux filesystem
| |
| $ sudo mount /dev/nbd1p1 a
| |
| $ sudo cp a/opensbi/unstable/fw_payload-uboot-qemu-virt-smode.elf .
| |
| $ sudo umount a
| |
| $ sudo qemu-nbd --disconnect /dev/nbd1
| |
| </pre>
| |
| | |
| Note NBD is highly useful if you need to run <code>fdisk</code>, <code>e2fsck</code> (e.g. after VM crash and filesystem lock up), <code>resize2fs</code>. It might be beneficial to look into <code>nbdkit</code> and <code>nbd</code> packages.
| |
| | |
| = Boot the image on virtual hardware =
| |
| | |
| There are several options for booting the image on virtual hardware once you've prepared it following the steps above.
| |
| | |
| == Boot with libvirt ==
| |
| | |
| Detailed instructions how to install libvirt: https://docs.fedoraproject.org/en-US/quick-docs/getting-started-with-virtualization/
| |
| | |
| Quick instructions for libvirt installation (tested on Fedora 30):
| |
|
| |
|
| <pre> | | <pre> |
| # dnf group install --with-optional virtualization
| | pu port /dev/ttyUSB0 |
| # systemctl enable --now libvirtd
| | pu baudrate 115200 |
| | pu bits 8 |
| | pu parity N |
| | pu stopbits 1 |
| | pu rtscts No |
| </pre> | | </pre> |
|
| |
|
| When running RISC-V guests, it's usually a good idea to use the very latest versions of QEMU, libvirt and virt-manager: the <code>virt-preview</code> repository offers just that for Fedora users. To enable it, simply run:
| | You will now be able to connect to the serial console by running: |
|
| |
|
| <pre> | | <pre> |
| # dnf copr enable @virtmaint-sig/virt-preview
| | $ minicom RISCV |
| </pre> | | </pre> |
|
| |
|
| and update your system.
| | For added reliability, you can use a stable device name in the configuration file. For example: |
| | |
| The steps below assume you have copied both the disk image and the firmware into <code>/var/lib/libvirt/images</code>: this is the location where libvirt usually expects to find disk images, so while using a different location might work it's a good idea to do this and reduce the possibility of issues caused by filesystem permissions and such.
| |
| | |
| Assuming you have QEMU ≥ 4.0.0, libvirt ≥ 5.3.0 and virt-manager ≥ 2.2.0, the installation will be as simple as:
| |
|
| |
|
| <pre> | | <pre> |
| # virt-install \
| | $ ls -l /dev/serial/by-id/* |
| --qemu-commandline='-bios none' \
| | /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0 -> ../../ttyUSB0 |
| --name fedora-riscv \
| |
| --arch riscv64 \
| |
| --vcpus 8 \
| |
| --memory 2048 \
| |
| --os-variant fedora30 \
| |
| --boot kernel=/var/lib/libvirt/images/Fedora-Developer-Rawhide-*-fw_payload-uboot-qemu-virt-smode.elf \
| |
| --import --disk path=/var/lib/libvirt/images/Fedora-Developer-Rawhide-*.raw \
| |
| --network network=default \
| |
| --graphics none
| |
| </pre> | | </pre> |
|
| |
|
| If you are stuck with older software (QEMU ≥ 2.12.0, libvirt ≥ 4.7.0), then you're going to need a more verbose command line:
| | This output indicates that you should replace <code>/dev/ttyUSB0</code> with <code>/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0</code> in the configuration file. |
| | |
| <pre>
| |
| # virt-install \
| |
| --name fedora-riscv \
| |
| --arch riscv64 \
| |
| --machine virt \
| |
| --vcpus 8 \
| |
| --memory 2048 \
| |
| --os-variant fedora30 \
| |
| --boot kernel=/var/lib/libvirt/images/Fedora-Developer-Rawhide-*-fw_payload-uboot-qemu-virt-smode.elf \
| |
| --import --disk path=/var/lib/libvirt/images/Fedora-Developer-Rawhide-*.raw,bus=virtio \
| |
| --network network=default,model=virtio \
| |
| --rng device=/dev/urandom,model=virtio \
| |
| --channel name=org.qemu.guest_agent.0 \
| |
| --graphics none
| |
| </pre>
| |
| | |
| Additionally, when using older software components you won't get PCI support, and so enabling graphics will not be possible.
| |
| | |
| Either one of the commands above will automatically boot you into the console. If you don't want that add <code>--noautoconsole</code> option. You can later use <code>virsh</code> tool to manage your VM and get to console.
| |
| | |
| A quick reference of <code>virsh</code> commands:
| |
| * <code>virsh list --all</code> - list all VMs and their states
| |
| * <code>virsh console <name></code> - connect to serial console (remember: <code>Escape character is ^]</code>)
| |
| * <code>virsh shutdown <name></code> - power down VM (see above for more details)
| |
| * <code>virsh start <name></code> - power up VM
| |
| * <code>virsh undefine <name></code> - remove VM
| |
| * <code>virsh net-list</code> - list network (useful for the next command)
| |
| * <code>virsh net-dhcp-leases <network_name></code> - list DHCP leases, <code><network_name></code> most likely will be <code>default</code>. This is useful when you want to get IPv4 and SSH to the VM.
| |
| * <code>virsh domifaddr <name></code> - alternative for the above two commands, only shows IPv4 for one VM
| |
| * <code>virsh reset <name></code> - hard reset VM
| |
| * <code>virsh destroy <name></code> hard power down of VM
| |
| | |
| If you want to use <code>ssh user@virtualMachine</code> you can setup libvirt NSS module. See: https://libvirt.org/nss.html
| |
| | |
| You might want also to setup logging for serial console (in case kernel panics or something else).
| |
| | |
| For this we will be using two commands: <code>virsh edit <name></code> (modifying VM XML) and <code>virsh dumpxml <name></code> (dump VM XML for backup). You need to modify <code><serial></code> node by adding <code><log file='/var/log/libvirt/qemu/fedora-riscv-mymagicbox.serial.log'/></code>. Then power down and power up the VM.
| |
| | |
| Alternatively you can use <code>--serial log.file=/.../whatever.serial.log</code> with <code>virt-install</code> command.
| |
| | |
| == Boot under QEMU ==
| |
| | |
| Here is the last tested configuration for the instructions below:
| |
| * Fedora 37
| |
| * QEMU emulator version 7.2.0 (qemu-7.2.0-4.fc37)
| |
| * Fedora-Developer-37-20221130.n.0.SiFive.Unmatched
| |
| | |
| <pre>
| |
| # Download disk image
| |
| wget https://dl.fedoraproject.org/pub/alt/risc-v/disk_images/Fedora-Developer-37-20221130.n.0.SiFive.Unmatched/Fedora-Developer-37-20221130.n.0-nvme.raw.img.xz
| |
| wget https://dl.fedoraproject.org/pub/alt/risc-v/disk_images/Fedora-Developer-37-20221130.n.0.SiFive.Unmatched/Fedora-Developer-37-20221130.n.0-nvme.raw.img.xz.sha512sum
| |
| | |
| # Verify
| |
| sha512sum -c *.sha512sum
| |
|
| |
|
| # Uncompress
| | == Media preparation == |
| unxz Fedora-Developer-37-20221130.n.0-nvme.raw.img.xz
| |
|
| |
|
| # Download the latest U-Boot (we need U-Boot SPL and U-Boot ITB files)
| | === Downloading the disk image === |
| mkdir u
| |
| pushd u
| |
| rpm2cpio http://fedora.riscv.rocks/kojifiles/packages/uboot-tools/2023.01/2.4.riscv64.fc37/noarch/uboot-images-riscv64-2023.01-2.4.riscv64.fc37.noarch.rpm | cpio -dvim
| |
| popd
| |
|
| |
|
| # We need to modify extlinux.conf for QEMU
| | Disk images can be obtained from: |
|
| |
|
| virt-edit -a Fedora-Developer-37-20221130.n.0-nvme.raw.img /boot/extlinux/extlinux.conf
| | * https://dl.fedoraproject.org/pub/alt/risc-v/release/41/Server/riscv64/images/ |
|
| |
|
| # Or use kpartx:
| | As of this writing, the most recent disk image is: |
| mkdir -p /tmp/disk_img
| |
| sudo kpartx -a -v Fedora-Developer-37-20221130.n.0-nvme.raw.img
| |
| # Output example
| |
| add map loop2p1 (253:4): 0 1433600 linear 7:2 34
| |
| add map loop2p2 (253:5): 0 19537853 linear 7:2 1433634
| |
| # We need to mount the 1st partition (or /boot partition)
| |
| sudo mount /dev/mapper/loop2p1 /tmp/disk_img
| |
| # Edit extlinux.conf
| |
| sudo nvim /tmp/disk_img/extlinux/extlinux.conf
| |
|
| |
|
| # Existing boot entry
| | * [https://dl.fedoraproject.org/pub/alt/risc-v/release/41/Server/riscv64/images/Fedora-Server-Host-Generic-41.20250224-1026a2d0e311.riscv64.raw.xz <code>Fedora-Server-Host-Generic-41.20250224-1026a2d0e311.riscv64.raw.xz</code>] |
| 9 label Fedora-Developer-37-20221130.n.0 (6.0.10-300.0.riscv64.fc37.riscv64)
| |
| 10 kernel /vmlinuz-6.0.10-300.0.riscv64.fc37.riscv64
| |
| 11 append ro root=UUID=d9334329-e2ad-4b72-8f5f-b61406e9d461 rhgb quiet LANG=en_US.UTF-8 console=ttySIF0,115200 earlycon
| |
| 12 fdtdir /dtb-6.0.10-300.0.riscv64.fc37.riscv64/
| |
| 13 initrd /initramfs-6.0.10-300.0.riscv64.fc37.riscv64.img
| |
|
| |
|
| # Modified
| | The file you've just downloaded will be referred to as <code>IMAGE.raw.xz</code> below. |
| 9 label Fedora-Developer-37-20221130.n.0 (6.0.10-300.0.riscv64.fc37.riscv64)
| |
| 10 kernel /vmlinuz-6.0.10-300.0.riscv64.fc37.riscv64
| |
| 11 append ro root=UUID=d9334329-e2ad-4b72-8f5f-b61406e9d461 rhgb quiet LANG=en_US.UTF-8 console=ttyS0 earlycon
| |
| 12 initrd /initramfs-6.0.10-300.0.riscv64.fc37.riscv64.img
| |
|
| |
|
| # We want to remove fdtdir because we will get DTB from the QEMU itself
| | A matching <code>IMAGE.raw.xz.sha256</code> file is also provided: this allows you to validate the integrity of your download. |
| # Set console to ttyS0
| |
|
| |
|
| # Unmount
| | === Writing the disk image to the target media === |
| sudo sync
| |
| sudo umount /tmp/disk_img
| |
| sudo kpartx -d -v Fedora-Developer-37-20221130.n.0-nvme.raw.img
| |
|
| |
|
| # Launch QEMU
| | The disk image is intended to work regardless of the type of media it's written to: SD cards, USB sticks, NVMe and SATA drives are all known to work. NVMe is preferred, if available on your machine, because it performs the best, but you can choose whatever is more suitable to you. SD cards, for example, are great when you want to test a disk image without affecting your existing installation. |
| qemu-system-riscv64 \
| |
| -bios u/usr/share/uboot/qemu-riscv64_spl/u-boot-spl.bin \
| |
| -nographic \
| |
| -machine virt \
| |
| -smp 4 \
| |
| -m 4G \
| |
| -device loader,file=u/usr/share/uboot/qemu-riscv64_spl/u-boot.itb,addr=0x80200000 \
| |
| -object rng-random,filename=/dev/urandom,id=rng0 \
| |
| -device virtio-rng-device,rng=rng0 \
| |
| -device virtio-blk-device,drive=hd0 \
| |
| -drive file=Fedora-Developer-37-20221130.n.0-nvme.raw.img,format=raw,id=hd0 \
| |
| -device virtio-net-device,netdev=usernet \
| |
| -netdev user,id=usernet,hostfwd=tcp::10000-:22
| |
| </pre>
| |
|
| |
|
| Once machine is booted you can connect via SSH:
| | The disk image comes compressed, so the first step after downloading it is to uncompress it: |
|
| |
|
| <pre> | | <pre> |
| $ ssh -p 10000 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PreferredAuthentications=password -o PubkeyAuthentication=no riscv@localhost | | $ unxz IMAGE.raw.xz |
| </pre> | | </pre> |
|
| |
|
| If need you can get DTB/DTS from QEMU:
| | The compressed <code>IMAGE.raw.xz</code> file will be replaced by the uncompressed <code>IMAGE.raw</code> file. The latter is the one that can be written to the target media. |
| <pre> | |
| qemu-system-riscv64 -nographic -smp 8 -m 2G -machine virt,dumpdtb=qemu-riscv.dtb
| |
| dtc -I dtb -O dts qemu-riscv.dtb -o qemu-riscv.dts
| |
| </pre> | |
|
| |
|
| This can run up to 32 CPUs.
| | There are several tools that can be used for writing the disk image. <code>dd</code> is perhaps the most common option: |
| | |
| == Boot under TinyEMU (RISCVEMU) ==
| |
| '''Note (2019 March 10):''' This is not supported anymore until TinyEMU is updated to support external initrd file. Please, use QEMU or libvirt/QEMU.
| |
| | |
| RISCVEMU recently (2018-09-23) was renamed to TinyEMU (https://bellard.org/tinyemu/).
| |
| | |
| TinyEMU allow booting Fedora disk images in TUI and GUI modes. You can experiment using JSLinux (no need to download/compile/etc) here: https://bellard.org/jslinux/
| |
| | |
| Below are instructions how to boot Fedora into X11/Fluxbox GUI mode.
| |
| | |
| '''Step 1'''. Compile TinyEMU:
| |
|
| |
|
| <pre> | | <pre> |
| wget https://bellard.org/tinyemu/tinyemu-2018-09-23.tar.gz
| | $ sudo dd iflag=fullblock oflag=direct status=progress bs=4M if=IMAGE.raw of=/dev/TARGET |
| tar xvf tinyemu-2018-09-23.tar.gz
| |
| cd tinyemu-2018-09-23
| |
| make
| |
| </pre> | | </pre> |
|
| |
|
| '''Step 2'''. Setup for booting Fedora: | | Replace `/dev/TARGET` with the name of the actual target device. Please be '''extremely careful''' and ensure that you're using the correct name here: if you get it wrong, you risk '''destroying''' your current OS. |
|
| |
|
| <pre>
| | [https://etcher.balena.io/ balenaEtcher] is another popular option. It's a user-friendly GUI that should make it a lot harder to mess things up. |
| mkdir fedora
| |
| cd fedora
| |
| cp ../temu .
| |
|
| |
|
| # Download pre-built BBL with embedded kernel
| | == First boot == |
| wget https://bellard.org/jslinux/bbl64-4.15.bin
| |
|
| |
|
| # Create configuration file for TinyEMU
| | Once the disk image has been written to the target media, you can pop that into your machine and power it on. |
| cat <<EOF > root-riscv64.cfg
| |
| /* VM configuration file */
| |
| {
| |
| version: 1,
| |
| machine: "riscv64",
| |
| memory_size: 1400,
| |
| bios: "bbl64-4.15.bin",
| |
| cmdline: "loglevel=3 console=tty0 root=/dev/vda rw TZ=${TZ}",
| |
| drive0: { file: "Fedora-Developer-Rawhide-*-sda1.raw" },
| |
| eth0: { driver: "user" },
| |
| display0: {
| |
| device: "simplefb",
| |
| width: 1920,
| |
| height: 1080,
| |
| },
| |
| input_device: "virtio",
| |
| }
| |
| EOF
| |
|
| |
|
| # Download disk image and unpack in the same directory
| | The process of getting the firmware to boot from the media is machine-specific and can't be documented in a generic fashion. It usually helps if only one media is connected to the machine at any given time. |
| </pre>
| |
|
| |
|
| '''Step 3'''. Boot it.
| | Assuming everything is fine, after a few seconds you should see the usual Linux boot messages scroll by on the serial console. |
|
| |
|
| <pre>
| | After a short while, you will be presented with a login prompt. You can use login `fedora` and password `linux` to gain access. |
| ./temu -rw root-riscv64.cfg | |
| </pre>
| |
| | |
| We need to use <code>-rw</code> if we want our changes to persist in disk image. Otherwise disk image will be loaded as read-only and all changes will not persist after reboot.
| |
| | |
| = Boot the image on physical hardware =
| |
|
| |
|
| == Install on the HiFive Unleashed SD card == | | == Post-installation tasks == |
|
| |
|
| The disk image can be copied directly to an SD card and run on the [https://www.sifive.com/products/hifive-unleashed/ HiFive Unleashed board].
| | === Enable the performance CPU governor === |
|
| |
|
| A good way to create the SD card is with this virt-builder command:
| | The default CPU governor is `schedutils`, which scales the CPU frequency dynamically. If you want to squeeze every last bit of performance out of your machine, you might want to switch to the `performance` CPU governor. To do so, simply run: |
|
| |
|
| <pre> | | <pre> |
| sudo virt-builder \ | | $ sudo grubby --update-kernel=ALL --args=cpufreq.default_governor=performance |
| --source https://dl.fedoraproject.org/pub/alt/risc-v/repo/virt-builder-images/images/index \
| |
| --no-check-signature \
| |
| --arch riscv64 \
| |
| --format raw \
| |
| --hostname testing.example.com \
| |
| --output /dev/sdXXX \
| |
| --root-password password:riscv \
| |
| fedora-rawhide-developer-20200108.n.0
| |
| </pre> | | </pre> |
|
| |
|
| == Install on the HiFive Unleashed using NBD server ==
| | A reboot is necessary for the change to take effect. |
|
| |
|
| You will need a separate machine on the same network which can act as an NBD server. It can be any Linux machine with [https://github.com/qemu/qemu/blob/master/qemu-nbd.c qemu-nbd] or [https://github.com/libguestfs/nbdkit nbdkit] installed.
| | === Disable use of tmpfs for /tmp === |
|
| |
|
| You will first need to get it working on the SD card using the instructions in the previous section.
| | Fedora uses `tmpfs` for `/tmp` by default, but that might cause issues if your machine doesn't have much RAM. If you run into OOMs or other related issues, you can revert to disk-backed `/tmp` by running: |
|
| |
|
| On the HiFive board, install <code>dracut-network</code> and <code>nbd</code>, and rebuild the initramfs with NBD support using these commands:
| |
| <pre> | | <pre> |
| dnf install dracut-network nbd
| | $ sudo systemctl mask tmp.mount |
| dracut -m "nbd network base" -v --force
| |
| </pre> | | </pre> |
|
| |
|
| Shut down the HiFive board, remove the SD card, and copy the 4th partition from the SD card into a file or partition on the NBD server.
| | A reboot is necessary for the change to take effect. |
| | |
| You will need to change the UUID on this filesystem to a new random one (else it will conflict with the SD-card root filesystem), eg:
| |
| <pre>
| |
| tune2fs -U random /dev/VG/jive
| |
| </pre>
| |
|
| |
|
| Start up the NBD server (in this example using <code>qemu-nbd</code> with the 4th partition having been copied to <code>/dev/VG/jive</code> listening on port 10810):
| | === Enable haveged === |
| <pre>
| |
| qemu-nbd -t -f raw -x "" -p 10810 /dev/VG/jive
| |
| </pre>
| |
|
| |
|
| Place the SD card back in the HiFive board and boot it. At this point you have still booted into the SD card's root filesystem (not NBD). Go and edit <code>/boot/extlinux/extlinux.conf</code>. To the <code>addappend</code> line you will need to set:
| | If your machine doesn't have a hardware RNG, it might take a long time to boot or accept ssh logins. A possible workaround is to configure a software RNG like so: |
|
| |
|
| <pre> | | <pre> |
| root=UUID=...uuid... netroot=nbd:192.168.0.220:10810 rootfstype=ext4 ro rootdelay=5 ip=dhcp rootwait
| | $ sudo dnf install -y haveged |
| | $ sudo systemctl enable --now haveged.service |
| </pre> | | </pre> |
|
| |
|
| I would also advise removing <code>rhgb quiet</code> if they are present. Note you need to set <code>uuid</code> and the address and port number of the NBD server correctly. Immediately reboot and it should come up with an NBD root. Check the boot messages carefully to see whether it used the SD card or NBD root.
| | = Machine-specific instructions = |
| | |
| == Install Fedora GNOME Desktop on SiFive HiFive Unleashed + Microsemi HiFive Unleashed Expansion board == | |
| | |
| Detailed instructions are provided by Atish Patra from Western Digital Corporation (WDC). See their GitHub page for details and pictures: https://github.com/westerndigitalcorporation/RISC-V-Linux
| |
| | |
| So far two GPUs are confirmed to be working: Radeon HD 6450 and Radeon HD 5450.
| |
|
| |
|
| = Use the image =
| | While the information above is generally applicable, some machines require additional or even completely different steps. |
|
| |
|
| Once the system is booted, login as <code>root</code> with <code>riscv</code> as password.
| | == Physical hardware == |
|
| |
|
| X11 with Fluxbox can be started using: <code>startx /usr/bin/startfluxbox</code>. The disk image also includes awesome and i3 for testing. Dillo is available as a basic web browser (no javascript support) and pcmanfm as file manager.
| | * [[Architectures/RISC-V/StarFive/VisionFive2|StarFive VisionFive 2]] |
| | * [[Architectures/RISC-V/SiFive/HiFiveUnmatched|SiFive HiFive Unmatched]] |
| | * [[Architectures/RISC-V/SiFive/HiFivePremierP550|SiFive HiFive Premier P550]] |
|
| |
|
| To gracefully shutdown just type <code>poweroff</code> into console.
| | == Virtual hardware == |
|
| |
|
| If you want more information being displayed during boot, remove <code>quiet</code> from the <code>append</code> line in <code>/boot/extlinux/extlinux.conf</code>.
| | * [[Architectures/RISC-V/QEMU|QEMU]] |
This page explains how to get Fedora running on either physical or virtual RISC-V hardware.
Disclaimer
riscv64 is currently not an officially supported Fedora architecture.
Most packages are built from unmodified Fedora sources, but in several cases architecture-specific patches are necessary. There is an ongoing effort to reduce (and eventually eliminate) this delta. Check out the tracker to see the current status.
Hardware support is limited to what mainline Linux provides, and that usually doesn't include the SoC's integrated GPU. Fedora RISC-V is primarily intended to be used as a headless build host / server environment for now.
Generic instructions
The following installation steps are applicable to most hardware.
If your machine is listed in the machine-specific instructions section below, make sure you check out the corresponding page first, as it might contain important information that (partially or completely) supersedes what's written here.
Requirements
Serial console access
While ssh
is likely going to be the primary way you'll interact with the machine, it's useful to have serial console access as a fallback. Moreover, it is required for the initial setup.
The process of connecting the USB to serial adapter is machine-specific and can't be documented in a generic fashion.
First of all, make sure your user is in the dialout
group:
$ sudo usermod -a -G dialout $(whoami)
This is necessary to access the serial console. Log out and back in for the change to take effect.
Now plug the USB to serial adapter into your computer. If you only have one such adapters connected, it should show up as /dev/ttyUSB0
.
Create a configuration file for minicom
, with the name you like, for example ~/.minirc.RISCV
. The contents should look like this:
pu port /dev/ttyUSB0
pu baudrate 115200
pu bits 8
pu parity N
pu stopbits 1
pu rtscts No
You will now be able to connect to the serial console by running:
$ minicom RISCV
For added reliability, you can use a stable device name in the configuration file. For example:
$ ls -l /dev/serial/by-id/*
/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0 -> ../../ttyUSB0
This output indicates that you should replace /dev/ttyUSB0
with /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0
in the configuration file.
Media preparation
Downloading the disk image
Disk images can be obtained from:
As of this writing, the most recent disk image is:
The file you've just downloaded will be referred to as IMAGE.raw.xz
below.
A matching IMAGE.raw.xz.sha256
file is also provided: this allows you to validate the integrity of your download.
Writing the disk image to the target media
The disk image is intended to work regardless of the type of media it's written to: SD cards, USB sticks, NVMe and SATA drives are all known to work. NVMe is preferred, if available on your machine, because it performs the best, but you can choose whatever is more suitable to you. SD cards, for example, are great when you want to test a disk image without affecting your existing installation.
The disk image comes compressed, so the first step after downloading it is to uncompress it:
$ unxz IMAGE.raw.xz
The compressed IMAGE.raw.xz
file will be replaced by the uncompressed IMAGE.raw
file. The latter is the one that can be written to the target media.
There are several tools that can be used for writing the disk image. dd
is perhaps the most common option:
$ sudo dd iflag=fullblock oflag=direct status=progress bs=4M if=IMAGE.raw of=/dev/TARGET
Replace /dev/TARGET
with the name of the actual target device. Please be extremely careful and ensure that you're using the correct name here: if you get it wrong, you risk destroying your current OS.
balenaEtcher is another popular option. It's a user-friendly GUI that should make it a lot harder to mess things up.
First boot
Once the disk image has been written to the target media, you can pop that into your machine and power it on.
The process of getting the firmware to boot from the media is machine-specific and can't be documented in a generic fashion. It usually helps if only one media is connected to the machine at any given time.
Assuming everything is fine, after a few seconds you should see the usual Linux boot messages scroll by on the serial console.
After a short while, you will be presented with a login prompt. You can use login fedora
and password linux
to gain access.
Post-installation tasks
Enable the performance CPU governor
The default CPU governor is schedutils
, which scales the CPU frequency dynamically. If you want to squeeze every last bit of performance out of your machine, you might want to switch to the performance
CPU governor. To do so, simply run:
$ sudo grubby --update-kernel=ALL --args=cpufreq.default_governor=performance
A reboot is necessary for the change to take effect.
Disable use of tmpfs for /tmp
Fedora uses tmpfs
for /tmp
by default, but that might cause issues if your machine doesn't have much RAM. If you run into OOMs or other related issues, you can revert to disk-backed /tmp
by running:
$ sudo systemctl mask tmp.mount
A reboot is necessary for the change to take effect.
Enable haveged
If your machine doesn't have a hardware RNG, it might take a long time to boot or accept ssh logins. A possible workaround is to configure a software RNG like so:
$ sudo dnf install -y haveged
$ sudo systemctl enable --now haveged.service
Machine-specific instructions
While the information above is generally applicable, some machines require additional or even completely different steps.
Physical hardware
Virtual hardware