VisionFive2:Tips

Jump to: navigation, search

Tips and Tricks for the VisionFive 2 board.

Upstream firmware construction

FW boot sequence:

  • BootROM -> u-boot SPL -> openSBI (PLATFORM: generic) -> u-boot (as openSBI FW_PAYLOAD)

Example

#!/bin/bash                                                                     
# opensbi compile
git clone https://github.com/riscv-software-src/opensbi.git
cd opensbi                                                            

make CROSS_COMPILE=riscv64-suse-linux- PLATFORM=generic

cd ..
                                                                                   
# u-boot compile                                                                   
git clone https://github.com/openSUSE/u-boot.git
cd u-boot

git checkout <tumbleweed-latest.YEAR-latest.MONTH>
make CROSS_COMPILE=riscv64-suse-linux- starfive_visionfive2_defconfig
make CROSS_COMPILE=riscv64-suse-linux- OPENSBI=../opensbi/build/platform/generic/firmware/fw_dynamic.bin
                                                                                   

Firmware update to QSPI flash via u-boot

  • Select the boot mode switch to RGPIO_0 = 0'b, RGPIO_1 = 0'b. (1-bit QSPI Nor Flash)
  • Copy u-boot-spl.bin.normal.out and u-boot.itb to your tftp server.
  • set the u-boot IP and the tftp server IP, for example:
setenv ipaddr 192.168.120.222; setenv serverip 192.168.120.99
  • Run the following u-boot commands:
#SPI flash probe
sf probe
# Download and flash the u-boot SPL
tftpboot 0xa0000000 ${serverip}:u-boot-spl.bin.normal.out
sf update 0xa0000000 0x0 $filesize
# Download and flash opensbi+u-boot-payload
tftpboot 0xa0000000 ${serverip}:u-boot.itb
sf update 0xa0000000 0x100000 $filesize
  • Board reset

Firmware update via StarFive image

Boot the StarFive image and then flash firmware blobs through MTD devices. First determine the mtd target devices via

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00080000 00001000 "spl"
mtd1: 00010000 00001000 "uboot-env"
mtd2: 00400000 00001000 "uboot"
mtd3: 00a00000 00001000 "reserved-data"

Then run

sudo flashcp -v u-boot-spl.bin.normal.out /dev/mtd0
sudo flashcp -v u-boot.itb /dev/mtd2

Firmware recovery tool

Troubleshooting

payload won't fit into /dev/mtd1!

# flashcp -v visionfive2_fw_payload.img /dev/mtd1
visionfive2_fw_payload.img won't fit into /dev/mtd1!

Cause: You likely used the wrong mtd device. Check the mtd partition table:

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00080000 00001000 "spl"
mtd1: 00010000 00001000 "uboot-env"
mtd2: 00400000 00001000 "uboot"
mtd3: 00a00000 00001000 "reserved-data"

You need to use the spl and uboot partitions.

See also https://github.com/starfive-tech/VisionFive2/issues/73#issuecomment-1683560369

(depcrecated) Downstream firmware construction

u-boot

  • branch: JH7110_VisionFive2_devel
  • config: starfive_visionfive2_defconfig
    • Set CONFIG_DISTRO_DEFAULTS=y if you want to boot from the preload FDT.

opensbi

  • branch: master, platform=generic

tools

  • Required tools:
    • spl_tool/create_spl
    • uboot_its/visionfive2-uboot-fit-image.its

FW boot sequence:

  • BootROM -> u-boot SPL -> openSBI (PLATFORM: generic) -> u-boot (as openSBI FW_PAYLOAD)

Example

#!/bin/bash                                                                     
# u-boot compile                                                                   
make -C u-boot -j8 ARCH=riscv CROSS_COMPILE=riscv64-suse-linux-                    
                                                                                   
# opensbi compile                                                                   
make -C opensbi ARCH=riscv CROSS_COMPILE=riscv64-suse-linux- \                     
  PLATFORM=generic FW_PAYLOAD_PATH=../u-boot/u-boot.bin \                          
  FW_FDT_PATH=../u-boot/arch/riscv/dts/starfive_visionfive2.dtb FW_TEXT_START=0x40000000
                                                                                   
# spl                                                                              
cd tools/spl_tool                                                                  
./create_sbl ../../u-boot/spl/u-boot-spl.bin 0x01010101                            
cd ../..                                                                           
                                                                                   
# u-boot payload                                                                   
cd tools/uboot_its                                                                 
cp ../../opensbi/build/platform/generic/firmware/fw_payload.bin .                  
../../u-boot/tools/mkimage -f visionfive2-uboot-fit-image.its -A riscv -O u-boot \
  -T firmware visionfive2_fw_payload.img                                           
cd ../../                                                                          
                                                                                   
rm -rf build                                                                       
mkdir build                                                                                                                                                                
                                                                                   
cp tools/spl_tool/u-boot-spl.bin.normal.out build/                                 
cp tools/uboot_its/visionfive2_fw_payload.img build/

See also