Port rootfs, Kernel, and dtb into VisionFive 2

Port the rootfs, kernel, and dtb images into VisionFive 2 using either a micro-SD card or an Ethernet cable.

Preparation

Move the compiled rootfs, kernel, and dtb images into the same directory.

Figure 1. Example Interface

Port using Micro-SD Card

To port the rootfs, kernel, and dtb images into VisionFive 2 with a micro-SD card:
  1. Insert a micro-SD card to the host PC.
  2. Run the following ro obtain the location of the connected micro-SD card.
    lsblk
  3. Run the following to enter the partition configuration.
    sudo gdisk /dev/sdb
  4. Delete the original partition and create a new partition by entering the following subsequently.
    d--->o--->n--->w--->y
  5. Format the micro-SD card and create the file system.
    sudo mkfs.vfat /dev/sdb1
  6. Remove the micro-SD card from PC and plug again to mount it.
  7. Run the following to check whether it gets mounted.
    df -h
    You can see an output like the following. Take a note of the mount location.
  8. Navigate to the directory that contains the rootfs file system package, kernel, and dtb.
  9. Copy the files to the micro-SD card.
    sudo cp Image.gz <Mount_Location>
    sudo cp rootfs.cpio.gz <Mount_Location>
    sudo cp <dtb_File_Name> <Mount_Location>
    sync
    where,
    • <Mount_Location> is the location you noted down in 7.
    • <dtb_File_Name> is the device tree file name. For details about VisionFive 2 device tree files, see Load Specific Device Tree at Startup.
  10. Remove the micro-SD card from PC, insert into VisionFive 2, and turn it on.
  11. Open minicom while USB to Serial Adapter is connected between VisionFive 2 and PC, and wait until the board enters U-Boot mode. You can see the following output when it is in U-Boot mode.
  12. Run the following:
    setenv kernel_comp_addr_r 0xb0000000;setenv kernel_comp_size 0x10000000;
    fatls mmc 1:1
    fatload mmc 1:1 ${kernel_addr_r} Image.gz
    fatload mmc 1:1 ${fdt_addr_r} jh7110-visionfive-v2.dtb
    fatload mmc 1:1 ${ramdisk_addr_r} rootfs.cpio.gz
    run chipa_set_linux;
    booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
  13. Log in using the credentials: root/starfive.

Port using Ethernet Cable

To port the rootfs, kernel, and dtb images into VisionFive 2 with an Ethernet cable:
  1. Connect an Ethernet cable from the RJ45 port of VisionFive 2 to a router, connect serial adapter cable, and power on the board.
  2. Open minicom and wait until the board enters U-Boot mode. You can see the following output when it is in U-Boot mode.
  3. Run the following to set U-Boot environment variables.
    setenv serverip 192.168.125.142;setenv ipaddr 192.168.125.200;
    setenv hostname starfive;setenv netdev eth0;
    setenv kernel_comp_addr_r 0xb0000000;setenv kernel_comp_size 0x10000000; 
    setenv bootargs console=ttyS0,115200 earlycon=sbi root=/dev/ram0 stmmaceth=chain_mode:1 loglevel=8

    By default, the IP of a router is 192.168.120.1. In this case, the IP assigned by the DHCP server of the router is used as the server IP, and VisionFive 2 IP 192.168.120.xxx is used. If your router IP is different (for example, 192.168.2.1), the server and VisionFive 2 should follow the IP format of 192.168.2.xxx.

  4. Check the connectivity by pining the host PC from VisionFive 2. For example,
    ping 192.168.120.12
    If you see the output like the following, the communication between the host PC and VisionFive 2 is established on the same network.
  5. Install a TFTP server on the host PC.
    sudo apt-get update
    sudo apt install tftpd-hpa
  6. Check the status of the server.
    sudo systemctl status tftpd-hpa
  7. Run the following to enter the TFTP server configuration.
    sudo nano /etc/default/tftpd-hpa
  8. Configure the TFTP server.
    TFTP_USERNAME="tftp"
    TFTP_DIRECTORY="/home/user/Desktop/compiled"
    TFTP_ADDRESS=":69"
    TFTP_OPTIONS="--secure"
    where, TFTP_DIRECTORY is the directory where rootfs file system package, kernel and dtb images are stored.
  9. Restart the TFTP server.
    sudo systemctl restart tftpd-hpa
  10. Type the following inside the U-Boot mode of VisionFive 2 to download the files from the TFTP server of the host PC and start the kernel.
    tftpboot ${fdt_addr_r} <dtb_File_Name>;
    tftpboot ${kernel_addr_r} Image.gz;tftpboot ${ramdisk_addr_r} rootfs.cpio.gz;
    run chipa_set_linux;
    booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
    For example,
    tftpboot ${fdt_addr_r} jh7110-visionfive-v2.dtb;
    tftpboot ${kernel_addr_r} Image.gz;
    tftpboot ${ramdisk_addr_r} rootfs.cpio.gz;
    run chipa_set_linux;
    booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
  11. Log in with the credentials: root/starfive.