VisionFive2:技巧

跳转到:导航搜索

关于 VisionFive 2 开发板的技巧和窍门。

上游固件构建

FW 启动顺序

  • BootROM -> u-boot SPL -> openSBI (平台: generic) -> u-boot (作为 openSBI FW_PAYLOAD)

示例

#!/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
                                                                                   

通过 u-boot 将固件更新到 QSPI 闪存

  • 将启动模式开关设置为 RGPIO_0 = 0'b, RGPIO_1 = 0'b. (1-bit QSPI Nor Flash)
  • 将 u-boot-spl.bin.normal.out 和 u-boot.itb 复制到您的 tftp 服务器。
  • 设置 u-boot IP 和 tftp 服务器 IP,例如
setenv ipaddr 192.168.120.222; setenv serverip 192.168.120.99
  • 运行以下 u-boot 命令
#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
  • 板子复位

通过 StarFive 镜像更新固件

启动 StarFive 镜像,然后通过 MTD 设备刷新固件 blob。首先确定mtd目标设备通过

# 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"

然后运行

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

固件恢复工具

故障排除

payload 无法装入 /dev/mtd1!

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

原因:您可能使用了错误的 mtd 设备。检查 mtd 分区表

# 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"

您需要使用spluboot分区。

另请参阅 https://github.com/starfive-tech/VisionFive2/issues/73#issuecomment-1683560369

(已弃用) 下游固件构建

u-boot

  • 分支: JH7110_VisionFive2_devel
  • 配置: starfive_visionfive2_defconfig
    • 如果您想从预加载 FDT 启动,请设置 CONFIG_DISTRO_DEFAULTS=y。

opensbi

  • 分支: master, platform=generic

工具

  • 所需工具
    • spl_tool/create_spl
    • uboot_its/visionfive2-uboot-fit-image.its

FW 启动顺序

  • BootROM -> u-boot SPL -> openSBI (平台: generic) -> u-boot (作为 openSBI FW_PAYLOAD)

示例

#!/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/

参见