Adding New File

To add new file, perform the following steps:

Note: If there is no update, no need to add the new file.
  1. Insert the micro-SD card to the PC with Ubuntu system, and execute the following command to check the SD card partition:
    sudo fdisk -l
    Example Output:
    Device      Start     End Sectors  Size Type
    /dev/sdc1    4096    8191    4096    2M unknown
    /dev/sdc2    8192   16383    8192    4M unknown
    /dev/sdc3   16384  221183  204800  100M EFI System
    /dev/sdc4  221184 4503518 4282335    2G Linux filesystem
    

    In this output, the /dev/sdc3 partition is the SD card partition.

  2. Mount the SD card partition under the mnt file path by executing:
    sudo mount /dev/sdc3 /mnt
  3. Compile the file under the linux directory with the following command:
    make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv INSTALL_PATH=<ROOTFS_PATH> zinstall -<jx>
    Tip:
    • <ROOTFS_PATH>: This is a user-defined directory where the vmliunz files will be generated.
    • <jx>: It refers to the number of cores in your CPU. If your CPU has 8 cores, change this to -j8.
    Figure 1. Example Command and Output
    Result:

    vmliunz files will be generated under the ROOTFS_PATH.

  4. View the files generated under ${ROOTFS_PATH}. The following is an example:
    Figure 2. Example
  5. Add the new file:
    1. View the Micro-SD card information.
      df -h
      Figure 3. Example SD Card Information
    2. Copy the kernel file to the Micro-SD card. Please operate under the path of ${ROOTFS_PATH}.
      sudo cp vmlinuz-5.15.0 /media/<User_Name>/root/boot/ && sync
      Tip:

      <User_Name> is your username, for example, atlas.

    3. Copy the modules file to the Micro-SD card. Please operate under the path of linux/arch/riscv/boot/dts/starfive.
      sudo cp jh7110-visionfive-v2.dtb jh7110-visionfive-v2-A11.dtb jh7110-visionfive-v2-ac108.dtb jh7110-visionfive-v2-wm8960.dtb /media/<User_Name>/root/usr/lib/linux-image-5.15.0-starfive/starfive/ && sync
      Figure 4. dtb File List
  6. Perform the following step to update the extlinux.conf file:
    cd /mnt/extlinux
    sudo vim extlinux.conf
  7. Add the following command lines, save and exit:
    label <Label >
            menu label <Menu_Label> 
            linux /boot/<Newly_Complied_Kernel_file> 
            initrd /boot/initrd.img-5.15.0-starfive
            fdtdir /usr/lib/linux-image-5.15.0-starfive/
            append  root=/dev/mmcblk1p3 rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0
    
    Tip:

    In these commands:

    • <Label>: The label of startup item. For example, l1.
    • <Menu_Label>: The configuration name displayed on the menu. For example, myDebian_atlas GNU/Linux-5.15.0-starfive.
    • <Newly_Complied_Kernel_file>: The vmlinuz file name that is newly compiled in the previous steps. For example, vmlinuz-5.15.0 or Image.gz.

    Example: The following are the example commands:

    label l1
    menu label myDebian_atlas GNU/Linux-5.15.0-starfive
    linux /boot/vmlinuz-5.15.0
    initrd /boot/initrd.img-5.15.0-starfive
    fdtdir /usr/lib/linux-image-5.15.0-starfive/
    append  root=/dev/mmcblk1p3 rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0
    
  8. (Optional) Load different dtb files:
    1. Execute the following commands to edit uEnv.txt:
      cd /mnt
      sudo vim uEnv.txt
    2. Modify the fdtfile parameter, save and exit:
      fdtfile=starfive/<dtb_File_Name>
      Note:
      • <User_Name>: Your user name. For example, atlas.
      • <dtb_File_Name>: The dtb files are located in boot/usr/lib/linux-image-5.15.0-starfive/starfive/ as shown below:
        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.
        Figure 5. dtb File List
        Example:

        The following is the example of editing uEnv.txt to load the jh7110-visionfive-v2-wm8960.dtb:

        Figure 6. Example uEnv.txt Content
  9. Unmount the /mnt directory:
    sudo umount /mnt
Verification:

The following steps are provided to verify if the configuration is successful:

  1. Pull out the card from the PC and insert it into the VisionFive 2 board. The system will start normally after power-on.
  2. You can find the defined configuration item, for example, myDebian_atlas GNU/Linux-5.15.0-starfive, on the menu, as shown below:
    Figure 7. Example Interface

    Also, you can see the loaded dtb file, jh7110-visionfive-v2-wm8960.dtb on the startup interface.

    Figure 8. Startup Interface
  3. After the system starts successfully, you can see the version of the new vmlinuz file:

    root@starfive:~# cat /proc/version 
    Linux= version 5.15.0 (atlas@atlas-VirtualBox) (riscv64-linux-ginu-gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0, GNU ld (GNU Binutils for Ubuntu) 2.30) #1 SMP Mon Oct 31 15:12:31 CST 2022 
    root@starfive:~#