2 Star 13 Fork 5

Samuel Yuan / riscv-openeuler-visionfive

Create your Gitee Account
Explore and code with more than 8 million developers,Free private repositories !:)
Sign up
Clone or Download
Prepare-firmware-for-visionfive.md 3.25 KB
Copy Edit Web IDE Raw Blame History

操作手册:Prepare firmware for visionfive


1 准备工作

在Ubuntu上安装工具链。

sudo apt install gcc-riscv64-linux-gnu

查看工具链,例如这里使用的gcc版本为9.4.0。

riscv64-linux-gnu-gcc -v

2 编译bootloader

2.1 bootloader源码

下载bootloader源码

git clone https://github.com/starfive-tech/JH7100_secondBoot.git

2.2 编译

cd JH7100_secondBoot/build
make

得到bootloader-JH7100-220211.bin.out

3 编译ddrinit

3.1 ddrinit源码

git clone https://github.com/starfive-tech/JH7100_ddrinit.git

3.2 编译

cd JH7100_ddrinit/build
make

得到ddrinit-2133-220211.bin.out

4 编译u-boot

4.1 u-boot源码

下载u-boot源码。

git clone https://github.com/starfive-tech/u-boot
cd u-boot
git checkout -b JH7100_upstream origin/JH7100_upstream
git pull

确认配置为从micro sd启动。

u-boot/configs/ starfive_jh7100_visionfive_smode_defconfig:35:CONFIG_PREBOOT ="run mmcbootenv"

修改代码(本文提供已完成修改的代码)

u-boot/include/configs/starfive-jh7100.h

4.2 编译

make starfive_jh7100_visionfive_smode_defconfig ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu-
make u-boot.bin u-boot.dtb ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu-

u-boot.dtbu-boot.bin将被用于编译OpenSBI。

5 编译OpenSBI

5.1 OpenSBI源码

下载OpenSBI源码。

git clone https://github.com/riscv/opensbi.git

5.2 编译

make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- PLATFORM=generic FW_PAYLOAD_PATH=/home/riscv/riscv64-linux/u-boot/u-boot.bin FW_FDT_PATH=/home/riscv/riscv64-linux/u-boot/u-boot.dtb

进入fw_payload.bin所在目录,查看fw_payload.bin

cd opensbi/build/platform/generic/firmware

事先在工作目录中新建payload目录,将这里的fw_payload.bin拷贝进去。

cp fw_payload.bin /home/riscv/riscv64-linux/payload/

进入payload目录,编辑批处理程序fsz.sh

#!/bin/bash

function handle_file {
 inFile=$1
 echo inFile: $inFile
 outFile=$inFile.out

 inSize=`stat -c "%s" $inFile`
 inSize32HexBe=`printf "%08x\n" $inSize`
 inSize32HexLe=${inSize32HexBe:6:2}${inSize32HexBe:4:2}${inSize32HexBe:2:2}${inSize32HexBe:0:2}
 echo "inSize: $inSize (0x$inSize32HexBe, LE:0x$inSize32HexLe)"

 echo $inSize32HexLe | xxd -r -ps > $outFile
 cat $inFile >> $outFile
 echo outFile: $outFile

 outSize=`stat -c "%s" $outFile`
 outSize32HexBe=`printf "%08x\n" $outSize`
 echo "outSize: $outSize (0x$outSize32HexBe)"
}

if [ "$1" = "" -o "$1" = "--help" ]; then
 echo "Add file size(32bits, Little Endian) before the content."
 echo "Usage: ./fsz.sh <file>"
 exit 1
fi

handle_file "$@"

给执行权限

chmod 777 fsz.sh

将fw_payload.bin转换为fw_payload.bin.out

./fsz.sh fw_payload.bin fw_payload.bin.out

得到fw_payload.bin.out

4 安装Firmware到板载Flash中

参考《操作手册:Build openeuler on visionfive》,安装bootloader ddrinit u-boot。

Comment ( 0 )

Sign in to post a comment

Shell
1
https://gitee.com/samuel_yuan/riscv-openeuler-visionfive.git
git@gitee.com:samuel_yuan/riscv-openeuler-visionfive.git
samuel_yuan
riscv-openeuler-visionfive
riscv-openeuler-visionfive
master

Search