本文作者 泓铭
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开发板烧写镜像方式ICE EVB 开发板可以使用 Linux、安卓系统 拿到的开发板出厂会烧写默认系统 当要更新或更换系统的时候 就需要进行镜像的烧写。
烧写开发板系统 大致分为以下三种情况
板载系统正常 升级内核镜像、rootfs 镜像板载系统正常 只更新内核、或更改设备树配置开发板无法启动 烧写 u-boot 镜像通常情况下 开发者只需要烧写、更新内核和 rootfs 镜像。从 eMMC 启动的方式 u-boot 镜像使用 eMMC 的 Boot Area Partition 一般情况不会被内核镜像和文件系统的用户数据破坏。
在 Windows 环境下烧写镜像、应用开发的时候 需要用到一些工具和依赖环境 推荐开发者使用 Windows 7 或 WIndows 10 环境开发。本文档以 Windows 10 环境为例说明。
下载、安装通用工具下载串口终端工具 PuTTY 或使用其他串口工具也可从官网下载 https://www.putty.org/ 根据实际电脑系统下载
32位版本 (https://the.earth.li/~sgtatham/putty/latest/w32/putty-0.74-installer.msi)
64位版本 (https://the.earth.li/~sgtatham/putty/latest/w64/putty-64bit-0.74-installer.msi)解压缩工具可下载 7-zip
https://www.7-zip.org/download.html
根据实际电脑系统下载 32位版本或 64位版本。下载 CCT_V0.95 工具 解压
https://yoc.docs.t-head.cn/tools/CCT_V0.95.zip
下载 fastboot 工具 解压
https://developer.android.google.cn/studio/releases/platform-tools
Python3 环境 (可选)
官网 https://www.python.org/downloads/
根据需要下载相应版本 推荐使用 3.x版本。
安装 pip (可选)
下载 https://bootstrap.pypa.io/get-pip.py
执行安装 python3 get-pip.py
安装 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?查使用说明
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
访问?http://mirrors.aliyun.com/thead/images/riscv64-ice/ice_images.zip?下载最新镜像并解压到电脑上 如?D:\?下
需要用到的是如下四个文件
ice_ck910_imgwriter_asci_v5.bin CCT 烧写 u-boot镜像工具u-boot-with-spl.bin uboot 引导镜像文件
boot.ext4 /boot 分区文件系统 ext4格式 包含 fw_jump.bin、uImage、hw.dtb
debian-rootfs.ext4 Debian 基础根文件系统镜像 ext4 格式
boot/ boot.ext4 镜像中的文件 直接更新内核、dtb 时候可以使用
1.按照如下系统连接图连接好开发板
2.串口终端工具配置
PuTTY是一款集成虚拟终端、系统控制台和网络文件传输为一体的自由及开放源代码的程序 它支持多种网络协议。
启动 PuTTY 进行串口参数设置。
按照实际电脑系统情况 在 Serial line 设置串口号 Speed 设为 115200。将 Flow control 设置为 None 注意 此步骤一定要设置正确 否则会造成串口终端无法输入。保存配置 下次启动直接在Saved Sessions 中点击相应配置即可连接。启动 PuTTY 串口终端。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 分区
在电脑上使用?fastboot?命令完成镜像烧写 192.168.1.100?是开发板的运行 u-boot 时配置的 IP 地址 使用?fastboot?命令前确认电脑与开发板在同一个子网。
为方便操作 可将?fastboot.exe、AdbWinApi.dll?两个文件拷贝到解压后的 ice_images 目录 启动 windows 的 cmd 终端 如解压到D盘 进入 D:\ice_images 目录 下载目录根据实际电脑目录填写
cd D:\ice_images fastboot.exe -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
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
解压 gz 文件 可下载安装开源数据压缩程序 7-Zip 根据实际电脑情况下载 32位 (https://www.7-zip.org/a/7z1900.exe) 或 64位 (https://www.7-zip.org/a/7z1900-x64.exe) 版本。
选项一 烧写基本系统镜像
在下载的 ice_images 中默认提供 debian-rootfs.ext4 镜像 使用 fastboot 命令烧写
fastboot.exe -s udp:192.168.1.100 -S 5M flash root debian-rootfs.ext4
选项二 烧写开发者镜像
下载文件并解压得到 debian-dev-rootfs.ext4 镜像 再用 fastboot 命令烧写
fastboot.exe -s udp:192.168.1.100 -S 5M flash root debian-dev-rootfs.ext4
选项三 烧写 xFce 桌面系统镜像
下载文件并解压得到 debian-desktop-rootfs.ext4 镜像 再用 fastboot 命令烧写
fastboot.exe -s udp:192.168.1.100 -S 5M flash root debian-desktop-rootfs.ext4
重启开发板进入系统 执行 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 ?下文件进行更新。
确保开发板正确联网 在开发板 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 进行配置。
# 更改密码 root thead-910:~# passwd New password: Retype new password: passwd: password updated successfully
scp uImage root 192.168.1.100:/boot/.
注意 如果上传内核镜像文件错误 会造成系统无法启动 此时需要参考上面步骤 重新烧写 boot 分区镜像文件。
# 安装 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
root thead-910:~# sync root thead-910:~# reboot
烧写 u-boot 镜像
当开发板上 u-boot 镜像异常 造成无法启动 俗称“变砖”的时候 就需要通过串口 先将引导程序载入到内存 正常引导后 再将固件镜像烧写到 eMMC 上。通过使用CCT 工具或 python 环境下的 thead 命令可自动完成以上操作 将 u-boot 镜像烧写到 eMMC 的Boot Area Partition 分区。
按照如下CCT烧写连接图连接好开发板
CCT 软件运行界面如下图所示 首先配置 CCT 的参数 其中
? Port 配置的是 CCT 烧写串口 根据实际电脑情况设置相应串口 Port
? Mem R.W Speed 是镜像传输协议速度 使用默认值
操作步骤
EVB 开发板上电 - 确认勾选 always 点击 Connect Device — 按 EVB 开发板上 系统复位键 复位开发板 出现 Connect device success. 即表示连接成功 进入下一步镜像烧写步骤
点击用户界面上的 Download 按钮 镜像就会开始自动下载与烧写。完成后 在完成之后 在用户界面的日志窗口中 将会出现 “Verify data success.” 的内容提示 表示镜像完成了烧写。
通过 thead-tools 烧写 u-boot 时需要使用开发板的 CCT 烧写串口 通过命令thead cct uart 命令看到电脑上安装的串口列表 并确认电脑上串口与开发板串的对应关系
thead cct uart uart device list: /dev/ttyUSB0 - USB-Serial Controller
如果出现上面状态 说明 thead 工具安装正常 串口设备连接正常。
通过命令 thead cct -u /dev/ttyUSB0 list 可以查看开发板支持的烧写存储器列表 如下
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 .......... 信息后再开启开发板电源。
如果未出现上述打印信息 先确认连线和开发板电源状态 同时电脑是接有多个串口 请更新另一个串口再次尝试。
通过命令 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/786371