Updating SPL and U-Boot of Flash

To update SPL and U-Boot of flash for VisionFive 2 Lite, two methods are provided:

Note: For instructions to create SPL and fw_payload (U-Boot) files, refer to Creating SPL File and Creating fw_payload File sections in the VisionFive 2 Lite Single Board Computer Software Technical Reference Manual (Coming Soon).
  1. Through the tftpboot command as described in Through tftpboot Command (U-Boot).
  2. Through the flashcp command as described in Through flashcp Command (Linux Distribution).

Through tftpboot Command (U-Boot)

To update SPL and U-Boot through the tftpboot command, perform the following steps:
Note: Step 1-7 are performed on the host PC while Step 8-13 are performed on VisionFive 2 Lite.
  1. Connect one end of an Ethernet cable to the VisionFive 2 Lite RJ45 connector, and connect the other end of the cable to a router.
  2. Install a TFTP server on the host PC by executing:
    sudo apt-get update
    sudo apt install tftpd-hpa
  3. Check the server status:
    sudo systemctl status tftpd-hpa
  4. Execute the following to enter the TFTP server:
    sudo nano /etc/default/tftpd-hpa
  5. Configure the TFTP server as follows:
    TFTP_USERNAME="tftp"
    TFTP_DIRECTORY="/home/user/tftp"
    TFTP_ADDRESS=":69"
    TFTP_OPTIONS="-c -l -s"
    Note: TFTP_DIRECTORY refers to the directory to store bootloader, u-boot, SPL, image and so on.
  6. Create tftp-server folder to store the files:
    sudo mkdir -p /home/user/tftp
  7. Restart the TFTP server by executing:
    sudo systemctl restart tftpd-hpa
  8. Power on VisionFive 2 Lite and wait until it enters the U-Boot command line interface.
    Tip:
    • Prerequisite:
      • An USB to TTL (Transistor-Transistor Logic) converter. Connect the USB to the computer, and connect the Dupont cable to the correct extension pin of VisionFive 2 Lite. Please pay attention to the cross connection of TX and RX.
      • Install Putty or secureCRT on your PC.
    • When you power on the VisionFive 2 Lite, the serial port will print countdown, usually starting from 3. Hit any key to stop autoboot before the number decreases to 0, and you can enter the U-Boot command mode.
  9. Configure the environment variables by executing:
    setenv ipaddr 192.168.120.222;setenv serverip 192.168.120.99
    Note: Generally, the default IP of a router is 192.168.120.1. In this case, use the server IP as the IP assigned by the DHCP server of the router and use the VisionFive 2 Lite IP as 192.168.120.xxx. However, if your router IP is different (for example, 192.168.2.1 ), make sure the server IP and VisionFive 2 Lite IP are in the same IP domain (for example, 192.168.2.xxx).
  10. Check the connectivity by pinging the host PC from VisionFive 2 Lite.
    Example command:
    ping 192.168.120.99

    Result:

    The following output indicates that the host PC and VisionFive 2 Lite have established communication on the same network.
    StarFive # ping 192.168.120.99
    speed: 1000, full duplex
    Using dwmac.10020000 device
    host 192.168.120.99 is alive
  11. Initialize SPI Flash:
    sf probe
    Result:
    StarFive # sf probe
    SF: Detected gd25lq128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
  12. Update SPL binary, the following is the command and example output:
    StarFive # tftpboot 0xa0000000 ${serverip}:u-boot-spl.bin.normal.out
    Using ethernet@16030000 device
    TFTP from server 192.168.120.99; our IP address is 192.168.120.222
    Filename ‘u-boot-spl.bin.normal.out’.
    Load address: 0xa0000000
    Loading: ##########
    1.6 MiB/s
    done
    Bytes transferred = 132208 (20470 hex)
    
    StarFive # sf update 0xa0000000 0x0 $filesize
    device 0 offset 0x0, size 0x20470
    0 bytes written, 132208 bytes skipped in 0.23s, speed 5206961 B/s
  13. Update U-Boot binary, the following is the command and example output:
    StarFive # tftpboot 0xa0000000 ${serverip}:visionfive2_fw_payload.img
    Using ethernet@16030000 device
    TFTP from server 192.168.120.99; our IP address is 192.168.120.222
    Filename ‘visionfive2_fw_payload.img’.
    Load address: 0xa0000000
    Loading: #################################################################
    #################################################################
    #################################################################
    #######
    2.2 MiB/s
    done
    Bytes transferred = 2955397 (2d1885 hex)
    
    StarFive # sf update 0xa0000000 0x100000 $filesize
    device 0 offset 0x100000, size 0x2d1885
    0 bytes written, 2955397 bytes skipped in 0.507s, speed 5922361 B/s
    StarFive #

Through flashcp Command (Linux Distribution)

To update SPL and U-Boot through the flashcp command, perform the following steps:

  1. Install the mtd-utils package by executing the following command:
    apt install mtd-utils
  2. Transfer the latest u-boot-spl.bin.normal.out and visionfive2_fw_payload.img files to Debian or Ubuntu system through SCP.
  3. Execute the following command to check the MTD partition:
    cat /proc/mtd
    Example Output:

    You will see the partition information in the QSPI flash:

    dev: size erasesize name 
    mtd0: 000f0000 00001000 "spl"
    mtd1: 00010000 00001000 "uboot-env"
    mtd2: 00f00000 00001000 "uboot"
  4. Update the SPL and U-Boot binaries according to different partitions:
    • Example command to update SPL:
      flashcp -v u-boot-spl.bin.normal.out /dev/mtd0
    • Example command to update U-Boot:
      flashcp -v visionfive2_fw_payload.img  /dev/mtd2
    Example Command and Output:
    # flashcp -v u-boot-spl.bin.normal.out /dev/mtd0
    Erasing blocks: 36/36 (100%)
    Writing data: 143k/143k (100%)
    Verifying data: 143k/143k (100%)
    
    
    # flashcp -v visionfive2_fw_payload.img  /dev/mtd2
    Erasing blocks: 736/736 (100%)
    Writing data: 2943k/2943k (100%)
    Verifying data: 2943k/2943k (100%)
  5. Restart the system to make the updates take effect.