Compiling Linux Kernel

Follow the following steps to compile Linux Kernel for VisionFive.

  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
  3. Type the following to set the default configuration settings for compiling Linux Kernel.
    cd linux
    make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv visionfive_defconfig 
    
  4. Type the following to set additional configuration settings for compiling Linux Kernel.
    make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv menuconfig
  5. 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
    compile_the_linux_kernel.png
    The Image.gz and .dtb files will be used later in this guide when we try to move rootfs, dtb and kernel to VisionFive. Different boards use different dtb files, and for the detailed information, refer to the dtb Files table in StarFive 40-Pin GPIO Header User Guide.