How are the kernels made for the visionfive2, where did the source come from for 6.1.59?

I have a milkv mars, which is very similar to the visionfive2. Both have the same riscv jh7110 processor and the dietpi image for the visionfive2 will boot the milkv. I was excited to see the DietPi was using a modern kernel, 6.1.59. The official image and only supported kernel is only 5.15.0 which is two years old. I need to be able to compile a kernel for my own project and I would very much like to be able to run a modern kernel like 6.1.59. I copied the kernel config from the DietPi image and tried to build it using the vanilla sources from kernels.org. It did not work. I must be missing some patches or something else. I would very much like to use the method that dietpi uses but I’m unsure where the sources are coming from. I’m also unsure if the kernel sources need to be patched for the jh7110 processor. There is very little information available as far as kernel building for the visionfive2 and milkv mars. I have had some success building a working 5.15.0 using the source provided for the visionfive2, but alas I would like something newer. Thanks

Taspenwall

I think I made some progress. GitHub - MichaIng/linux is the repo for the kernels. I’m still having some trouble getting a kernel built that works. I’ve tried using the config from the dietpi image which is 6.1.59 but the repo has updated to 6.1.61 so I’ts not a perfect match but should be most the way there. There are a few defconfigs from the MichaIng repo but I’m not sure what I need to use. (I’m thinking dietpi-visionfive2-defconfig ) The dietpi config is really close to what I need, but I need to make deb packages for what I’m wanting to do. MIchaIng’s repo is a fork of the starfive visionfive2 repo. I’ve built kernels (5.15.0)from the starfive repo but I had to go back to commit when milkv forked it to get a working kernel. I havn’t used the milkv fork very much as they are rearranging thier github quite alot in the last few days and it’s still going to 5.15.0. Any advice on how to build a working kernel for the milkv mars out of the MichaIng repo would be helpful.

ping @MichaIng

I have tried to build the kernels using the MIchaIng/linux repo using both the config from the dietpi image and the dietpi_visionfive2_defconfig. Both throw issues with video and I don’t get any video out on HDMI. It also doesn’t boot and gets stuck. I’d be happy to post an error log if that would help. I hope the @michaing can shed some light on the kernel building process for the dietpi image. I really appreciate the effort that has been put into the kernel and keeping it up to date with the LTS kernel. It might be a issue that I’m using a Milkv Mars, and not a visionfive2, but the dietpi image works so … For now I’m kinda stuck.

So I made a mistake or a discovery depending how you look at it. I used one of my dietpi kernels I had compiled on the dietpi image, and it worked. However the dietpi kernel is not compatible with the image I was using to test kernels, so thats where my problem was. I guess now I will be studying kernel configs to try to a get a newer kernel to run on my milk-v.

Here is the workflow we use to build our kernel packages for the VisionFive 2: https://github.com/MichaIng/linux/blob/42030d76725644409fe8df520162356649d0706c/.github/workflows/visionfive2.yml

Here is the base directory for the package, which includes an extlinux template and some config files, including those required to U-Boot tools to flash a U-Boot environment, and the U-Boot environment required to boot our images: https://github.com/MichaIng/linux/tree/6.1-visionfive2/linux-image-visionfive2

The problem might be a different one, but the latest U-Boot sources from StarFive do not support anything else than Linux image/dtb/initramfs/extlinux on a partition 3 with FAT filesystem and the rootfs on partition 4. We provide our image with a single ext4 partition only, and for this, the U-Boot environment is required: https://github.com/MichaIng/linux/blob/42030d76725644409fe8df520162356649d0706c/linux-image-visionfive2/etc/u-boot-initial-env

Best is to attach a USB-UART adapter to check the serial console for the reason why it does not boot. If it really is the problematic default U-Boot environment only, then it is also simple to fix it within the U-Boot console, at first temporarily, and then permanently via mentioned tools from the booted image. Our environment supports booting form any boot media, any partition and any filesystem, so is universally compatible :slightly_smiling_face:.