Compiling Linux Kernel

Follow the following steps to compile Linux Kernel for VisionFive 2.

  1. Locate to your desired directory to store the Linux Kernel files. For example, the home directory.

    Example:

    cd ~ # home directory
  2. Download the source code for Linux Kernel.
    git clone https://github.com/starfive-tech/linux.git
  3. Switch to the code branch by executing the following commands:
    cd linux
    git checkout -b JH7110_VisionFive2_devel origin/JH7110_VisionFive2_devel
    git pull
    
  4. Type the following to set the default configuration settings for compiling Linux Kernel.
    make <Configuration_File> CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv
    Tip: <Configuration_File>: For VisionFive 2, the file is starfive_visionfive2_defconfig.
  5. Type the following to set additional configuration settings for compiling Linux Kernel.
    make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv menuconfig
  6. Compile the Linux Kernel.
    make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv -jx
    Note: Here you need to change the -jx value according to the number of cores in your CPU. If your CPU has 8 cores, change this to -j8. This process will take some time and therefore please wait patiently.
    Result:
    The kernel image will be generated inside the directory linux/arch/riscv/boot as Image.gz.
    Figure 1. Example Output
    The dtb files will be generated inside the directory linux/arch/riscv/boot/dts/starfive
    Figure 2. Generated dtb Files
    The Image.gz and .dtb files will be used later in this guide when we try to move rootfs, dtb and kernel to VisionFive 2.
    Different boards use different dtb files:
    • jh7110-visionfive-v2.dtb: for Version 1.2A and 1.3B board.
    • jh7110-visionfive-v2-ac108.dtb: for version 1.2A and 1.3B board with ac108 codec.
    • jh7110-visionfive-wm8960.dtb: for Version 1.2A and 1.3B board with wm8960 codec.
    Tip: You can refer to the silk print on the board for version information.