How to compile and install kernel?

Hello,
How can I compile and install the linux 6.6.21-9-premier kernel which comes with https://github.com/sifive/hifive-premier-p550-ubuntu/releases/download/2024.11.00/ubuntu-24.04-preinstalled-server-riscv64.img.xz?
And is there a plan to upgrage the version to linux-6.8 which ships with the official ubuntu-24.04 LTS? Thanks!

There’s more than one way to skin this cat, but I like to build .deb packages. They make for easy installation and removal.

Ubuntu uses a custom location for the device tree. The .deb build needs to be patched for this. The patch can be downloaded here (w6rz.net is my personal website):

wget https://www.w6rz.net/0001-xxx.patch

Here’s the steps for a native build.

git clone https://github.com/sifive/riscv-linux.git

cd riscv-linux

git checkout rel/kernel/hifive-premier-p550

patch -p1 < ../0001-xxx.patch

cp /boot/config-6.6.21-9-premier ./.config

make ARCH=riscv LOCALVERSION= olddefconfig

make ARCH=riscv LOCALVERSION= -j4

make ARCH=riscv INSTALL_MOD_STRIP=1 LOCALVERSION= -j4 bindeb-pkg

cd ..

Then install the new kernel.

sudo dpkg -i linux-image-6.6.21_6.6.21-g022315aa62e5-2_riscv64.deb

sudo dpkg -i linux-headers-6.6.21_6.6.21-g022315aa62e5-2_riscv64.deb

Reboot and select the new kernel in grub.

To remove the kernel.

sudo apt-get purge linux-image-6.6.21 linux-headers-6.6.21

1 Like

Thanks for the reply! I will give it a try. BTW: How long does it take to build kernel on this p550 board?

A little less than 3 hours. They’ve stripped down this kernel from what’s shipped with Unmatched or the other boards like VisionFive 2.

Hi @fyang,

The source code for version “6.6.21-9-premier” is available on the GitHub release branch:
Commits · sifive/riscv-linux · GitHub

To use it:

  1. Download the source from the above link.
  2. Compile the kernel following the manual build steps.
  3. Copy the compiled kernel image and DTBs to the /boot/ directory on the board.
  4. Either replace the existing kernel images or update the GRUB configuration to reflect the new image path.

Currently, there are no plans to upgrade to Linux 6.8, as Linux 6.6 is designated as an LTS (Long-Term Support) version.

1 Like

Yes, 6.8 would not make much sense since either 6.12 or 6.13 is expected to be made the new LTS within a couple of weeks, so better to wait for that.
In the meantime a more recent 6.6 version than .21 could be nice though.
What is the current upstreaming situation? The riscv-linux repo contains over 100 patches to the upstreams sources, which is a rather large patchset with a significant maintenance burden to bring forward to new upstreams releases…

Linux 6.12 was made the new LTS back on December 5.

https://www.kernel.org/category/releases.html

https://git.kernel.org/pub/scm/docs/kernel/website.git/commit/?id=72a3f4b37ec3bbc05668ee62973e1e608e370ebb

Ah, they announced it early this year. Nice.

In the meantime, I ported the current patchset forward to 6.6.66:
https://mc.pp.se/p550_kernel_patches_6.6.66.tar.xz
Three of the 117 patches were already upstreams on the 6.6 branch. There were two minor conflicts, and one case of a kernel API function being renamed. But no big issues. I haven’t tested to apply the patchset to 6.6.67 or 6.6.68, but there’s a good chance it will still work.
Caveat emptor: I don’t build debs of my kernels (I run Gentoo on the P550), so I don’t know if anything in the debian/ dir needs updating.

Compared to the SpacemiT K1, 100 patches is small. This repo has over 1100 patches for Linux 6.13-rc5!

PS: Your kernel build steps works for me. Thanks!

BTW: I witnessed quite some warnings when building the kernel. Not sure what’s going on and whether this will affect basic functionality.

    ......

  NM      System.map
  CC [M]  crypto/rmd160.mod.o
  CC [M]  crypto/sm3.mod.o
  CC [M]  crypto/sm3_generic.mod.o
  CC [M]  crypto/streebog_generic.mod.o
  CC [M]  crypto/wp512.mod.o
  CC [M]  crypto/blake2b_generic.mod.o
  SORTTAB vmlinux
  CC [M]  crypto/cfb.mod.o
  CHKREL  vmlinux
  CC [M]  crypto/pcbc.mod.o
  CC [M]  crypto/lrw.mod.o
  CC [M]  crypto/xctr.mod.o
  CC [M]  crypto/hctr2.mod.o
  CC [M]  crypto/keywrap.mod.o
WARNING: 24835 bad relocations
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*
0000000000000000 R_RISCV_NONE      *ABS*

    ......

You can ignore those warnings, they don’t cause any problems. They could be suppressed by adding R_RISCV_NONE here:

Just like it’s been done for PowerPC:

1 Like