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