当前位置:主页 > 查看内容

RISC-V ICE EVB 开发板 linux环境下烧写更新开发板镜像

发布时间:2021-08-06 00:00| 位朋友查看

简介:本文作者 泓铭 简介 ICE EVB 是基于平头哥 RISCV 架构的 C910 CPU 的 ICE 高性能 SoC 开发板。 ICE 是一款通用智能数字 SoC 芯片 主要集了一个双核RISCV 64位 C910 处理器 一个 GPU 和 DPU 单元。同时提供了高速接口以及通用外设接口 用于与主控设备间的数据……

本文作者 泓铭


简介

ICE EVB 是基于平头哥 RISCV 架构的 C910 CPU 的 ICE 高性能 SoC 开发板。


ICE 是一款通用智能数字 SoC 芯片 主要集了一个双核RISCV 64位 C910 处理器 一个 GPU 和 DPU 单元。同时提供了高速接口以及通用外设接口 用于与主控设备间的数据和命令交互。

内嵌平头哥双核 C910 1.2GHz支持 DDR4 up to 2400Mbps支持 GMAC 接口支持 GPU 支持 3D支持 RGB888 LCD 显示 最大支持 1080P

1.png


开发板烧写镜像方式

ICE EVB 开发板可以使用 Linux、安卓系统 拿到的开发板出厂会烧写默认系统 当要更新或更换系统的时候 就需要进行镜像的烧写。


烧写开发板系统 大致分为以下三种情况

板载系统正常 升级内核镜像、rootfs 镜像板载系统正常 只更新内核、或更改设备树配置开发板无法启动 烧写 u-boot 镜像


通常情况下 开发者只需要烧写、更新内核和 rootfs 镜像。从 eMMC 启动的方式 u-boot 镜像使用 eMMC 的 Boot Area Partition 一般情况不会被内核镜像和文件系统的用户数据破坏。


PC 环境准备

在 Linux 环境下烧写镜像、应用开发的时候 需要用到一些工具和依赖环境 推荐开发者使用 ubuntu18.04 或 ubuntu20.04 环境开发。本文档以 ubuntu 18.04 环境为例说明。


安装工具
sudo apt-get update
# 安装通用工具
sudo apt-get install git gzip unzip wget
# 串口工具可以使用 minicom 或 picocom
sudo apt-get install minicom
sudo apt-get install picocom
# 安装 python3 环境
sudo apt-get install python3 python3-pip
# 安装 fastboot
sudo apt-get install fastboot
# 或者从官网下载二进制文件 
# 下载地址 https://developer.android.google.cn/studio/releases/platform-tools


安装 thead-tools
通过 pip 命令来安装 thead-tools 到你的系统中 thead-tools 支持 python2.7 、python3.6 。
sudo pip install thead-tools
# 如果使用官方地址下载过慢 可使用国内清华镜像源加速
sudo pip install -i https://pypi.tuna.tsinghua.edu.cn/simple thead-tools


通过 thead-tools 命令可以烧写 u-boot 镜像 通过命令 thead cct --help 查使用说明
root linux thead cct --help
Usage: thead cct uart|list|download [param]
Options:
 -h, --help show this help message and exit
 -u UART CCT serial port device
 -f FILE
 -o OFFSET Device start address
 -b BLOCK, --block BLOCK
 -d DEVICE, --device DEVICE
 Device name
 -c, --compress
 -D, --debug Enable debbug trace info


镜像介绍

访问 https://gitee.com/thead-linux/ice_images/ 软件仓库可以下载最新镜像 也可直接使用下面命令行下载 Linux SDK 镜像文件

wget https://gitee.com/thead-linux/ice_images/repository/archive/master?format zip -O ice_images.zip
unzip ice_images.zip
cd ice_images
ls -l
-rw-r--r-- 1 thead users 11558 Feb 25 11:39 LICENSE
-rw-r--r-- 1 thead users 1214 Feb 25 11:39 README.md
drwxr-xr-x 5 thead users 160 Feb 25 11:39 boot
-rw-r--r-- 1 thead users 20971520 Feb 25 11:39 boot.ext4
-rw-r--r-- 1 thead users 167772160 Feb 25 11:39 debian-rootfs.ext4
-rw-r--r-- 1 thead users 18652 Feb 25 11:39 ice_ck910_imgwriter_asci_v5.bin
-rw-r--r-- 1 thead users 562536 Feb 25 11:39 u-boot-with-spl.bin


需要用到的是如下三个文件

u-boot-with-spl.bin u-boot 引导镜像文件
boot.ext4 /boot 分区文件系统 ext4格式 包含 fw_jump.bin、uImage、hw.dtb
debian-rootfs.ext4 Debian 基础根文件系统镜像 ext4 格式
boot/ boot.ext4 镜像中的文件 直接更新内核、dtb 时候可以使用
烧写 boot 分区镜像

1.按照如下系统连接图连接好开发板

2.png

※ USB转TTL 串口设备使用常用的 PL2303*、CH340*、CP2102* 等均可。


2.启动串口工具minicom 或 picocom

minicom
minicom -c on -b 115200 -D /dev/ttyUSB0
# 如无法启动 minicom 可以加上 sudo 执行或设置用户组权限。

※ 退出 minicom CRTL A、X


-c on 打开颜色显示-b 115200 ICE-EVB 串口控制台的默认波特率为 115200 bps-D 指令PC上与ICE-EVB 开发板连接的串口设备 使用时要注意串口设备是否正确


picocom
# 或使用 picocom
picocom -b 115200 -f n -r -l /dev/ttyUSB0

※ 退出 picocom CTRL A、CTRL X


3.开发板开机后进入 u-boot 当 Console 串口出下提示时 按任键即可进行命令模式。

Warning: ethernet 3fffc0000 (eth0) using random MAC address - a6:7d:bc:02:7d:4d
eth0: ethernet 3fffc0000
Hit any key to stop autoboot: 3 --- 出现此信息时按任意键进入u-boot


4.u-boot 环境配置
u-boot 配置命令列表如下 通过串口终端 在开发板上执行

# 恢复默认值
env default -a
# 配置 eMMC 分区
setenv uuid_rootfs 80a5a8e9-c744-491a-93c1-4f4194fd690b 
setenv partitions name table,size 2031KB 
setenv partitions $partitions;name boot,size 60MiB,type boot 
setenv partitions $partitions;name root,size -,type linux,uuid $uuid_rootfs 
gpt write mmc 0 $partitions
# 配置网络
# !!!!!!!!!!!!!!!!!!!! 特别注意 !!!!!!!!!!!!!!!!!!!!!!!!
# 如果网络中接入多块 ICE-EVB 开发板 每块开发板的 ethaddr 要唯一
setenv ethaddr 00:a0:a0:a0:a0:a1 # 如果网络中接入多块 ICE-EVB 开发板 ethaddr 要唯一
setenv ipaddr 192.168.1.100 # 开发板 IP 地址
setenv netmask 255.255.255.0
# ping 192.168.1.1 # ping 主机的IP 可检验网络是否正常
saveenv # 将配置保存到 eMMC, 下次启动时无需再配置
# 开启fastboot模式
fastboot udp

※ printenv 可查看 u-boot 环境变量


5.烧写 boot 分区
在 Linux 终端上使用 fastboot 命令完成镜像烧写 192.168.1.100 是开发板的运行 u-boot 时配置的 IP 地址 使用 fastboot 命令前确认电脑与开发板在同一个子网。在电脑的终端上执行

 fastboot -s udp:192.168.1.100 flash boot boot.ext4


6.调整分区空间
重启开发板进入系统 执行 resize2fs 命令调整分区空间

cd /boot
resize2fs /dev/mmcblk1p2
# 调整后分区
root thead-910:/boot# df -h
Filesystem Size Used Avail Use% Mounted on
... 省略 
/dev/mmcblk1p2 56M 14M 41M 25% /boot


烧写 rootfs 分区镜像1 ~ 4 与《烧写 boot 分区镜像》 一致。
5.烧写 rootfs 镜像
ICE-EVB 开发板提供三种根文件系统镜像 开发者可以根据自己的需要选择下载 镜像下载地址大小基本镜像(debian-base)http://mirrors.aliyun.com/thead/images/riscv64-ice/debian-rootfs.ext4.gz59MB开发镜像 (debian-dev)http://mirrors.aliyun.com/thead/images/riscv64-ice/debian-dev-rootfs.ext4.gz197MBxfce 桌面(debian-desktop)http://mirrors.aliyun.com/thead/images/riscv64-ice/debian-desktop-rootfs.ext4.gz517MB


选项一 烧写基本系统镜像
在下载的 ice_images 中默认提供 debian-rootfs.ext4 镜像 使用 fastboot 命令烧写

fastboot -s udp:192.168.1.100 -S 5M flash root debian-rootfs.ext4


选项二 烧写开发者镜像
需要另外下载 debian-dev-rootfs.ext4 镜像 再用 fastboot 命令烧写

wget http://mirrors.aliyun.com/thead/images/riscv64-ice/debian-dev-rootfs.ext4.gz 
gzip -d debian-dev-rootfs.ext4.gz
fastboot -s udp:192.168.1.100 -S 5M flash root debian-dev-rootfs.ext4


选项三 烧写 xFce 桌面系统镜像
需要另外下载 debian-desktop-rootfs.ext4 镜像 再用 fastboot 命令烧写

wget http://mirrors.aliyun.com/thead/images/riscv64-ice/debian-desktop-rootfs.ext4.gz 
gzip -d debian-desktop-rootfs.ext4.gz
fastboot -s udp:192.168.1.100 -S 5M flash root debian-desktop-rootfs.ext4


6.调整分区空间
重启开发板进入系统 执行 resize2fs 命令调整分区空间

resize2fs /dev/mmcblk1p3
# 调整后分区
root thead-910:/boot# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 3.6G 421M 3.0G 13% /
... 省略 


更新内核、dtb 配置

如果只更新内核、更改设备树配置 可以直接对操作 /boot ?下文件进行更新。


1.确保开发板正确联网 在开发板 Console 执行 ifconfig 查看开发板 IP 地址

root thead-910:~# ifconfig
eth0: flags 4163 UP,BROADCAST,RUNNING,MULTICAST mtu 1500
 inet 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.1
 inet6 fe80::2a0:a0ff:fea0:a0a1 prefixlen 64 scopeid 0x20 link 
 ether 00:a0:a0:a0:a0:a1 txqueuelen 1000 (Ethernet)
 RX packets 48 bytes 12429 (12.1 KiB)
 RX errors 0 dropped 0 overruns 0 frame 0
 TX packets 50 bytes 7348 (7.1 KiB)
 TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
 device interrupt 7 base 0xa000
lo: flags 73 UP,LOOPBACK,RUNNING mtu 65536
 inet 127.0.0.1 netmask 255.0.0.0
 inet6 ::1 prefixlen 128 scopeid 0x10 host 
 loop txqueuelen 1000 (Local Loopback)
 RX packets 0 bytes 0 (0.0 B)
 RX errors 0 dropped 0 overruns 0 frame 0
 TX packets 0 bytes 0 (0.0 B)
 TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

※ 配置开发板 IP 地址 可执行 dhclient 自动获取 IP 地址 或对 ?/etc/network/interfaces 进行配置。


2.确保开发板上已经配置好登录密码或已经上传公钥

# 更改密码
root thead-910:~# passwd
New password:
Retype new password:
passwd: password updated successfully


3.scp 上传 uImage 文件 在 PC 上操作

 scp uImage root 192.168.1.100:/boot/.

※ 注意 如果上传内核镜像文件错误 会造成系统无法启动 此时需要参考上面步骤 重新烧写 boot 分区镜像文件。


4.更改设备树 dtb 配置

# 安装 dtc 工具
apt update
apt install device-tree-compiler
# 修改设备树配置
cd /boot
dtc -I dtb -O dts hw.dtb hw.dts
# 使用 vi 或其他 editor 修改 hw.dts 配置
# 修改后生成新的 dtb
dtc -I dts -O dtb hw.dts hw.dtb
sync


5.开发板重启

root thead-910:~# sync
root thead-910:~# reboot


烧写 u-boot 镜像

当开发板上 u-boot 镜像异常 造成无法启动 俗称“变砖”的时候 就需要通过串口 先将引导程序载入到内存 正常引导后 再将固件镜像烧写到 eMMC 上。通过使用 python 环境下的 thead 命令可自动完成以上操作 将 u-boot 镜像烧写到 eMMC 的Boot Area Partition 分区。

按照如下CCT烧写连接图连接好开发板

3.png


查看系统环境和串口
通过 thead-tools 烧写 u-boot 时需要使用开发板的 CCT 烧写串口 通过命令thead cct uart 命令看到电脑上安装的串口列表 并确认电脑上串口与开发板串的对应关系
root linux thead cct uart
uart device list:
 /dev/ttyUSB0 - USB-Serial Controller

如果出现上面状态 说明 thead 工具安装正常 串口设备连接正常。


查找开发板存储器列表
通过命令 thead cct -u /dev/ttyUSB0 list 可以查看开发板支持的烧写存储器列表 如下
root linux thead cct -u /dev/ttyUSB0 list
Wait .....................
CCT Version: 2
memory device list:
 dev ram0 , size 256.0KB
 dev emmc0 , size 2.0MB
 dev emmc1 , size 2.0MB
 dev emmc2 , size 3.7GB

注意 使用该命令时 先确定串口的连接是否正确 运行命令前先关闭开发板电源后再运行该命令 等到出现Wait .......... 信息后再开启开发板电源。


如果未出现上述打印信息 先确认连线和开发板电源状态 同时电脑是接有多个串口 请更新另一个串口再次尝试。


烧写 u-boot
通过命令 thead cct -u /dev/ttyUSB0 download -f u-boot-with-spl.bin -d emmc0 将 u-boot 镜像烧写到 eMMC 的 Boot Area Partition 分区 烧写过程信息如下
CCT Version: 2
Send file u-boot-with-spl.bin to 21:0 ...
Writing at 0x00009800... (3%)

待打印 File u-boot-with-spl.bin download success. 后烧写成功。


启动登录 Linux 系统

完成 Linux 镜像烧写后 重新启动 ICE EVB 开发板 开发板 Console 串口显示如下

[ OK ] Started Serial Getty on hvc0.
[ OK ] Started Serial Getty on ttyS0.
[ OK ] Reached target Login Prompts.
[ OK ] Started System Logging Service.
[ OK ] Finished Remove Stale Onli…ext4 Metadata Check Snapshots.
[ OK ] Reached target Multi-User System.
[ OK ] Reached target Graphical Interface.
 Starting Update UTMP about System Runlevel Changes...
[ OK ] Finished Update UTMP about System Runlevel Changes.
Debian GNU/Linux bullseye/sid thead-910 ttyS0
thead-910 login: [ 94.362252] random: crng init done
[ 94.365674] random: 6 urandom warning(s) missed due to ratelimiting
thead-910 login:


登录用户名 root 初始无密码 开发者可根据需要更改密码。


本文转自网络,原文链接:https://developer.aliyun.com/article/786376
本站部分内容转载于网络,版权归原作者所有,转载之目的在于传播更多优秀技术内容,如有侵权请联系QQ/微信:153890879删除,谢谢!

推荐图文


随机推荐