building kernel for scaleway riscv

scaleway-riscv scaleway-riscv-kernel scaleway-riscv-drbd scaleway-riscv-gfs2

warning // lessons learned

as of Dec 2024, the th1520-lichee-cluster-4a-16g.dts device tree is not available just yet for kernel 6.6.66 in the th1520-lts default branch, but it is still available and unsupported on older code bases e.g. branches th1520-master (6.8) and th1520-mainline (6.9).

however the advice from RevyOS on Telegram is to stay in the the supported and default branch whie using the lpi4a device tree and ignore the alike following error messages.

    [23051.895185] mmc2: Got command interrupt 0x00000001 even though no command operation was in progress.
    [23051.904355] mmc2: sdhci: ============ SDHCI REGISTER DUMP ===========
    ...

building node sysprep

apt install \
    build-essential flex bison libssl-dev bc libelf-dev libncurses-dev \
    autoconf \
    curl \
    file \
    git \
    htop \
    ifupdown \
    manpages man-db \
    net-tools \
    plocate \
    screen \
    wget \
    u-boot-tools device-tree-compiler \
    xz-utils

# ifupdown-ng ifupdown-ng-compat \
# dwarves pahole

kernel build

git clone --depth=1 https://github.com/revyos/th1520-linux-kernel.git
cd th1520-linux-kernel/

we stay in the default branch

git branch # th1520-lts
head -5 Makefile # 6.6.73 as of Feb 2025

we are going to use the ‘pi’ dts instead of the ‘cluster’ one, as it is not available yet for this newer code base (which are still there on older th1520-master and th1520-mainline branches, as of Feb 2025)

# https://github.com/revyos/th1520-linux-kernel/tree/th1520-lts/arch/riscv/boot/dts/thead/
# https://github.com/revyos/th1520-linux-kernel/tree/th1520-master/arch/riscv/boot/dts/thead/
# https://github.com/revyos/th1520-linux-kernel/tree/th1520-mainline/arch/riscv/boot/dts/thead/
ls -lhF arch/riscv/boot/dts/thead/*16g*

tune the kernel for our purpose

make revyos_defconfig
cat >> .config <<EOF
CONFIG_OCFS2_FS=m
CONFIG_GFS2_FS=m
CONFIG_GFS2_FS_LOCKING_DLM=y
CONFIG_DLM=m
CONFIG_DEBUG_INFO_BTF=n
EOF
make olddefconfig
for kconf in CONFIG_OCFS2_FS CONFIG_GFS2_FS CONFIG_GFS2_FS_LOCKING_DLM CONFIG_DLM CONFIG_DEBUG_INFO_BTF; do
    grep -E "^$kconf=|^# $kconf is not set" .config || echo $kconf FAIL
done; unset kconf
screen -ls
screen -S build

grep ^proc /proc/cpuinfo
time make -j4 > ../th1520-lts.log && echo KERNEL BUILT

# th1520-lts 238m9.809s @5.10.113-scw1
# th1520-lts 224m50.147s @6.9.0-rc3+

make modules_install >/dev/null && echo MODULES INSTALLED
cd ../

git clone https://github.com/revyos/thead-opensbi.git
cd thead-opensbi/
time make PLATFORM=generic -j4 > ../thead-opensbi.log && echo BUILT
cd ../

ln -s th1520-linux-kernel linux
ln -s thead-opensbi opensbi

git clone https://github.com/scaleway/em-rv1.git
cd em-rv1/fit/

ls -lhF ../../linux/arch/riscv/boot/dts/thead/*16g*
vi em-rv1-c4m16s128-a-boot.its

    fdt {
    ...
        data = /incbin/("../../linux/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a-16g.dtb");
        // data = /incbin/("../../linux/arch/riscv/boot/dts/thead/th1520-lichee-cluster-4a-16g.dtb");

build the FIT

mv /boot/boot.itb /boot/boot.itb.bak
mkimage -f em-rv1-c4m16s128-a-boot.its /boot/boot.itb

check you’ve got the right kernel within

sha256sum ../../linux/arch/riscv/boot/Image

and reboot

reboot

drbd & gfs2

see scaleway-riscv-drbd

see scaleway-riscv-gfs2

troubleshooting

kernel build

    FAILED: load BTF from vmlinux: Invalid argument

==> CONFIG_DEBUG_INFO_BTF=n – no pahole required

em-rv1-c4m16s128-a.dts:3:10: fatal error: th1520-lichee-cluster-4a-16g.dts: No such file or directory
    3 | #include "th1520-lichee-cluster-4a-16g.dts"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

==> vanilla 5.10 or 5.16 won’t do, use RevyOS th1520 kernel source instead

resources

https://github.com/scaleway/docs-content/blob/main/pages/elastic-metal/reference-content/elastic-metal-rv1-guidelines.mdx https://www.scaleway.com/en/docs/bare-metal/elastic-metal/reference-content/elastic-metal-rv1-guidelines/

https://github.com/scaleway/kernel-tools

https://stackoverflow.com/questions/60458452/how-can-i-list-all-remote-existing-branches-in-git

pull requests

fix(riscv): fix path to device tree #2 https://github.com/scaleway/em-rv1/pull/2

fix(riscv): xz-utils required #4151 https://github.com/scaleway/docs-content/pull/4151


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun