Skip to content

Feature: Build riscv64 image #51

@ffgan

Description

@ffgan

Hi there,

I've recently been trying to build a riscv64+alpine image that can be used for QEMU booting. Below is a detailed introduction to the content.

Currently, Alpine does not support linux-virt for rv64; only linux-lts is available. Therefore, I used linux-lts as the kernel for the subsequent build. To follow the original logic in the script, rv64 uses UEFI mode for booting.

However, when booting, I encountered the following error:

Shell> vmlinuz-lts initrd=initramfs-lts root=UUID=bd80998d-8b58-4522-beef-46727d
ab0c31 rootfstype=ext4 modules=kms,scsi,virtio console=tty0
Script Error Status: Unsupported (line number 1)

The boot script is as follows:

qemu-system-riscv64 \
-m 4G \
-machine virt,acpi=off \
-device virtio-net-pci,netdev=net00 \
-device virtio-rng-pci \
-netdev type=user,id=net00 \
-drive if=virtio,file=alpine-riscv64-xx.qcow2 \
-drive file=RISCV_VIRT_CODE.fd,if=pflash,format=raw,readonly=on \
-drive file=RISCV_VIRT_CODE.fd,if=pflash,format=raw \
-nographic \
-smp 4

The RISCV_VIRT_CODE.fd is a generic rv64 firmware that can be downloaded from: https://dl-cdn.openeuler.openatom.cn/openEuler-24.03-LTS/virtual_machine_img/riscv64/

After installing and enabling grub in configure.sh, I was able to successfully obtain a bootable rv64 image, but this approach seems different from the EFI Stub method currently used in the repository. So if anyone is interested in my grub-based boot method, you can check out my repository: https://github.com/ffgan/alpine-make-vm-image/tree/test

I've done a simple investigation on this, but there may be some oversights. If there are any errors, please point them out promptly.

By checking https://gitlab.alpinelinux.org/alpine/aports/-/tree/master/main/linux-lts, I obtained the build information for the kernels currently supported by Alpine. I've organized the following table:

Note: there is no virt.riscv64.config

name CONFIG_EFI CONFIG_EFI_STUB CONFIG_EFI_ZBOOT
virt.x86_64.config y y -
lts.x86_64.config y y -
lts.riscv64.config - - -
virt.aarch64.config - - y
lts.aarch64.config - - y

- indicates the configuration doesn't exist.

From the table above, we can see that rv64 does not support the EFI Stub UEFI boot method currently used in this repository. Therefore, if we need to build an img that can be used on rv64, using grub is a more appropriate approach.

So my main question is: Will Alpine accept images built using grub? If supported, I can quickly submit a PR to support rv64. Alternatively, if there are other viable approaches, I would be happy to assist Alpine in completing the related work. I'd like to thank in advance everyone who provides help.


other info
Co-authored by: nijincheng@iscas.ac.cn;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions