Compile Kernel, Device Tree, and Driver Module

Follow the steps below to compile kernel, device tree, and driver module:
  1. Execute the following command to set the default configuration of compiling Linux kernel:
    make <Configuration_File> CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv
    Tip: <Configuration_File>: This file is starfive_visionfive2_defconfig on VisionFive 2.
  2. After setting up the software environment, execute the following command to compile the source code:
    $ make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv -j$(nproc)
  3. Execute the following command to create a directory for storing the generated kernel files:
    $ mkdir ../compiled
  4. Execute the following command to compile and generate files such as config, system.map, and vmlinuz to the specified path:
    $ make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv INSTALL_PATH=../compiled zinstall -j$(nproc)
    The following figure is an example output:
    Figure 1. Example Output
  5. Execute the following command to copy dtb files:
    $ cp arch/riscv/boot/dts/starfive/jh7110-visionfive-v2.dtb ../compiled
  6. (Optional) Execute the following command to compile and generate files to the specified path:
    $ make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- INSTALL_MOD_PATH=../compiled modules_install
    Note: If the new kernel does not involve changes to the driver module, it can be omitted and the default kernel's driver module will still be used.
    The following figure is an example output:
    Figure 2. Example Output
    Figure 3. Example Output
    Note: There is no link between build and source in the corresponding path of the Debian image. The corresponding item in the above figure can be deleted.