Can someone post a nice manual, how to compile a custom linux kernel for the Vision Five 2

The Debian User Guide for the Vision Five 2 gives only half a page of quite sparse content on how to compile ones own kernel. From that documentation alone I was not able to make my custom kernel. The information there seems to be quite incomplete. It would be nice if someone could give some references, help and links on how to compile a custom kernel for the Vision Five 2 and what drivers have to be supplied from the StarFive developer team.

Not a nice manual but at least all the steps are there including the out of tree kernel modules. This is what the Arch image is using.

1 Like

Not so helpful…

The information about the new RISC-V 64bit architecture in the linux kernel on the official kernel webpage:

https://www.kernel.org/doc/html/latest/riscv/index.html

1 Like

The Linux kernel building process is neither straightforward nor excessively challenging. Personally, I prefer building it natively in the VF2. Here, I provide a rough guideline rather than a comprehensive manual.

To begin:

  1. Obtain the latest release of the kernel source from the Starfive repository, for instance, https://github.com/starfive-tech/linux/archive/refs/tags/VF2_v3.6.1.tar.gz. Note that as of now, v3.7.5 has not been officially released. Extract the source to the directory /usr/src/kernels/.

  2. Utilize the /boot/config-5.15.0-starfive file from the Debian image as your baseline configuration:

    # cd /usr/src/kernels/<extracted kernel source>
    # cp /boot/config-5.15.0-starfive .config
    # make menuconfig
    
  3. At this stage, you may encounter certain errors, such as missing development tools or the absence of the ncurses library. However, I believe you can install these dependencies (although I am not an expert in Debian), allowing you to proceed with menuconfig.

  4. If you want to use nt_tables as I saw your other posts, then navigate to Networking support → Networking options → Network packet filtering framework (Netfilter) → Core Netfilter Configuration.

  5. Select “Netfilter nf_tables support” options as you see fit.

  6. Exit from menuconfig, and then perform the following steps:

    • make -j4 all
    • make modules_install
    • make dtbs_install
    • cp arch/riscv/boot/Image.gz to /boot/vmlinuz-your_kernel_version
    • update-initramfs -k your_kernel_version -u
    • cd /boot/dtbs # ← this step is crucial!
      • mkdir orig
      • mv sifive starfive orig
      • cp -a your_kernel_version/* .
  7. Edit the /boot/extlinux/extlinux.conf file and add a new menu entry for booting your kernel. You do not need to set it as the default boot option if you have USB-UART access and can use the serial console (which I highly recommend). This way, you can select, boot, and debug your kernel from the serial console.

  8. If everything functions as expected, revise the extlinux.conf file once more and set your kernel as the default boot option.

Feel free to seek further assistance if you encounter any challenges during this process.

3 Likes

I found the official documentation webpage for the StarFive Vision Five 2 Software, which explains how to deploy all the 14 assets of the Vision Five Software current version (VisionFive Software v3.7.5 Release) to get a working kernel and basic debian system at VisionFive 2 Single Board Computer Software Technical Reference Manual resp. VisionFive 2. It would be nice though to have a debian package for installing the respectively new kernel as it is quite tedious to reformat the SD card for every new kernel version especially, when one has already made the debian system comfortable for the previous version.

You don’t need to reformat the SD card if you switch to using a rolling release distro, such as Arch or Alpine edge. I’ve been running Arch on two of my VF2 boards (on NVMe) for the past eight months, and I haven’t had to reformat them since. I’ve provided multiple iterations of my Arch images, but for anyone familiar with Arch, they can simply grab new kernel packages and upgrade the existing one effortlessly.

As for Starfive’s Debian, I believe they offer a stable and functional version that can serve as a baseline for us developers. Keep in mind that these boards, including their predecessors, are development boards and not production-ready like the Raspberry Pi. In fact, my very first iteration of Arch was also built on Starfive’s Debian.

1 Like