0%

uboot 运行 baremental bin

注意: 下面的操作步骤, 开发板不要插 sd 卡

配置tftpd

1
2
3
4
5
6
7
8
9
10
sudo apt install tftpd-hpa
sudo vi /etc/default/tftpd-hpa #编辑 /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftp"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="-s"

sudo chmod 777 -R /srv/tftp

配置完后, tftp 使用的目录为 /srv/tftp

下载 https://cloud.hexintek.com:10003/d/f/731200443442580601 visionfive2_fw_payload.img 拷贝到该文件夹中

1
sudo cp visionfive2_fw_payload.img /srv/tftp

本机测试

1
2
tftp localhost
> get visionfive2_fw_payload.img

无错误代表没问题

配置toolchain

https://cloud.hexintek.com:10003/d/f/731199345990354997 下载 riscv64-elf-x86_64-20210120.tar.gz

1
2
3
mkdir riscv64-unknown-elf-toolchain
cd riscv64-unknown-elf-toolchain
tar -xzvf <riscv64-elf-x86_64-20210120.tar.gz所在路径> -o .

将该路径加到环境变量
vi ~/.bashrc
末尾加入

1
export PATH=$PATH:<riscv64-unknown-elf-toolchain的路径>

最后

1
source ~/.bashrc

开发板 u-boot tftp 下载

1
StarFive # setenv ipaddr 192.168.xx.xx;setenv serverip 192.168.xx.xx

serverip 为 tftpd 即刚才配置好 tftpd 的pc的ip
ipaddr 为 开发板的 ip

更新U-Boot二进制文件

1
2
3
StarFive # tftpboot 0xa0000000 ${serverip}:visionfive2_fw_payload.img
StarFive # sf probe
StarFive # sf update 0xa0000000 0x100000 $filesize

开发板断电重启

baremental demo 编译运行

下载demo项目 riscv64_bamental_demo.zip https://cloud.hexintek.com:10003/d/f/731199428230170761 解压
将代码加入到该项目下, 编辑下Makefile

1
2
make clean
make -j4

最终生成bin/image.bin

将image.bin 拷贝到 刚才配置好tftpd的pc的 /srv/tftp

开发板下载 image.bin 到 0x44000000地址

1
StarFive # tftpboot 0x44000000 ${serverip}:image.bin

0x44000000地址 位置运行bin

1
StarFive # bootr 0x44000000

正常的话应该能看到log
info() 打印的log.

1
2
3
4
5
6
7
8
9
10
11
TFTP from server 192.168.18.55; our IP address is 192.168.18.24
Filename 'image.bin'.
Load address: 0x44000000
Loading: #
2.9 MiB/s
done
Bytes transferred = 6016 (1780 hex)
StarFive # bootr 0x44000000
call begin 0000000044000000
Hello world!
sizeof long 8