Rockchip RK3588 - Rockchip Linux SDK编译
----------------------------------------------------------------------------------------------------------------------------
开发板 :ArmSoM-Sige7
开发板
eMMC
:64GB
LPDDR4
:8GB
显示屏 :15.6
英寸HDMI
接口显示屏
u-boot
:2017.09
linux
:5.10
----------------------------------------------------------------------------------------------------------------------------
一、SDK
软件架构
1.1 SDK
工程目录介绍
一个通用Linux SDK
工程目录包含有buildroot
、debian
、app
、kernel
、u-boot
、device
、external
等目录;
app
:存放上层应用APP
,主要是一些应用Demo
;buildroot
:存放Buildroot
开发的根文件系统;debian
:存放Debian
开发的根文件系统;device/rockchip
:存放芯片板级配置以及一些编译和打包固件的脚本和文件;docs
:存放通用开发指导文档、Linux
系统开发指南、芯片平台相关文档等;external
:存放第三方相关仓库,包括显示、音视频、摄像头、网络、安全、recovery
等;kernel
:存放Kernel
开发的代码;output
:存放每次生成的固件信息、编译信息、XML
、主机环境等;prebuilts
:存放外部交叉编译工具链;rkbin
:存放Rockchip
相关二进制和工具;rockdev
:存放编译输出固件,实际软链接到output/firmware
;tools
:存放Linux
和Window
操作系统下常用工具;u-boot
:存放基于v2017.09
版本进行开发的U-Boot
代码;yocto
:存放Yocto
开发的根文件系统;
1.2 SDK
概述
通用Linux SDK
目前已集成主流的几个Linux
发行版(Distribution
),发行版就是我们日常在Linux
主机上使用的那些系统,为用户预先集成好的Linux
操作系统及各种应用软件。Linux
发行版的形式多种多样,有从功能齐全的桌面系统到服务器版本到小型系统。比如支持桌面版本的Debian
系统,可定制化的Buildroot/Yocto
轻量级系统。
1.2.1 Buildroot
系统
Rockchip Linux SDK
的Buildroot
系统,其包含了基于Linux
系统开发用到的各种系统源码,驱动,工具,应用软件包。Buildroot
是Linux
平台上一个开源的嵌入式Linux
系统自动构建框架。整个Buildroot
是由Makefile
脚本和Kconfig
配置文件构成的。可通过Buildroot
配置,编译出一个完整的可以直接烧写到机器上运行的Linux
系统软件。
Buildroot
有以下几点优势:
- 通过源码构建,有很大的灵活性;
- 方便的交叉编译环境,可以进行快速构建,容易上手;
- 提供系统各组件的配置,方便定制开发。
使用Buildroot
的project
最出名的就是Openwrt
。可以看到,由它制作出的镜像可以跑在搭载16 Mb SPINOR
的路由器上,系统基本没包含多余的东西。 这就是得益于Buildroot
的简单化。整个Buildroot
工程在一个git
维护。
Buildroot
使用kconfig
和make
,一个defconfig
配置代表一种BSP
支持。Buildroot
本身不具备扩展能力,用户需要自己通过脚本来完成工作。这些列出来的特点,都是和Yocto
不同的地方。
注意:Buildroot
实际上使用Busybox
来制作根文件系统。
1.2.2 Yocto
Yocto
和Buildroot
一样, 是一套构建嵌入式系统的工具,但是两者的风格完全不同。
Yocto
工程是通过一个个单独的包(meta
)来维护,比如有的包负责核心,有的包负责外围。有的包用于跑Rockchip
的芯片,有的包用于安装上weston
, 有的包是则是用于跑debian
, 同样采用类似机制的nodejs
,社区膨胀非常厉害,活跃度很高,每个人都可分享自己的成果到github
上,这样的机制保证了我们可从互联网复用别人的工作成果,相当有价值。
相比Buildroot
系统,Yocto
有其更强的编译机制,比如第三方包的依赖和重编,都会自动处理。缺点相对复杂、需VPN
网络。
Yocto
是一个非常灵活的构建系统,允许用户使用shell
和Python
来处理各种特殊情况。目前,该系统主要针对国外客户。如果您需要更多关于Yocto
的信息,请查看以下参考资料:
1.2.3 Debian
Debian
是一种完全自由开放并广泛用于各种设备的Linux
操作系统,选择Debian
原因如下:
Debian
是自由软件:Debian
是由自由和开放源代码的软件组成,并将始终保持100%
自由,每个人都能自由使用、修改,以及发布,大家可以基Rockchip
构建的Debian
系统进行二次开发;Debian
是一个基于Linux
稳定且安全的的操作系统:Debian
是一个广泛用于各种设备的操作系统,其使用范围包括笔记本计算机,台式机和服务器。自1993
年以来,它的稳定性和可靠性就深受用户的喜爱。我们为每个软件包提供合理的默认配置,Debian
开发人员会尽可能在其生命周期内为所有软件包提供安全更新;Debian
具有广泛的硬件支持:大多数硬件已获得Linux
内核的支持。当自由软件无法提供足够的支持时,也可使用专用的硬件驱动程序。目前Rockchip RK3588/RK3568/RK3566/RK3399/RK3288
等芯片已经适配并支持;Debian
提供平滑的更新:Debian
以在其发行周期内轻松流畅地进行更新而闻名,不仅如此,还包括轻松升级到下一个大版本。Rockchip
目前已从Debian Stretch(9)
升级到Debian Buster(10)
和Bullseye(11)
版本;Debian
是许多其他发行版的种子和基础:许多非常受欢迎的Linux
发行版,例如Ubuntu
、Knoppix
、PureOS
、SteamOS
以及Tails
,都选择了Debian
作为它们的软件基础。Debian
提供了所有工具,因此每个人都可以用能满足自己需求的软件包来扩展Debian
档案库中的软件包;Debian
项目是一个社区:Debian
不只是一个Linux
操作系统。该软件由来自世界各地的数百名志愿者共同制作。即使您不是一个程序员或系统管理员,也可以成为Debian
社区的一员;
Rockchip
定制版的Debian
系统是通过Shell
脚本来达到获取构建Linux Debian
发行版源码,编译和安装适配Rockchip
硬加速包的操作系统。
1.3 SDK
软件框图
SDK
软件框图如下图所示:
从下至上分为启动层、内核层、库、应用层四个层次。各层次内容如下:
- 启动层主要提供系统启动,如
BootROM
、U-Boot
、ATF
等相关支持; - 内核层主要提供
Linux Kernel
的标准实现,Linux
也是一个开放的操作系统,Rockchip
平台的Linux
核心为标准的Linux4.4/4.19/5.10
内核,提供安全性,内存管理,进程管理,网络协议栈等基础支持;主要是通过Linux
内核管理设备硬件资源,如CPU
调度、缓存、内存、I/O
等; - 库层对应一般嵌入式系统,相当于中间件层次。包含了各种系统基础库,及第三方开源程序库支持,对应用层提供
API
接口,系统定制者和应用开发者可以基于Libraries
层的API
开发新的应用; - 应用层主要是实现具体的产品功能及交互逻辑,需要一些系统基础库及第三方程序库支持,开发者可以开发实现自己的应用程序,提供系统各种能力给到最终用户。
SDK
系统启动流程是指系统上电到系统启动完成的一个软件流程,下面是linux
系统启动流程:
注意:
AP
和MCU
内部都有集成一个BootROM
,系统上电时先会运行BootROM
代码,然后BootROM
代码会探测外设存储器并加载Loader
代码;PreLoader
前有3个:miniloader
(非开源),uboot tpl
和uboot spl
loader
;
1.4 SDK
开发流程
Rockchip Linux
系统是基于Buildroot/Yocto/Debian
系统,,内核基于kernel 4.4/4.19/5.10
开发,针对多种不同产品形态开发的SDK
。可以基于本SDK
,有效地实现系统定制和应用移植开发。
如图所示,开发者可以遵循上述开发流程,在本地快速构建Rockchip Linux
系统的开发环境和编译代码。下面将简单介绍下该流程:
- 检查系统需求:在下载代码和编译前,需确保本地的开发设备能够满足需求,包括机器的硬件能力,软件系统,工具链等。目前
SDK
支持Linux
操作系统环境下编译,并仅提供Linux
环境下的工具链支持,其他如MacOS
,Windows
等系统暂不支持; - 搭建编译环境:介绍开发机器需要安装的各种软件包和工具,详见第二节
SDK
开发坏境搭建。 - 选择设备:在开发过程中,需要开发者根据自己的需求,选择对应的硬件板型;
- 下载源代码:选定设备类型后,需要安装
repo
工具用于批量下载源代码; - 系统定制:开发者可以根据使用的硬件板子、产品定义,定制
u-boot
、kernel
及rootfs
,详见第五节SDK
开发; - 编译与打包:介绍具备源代码后,选择产品及初始化相关的编译环境,而后执行编译命令,包括整体或模块编译以及编译清理等工作,进一步内容详见第三节
SDK
编译说明。 - 烧录并运行:继生成镜像文件后,将介绍如何烧录镜像并运行在硬件设备,进一步内容详见第四节
SDK
固件升级;
二、SDK
开发环境搭建
2.1 概述
本节主要介绍了如何在本地搭建编译环境来编译Rockchip Linux SDK
源代码,当前SDK
只支持在Linux
环境下编译和进行二次开发。
一个典型的嵌入式开发环境通常包括Linux
服务器、PC
和目标硬件版,典型开发环境如下图所示;
其中:
Linux
服务器上建立交叉编译环境,为软件开发提供代码、更新下载和进行编译等服务;PC
和Linux
服务器共享程序,并安装Putty
或Minicom
,通过网络远程登陆到Linux
服务器,进行交叉编译,及代码的开发调试;PC
通过串口和USB
与目标硬件板连接,可将编译后的镜像文件烧写到目标硬件板,并调试系统或应用程序。
2.2 源码获取
在一个大型项目中,一般会拆成多个子系统来分开管理,每一个子系统都对应着一个git
仓库。但在拉取整个项目的时候就需要一个一个去拉取仓库,或者要写一个shell
脚本去拉取,这样做可以,但略显笨拙。于是repo
来拯救了我们,它是一个建立在git
上的工具,本质其实是一个Python
脚本,所以需要安装Python
,像Android
这样的系统也是用repo
来管理的。
Rockchip Linux SDK
的代码和相关文档被划分为了若干git
仓库分别进行版本管理,开发者可以使用repo
对这些git
仓库进行统一的下载、提交、切换分支等操作。
获取Rockchip Linux
软件包,需要有一个帐户访问Rockchip
提供的源代码仓库。客户向瑞芯微技术窗口申请SDK
,同步提供SSH
公钥进行服务器认证授权,获得授权后即可同步代码。
请根据《Rockchip_User_Guide_SDK_Application_And_Synchronization_CN
》文档说明操作,生成SSH
公钥,发邮件至fae@rock-chips.com,
申请开通SDK
代码。该文档会在申请开通权限流程中,释放给客户使用。
作为一个用户这里我们大概率是无法直接申请开通SDK
代码的,所以这里直接使用armsom
开发板厂商提供的SDK
源码;
这里我们从https://github.com/ArmSoM/armsom-rk3588-bsp
下载SDK
源码,命令如下:
root@ubuntu:/work/sambashare/rk3588/armsom# git clone https://github.com/ArmSoM/armsom-rk3588-bsp.git
root@ubuntu:/work/sambashare/rk3588/armsom# cd armsom-rk3588-bsp
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# ll
drwxr-xr-x 5 zhengyang zhengyang 4096 6月 10 21:42 ../
drwxr-xr-x 10 root root 4096 6月 9 12:58 app/
drwxr-xr-x 16 root root 4096 6月 9 12:58 buildroot/
lrwxrwxrwx 1 root root 39 6月 9 12:58 build.sh -> device/rockchip/common/scripts/build.sh*
drwxr-xr-x 9 root root 4096 6月 9 12:58 debian/
drwxr-xr-x 3 root root 4096 6月 9 12:58 device/
drwxr-xr-x 6 root root 4096 6月 9 12:58 docs/
lrwxrwxrwx 1 root root 27 6月 9 12:58 envsetup.sh -> buildroot/build/envsetup.sh*
drwxr-xr-x 26 root root 4096 6月 9 12:59 external/
drwxr-xr-x 8 root root 4096 6月 9 12:59 .git/
drwxr-xr-x 26 root root 4096 6月 9 12:59 kernel/
lrwxrwxrwx 1 root root 31 6月 9 12:58 Makefile -> device/rockchip/common/Makefile
drwxr-xr-x 3 root root 4096 6月 9 12:59 prebuilts/
drwxr-xr-x 9 root root 4096 6月 9 12:59 rkbin/
lrwxrwxrwx 1 root root 41 6月 9 12:59 rkflash.sh -> device/rockchip/common/scripts/rkflash.sh*
drwxr-xr-x 5 root root 4096 6月 9 12:59 tools/
drwxr-xr-x 24 root root 4096 6月 9 12:59 u-boot/
drwxr-xr-x 5 root root 4096 6月 9 12:59 uefi/
drwxr-xr-x 9 root root 4096 6月 9 12:59 yocto/
注意:这里我直接从开发板厂商获取了最新的代码。
除了文章最开介绍的目录外,Rockchip Linux SDK
还包含如下内容:
build.sh
:指向device/rockchip/common/scripts/build.sh
,SDK
编译脚本;envsetup.sh
:指向buildroot/build/envsetup.sh
,配置Buildroot
编译环境脚本;
2.2.1 u-boot
及kernel
编译工具链
鉴于Rockchip Linux SDK
目前只在Linux PC
环境下编译,SDK
提供了Linux
下的交叉编译工具链。prebuilt
目录下的工具链是u-boot
和kernel
使用;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# ls prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/
aarch64-none-linux-gnu-addr2line aarch64-rockchip1031-linux-gnu-addr2line
aarch64-none-linux-gnu-ar aarch64-rockchip1031-linux-gnu-ar
aarch64-none-linux-gnu-as aarch64-rockchip1031-linux-gnu-as
aarch64-none-linux-gnu-c++ aarch64-rockchip1031-linux-gnu-c++
aarch64-none-linux-gnu-c++filt aarch64-rockchip1031-linux-gnu-c++filt
aarch64-none-linux-gnu-cpp aarch64-rockchip1031-linux-gnu-cpp
aarch64-none-linux-gnu-dwp aarch64-rockchip1031-linux-gnu-dwp
aarch64-none-linux-gnu-elfedit aarch64-rockchip1031-linux-gnu-elfedit
aarch64-none-linux-gnu-g++ aarch64-rockchip1031-linux-gnu-g++
aarch64-none-linux-gnu-gcc aarch64-rockchip1031-linux-gnu-gcc
aarch64-none-linux-gnu-gcc-10.3.1 aarch64-rockchip1031-linux-gnu-gcc-10.3.1
aarch64-none-linux-gnu-gcc-ar aarch64-rockchip1031-linux-gnu-gcc-ar
aarch64-none-linux-gnu-gcc-nm aarch64-rockchip1031-linux-gnu-gcc-nm
aarch64-none-linux-gnu-gcc-ranlib aarch64-rockchip1031-linux-gnu-gcc-ranlib
aarch64-none-linux-gnu-gcov aarch64-rockchip1031-linux-gnu-gcov
aarch64-none-linux-gnu-gcov-dump aarch64-rockchip1031-linux-gnu-gcov-dump
aarch64-none-linux-gnu-gcov-tool aarch64-rockchip1031-linux-gnu-gcov-tool
aarch64-none-linux-gnu-gdb aarch64-rockchip1031-linux-gnu-gdb
aarch64-none-linux-gnu-gdb-add-index aarch64-rockchip1031-linux-gnu-gdb-add-index
aarch64-none-linux-gnu-gfortran aarch64-rockchip1031-linux-gnu-gfortran
aarch64-none-linux-gnu-gprof aarch64-rockchip1031-linux-gnu-gprof
aarch64-none-linux-gnu-ld aarch64-rockchip1031-linux-gnu-ld
aarch64-none-linux-gnu-ld.bfd aarch64-rockchip1031-linux-gnu-ld.bfd
aarch64-none-linux-gnu-ld.gold aarch64-rockchip1031-linux-gnu-ld.gold
aarch64-none-linux-gnu-lto-dump aarch64-rockchip1031-linux-gnu-lto-dump
aarch64-none-linux-gnu-nm aarch64-rockchip1031-linux-gnu-nm
aarch64-none-linux-gnu-objcopy aarch64-rockchip1031-linux-gnu-objcopy
aarch64-none-linux-gnu-objdump aarch64-rockchip1031-linux-gnu-objdump
aarch64-none-linux-gnu-ranlib aarch64-rockchip1031-linux-gnu-ranlib
aarch64-none-linux-gnu-readelf aarch64-rockchip1031-linux-gnu-readelf
aarch64-none-linux-gnu-size aarch64-rockchip1031-linux-gnu-size
aarch64-none-linux-gnu-strings aarch64-rockchip1031-linux-gnu-strings
aarch64-none-linux-gnu-strip aarch64-rockchip1031-linux-gnu-strip
对应版本:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-gcc -v
......
gcc 版本 10.3.1 20210621 (GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29))
2.2.2 rootfs
编译工具链
具体rootfs
需要用各自对应的工具链,或者使用第三方工具链进行编译。
以Buildroo
为例,具体参考:
buildroot/docs/manual/using-buildroot-toolchain.txt
;buildroot/docs/manual/adding-packages.txt
。
2.3 Linux
服务器搭建
2.3.1 ubuntu 22.04
这里我们使用ubuntu 22.04
来进行编译,因为只有该版本及以上版本glibc
才支持GLIBC_2.33
、GLIBC_2.34
版本;由于我之前在虚拟机搭建的ubuntu
版本为20.04
,因此这里需要对系统进行升级;
zhengyang@ubuntu:~/桌面$ sudo apt install update-manager-core
然后运行软件更新器:
主要:这里不要通过对glibc
源码进行编译得到高版本的glibc
,这种做法可能导致系统崩溃。
此外:硬盘空间大于40G
,如果您进行多个构建,将需要更大的硬盘空间。
2.3.2 安装库和工具集
使用命令行进行设备开发时,可以通过以下步骤安装编译SDK
需要的库和工具;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# sudo apt update
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# sudo apt install git ssh make gcc libssl-dev \
liblz4-tool expect expect-dev g++ patchelf chrpath gawk texinfo chrpath \
diffstat binfmt-support qemu-user-static live-build bison flex fakeroot \
cmake gcc-multilib g++-multilib unzip device-tree-compiler ncurses-dev \
libgucharmap-2-90-dev bzip2 expat gpgv2 cpp-aarch64-linux-gnu libgmp-dev \
libmpc-dev bc python-is-python3 python2
2.3.3 设置DNS
支持kgithub.com
如果PC
在编译Buildroot
时无法访问Google
网站,需设置DNS
来支持使用国内镜像kgithub.com
下载dl
包。
sudo sed -i '$a 43.154.68.204\tkgithub.com' /etc/hosts
sudo sed -i '$a 43.155.83.75traw.kgithub.com objects.githubusercontent.kgithub.com' /etc/hosts
2.3.4 检查和升级主机的python
版本
python
要求安装python 3.6
及以上版本,检查主机python
版本:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# python3 --version
Python 3.10.12
如果不满足python>=3.6
版本的要求, 可通过如下方式升级:
PYTHON3_VER=3.6.15
echo "wget
https://www.python.org/ftp/python/${PYTHON3_VER}/Python-${PYTHON3_VER}.tgz"
echo "tar xf Python-${PYTHON3_VER}.tgz"
echo "cd Python-${PYTHON3_VER}"
echo "sudo apt-get install libsqlite3-dev"
echo "./configure --enable-optimizations"
echo "sudo make install -j8"
2.3.5 检查和升级主机的make
版本
make
要求安装make 4.0
及以上版本,检查主机make
版本;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# make -v
GNU Make 4.3
为 x86_64-pc-linux-gnu 编译
Copyright (C) 1988-2020 Free Software Foundation, Inc.
许可证:GPLv3+:GNU 通用公共许可证第 3 版或更新版本<http://gnu.org/licenses/gpl.html>。
本软件是自由软件:您可以自由修改和重新发布它。
在法律允许的范围内没有其他保证。
如果不满足make>=4.0
版本的要求, 可通过如下方式升级:
sudo apt update && sudo apt install -y autoconf autopoint
git clone https://gitee.com/mirrors/make.git
cd make
git checkout 4.2
git am $BUILDROOT_DIR/package/make/*.patch
autoreconf -f -i
./configure
make make -j8
sudo install -m 0755 make /usr/bin/make
2.3.6 检查和升级主机的lz4
版本
lz4
要求安装1.7.3
及以上版本,检查主机lz4
版本
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# lz4 -v
*** LZ4 command line interface 64-bits v1.9.3, by Yann Collet ***
refusing to read from a console
如果不满足LZ4>=1.7.3
版本的要求, 可通过如下方式升级:
git clone https://gitee.com/mirrors/LZ4_old1.git
cd LZ4_old1
make
sudo make install
sudo install -m 0755 lz4 /usr/bin/lz4
三、SDK
编译说明
3.1 SDK
编译命令查看
首先通过help
命令查看SDK
编译命令:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# make help
menuconfig - interactive curses-based configurator
oldconfig - resolve any unresolved symbols in .config
syncconfig - Same as oldconfig, but quietly, additionally update deps
olddefconfig - Same as syncconfig but sets new symbols to their default value
savedefconfig - Save current config to RK_DEFCONFIG (minimal config)
clean - Cleanup
......
make
实际运行是./build.sh
,即也可运行./build.sh <target>
来编译相关功能,具体可通过./build.sh help
查看具体编译命
令:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# ./build.sh help
Usage: build.sh [OPTIONS]
Available options:
chip[:<chip>[:<config>]] choose chip
defconfig[:<config>] choose defconfig
*_defconfig switch to specified defconfig
available defconfigs:
rockchip_defconfig
rockchip_rk3588_evb1_lp4_v10_defconfig
rockchip_rk3588_evb7_v11_defconfig
rockchip_rk3588_sige7_defconfig
rockchip_rk3588s_evb1_lp4x_v10_defconfig
olddefconfig resolve any unresolved symbols in .config
savedefconfig save current config to defconfig
menuconfig interactive curses-based configurator
config modify SDK defconfig
shell setup a shell for developing
print-parts print partitions
mod-parts interactive partition table modify
edit-parts edit raw partitions
new-parts:<offset>:<name>:<size>... re-create partitions
insert-part:<idx>:<name>[:<size>] insert partition
del-part:(<idx>|<name>) delete partition
move-part:(<idx>|<name>):<idx> move partition
rename-part:(<idx>|<name>):<name> rename partition
resize-part:(<idx>|<name>):<size> resize partition
kernel[:cmds] build kernel
modules[:cmds] build kernel modules
linux-headers[:cmds] build linux-headers
kernel-config[:cmds] modify kernel defconfig
kernel-make[:<arg1>:<arg2>] run kernel make (alias kmake)
wifibt[:<dst dir>[:<chip>]] build Wifi/BT
rtos build and pack RTOS
buildroot-config[:<config>] modify buildroot defconfig
buildroot-make[:<arg1>:<arg2>] run buildroot make (alias bmake)
rootfs[:<rootfs type>] build default rootfs
buildroot build buildroot rootfs
yocto build yocto rootfs
debian build debian rootfs
recovery build recovery
pcba build PCBA
security_check check contidions for security boot
createkeys build security boot keys
security_ramboot build security ramboot
security_uboot build uboot with security
security_boot build boot with security
security_recovery build recovery with security
security_rootfs build rootfs with security
loader[:cmds] build loader (uboot)
uboot[:cmds] build u-boot
uefi[:cmds] build uefi
firmware pack and check firmwares
edit-package-file edit package-file
edit-ota-package-file edit A/B OTA package-file
updateimg build update image
otapackage build A/B OTA update image
all build all images
save save images and build info
allsave build all images and save them
cleanall cleanup
clean[:module[:module]]... cleanup modules
available modules:
all
config
firmware
kernel
loader
pcba
recovery
rootfs
updateimg
post-rootfs <rootfs dir> trigger post-rootfs hook scripts
help usage
Default option is 'allsave'.
我们定位到build.sh
脚本入口,当我们执行./build.sh <target>
时将会执行如下代码;
if [ "$0" != "$BASH_SOURCE" ]; then
# Sourced, executing it directly
"$BASH_SOURCE" ${@:-shell}
elif [ "$0" == "$BASH_SOURCE" ]; then
# Executed directly
main $@
fi
$0
代表脚本名,而$BASH_SOURCE
代表脚本文件的路径,因此当执行./build.sh <target>
时,$0
和$BASH_SOURCE
会相同。
因此执行main $@
,将调用名为main
的函数,并将所有传递给脚本的参数传递给main
函数。
有关build.sh
文件的分析参考最后一节内容。
3.2 SDK
板级配置
具体板级配置说明如下,进入工程device/rockchip/rk3588
目录
板级配置 | 说明 |
---|---|
rockchip_rk3588_evb1_lp4_v10_defconfig | 适用于RK3588 EVB1搭配LPDDR4开发板 |
rockchip_rk3588_evb3_lp5_v10_defconfig | 适用于RK3588 EVB3 搭配 LPDDR5开发板 |
rockchip_rk3588_evb7_lp4_v10_defconfig | 适用于RK3588 EVB7搭配LPDDR4开发板 |
rockchip_rk3588s_evb1_lp4x_v10_defconfig | 适用于RK3588S EVB1搭配LPDDR4开发板 |
rockchip_rk3562_evb1_lp4x_v10_defconfig | 适用于RK3562 EVB1搭配LPDDR4开发板 |
rockchip_rk3562_evb2_ddr4_v10_defconfig | 适用于 RK3566 EVB2 搭配DDR4开发板 |
rockchip_rk3588_sige7_defconfig | 适用于RK3355 Sige7开发板 |
...... | ...... |
rockchip_defconfig | 默认配置, 具体会软链接到默认一个板级配置 |
可通过make lunch
或者./build.sh lunch
进行配置,比如rk3588
芯片;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# ./build.sh lunch
Log saved at /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/sessions/2024-06-10_22-25-38
Pick a defconfig:
1. rockchip_defconfig
2. rockchip_rk3588_evb1_lp4_v10_defconfig
3. rockchip_rk3588_evb7_v11_defconfig
4. rockchip_rk3588_sige7_defconfig
5. rockchip_rk3588s_evb1_lp4x_v10_defconfig
Which would you like? [1]:
比如这里我们选择4
:
Which would you like? [1]: 4
Switching to defconfig: /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/device/rockchip/.chip/rockchip_rk3588_sige7_defconfig
make: Entering directory '/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/device/rockchip/common'
#
# configuration written to /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/.config
#
make: Leaving directory '/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/device/rockchip/common'
这里生成了output/.config
配置文件,内容如下:
#
# Automatically generated file; DO NOT EDIT.
# Rockchip Linux SDK Configuration
#
RK_DEFCONFIG="/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/device/rockchip/.chips/rk3588/rockchip_rk3588_sige7_defconfig"
RK_CHIP_FAMILY="rk3588"
RK_CHIP="rk3588"
#
# Rootfs
#
RK_BUILDROOT_BASE_CFG="rk3588"
RK_BUILDROOT_CFG="rockchip_${RK_BUILDROOT_BASE_CFG}"
RK_YOCTO_CFG="rockchip-rk3588-evb"
RK_YOCTO_CHROMIUM=y
RK_YOCTO_DISPLAY_PLATFORM="wayland"
RK_YOCTO_DISPLAY_PLATFORM_WAYLAND=y
# RK_YOCTO_DISPLAY_PLATFORM_X11 is not set
RK_YOCTO_USBMOUNT=y
RK_DEBIAN_VERSION="bullseye"
RK_DEBIAN_ARCH="arm64"
RK_DEBIAN_ARM64=y
# RK_DEBIAN_ARMHF is not set
RK_ROOTFS_SYSTEM="buildroot"
RK_ROOTFS_SYSTEM_BUILDROOT=y
# RK_ROOTFS_SYSTEM_DEBIAN is not set
# RK_ROOTFS_SYSTEM_YOCTO is not set
RK_ROOTFS_TYPE="ext4"
# RK_ROOTFS_INITRD is not set
......
3.3 配置不同启动/内核/系统等组件
SDK
可通过make menuconfig
进行相关配置,目前可配组件主要如下:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# make menuconfig
(/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/device/rockchip/.chips/rk3588/rockchip_rk
Rootfs --->
Loader (u-boot) --->
RTOS --->
Kernel --->
Boot --->
Recovery (buildroot) --->
PCBA test (buildroot) --->
Security --->
Extra partitions --->
Firmware --->
Update (Update image, OTA and A/B) --->
Others configurations --->
通过以上config
,可选择不同rootfs/loader/kernel
等配置,进行各种定制化编译。另外还带有强大命令行切换功能。
注意menuconfig
配置之后,需要make savedefconfig
保存配置;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# make savedefconfig
这里本质上就是修改output/.config
文件。
3.4 全自动编译
进入工程根目录执行以下命令自动完成所有的编译,如果只编译模块代码(uboot
,kernel
,rootfs
,recovery
),运行:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# ./build.sh all
输出内容如下:
点击查看代码
Log saved at /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/sessions/2024-06-10_22-51-26
==========================================
Final configs
==========================================
RK_BOOT_FIT_ITS=boot.its
RK_BOOT_IMG=boot.img
RK_BUILDROOT_CFG=rockchip_rk3588
RK_CHIP=rk3588
RK_CHIP_FAMILY=rk3588
RK_DEBIAN_ARCH=arm64
RK_DEBIAN_ARM64=y
RK_DEBIAN_VERSION=bullseye
RK_DEFCONFIG=/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/device/rockchip/.chips/rk3588/rockchip_rk3588_sige7_defconfig
RK_EXTRA_PARTITION_NUM=2
RK_EXTRA_PARTITION_STR=oem:oem:/oem:ext4:defaults:normal:auto:@userdata:userdata:/userdata:ext4:defaults:normal:auto:@@@
RK_KERNEL_ARCH=arm64
RK_KERNEL_ARM64=y
RK_KERNEL_CFG=rockchip_linux_defconfig
RK_KERNEL_CFG_FRAGMENTS=rk3588_linux.config
RK_KERNEL_DTB=kernel/arch/arm64/boot/dts/rockchip/rk3588-armsom-sige7.dtb
RK_KERNEL_DTS=kernel/arch/arm64/boot/dts/rockchip/rk3588-armsom-sige7.dts
RK_KERNEL_IMG=kernel/arch/arm64/boot/Image
RK_KERNEL_KBUILD_ARCH=host
RK_KERNEL_KBUILD_HOST=y
RK_KERNEL_VERSION=5.10
RK_KERNEL_VERSION_REAL=5.10
RK_MISC=y
RK_MISC_BLANK=y
RK_PARAMETER=parameter.txt
RK_PCBA_CFG=rockchip_rk3588_pcba
RK_RECOVERY_CFG=rockchip_rk3588_recovery
RK_RECOVERY_FIT_ITS=boot4recovery.its
RK_ROOTFS_IRQBALANCE=y
RK_ROOTFS_OVERLAY_DIRS=y
RK_ROOTFS_SYSTEM=buildroot
RK_ROOTFS_SYSTEM_BUILDROOT=y
RK_ROOTFS_TYPE=ext4
RK_ROOTFS_UDEV_RULES=y
RK_SAVE_TRACKED=y
RK_SESSION=2024-06-11_22-45-04
RK_UBOOT_ARCH=arm64
RK_UBOOT_ARM64=y
RK_UBOOT_CFG=rk3588
RK_UPDATE=y
RK_USB_ADBD=y
RK_USB_ADBD_BASH=y
RK_USB_ADBD_TCP_PORT=5555
RK_USE_FIT_IMG=y
RK_WIFIBT_CHIP=ALL_AP
RK_YOCTO_CFG=rockchip-rk3588-evb
RK_YOCTO_CHROMIUM=y
RK_YOCTO_DISPLAY_PLATFORM=wayland
RK_YOCTO_DISPLAY_PLATFORM_WAYLAND=y
RK_YOCTO_USBMOUNT=y
==========================================
Start building all images
==========================================
Using kernel version(5.10) from environment
Toolchain for kernel:
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-
==========================================
Start building kernel
==========================================
+ make -C /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/kernel/ -j7 CROSS_COMPILE=/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu- ARCH=arm64 rockchip_linux_defconfig rk3588_linux.config
make: Entering directory '/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/kernel'
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/confdata.o
HOSTCC scripts/kconfig/expr.o
LEX scripts/kconfig/lexer.lex.c
YACC scripts/kconfig/parser.tab.[ch]
HOSTCC scripts/kconfig/preprocess.o
HOSTCC scripts/kconfig/symbol.o
HOSTCC scripts/kconfig/util.o
HOSTCC scripts/kconfig/lexer.lex.o
HOSTCC scripts/kconfig/parser.tab.o
HOSTLD scripts/kconfig/conf
#
# configuration written to .config
#
......
LD [M] drivers/leds/trigger/ledtrig-camera.ko
Image: resource.img (with rk3588-armsom-sige7.dtb logo.bmp logo_kernel.bmp) is ready
Image: boot.img (with Image resource.img) is ready
Image: zboot.img (with Image.lz4 resource.img) is ready
make: Leaving directory '/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/kernel'
+ /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/device/rockchip/common/scripts/mk-fitimage.sh kernel/boot.img boot.its kernel/arch/arm64/boot/Image
FIT description: U-Boot FIT source file for arm
Created: Tue Jun 11 22:52:08 2024
Image 0 (fdt)
Description: unavailable
Created: Tue Jun 11 22:52:08 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 276878 Bytes = 270.39 KiB = 0.26 MiB
Architecture: AArch64
Load Address: 0xffffff00
Hash algo: sha256
Hash value: 2e1efecb7de8f6d6f6dc99aceac3316169528dbe2343075acbc97c676863a54a
Image 1 (kernel)
Description: unavailable
Created: Tue Jun 11 22:52:08 2024
Type: Kernel Image
Compression: uncompressed
Data Size: 35650048 Bytes = 34814.50 KiB = 34.00 MiB
Architecture: AArch64
OS: Linux
Load Address: 0xffffff01
Entry Point: 0xffffff01
Hash algo: sha256
Hash value: 2de5ee7d2ebdda89a527236a37b485ec9a695366fee730a72d5c887f76026682
Image 2 (resource)
Description: unavailable
Created: Tue Jun 11 22:52:08 2024
Type: Multi-File Image
Compression: uncompressed
Data Size: 1692160 Bytes = 1652.50 KiB = 1.61 MiB
Hash algo: sha256
Hash value: 16b3aea0b954a45350b6569f67cd6aa082d112a288a4d22331a41b1dee58699d
Default Configuration: 'conf'
Configuration 0 (conf)
Description: unavailable
Kernel: kernel
FDT: fdt
Not Found io-domains in kernel/arch/arm64/boot/dts/rockchip/rk3588-armsom-sige7.dts
==========================================
Start building rootfs(buildroot)
==========================================
==========================================
Start building buildroot(2021.11)
==========================================
make: Entering directory '/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot'
GEN /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588/Makefile
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/build/parse_defconfig.sh /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/configs/rockchip_rk3588_defconfig /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588/.config.in
Parsing defconfig: /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/configs/rockchip_rk3588_defconfig
.......
Log saved on /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/sessions/2024-06-11_22-45-04/br-rockchip_rk3588_2024-06-11_22-52-17.log
Generated images:
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/rootfs/rootfs.cpio
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/rootfs/rootfs.cpio.gz
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/rootfs/rootfs.ext2
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/rootfs/rootfs.ext4
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/rootfs/rootfs.squashfs
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/rootfs/rootfs.tar
you take 7:31.54 to build buildroot
# 2024-06-11 22:53:12
# run hook: /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588/target rockchip_rk3588_defconfig"
Running 00-wifibt.sh for /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588/target (buildroot init=busybox)...
Building Wifi/BT module and firmwares...
==========================================
Start building wifi/BT (ALL_AP)
==========================================
kernel config: CONFIG_USB=y CONFIG_MMC=y CONFIG_RFKILL=y
building bcmdhd sdio
make[1]: Entering directory '/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/kernel'
CC [M] /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/external/rkwifibt/drivers/bcmdhd/aiutils.o
CC [M] /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/external/rkwifibt/drivers/bcmdhd/siutils.o
CC [M] /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/external/rkwifibt/drivers/bcmdhd/sbutils.o
......
sent 1,143,224 bytes received 71 bytes 2,286,590.00 bytes/sec
total size is 1,143,678 speedup is 1.00
Handling overlay: /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/device/rockchip/common/overlays/rootfs/frecon)...
Installing overlay: /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/device/rockchip/common/overlays/rootfs/common-tools to /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588/target...
sending incremental file list
copying unsafe symlink "usr/bin/vendor_storage" -> "../../../../../tools/armhf/vendor_storage"
copying unsafe symlink "usr/bin/modetest" -> "../../../../../tools/armhf/modetest"
copying unsafe symlink "usr/bin/updateEngine" -> "../../../../../tools/armhf/updateEngine"
copying unsafe symlink "usr/bin/update" -> "../../../../../tools/armhf/update"
copying unsafe symlink "usr/bin/io" -> "../../../../../tools/armhf/io"
usr/bin/io
usr/bin/update
usr/bin/updateEngine
usr/bin/vendor_storage
sent 4,384,849 bytes received 94 bytes 8,769,886.00 bytes/sec
total size is 4,999,800 speedup is 1.14
Running 95-partitions.sh for /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588/target (buildroot init=busybox)...
Preparing extra partitions...
Running 99-owner.sh for /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588/target (buildroot init=busybox)...
Running mk-rootfs.sh - build_buildroot /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/rootfs succeeded.
Running mk-rootfs.sh - build_rootfs succeeded.
==========================================
Start building recovery(buildroot)
==========================================
make: Entering directory '/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot'
GEN /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588_recovery/Makefile
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/build/parse_defconfig.sh /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/configs/rockchip_rk35
......
2024-06-11T23:00:03 >>> Generating root filesystems common tables
2024-06-11T23:00:03 >>> Generating filesystem image rootfs.cpio
2024-06-11T23:00:06 >>> Generating filesystem image rootfs.ext2
2024-06-11T23:00:06 >>> Generating filesystem image rootfs.squashfs
2024-06-11T23:00:07 >>> Generating filesystem image rootfs.tar
Done in 21s
Log saved on /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/sessions/2024-06-11_22-45-04/br-rockchip_rk3588_recovery_2024-06-11_22-59-47.log
Generated images:
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/recovery/rootfs.cpio
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/recovery/rootfs.cpio.gz
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/recovery/rootfs.ext2
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/recovery/rootfs.ext4
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/recovery/rootfs.squashfs
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/recovery/rootfs.tar
you take 0:27.69 to build recovery(buildroot)
Packing /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/recovery/rootfs.cpio.gz to /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/recovery/recovery.img
FIT description: U-Boot FIT source file for arm
Created: Tue Jun 11 23:00:08 2024
Image 0 (fdt)
Description: unavailable
Created: Tue Jun 11 23:00:08 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 276878 Bytes = 270.39 KiB = 0.26 MiB
Architecture: AArch64
Load Address: 0xffffff00
Hash algo: sha256
Hash value: 2e1efecb7de8f6d6f6dc99aceac3316169528dbe2343075acbc97c676863a54a
Image 1 (kernel)
Description: unavailable
Created: Tue Jun 11 23:00:08 2024
Type: Kernel Image
Compression: uncompressed
Data Size: 35650048 Bytes = 34814.50 KiB = 34.00 MiB
Architecture: AArch64
OS: Linux
Load Address: 0xffffff01
Entry Point: 0xffffff01
Hash algo: sha256
Hash value: 2de5ee7d2ebdda89a527236a37b485ec9a695366fee730a72d5c887f76026682
Image 2 (ramdisk)
Description: unavailable
Created: Tue Jun 11 23:00:08 2024
Type: RAMDisk Image
Compression: uncompressed
Data Size: 6673958 Bytes = 6517.54 KiB = 6.36 MiB
Architecture: AArch64
OS: Linux
Load Address: 0xffffff02
Entry Point: unavailable
Hash algo: sha256
Hash value: 61124fb71f146a757ce43bb199e5fa39be4c6adb56ba80251cd3b184c3aca900
Image 3 (resource)
Description: unavailable
Created: Tue Jun 11 23:00:08 2024
Type: Multi-File Image
Compression: uncompressed
Data Size: 1692160 Bytes = 1652.50 KiB = 1.61 MiB
Hash algo: sha256
Hash value: 16b3aea0b954a45350b6569f67cd6aa082d112a288a4d22331a41b1dee58699d
Default Configuration: 'conf'
Configuration 0 (conf)
Description: unavailable
Kernel: kernel
Init Ramdisk: ramdisk
FDT: fdt
you take 0:00.51 to pack recovery image
Running mk-recovery.sh - build_recovery succeeded.
Toolchain for loader (u-boot):
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-
==========================================
Start building loader
==========================================
+ cd u-boot
+ ./make.sh CROSS_COMPILE=/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu- rk3588
## make rk3588_defconfig -j12
#
# configuration written to .config
#
scripts/kconfig/conf --silentoldconfig Kconfig
CHK include/config.h
CFG u-boot.cfg
GEN include/autoconf.mk.dep
CFG spl/u-boot.cfg
CFG tpl/u-boot.cfg
GEN include/autoconf.mk
......
CAT spl/u-boot-spl-dtb.bin
COPY spl/u-boot-spl.bin
CFGCHK u-boot.cfg
SEC=1
pack u-boot.itb okay! Input: /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/rkbin/RKTRUST/RK3588TRUST.ini
FIT description: FIT Image with ATF/OP-TEE/U-Boot/MCU
Created: Tue Jun 11 23:00:17 2024
Image 0 (uboot)
Description: U-Boot
Created: Tue Jun 11 23:00:17 2024
Type: Standalone Program
Compression: uncompressed
Data Size: 1317128 Bytes = 1286.26 KiB = 1.26 MiB
Architecture: AArch64
Load Address: 0x00200000
Entry Point: unavailable
Hash algo: sha256
Hash value: 7fd2ffe37130ca48d6f18001add4039373925d4d0619cc31de411ef3e187f02d
Image 1 (atf-1)
Description: ARM Trusted Firmware
Created: Tue Jun 11 23:00:17 2024
Type: Firmware
Compression: uncompressed
Data Size: 200008 Bytes = 195.32 KiB = 0.19 MiB
Architecture: AArch64
Load Address: 0x00040000
Hash algo: sha256
Hash value: c902200be1343fe569e54778c286005b1c6163606664c463a24d787be4376966
Image 2 (atf-2)
Description: ARM Trusted Firmware
Created: Tue Jun 11 23:00:17 2024
Type: Firmware
Compression: uncompressed
Data Size: 24576 Bytes = 24.00 KiB = 0.02 MiB
Architecture: AArch64
Load Address: 0x000f0000
Hash algo: sha256
Hash value: aa71013e72d7ab4be264c1093b155ef06e65d0a263d552be25b13c8ddf285586
Image 3 (atf-3)
Description: ARM Trusted Firmware
Created: Tue Jun 11 23:00:17 2024
Type: Firmware
Compression: uncompressed
Data Size: 24576 Bytes = 24.00 KiB = 0.02 MiB
Architecture: AArch64
Load Address: 0xff100000
Hash algo: sha256
Hash value: 225d6bf0712f850648223365ba06a73ba5f6315fb8a9580f23ab48ece795f91e
Image 4 (optee)
Description: OP-TEE
Created: Tue Jun 11 23:00:17 2024
Type: Firmware
Compression: uncompressed
Data Size: 465304 Bytes = 454.40 KiB = 0.44 MiB
Architecture: AArch64
Load Address: 0x08400000
Hash algo: sha256
Hash value: 66e30bf9e879405a49797aaa6c08ca1c41aa325443e910af42e3df309e65909b
Image 5 (fdt)
Description: U-Boot dtb
Created: Tue Jun 11 23:00:17 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 8141 Bytes = 7.95 KiB = 0.01 MiB
Architecture: AArch64
Hash algo: sha256
Hash value: 8ecccd16d2f12c4f5639c386e51f206eb679638495283d9297497ddfb0aae01a
Default Configuration: 'conf'
Configuration 0 (conf)
Description: rk3588-evb
Kernel: unavailable
Firmware: atf-1
FDT: fdt
Loadables: uboot
atf-2
atf-3
optee
********boot_merger ver 1.31********
Info:Pack loader ok.
pack loader okay! Input: /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/rkbin/RKBOOT/RK3588MINIALL.ini
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/u-boot
Image(no-signed, version=0): uboot.img (FIT with uboot, trust...) is ready
Image(no-signed): rk3588_spl_loader_v1.13.112.bin (with spl, ddr...) is ready
pack uboot.img okay! Input: /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/rkbin/RKTRUST/RK3588TRUST.ini
Platform RK3588 is build OK, with new .config(make rk3588_defconfig -j12)
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-
Tue Jun 11 23:00:17 CST 2024
+ cd ..
Running mk-loader.sh - build_loader succeeded.
==========================================
Start packing firmwares
==========================================
Linking /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/firmware/parameter.txt from /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/device/rockchip/.chip/parameter.txt...
Generating blank misc...
Generated blank misc image:
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/firmware/misc.img
Preparing partiton oem
Merging /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/device/rockchip/common/images/oem/normal into /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/oem
Packing /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/firmware/oem.img from /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/oem.fs
Using host tools in /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588/host
Making /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/firmware/oem.img from /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/oem (auto sized)
Making /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/firmware/oem.img from /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/oem with size(17048KB)
mke2fs 1.46.5 (30-Dec-2021)
Creating regular file /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/firmware/oem.img
Creating filesystem with 17048 1k blocks and 4272 inodes
Filesystem UUID: b3ce6911-8296-4559-b1bc-df021c5476d0
Superblock backups stored on blocks:
8193
Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Copying files into the device: done
Writing superblocks and filesystem accounting information: done
tune2fs 1.46.5 (30-Dec-2021)
Setting maximal mount count to -1
Setting interval between checks to 0 seconds
Done packing /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/firmware/oem.img
Preparing partiton userdata
Merging /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/device/rockchip/common/images/userdata/normal into /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/userdata
Packing /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/firmware/userdata.img from /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/userdata.fs
Using host tools in /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588/host
Making /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/firmware/userdata.img from /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/userdata (auto sized)
Making /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/firmware/userdata.img from /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/userdata with size(4368KB)
mke2fs 1.46.5 (30-Dec-2021)
Creating regular file /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/firmware/userdata.img
Creating filesystem with 4368 1k blocks and 1088 inodes
Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Copying files into the device: done
Writing superblocks and filesystem accounting information: done
tune2fs 1.46.5 (30-Dec-2021)
Setting maximal mount count to -1
Setting interval between checks to 0 seconds
Done packing /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/firmware/userdata.img
Packed files:
MiniLoaderAll.bin(/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/u-boot/rk3588_spl_loader_v1.13.112.bin): 461K
boot.img(/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/kernel/boot.img): 36M
misc.img: 48K
oem.img: 17M
parameter.txt(/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/device/rockchip/.chips/rk3588/parameter.txt): 539
recovery.img(/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588_recovery/images/recovery.img): 43M
rootfs.img(/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588/images/rootfs.ext2): 728M
uboot.img(/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/u-boot/uboot.img): 4.0M
userdata.img: 4.3M
Images in /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/firmware are ready!
Running mk-firmware.sh - build_firmware succeeded.
==========================================
Start packing update image
==========================================
Generating package-file for update:
# NAME PATH
package-file package-file
parameter parameter.txt
bootloader MiniLoaderAll.bin
uboot uboot.img
misc misc.img
boot boot.img
recovery recovery.img
backup RESERVED
rootfs rootfs.img
oem oem.img
userdata userdata.img
Packing /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/rockdev/update.img for update...
Android Firmware Package Tool v2.2
------ PACKAGE ------
Add file: ./package-file
package-file,Add file: ./package-file done,offset=0x800,size=0xe1,userspace=0x1
Add file: ./parameter.txt
parameter,Add file: ./parameter.txt done,offset=0x1000,size=0x227,userspace=0x1,flash_address=0x00000000
Add file: ./MiniLoaderAll.bin
bootloader,Add file: ./MiniLoaderAll.bin done,offset=0x1800,size=0x731c0,userspace=0xe7
Add file: ./uboot.img
uboot,Add file: ./uboot.img done,offset=0x75000,size=0x400000,userspace=0x800,flash_address=0x00004000
Add file: ./misc.img
misc,Add file: ./misc.img done,offset=0x475000,size=0xc000,userspace=0x18,flash_address=0x00006000
Add file: ./boot.img
boot,Add file: ./boot.img done,offset=0x481000,size=0x23e1200,userspace=0x47c3,flash_address=0x00008000
Add file: ./recovery.img
recovery,Add file: ./recovery.img done,offset=0x2862800,size=0x2a3ea00,userspace=0x547e,flash_address=0x00028000
Add file: ./rootfs.img
rootfs,Add file: ./rootfs.img done,offset=0x52a1800,size=0x2d800000,userspace=0x5b000,flash_address=0x00078000
Add file: ./oem.img
oem,Add file: ./oem.img done,offset=0x32aa1800,size=0x10a6000,userspace=0x214c,flash_address=0x01c78000
Add file: ./userdata.img
userdata,Add file: ./userdata.img done,offset=0x33b47800,size=0x444000,userspace=0x888,flash_address=0x01cb8000
Add CRC...
Make firmware OK!
------ OK ------
********rkImageMaker ver 2.23********
Generating new image, please wait...
Writing head info...
Writing boot file...
Writing firmware...
Generating MD5 data...
MD5 data generated successfully!
New image generated successfully!
Running mk-updateimg.sh - build_updateimg succeeded.
Running 99-all.sh - build_all succeeded.
从输出日志可以看出编译顺序,我们接下来依次介绍。
3.4.1 编译kernel
通过mk-fitimage.sh
脚本生成boot.img
位于kernel
目录下;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll kernel/boot.img
-rw-r--r-- 1 root root 37622272 6月 11 22:52 kernel/boot.img
3.4.2 编译rootfs
编译输出根文件系统rootfs.ext4
位于output/rootfs
目录下;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll output/rootfs
lrwxrwxrwx 1 root root 42 6月 11 22:52 output/rootfs -> ../buildroot/output/rockchip_rk3588/images/
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll output/rootfs/
-rw-r--r-- 1 root root 615713280 6月 11 22:58 rootfs.cpio
-rw-r--r-- 1 root root 273882955 6月 11 22:59 rootfs.cpio.gz
-rw-r--r-- 1 root root 763363328 6月 11 22:59 rootfs.ext2
lrwxrwxrwx 1 root root 11 6月 11 22:59 rootfs.ext4 -> rootfs.ext2
-rw-r--r-- 1 root root 275013632 6月 11 22:59 rootfs.squashfs
-rw-r--r-- 1 root root 624517120 6月 11 22:59 rootfs.tar
系统默认是Buildroot
,可以通过设置坏境变量RK_ROOTFS_SYSTEM
指定不同rootfs
。RK_ROOTFS_SYSTEM
目前可设定三种系统:buildroot
、debian
、 yocto
。
比如需要debain
可以通过以下命令进行生成:
RK_ROOTFS_SYSTEM=debian ./build.sh all
3.4.3 编译wifi/BT
模块
编译wifi/BT
模块,并打包到根文件系统。
3.4.4 编译recovery
通过mk-recovery.sh
脚本编译完成输出recovery.img
,位于output/recovery
目录下;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll output/recovery
lrwxrwxrwx 1 root root 51 6月 11 22:59 output/recovery -> ../buildroot/output/rockchip_rk3588_recovery/images/
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll output/recovery/
-rw-r--r-- 1 root root 44296704 6月 11 23:00 recovery.img
-rw-r--r-- 1 root root 15763968 6月 11 23:00 rootfs.cpio
-rw-r--r-- 1 root root 6673958 6月 11 23:00 rootfs.cpio.gz
-rw-r--r-- 1 root root 43187200 6月 11 23:00 rootfs.ext2
lrwxrwxrwx 1 root root 11 6月 11 23:00 rootfs.ext4 -> rootfs.ext2
-rw-r--r-- 1 root root 6635520 6月 11 23:00 rootfs.squashfs
-rw-r--r-- 1 root root 16844800 6月 11 23:00 rootfs.tar
注意:recovery.img
是由kernel+dtb+ramdisk
组成的根文件系统,主要用于升级操作。
3.4.5 编译u-boot
通过mk-loader.sh
脚本编译loader
,编译完成生成uboot.img
、rk3588_spl_loader_v1.13.112.bin
位于u-boot
目录下;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll u-boot/uboot.img
-rw-r--r-- 1 root root 4194304 6月 11 23:00 u-boot/uboot.img
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll u-boot/rk3588_spl_loader_v1.13.112.bin
-rw-r--r-- 1 root root 471488 6月 11 23:00 u-boot/rk3588_spl_loader_v1.13.112.bin
3.4.6 打包分区镜像
通过mk-firmware.sh
脚本生成存放各个分区镜像的目录,位于output/firmware/
目录下;
- 创建
parameter.txt
链接文件,指向device/rockchip/.chips/rk3588/parameter.txt
; - 创建
misc
分区镜像文件:misc.img
; - 创建
oem
分区镜像文件:oem.img
; - 创建
userdata
分区镜像文件:userdata.img
; - 创建
MiniLoaderAll.bin
链接文件,指向u-boot/rk3588_spl_loader_v1.13.112.bin
; - 创建
uboot.img
链接文件,指向u-boot/uboot.img
; - 创建
boot.img
链接文件,指向kernel/boot.img
; - 创建
recovery.img
链接文件,指向buildroot/output/rockchip_rk3588_recovery/images/recovery.img
; - 创建
rootfs.img
链接文件,指向buildroot/output/rockchip_rk3588/images/rootfs.img
。
查看目录:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll output/firmware/
lrwxrwxrwx 1 root root 21 6月 11 22:52 boot.img -> ../../kernel/boot.img
lrwxrwxrwx 1 root root 44 6月 11 23:00 MiniLoaderAll.bin -> ../../u-boot/rk3588_spl_loader_v1.13.112.bin
-rw-r--r-- 1 root root 49152 6月 11 23:00 misc.img
-rw-r--r-- 1 root root 17457152 6月 11 23:00 oem.img
lrwxrwxrwx 1 root root 49 6月 11 23:00 parameter.txt -> ../../device/rockchip/.chips/rk3588/parameter.txt
lrwxrwxrwx 1 root root 67 6月 11 23:00 recovery.img -> ../../buildroot/output/rockchip_rk3588_recovery/images/recovery.img
lrwxrwxrwx 1 root root 57 6月 11 22:59 rootfs.img -> ../../buildroot/output/rockchip_rk3588/images/rootfs.ext2
lrwxrwxrwx 1 root root 22 6月 11 23:00 uboot.img -> ../../u-boot/uboot.img
lrwxrwxrwx 1 root root 26 6月 11 23:00 update.img -> ../update/Image/update.img
-rw-r--r-- 1 root root 4472832 6月 11 23:00 userdata.img
此外,我们在rockdev
目录下也可看到这些分区镜像;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll rockdev
lrwxrwxrwx 1 root root 15 6月 11 23:00 rockdev -> output/firmware/
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll rockdev/
lrwxrwxrwx 1 root root 21 6月 11 22:52 boot.img -> ../../kernel/boot.img
lrwxrwxrwx 1 root root 44 6月 11 23:00 MiniLoaderAll.bin -> ../../u-boot/rk3588_spl_loader_v1.13.112.bin
-rw-r--r-- 1 root root 49152 6月 11 23:00 misc.img
-rw-r--r-- 1 root root 17457152 6月 11 23:00 oem.img
lrwxrwxrwx 1 root root 49 6月 11 23:00 parameter.txt -> ../../device/rockchip/.chips/rk3588/parameter.txt
lrwxrwxrwx 1 root root 67 6月 11 23:00 recovery.img -> ../../buildroot/output/rockchip_rk3588_recovery/images/recovery.img
lrwxrwxrwx 1 root root 57 6月 11 22:59 rootfs.img -> ../../buildroot/output/rockchip_rk3588/images/rootfs.ext2
lrwxrwxrwx 1 root root 22 6月 11 23:00 uboot.img -> ../../u-boot/uboot.img
lrwxrwxrwx 1 root root 26 6月 11 23:00 update.img -> ../update/Image/update.img
-rw-r--r-- 1 root root 4472832 6月 11 23:00 userdata.img
3.4.7 打包统一固件
打包各个分区镜像生成update.img
;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll output/update/
drwxr-xr-x 2 root root 4096 6月 11 23:00 Image/
lrwxrwxrwx 1 root root 18 6月 11 23:00 package-file -> Image/package-file
lrwxrwxrwx 1 root root 16 6月 11 23:00 update.img -> Image/update.img
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll output/update/Image/
lrwxrwxrwx 1 root root 24 6月 11 23:00 boot.img -> ../../../kernel/boot.img
lrwxrwxrwx 1 root root 47 6月 11 23:00 MiniLoaderAll.bin -> ../../../u-boot/rk3588_spl_loader_v1.13.112.bin
lrwxrwxrwx 1 root root 23 6月 11 23:00 misc.img -> ../../firmware/misc.img
lrwxrwxrwx 1 root root 22 6月 11 23:00 oem.img -> ../../firmware/oem.img
-rw-r--r-- 1 root root 225 6月 11 23:00 package-file
lrwxrwxrwx 1 root root 52 6月 11 23:00 parameter.txt -> ../../../device/rockchip/.chips/rk3588/parameter.txt
lrwxrwxrwx 1 root root 70 6月 11 23:00 recovery.img -> ../../../buildroot/output/rockchip_rk3588_recovery/images/recovery.img
lrwxrwxrwx 1 root root 60 6月 11 23:00 rootfs.img -> ../../../buildroot/output/rockchip_rk3588/images/rootfs.ext2
lrwxrwxrwx 1 root root 25 6月 11 23:00 uboot.img -> ../../../u-boot/uboot.img
-rw-r--r-- 1 root root 872409674 6月 11 23:00 update.img
-rw-r--r-- 1 root root 871938052 6月 11 23:00 update.raw.img
lrwxrwxrwx 1 root root 27 6月 11 23:00 userdata.img -> ../../firmware/userdata.img
如果output/firmware/update.img
文件不存在,会创建output/firmware/update.img
链接文件指向output/update/Image/update.img
。
3.4.8 清理磁盘
因此我们将根文件系统移动到/work/tftproot
文件;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ cp buildroot/output/rockchip_rk3588/images/rootfs.ext2 /work/tftpboot/
该次编译会占用大量磁盘空间(我这里占用了40G+
),导致剩余磁盘空间不充足,因此必要时候可以删除buildroot/output
目录。
3.5 模块编译
3.5.1 U-Boot
编译
编译命令如下:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# ./build.sh uboot
输出详情如下:
点击查看代码
Log saved at /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/sessions/2024-06-16_19-21-59
==========================================
Final configs
==========================================
RK_BOOT_FIT_ITS=boot.its
RK_BOOT_IMG=boot.img
RK_BUILDROOT_CFG=rockchip_rk3588
RK_CHIP=rk3588
RK_CHIP_FAMILY=rk3588
RK_DEBIAN_ARCH=arm64
......
Toolchain for loader (u-boot):
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-
==========================================
Start building uboot
==========================================
+ cd u-boot
+ ./make.sh CROSS_COMPILE=/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu- rk3588
## make rk3588_defconfig -j12
#
# configuration written to .config
#
scripts/kconfig/conf --silentoldconfig Kconfig
CHK include/config.h
CFG u-boot.cfg
......
CAT spl/u-boot-spl-dtb.bin
COPY spl/u-boot-spl.bin
CFGCHK u-boot.cfg
SEC=1
pack u-boot.itb okay! Input: /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/rkbin/RKTRUST/RK3588TRUST.ini
FIT description: FIT Image with ATF/OP-TEE/U-Boot/MCU
Created: Sun Jun 16 19:23:11 2024
Image 0 (uboot)
Description: U-Boot
Created: Sun Jun 16 19:23:11 2024
Type: Standalone Program
Compression: uncompressed
Data Size: 1317128 Bytes = 1286.26 KiB = 1.26 MiB
Architecture: AArch64
Load Address: 0x00200000
Entry Point: unavailable
Hash algo: sha256
Hash value: de3ce33f68a9408cbcdfd582c4455ea803ca5fbc5a4c96d07f7a519c4d110340
Image 1 (atf-1)
Description: ARM Trusted Firmware
Created: Sun Jun 16 19:23:11 2024
Type: Firmware
Compression: uncompressed
Data Size: 200008 Bytes = 195.32 KiB = 0.19 MiB
Architecture: AArch64
Load Address: 0x00040000
Hash algo: sha256
Hash value: c902200be1343fe569e54778c286005b1c6163606664c463a24d787be4376966
Image 2 (atf-2)
Description: ARM Trusted Firmware
Created: Sun Jun 16 19:23:11 2024
Type: Firmware
Compression: uncompressed
Data Size: 24576 Bytes = 24.00 KiB = 0.02 MiB
Architecture: AArch64
Load Address: 0x000f0000
Hash algo: sha256
Hash value: aa71013e72d7ab4be264c1093b155ef06e65d0a263d552be25b13c8ddf285586
Image 3 (atf-3)
Description: ARM Trusted Firmware
Created: Sun Jun 16 19:23:11 2024
Type: Firmware
Compression: uncompressed
Data Size: 24576 Bytes = 24.00 KiB = 0.02 MiB
Architecture: AArch64
Load Address: 0xff100000
Hash algo: sha256
Hash value: 225d6bf0712f850648223365ba06a73ba5f6315fb8a9580f23ab48ece795f91e
Image 4 (optee)
Description: OP-TEE
Created: Sun Jun 16 19:23:11 2024
Type: Firmware
Compression: uncompressed
Data Size: 465304 Bytes = 454.40 KiB = 0.44 MiB
Architecture: AArch64
Load Address: 0x08400000
Hash algo: sha256
Hash value: 66e30bf9e879405a49797aaa6c08ca1c41aa325443e910af42e3df309e65909b
Image 5 (fdt)
Description: U-Boot dtb
Created: Sun Jun 16 19:23:11 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 8141 Bytes = 7.95 KiB = 0.01 MiB
Architecture: AArch64
Hash algo: sha256
Hash value: 8ecccd16d2f12c4f5639c386e51f206eb679638495283d9297497ddfb0aae01a
Default Configuration: 'conf'
Configuration 0 (conf)
Description: rk3588-evb
Kernel: unavailable
Firmware: atf-1
FDT: fdt
Loadables: uboot
atf-2
atf-3
optee
********boot_merger ver 1.31********
Info:Pack loader ok.
pack loader okay! Input: /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/rkbin/RKBOOT/RK3588MINIALL.ini
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/u-boot
Image(no-signed, version=0): uboot.img (FIT with uboot, trust...) is ready
Image(no-signed): rk3588_spl_loader_v1.13.112.bin (with spl, ddr...) is ready
pack uboot.img okay! Input: /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/rkbin/RKTRUST/RK3588TRUST.ini
Platform RK3588 is build OK, with new .config(make rk3588_defconfig -j12)
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-
Sun Jun 16 19:23:11 CST 2024
+ cd ..
Running 70-loader.sh - build_uboot succeeded.
编译生成uboot.img
、MiniLoaderAll.bin
,同时更新rockdev
目录下uboot.img
、MiniLoaderAll.bin
;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll u-boot/uboot.img
-rw-r--r-- 1 root root 4194304 6月 16 19:23 u-boot/uboot.img
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll u-boot/rk3588_spl_loader_v1.13.112.bin
-rw-r--r-- 1 root root 471488 6月 16 19:23 u-boot/rk3588_spl_loader_v1.13.112.bin
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll rockdev/
lrwxrwxrwx 1 root root 21 6月 11 22:52 boot.img -> ../../kernel/boot.img
lrwxrwxrwx 1 root root 44 6月 16 19:23 MiniLoaderAll.bin -> ../../u-boot/rk3588_spl_loader_v1.13.112.bin
-rw-r--r-- 1 root root 49152 6月 11 23:00 misc.img
-rw-r--r-- 1 root root 17457152 6月 11 23:00 oem.img
lrwxrwxrwx 1 root root 49 6月 11 23:00 parameter.txt -> ../../device/rockchip/.chips/rk3588/parameter.txt
lrwxrwxrwx 1 root root 67 6月 11 23:00 recovery.img -> ../../buildroot/output/rockchip_rk3588_recovery/images/recovery.img
lrwxrwxrwx 1 root root 57 6月 11 22:59 rootfs.img -> ../../buildroot/output/rockchip_rk3588/images/rootfs.ext2
lrwxrwxrwx 1 root root 22 6月 16 19:23 uboot.img -> ../../u-boot/uboot.img
lrwxrwxrwx 1 root root 26 6月 11 23:00 update.img -> ../update/Image/update.img
-rw-r--r-- 1 root root 4472832 6月 11 23:00 userdata.img
3.5.2 Kernel
编译
编译命令如下:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp#./build.sh kernel
输出详情如下:
点击查看代码
Log saved at /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/sessions/2024-06-16_19-27-50
==========================================
Final configs
==========================================
RK_BOOT_FIT_ITS=boot.its
RK_BOOT_IMG=boot.img
RK_BUILDROOT_CFG=rockchip_rk3588
RK_CHIP=rk3588
RK_CHIP_FAMILY=rk3588
RK_DEBIAN_ARCH=arm64
RK_DEBIAN_ARM64=y
......
==========================================
Start building kernel
==========================================
+ make -C /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/kernel/ -j7 CROSS_COMPILE=/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu- ARCH=arm64 rockchip_linux_defconfig rk3588_linux.config
make: Entering directory '/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/kernel'
#
# No change to .config
#
Using .config as base
Merging ./arch/arm64/configs/rk3588_linux.config
#
# merged configuration written to .config (needs make)
#
#
# configuration written to .config
#
make: Leaving directory '/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/kernel'
+ make -C /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/kernel/ -j7 CROSS_COMPILE=/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu- ARCH=arm64 rk3588-armsom-sige7.img
......
Image: zboot.img (with Image.lz4 resource.img) is ready
make: Leaving directory '/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/kernel'
+ /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/device/rockchip/common/scripts/mk-fitimage.sh kernel/boot.img boot.its kernel/arch/arm64/boot/Image
FIT description: U-Boot FIT source file for arm
Created: Sun Jun 16 19:28:28 2024
Image 0 (fdt)
Description: unavailable
Created: Sun Jun 16 19:28:28 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 276878 Bytes = 270.39 KiB = 0.26 MiB
Architecture: AArch64
Load Address: 0xffffff00
Hash algo: sha256
Hash value: 2e1efecb7de8f6d6f6dc99aceac3316169528dbe2343075acbc97c676863a54a
Image 1 (kernel)
Description: unavailable
Created: Sun Jun 16 19:28:28 2024
Type: Kernel Image
Compression: uncompressed
Data Size: 35650048 Bytes = 34814.50 KiB = 34.00 MiB
Architecture: AArch64
OS: Linux
Load Address: 0xffffff01
Entry Point: 0xffffff01
Hash algo: sha256
Hash value: 75156ece8874de3e407e006dc1cc4b471fccbb3d192a7f57b9aeb85419d34445
Image 2 (resource)
Description: unavailable
Created: Sun Jun 16 19:28:28 2024
Type: Multi-File Image
Compression: uncompressed
Data Size: 1692160 Bytes = 1652.50 KiB = 1.61 MiB
Hash algo: sha256
Hash value: 35f3f91ac5fc2bbcfc9e9922ead7f9df34d9a5b31be32cb144a9366852fc514c
Default Configuration: 'conf'
Configuration 0 (conf)
Description: unavailable
Kernel: kernel
FDT: fdt
Not Found io-domains in kernel/arch/arm64/boot/dts/rockchip/rk3588-armsom-sige7.dts
Running 10-kernel.sh - build_kernel succeeded.
编译生成boot.img
,同时更新rockdev
目录下boot.img
;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll kernel/boot.img
-rw-r--r-- 1 root root 37622272 6月 16 19:28 kernel/boot.img
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll rockdev/
lrwxrwxrwx 1 root root 21 6月 16 19:28 boot.img -> ../../kernel/boot.img
lrwxrwxrwx 1 root root 44 6月 16 19:23 MiniLoaderAll.bin -> ../../u-boot/rk3588_spl_loader_v1.13.112.bin
-rw-r--r-- 1 root root 49152 6月 11 23:00 misc.img
-rw-r--r-- 1 root root 17457152 6月 11 23:00 oem.img
lrwxrwxrwx 1 root root 49 6月 11 23:00 parameter.txt -> ../../device/rockchip/.chips/rk3588/parameter.txt
lrwxrwxrwx 1 root root 67 6月 11 23:00 recovery.img -> ../../buildroot/output/rockchip_rk3588_recovery/images/recovery.img
lrwxrwxrwx 1 root root 57 6月 11 22:59 rootfs.img -> ../../buildroot/output/rockchip_rk3588/images/rootfs.ext2
lrwxrwxrwx 1 root root 22 6月 16 19:23 uboot.img -> ../../u-boot/uboot.img
lrwxrwxrwx 1 root root 26 6月 11 23:00 update.img -> ../update/Image/update.img
-rw-r--r-- 1 root root 4472832 6月 11 23:00 userdata.img
3.5.3 Recovery
编译
编译命令如下:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp#./build.sh recovery
输出详情如下:
点击查看代码
Log saved at /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/sessions/2024-06-16_19-45-21
==========================================
Final configs
==========================================
RK_BOOT_FIT_ITS=boot.its
RK_BOOT_IMG=boot.img
RK_BUILDROOT_CFG=rockchip_rk3588
RK_CHIP=rk3588
RK_CHIP_FAMILY=rk3588
RK_DEBIAN_ARCH=arm64
RK_DEBIAN_ARM64=y
......
RK_YOCTO_USBMOUNT=y
==========================================
Start building recovery(buildroot)
==========================================
make: Entering directory '/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot'
GEN /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588_recovery/Makefile
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/build/parse_defconfig.sh /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/configs/rockchip_rk3588_recovery_defconfig /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588_recovery/.config.in
Parsing defconfig: /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/configs/rockchip_rk3588_recovery_defconfig
Using configs/rockchip/base/kernel.config as base
Merging configs/rockchip/fs/e2fs.config
Merging configs/rockchip/base/common.config
Merging configs/rockchip/base/base.config
Merging configs/rockchip/base/kernel.config
Merging configs/rockchip/fs/e2fs.config
Merging configs/rockchip/base/common.config
Merging configs/rockchip/fs/vfat.config
Merging configs/rockchip/base/recovery.config
Merging configs/rockchip/chips/rk3588.config
Value of BR2_ROOTFS_OVERLAY is redefined by configs/rockchip/chips/rk3588.config:
Previous value: BR2_ROOTFS_OVERLAY="board/rockchip/common/base"
Modify value: BR2_ROOTFS_OVERLAY+="board/rockchip/rk3588/fs-overlay/"
New value: BR2_ROOTFS_OVERLAY="board/rockchip/common/base board/rockchip/rk3588/fs-overlay/"
Merging configs/rockchip/chips/rk3588_aarch64.config
Merging /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/configs/rockchip_rk3588_recovery_defconfig
#
# merged configuration written to /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588_recovery/.config.in (needs make)
#
BR2_DEFCONFIG='' KCONFIG_AUTOCONFIG=/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588_recovery/build/buildroot-config/auto.conf KCONFIG_AUTOHEADER=/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588_recovery/build/buildroot-config/autoconf.h KCONFIG_TRISTATE=/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588_recovery/build/buildroot-config/tristate.config BR2_CONFIG=/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588_recovery/.config HOST_GCC_VERSION="9" BASE_DIR=/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588_recovery SKIP_LEGACY= CUSTOM_KERNEL_VERSION="5.10" BR2_DEFCONFIG=/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/configs/rockchip_rk3588_recovery_defconfig /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588_recovery/build/buildroot-config/conf --defconfig=/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588_recovery/.config.in Config.in
#
# configuration written to /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588_recovery/.config
#
make: Leaving directory '/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot'
3c3
< # Buildroot -g28f720bc5-dirty Configuration
---
> # Buildroot -g2d3236bd2-dirty Configuration
Buildroot config changed!
You might need to clean it before building:
rm -rf /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/buildroot/output/rockchip_rk3588_recovery
2024-06-16T19:45:36 >>> Finalizing host directory
2024-06-16T19:45:36 >>> Finalizing target directory
2024-06-16T19:45:38 >>> Sanitizing RPATH in target tree
2024-06-16T19:45:39 >>> Sanity check in overlay board/rockchip/common/base
2024-06-16T19:45:39 >>> Sanity check in overlay board/rockchip/rk3588/fs-overlay/
2024-06-16T19:45:39 >>> Copying overlay board/rockchip/common/base
2024-06-16T19:45:39 >>> Copying overlay board/rockchip/rk3588/fs-overlay/
2024-06-16T19:45:40 >>> Executing post-build script board/rockchip/common/post-build.sh
2024-06-16T19:45:41 >>> Generating root filesystems common tables
2024-06-16T19:45:41 >>> Generating filesystem image rootfs.cpio
2024-06-16T19:45:44 >>> Generating filesystem image rootfs.ext2
2024-06-16T19:45:45 >>> Generating filesystem image rootfs.squashfs
2024-06-16T19:45:45 >>> Generating filesystem image rootfs.tar
Done in 20s
Log saved on /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/sessions/2024-06-16_19-45-21/br-rockchip_rk3588_recovery_2024-06-16_19-45-26.log
Generated images:
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/recovery/rootfs.cpio
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/recovery/rootfs.cpio.gz
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/recovery/rootfs.ext2
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/recovery/rootfs.ext4
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/recovery/rootfs.squashfs
/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/recovery/rootfs.tar
you take 0:23.86 to build recovery(buildroot)
Packing /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/recovery/rootfs.cpio.gz to /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/recovery/recovery.img
FIT description: U-Boot FIT source file for arm
Created: Sun Jun 16 19:45:46 2024
Image 0 (fdt)
Description: unavailable
Created: Sun Jun 16 19:45:46 2024
Type: Flat Device Tree
Compression: uncompressed
Data Size: 276878 Bytes = 270.39 KiB = 0.26 MiB
Architecture: AArch64
Load Address: 0xffffff00
Hash algo: sha256
Hash value: 2e1efecb7de8f6d6f6dc99aceac3316169528dbe2343075acbc97c676863a54a
Image 1 (kernel)
Description: unavailable
Created: Sun Jun 16 19:45:46 2024
Type: Kernel Image
Compression: uncompressed
Data Size: 35650048 Bytes = 34814.50 KiB = 34.00 MiB
Architecture: AArch64
OS: Linux
Load Address: 0xffffff01
Entry Point: 0xffffff01
Hash algo: sha256
Hash value: 75156ece8874de3e407e006dc1cc4b471fccbb3d192a7f57b9aeb85419d34445
Image 2 (ramdisk)
Description: unavailable
Created: Sun Jun 16 19:45:46 2024
Type: RAMDisk Image
Compression: uncompressed
Data Size: 6673191 Bytes = 6516.79 KiB = 6.36 MiB
Architecture: AArch64
OS: Linux
Load Address: 0xffffff02
Entry Point: unavailable
Hash algo: sha256
Hash value: efbbfccf3445edd16363ee75449e13cabf19c48910354004f788878afb628d25
Image 3 (resource)
Description: unavailable
Created: Sun Jun 16 19:45:46 2024
Type: Multi-File Image
Compression: uncompressed
Data Size: 1692160 Bytes = 1652.50 KiB = 1.61 MiB
Hash algo: sha256
Hash value: 35f3f91ac5fc2bbcfc9e9922ead7f9df34d9a5b31be32cb144a9366852fc514c
Default Configuration: 'conf'
Configuration 0 (conf)
Description: unavailable
Kernel: kernel
Init Ramdisk: ramdisk
FDT: fdt
you take 0:00.60 to pack recovery image
Running 40-recovery.sh - build_recovery succeeded.
编译后在buildroot/output/rockchip_rk3588_recovery/images/
生成recovery.img
;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll buildroot/output/rockchip_rk3588_recovery/images/
-rw-r--r-- 1 root root 44295680 6月 16 19:45 recovery.img
-rw-r--r-- 1 root root 15763968 6月 16 19:45 rootfs.cpio
-rw-r--r-- 1 root root 6673191 6月 16 19:45 rootfs.cpio.gz
-rw-r--r-- 1 root root 43187200 6月 16 19:45 rootfs.ext2
lrwxrwxrwx 1 root root 11 6月 16 19:45 rootfs.ext4 -> rootfs.ext2
-rw-r--r-- 1 root root 6635520 6月 16 19:45 rootfs.squashfs
-rw-r--r-- 1 root root 16844800 6月 16 19:45 rootfs.tar
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll rockdev/
lrwxrwxrwx 1 root root 21 6月 16 19:28 boot.img -> ../../kernel/boot.img
lrwxrwxrwx 1 root root 44 6月 16 19:23 MiniLoaderAll.bin -> ../../u-boot/rk3588_spl_loader_v1.13.112.bin
-rw-r--r-- 1 root root 49152 6月 11 23:00 misc.img
-rw-r--r-- 1 root root 17457152 6月 11 23:00 oem.img
lrwxrwxrwx 1 root root 49 6月 11 23:00 parameter.txt -> ../../device/rockchip/.chips/rk3588/parameter.txt
lrwxrwxrwx 1 root root 67 6月 16 19:45 recovery.img -> ../../buildroot/output/rockchip_rk3588_recovery/images/recovery.img
lrwxrwxrwx 1 root root 57 6月 11 22:59 rootfs.img -> ../../buildroot/output/rockchip_rk3588/images/rootfs.ext2
lrwxrwxrwx 1 root root 22 6月 16 19:23 uboot.img -> ../../u-boot/uboot.img
lrwxrwxrwx 1 root root 26 6月 11 23:00 update.img -> ../update/Image/update.img
-rw-r--r-- 1 root root 4472832 6月 11 23:00 userdata.img
注意:recovery.img
是由kernel+dtb+ramdisk
组成的根文件系统,主要用于升级操作。因此所以每次kernel
更改,recovery.img
是需要重新打包生成。
recovery
重新打包的方法如下:
source buildroot/envsetup.sh
cd buildroot
make recovery-reconfigure
cd -
./build.sh recovery
注意:recovery
是非必需的功能。
3.5.4 Buildroot
编译
执行以下命令自动完成Buildroot
的编译及打包:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# ./build.sh buildroot
编译后在buildroot/output/rockchip_rk3588/images
下生成不同格式的镜像, 默认使用rootfs.ext4
格式。
由于全自动编译默认系统就是Buildroot
,这里我就不重新编译了;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll buildroot/output/rockchip_rk3588/images/
-rw-r--r-- 1 root root 615713280 6月 11 22:58 rootfs.cpio
-rw-r--r-- 1 root root 273882955 6月 11 22:59 rootfs.cpio.gz
-rw-r--r-- 1 root root 763363328 6月 11 22:59 rootfs.ext2
lrwxrwxrwx 1 root root 11 6月 11 22:59 rootfs.ext4 -> rootfs.ext2
-rw-r--r-- 1 root root 275013632 6月 11 22:59 rootfs.squashfs
-rw-r--r-- 1 root root 624517120 6月 11 22:59 rootfs.tar
其中:rockdev/
目录下的rootfs.img
指向了buildroot/output/rockchip_rk3588/images/rootfs.ext2
。
3.5.5 Debian
编译
需要预先安装以下相关依赖包:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# cd debian
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# sudo apt install binfmt-support qemu-user-static live-build
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# sudo dpkg -i ubuntu-build-service/packages/*
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# sudo apt install -f
执行以下命令自动完成Debian
的编译及打包:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# ./build.sh debian
输出详情如下:
点击查看代码
Log saved at /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/sessions/2024-06-16_19-48-51
WARN: /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/defconfig not exists
Pick a defconfig:
1. rockchip_defconfig
2. rockchip_rk3588_evb1_lp4_v10_defconfig
3. rockchip_rk3588_evb7_v11_defconfig
4. rockchip_rk3588_sige7_defconfig
5. rockchip_rk3588s_evb1_lp4x_v10_defconfig
Which would you like? [1]: 4
Switching to defconfig: /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/device/rockchip/.chip/rockchip_rk3588_sige7_defconfig
make: Entering directory '/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/device/rockchip/common'
......
make: Leaving directory '/work/sambashare/rk3588/armsom/armsom-rk3588-bsp/device/rockchip/common'
Using rootfs system(debian) from cmdline
==========================================
Final configs
==========================================
RK_BOOT_FIT_ITS=boot.its
RK_BOOT_IMG=boot.img
RK_BUILDROOT_CFG=rockchip_rk3588
RK_CHIP=rk3588
RK_CHIP_FAMILY=rk3588
RK_DEBIAN_ARCH=arm64
RK_DEBIAN_ARM64=y
RK_DEBIAN_VERSION=bullseye
......
==========================================
Start building rootfs(debian)
==========================================
==========================================
Start building bullseye(arm64)
==========================================
Staring Download......
sudo lb clean --purge
[2024-06-16 19:49:07] lb clean --purge
P: Cleaning chroot
rm -f linaro-bullseye-alip-*
rm -rf config
I: create configuration
.......
Fixing up owner for /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/debian/binary...
Fixing up /home/armsom for uid=1000(armsom)...
Running build.sh - post-rootfs succeeded.
mke2fs 1.46.5 (30-Dec-2021)
Creating regular file linaro-rootfs.img
Creating filesystem with 808960 4k blocks and 202400 inodes
Filesystem UUID: c93a2c93-553d-44d8-aa57-dddb8c8a33e8
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Copying files into the device: done
Writing superblocks and filesystem accounting information: done
Rootfs Image: linaro-rootfs.img
Running 30-rootfs.sh - build_debian /work/sambashare/rk3588/armsom/armsom-rk3588-bsp/output/rootfs succeeded.
Running 30-rootfs.sh - build_rootfs debian succeeded.
该次编译会重新编译内核和根文件系统。耐心等待1个小时,与buildroot
编译类似,编译完成我们在rockdev
目录下可以看到各个分区镜像;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll rockdev/
lrwxrwxrwx 1 root root 21 6月 16 19:28 boot.img -> ../../kernel/boot.img
lrwxrwxrwx 1 root root 44 6月 16 19:35 MiniLoaderAll.bin -> ../../u-boot/rk3588_spl_loader_v1.13.112.bin
-rw-r--r-- 1 root root 49152 6月 11 23:00 misc.img
-rw-r--r-- 1 root root 17457152 6月 11 23:00 oem.img
lrwxrwxrwx 1 root root 49 6月 11 23:00 parameter.txt -> ../../device/rockchip/.chips/rk3588/parameter.txt
lrwxrwxrwx 1 root root 67 6月 16 19:45 recovery.img -> ../../buildroot/output/rockchip_rk3588_recovery/images/recovery.img
lrwxrwxrwx 1 root root 30 6月 16 19:59 rootfs.img -> ../../debian/linaro-rootfs.img
lrwxrwxrwx 1 root root 22 6月 16 19:35 uboot.img -> ../../u-boot/uboot.img
lrwxrwxrwx 1 root root 26 6月 11 23:00 update.img -> ../update/Image/update.img
-rw-r--r-- 1 root root 4472832 6月 11 23:00 userdata.img
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll debian/
drwxr-xr-x 22 root root 4096 6月 9 12:58 binary/
-rw-rw-rw- 1 root root 579714760 6月 16 13:24 linaro-bullseye-alip-20240616-1.tar.gz
lrwxrwxrwx 1 root root 38 6月 16 13:26 linaro-bullseye-arm64.tar.gz -> linaro-bullseye-alip-20240616-1.tar.gz
-rw-r--r-- 1 root root 3362783232 6月 16 19:59 linaro-rootfs.img
-rwxr-xr-x 1 root root 955 6月 9 12:58 mk-base-debian.sh*
-rwxr-xr-x 1 root root 526 6月 9 12:58 mk-image.sh*
-rwxr-xr-x 1 root root 4554 6月 9 12:58 mk-iso-debian.sh*
-rwxr-xr-x 1 root root 7358 6月 11 22:36 mk-rootfs-bullseye.sh*
-rwxr-xr-x 1 root root 87 6月 9 12:58 mk-rootfs.sh*
drwxr-xr-x 4 root root 4096 6月 9 12:58 overlay/
drwxr-xr-x 5 root root 4096 6月 9 12:58 overlay-debug/
drwxr-xr-x 3 root root 4096 6月 9 12:58 overlay-firmware/
drwxr-xr-x 4 root root 4096 6月 9 12:58 packages/
drwxr-xr-x 7 root root 4096 6月 9 12:58 packages-patches/
-rwxr-xr-x 1 root root 2483 6月 9 12:58 post-build.sh*
-rw-r--r-- 1 root root 2373 6月 9 12:58 readme.md
drwxr-xr-x 4 root root 4096 6月 9 12:58 scripts/
drwxr-xr-x 11 root root 4096 6月 9 12:58 ubuntu-build-service/
可以看到该次编译重新生成了boot.img
、rootfs.img
。此外由于我们执行了./build.sh debian
,此时output/.config
中默认系统已经设置为了debian
。
编译完成会在debian
目录下生成:linaro-buster-alip-xxxxx-1.tar.gz
(xxxxx
表示生成时间戳)。
因此我们将debian
根文件系统移动到/work/tftproot
文件;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ mv debian/linaro-rootfs.img /work/tftpboot/
3.5.6 Yocto
编译
执行以下命令自动完成Yocto
的编译及打包:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# ./build.sh yocto
编译后在yocto
目录build/lastest
下生成rootfs.img
。
3.5.7 打包分区镜像
执行以下命令更新output/firmware/
下各个分区镜像;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ./build.sh firmware
查看目录:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll rockdev/
lrwxrwxrwx 1 root root 21 6月 16 19:28 boot.img -> ../../kernel/boot.img
lrwxrwxrwx 1 root root 44 6月 16 19:35 MiniLoaderAll.bin -> ../../u-boot/rk3588_spl_loader_v1.13.112.bin
-rw-r--r-- 1 root root 49152 6月 16 21:13 misc.img
-rw-r--r-- 1 root root 21651456 6月 16 21:13 oem.img
lrwxrwxrwx 1 root root 49 6月 16 21:13 parameter.txt -> ../../device/rockchip/.chips/rk3588/parameter.txt
lrwxrwxrwx 1 root root 67 6月 16 19:45 recovery.img -> ../../buildroot/output/rockchip_rk3588_recovery/images/recovery.img
lrwxrwxrwx 1 root root 30 6月 16 19:59 rootfs.img -> ../../debian/linaro-rootfs.img
lrwxrwxrwx 1 root root 22 6月 16 19:35 uboot.img -> ../../u-boot/uboot.img
lrwxrwxrwx 1 root root 26 6月 11 23:00 update.img -> ../update/Image/update.img
-rw-r--r-- 1 root root 4472832 6月 16 21:13 userdata.img
可以看到该次编译重新生成了: parameter.txt
、 misc.img
、 oem.img
、 userdata.img
。
3.5.8 打包统一固件
执行如下命令重新生成统一固件;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ./build.sh updateimg
查看目录:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll rockdev/
lrwxrwxrwx 1 root root 21 6月 16 19:28 boot.img -> ../../kernel/boot.img
lrwxrwxrwx 1 root root 44 6月 16 19:35 MiniLoaderAll.bin -> ../../u-boot/rk3588_spl_loader_v1.13.112.bin
-rw-r--r-- 1 root root 49152 6月 16 21:13 misc.img
-rw-r--r-- 1 root root 21651456 6月 16 21:13 oem.img
lrwxrwxrwx 1 root root 49 6月 16 21:13 parameter.txt -> ../../device/rockchip/.chips/rk3588/parameter.txt
lrwxrwxrwx 1 root root 67 6月 16 19:45 recovery.img -> ../../buildroot/output/rockchip_rk3588_recovery/images/recovery.img
lrwxrwxrwx 1 root root 30 6月 16 19:59 rootfs.img -> ../../debian/linaro-rootfs.img
lrwxrwxrwx 1 root root 22 6月 16 19:35 uboot.img -> ../../u-boot/uboot.img
lrwxrwxrwx 1 root root 26 6月 16 21:20 update.img -> ../update/Image/update.img
-rw-r--r-- 1 root root 4472832 6月 16 21:13 userdata.img
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ls -l output/update/
drwxr-xr-x 2 root root 4096 6月 16 21:19 Image
lrwxrwxrwx 1 root root 18 6月 16 21:20 package-file -> Image/package-file
lrwxrwxrwx 1 root root 16 6月 16 21:20 update.img -> Image/update.img
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll output/update/Image/
lrwxrwxrwx 1 root root 24 6月 16 21:18 boot.img -> ../../../kernel/boot.img
lrwxrwxrwx 1 root root 47 6月 16 21:18 MiniLoaderAll.bin -> ../../../u-boot/rk3588_spl_loader_v1.13.112.bin
lrwxrwxrwx 1 root root 23 6月 16 21:18 misc.img -> ../../firmware/misc.img
lrwxrwxrwx 1 root root 22 6月 16 21:18 oem.img -> ../../firmware/oem.img
-rw-r--r-- 1 root root 225 6月 16 21:18 package-file
lrwxrwxrwx 1 root root 52 6月 16 21:18 parameter.txt -> ../../../device/rockchip/.chips/rk3588/parameter.txt
lrwxrwxrwx 1 root root 70 6月 16 21:18 recovery.img -> ../../../buildroot/output/rockchip_rk3588_recovery/images/recovery.img
lrwxrwxrwx 1 root root 33 6月 16 21:18 rootfs.img -> ../../../debian/linaro-rootfs.img
lrwxrwxrwx 1 root root 25 6月 16 21:18 uboot.img -> ../../../u-boot/uboot.img
-rw-r--r-- 1 root root 3480216138 6月 16 21:20 update.img
-rw-r--r-- 1 root root 3479744516 6月 16 21:19 update.raw.img
lrwxrwxrwx 1 root root 27 6月 16 21:18 userdata.img -> ../../firmware/userdata.img
可以看到该次编译重新生成了: update.img
。
四、SDK
固件升级
RK3588
有两种工作模式,
工作模式 | Normal 模式 | 升级模式 |
---|---|---|
启动介质 | eMMC 接口/SDMMC 接口 | |
描述 | Normal 模式就是正常的启动过程, 各个组件依次加载,正常进入系统。 | 目前支持3种升级模式,各有优缺点: 1. Maskrom升级模式 2. Loader 升级模式 3. SD 升级模式 |
一般情况下,开机直接进入Normal模式正常启动系统。
其中升级模式中,不同升级模式之间的对比:
升级模式 | Maskrom升级模式 | Loader 升级模式 | SD 升级模式 |
---|---|---|---|
简单描述 | 1. 使用USB线将主板连接到电脑上; 2. 硬件操作使板子进入升级模式; 3. 在PC上使用USB升级单板固件。 |
1. 使用USB线将主板连接到电脑上; 2. 软件或按键操作使板子进入升级模式; 3. 在PC上使用USB升级单板固件。 |
1. 通过升级卡制作工具,将MicroSD卡制作为升级卡; 2. 将升级卡插入主板,上电开机,机器自动执行升级。 |
连接方式 | USB | USB | TF卡(少数为SD卡槽) |
升级工具 Windows PC Linux PC | Windows 上升级固件 Linux 上升级固件 |
Windows 上升级固件 Linux 上升级固件 |
Windows 上制作升级卡 不支持 |
进入方法 | 需要硬件操作 | 按键或软件进入(在串口或 ADB 命令行模式下,输入 reboot loader 命令) | 上电直接进入 |
使用条件 | 硬件操作进入 | 能正常使用uboot | 无 |
使用场景推荐 | 1. 当板子无法正常启动时候; 2. 在切换烧写Linux和Android固件的情况下。 |
1. 有完整uboot或能正常进入系统; 2. 需要单独烧写分区(uboot或boot分区等)。 |
1. 工人操作方便,适合产品批量生产时候; 2. 产品定型后升级,方便最终客户操作。 |
优点 | 1. 最基本的烧写方式; 2. 非固件和硬件问题,一般都能成功烧写; 3. 不需要uboot支持,拯救变砖的单板; 4. 支持跨系统升级(Linux和安卓等)。 |
1. 烧写效果Maskrom升级模式差不多; 2. 能单独烧写分区; 3. 进入Loader模式方便。 |
1. 操作方便,只需插卡启动; 2.集合了Maskrom升级模式的优点。 |
缺点 | 1. 进入方式麻烦,不适难拆除外壳的产品; 2. 烧写分区表麻烦,较难单独烧写分区; 3. 需要完全擦除设备再烧写。 |
1. 需要完整的Loader(通常指uboot); 2. 跨系统升级需要完全擦除设备再烧写。 |
1. 需要合成完整固件。 |
4.1 Windows
刷机
Winodws
刷机我们有两种方式:
- 采用
SD
升级模式: RKDevTool
烧写固件到eMMC
;
4.1.1 SD
卡升级模式
这里我们就采用SD
升级模式来将我们全自动编译的镜像文件烧录到eMMC
,具体可以参考《若固件大于4G
的SD
升级卡制作教程》。
(1) 准备工作:
- 烧写工具下载:将
tools/windows
目录下的SDDiskTool_v1.76.zip
工具上传到Windows
系统,并进行解压; - 下载需要升级的统一固件:将
buildroot
系统统一镜像rockdev/update.img
上传到Windows
系统; - 将
MicroSD
通过读卡器插入PC
; - 将开发板连接到
HDMI
显示屏;
(2) 以管理员身份运行SD_Firmware_Tool.exe
,勾选固件升级框,选择正确的可移动磁盘设备和升级固件;
(3) 点击开始创建之后,等待创建结束;烧录完成后,可以查看MicroSD
的内容:
(4) 取出MicroSD
卡,插入开发板的MicroSD
卡插槽,对主板上电开机,主板自动开始升级。
注意:由于我们无法可视化查看升级进度,因此此处需要耐心等待3分钟。
(5) 升级完成后,取出MicroSD
卡,开发板自动重启,显示屏显示如下;
关于buildroot
系统简单测试可以参考后续《Rockchip RK3588 - Rockchip Linux SDK Buildroot
文件系统构建》。
4.1.2 RKDevTool
烧写固件到eMMC
SDK
提供Windows
烧写工具(RKDevTool
工具版本需要V3.15
或以上),工具位于工程根目录:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll tools/windows/
-rwxr-xr-x 1 root root 7080412 6月 9 12:59 boot_merger_v1.32.zip*
-rwxr-xr-x 1 root root 27440555 6月 9 12:59 DDR_UserTool_v1.41.zip*
-rwxr-xr-x 1 root root 9814896 6月 9 12:59 DriverAssitant_v5.12.zip*
-rwxr-xr-x 1 root root 731921 6月 9 12:59 EfuseTool_v1.42.zip*
-rw-r--r-- 1 root root 1793777 6月 9 12:59 FactoryTool_v1.81.zip
-rwxr-xr-x 1 root root 19443215 6月 9 12:59 ParameterTool_v1.2.zip*
-rw-r--r-- 1 root root 50668825 6月 9 12:59 pin_debug_tool_v1.12_20230310_win.zip
-rw-r--r-- 1 root root 380719 6月 9 12:59 programmer_image_tool_v1.26.zip
-rwxr-xr-x 1 root root 59731296 6月 9 12:59 rk_ddrbin_tool_V1.01.7z*
drwxr-xr-x 2 root root 4096 6月 9 12:59 RKDevInfoWriteTool/
-rwxr-xr-x 1 root root 3140313 6月 9 12:59 RKDevInfoWriteTool-1.3.0.7z*
drwxr-xr-x 4 root root 4096 6月 9 12:59 RKDevTool/
-rw-r--r-- 1 root root 2433639 6月 9 12:59 RKDevTool_Release_v3.19.zip
-rwxr-xr-x 1 root root 4181454 6月 9 12:59 RKImageMaker_20230109.zip*
-rwxr-xr-x 1 root root 4164049 6月 9 12:59 RKPCBATool_V1.0.9.zip*
-rwxr-xr-x 1 root root 26104417 6月 9 12:59 rk_sign_tool_v1.42.zip*
-rwxr-xr-x 1 root root 4334042 6月 9 12:59 Rockchip_HdcpKey_Writer_V1.0.5.7z*
drwxr-xr-x 2 root root 4096 6月 9 12:59 Rockchip_USB_SQ_Tool/
-rwxr-xr-x 1 root root 17253972 6月 9 12:59 Rockchip_USB_SQ_Tool_V1.5.7z*
-rw-r--r-- 1 root root 331802 6月 9 12:59 SDDiskTool_v1.76.zip
-rwxr-xr-x 1 root root 3011296 6月 9 12:59 SecureBootTool_v2.2.zip*
-rwxr-xr-x 1 root root 1089 6月 9 12:59 ToolsRelease.txt*
-rw-r--r-- 1 root root 676148 6月 9 12:59 upgrade_tool_v2.23.zip
该方式我们在前面的文章中已经介绍了,具体可以参考《Rockchip RK3588 - NanoPC-T6
开发板介绍》第2.3
节。
4.2 Linux
刷机
Linux
下的烧写工具位于tools/linux
目录下(Linux_Upgrade_Tool
工具版本需要V2.17
或以上),请确认你
的板子连接到Maskrom/Loader rockusb
;
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll tools/linux/
drwxr-xr-x 2 root root 4096 6月 9 12:59 boot_merger/
drwxr-xr-x 2 root root 4096 6月 9 12:59 Firmware_Merger/
drwxr-xr-x 2 root root 4096 6月 9 12:59 Linux_DDR_Bandwidth_Tool/
drwxr-xr-x 2 root root 4096 6月 9 12:59 Linux_Diff_Firmware/
drwxr-xr-x 3 root root 4096 6月 9 12:59 Linux_Pack_Firmware/
drwxr-xr-x 2 root root 4096 6月 9 12:59 Linux_SecureBoot/
drwxr-xr-x 4 root root 4096 6月 9 12:59 Linux_SecurityAVB/
-rw-r--r-- 1 root root 5393885 6月 9 12:59 Linux_SecurityDM_v1_01.tar.gz
drwxr-xr-x 3 root root 4096 6月 9 12:59 Linux_Upgrade_Tool/
drwxr-xr-x 2 root root 4096 6月 9 12:59 PinDebug/
drwxr-xr-x 2 root root 4096 6月 9 12:59 programming_image_tool/
-rw-r--r-- 1 root root 81801567 6月 9 12:59 rk_ddrbin_tool_V1.01.7z
drwxr-xr-x 3 root root 4096 6月 9 12:59 rk_sign_tool/
-rwxr-xr-x 1 root root 22457713 6月 9 12:59 rk_sign_tool_v1.42_linux.zip*
-rwxr-xr-x 1 root root 794 6月 9 12:59 ToolsRelease.txt*
比如buildroot
系统编译生成的固件在rockdev
目录下:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ll rockdev/
lrwxrwxrwx 1 root root 21 6月 11 22:52 boot.img -> ../../kernel/boot.img
lrwxrwxrwx 1 root root 44 6月 11 23:00 MiniLoaderAll.bin -> ../../u-boot/rk3588_spl_loader_v1.13.112.bin
-rw-r--r-- 1 root root 49152 6月 11 23:00 misc.img
-rw-r--r-- 1 root root 17457152 6月 11 23:00 oem.img
lrwxrwxrwx 1 root root 49 6月 11 23:00 parameter.txt -> ../../device/rockchip/.chips/rk3588/parameter.txt
lrwxrwxrwx 1 root root 67 6月 11 23:00 recovery.img -> ../../buildroot/output/rockchip_rk3588_recovery/images/recovery.img
lrwxrwxrwx 1 root root 57 6月 11 22:59 rootfs.img -> ../../buildroot/output/rockchip_rk3588/images/rootfs.ext2
lrwxrwxrwx 1 root root 22 6月 11 23:00 uboot.img -> ../../u-boot/uboot.img
lrwxrwxrwx 1 root root 26 6月 11 23:00 update.img -> ../update/Image/update.img
-rw-r--r-- 1 root root 4472832 6月 11 23:00 userdata.img
升级命令如下:
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ ./rkflash.sh
这里rkflash.sh
脚本实际上就是使用upgrade_tool
命令烧写各个分区,比如核心脚本:
if [ ! -n "$1" ];then
echo "flash all images as default"
FLASH_TYPE=all
else
FLASH_TYPE="$1"
fi
if [ $FLASH_TYPE = all ]
then
$UPGRADETOOL ul -noreset $LOADER
$UPGRADETOOL di -p $PARAMETER
$UPGRADETOOL di -uboot $UBOOT
$UPGRADETOOL di -trust $TRUST
$UPGRADETOOL di -b $BOOT
$UPGRADETOOL di -r $RECOVERY
$UPGRADETOOL di -m $MISC
$UPGRADETOOL di -oem $OEM
$UPGRADETOOL di -userdata $USERDATA
$UPGRADETOOL di -rootfs $ROOTFS
$UPGRADETOOL rd
fi
当然也可以直接使用upgrade_tool
命令一一烧写各个分区镜像或者打包后完整的固件,具体操作可以参考:《Linux
下烧录固件》。
4.3 系统分区介绍
parameter.txt
保存着分区信息:
FIRMWARE_VER: 1.0
MACHINE_MODEL: RK3588
MACHINE_ID: 007
MANUFACTURER: RK3588
MAGIC: 0x5041524B
ATAG: 0x00200800
MACHINE: 0xffffffff
CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1
TYPE: GPT
GROW_ALIGN: 0
CMDLINE: mtdparts=:0x00002000@0x00004000(uboot),0x00002000@0x00006000(misc),0x00020000@0x00008000(boot),0x00040000@0x00028000(recovery),0x00010000@0x00068000(backup),0x01c00000@0x00078000(rootfs),0x00040000@0x01c78000(oem),-@0x01cb8000(userdata:grow)
uuid:rootfs=614e0000-0000-4b53-8000-1d28000054a9
uuid:boot=7A3F0000-0000-446A-8000-702F00006273
解析信息如下:
Number | Start (sector) | Start (sector) End (sector) | Size | Name |
---|---|---|---|---|
1 | 0x4000(16384) | 0x5FFF(24575) | 4M | uboot |
2 | 0x6000(24576) | 0x7FFF(32767) | 4M | misc |
3 | 0x8000(32768) | 0x27FFF(163839) | 64M | boot |
4 | 0x28000(163840) | 0x67FFF(425983) | 128M | recovery |
5 | 0x68000(425984) | 0x77FFF(491519) | 32M | backup |
6 | 0x78000(491520) | 0x1C77FFF(29851647) | 14GB | rootfs |
7 | 0x1C78000(29851648) | 0x01CB7FFF(30113791) | 128M | oem |
8 | 0x01CB8000(30113792) | - | userdata |
其中:
uboot
分区:供uboot
编译出来的uboot.img
;misc
分区:引导参数分区,供misc.img
,给recovery
使用;boot
分区:供kernel
编译出来的boot.img
(kernel + dtb
,对于该类型镜像uboot
需要采用distro_boo extlinux
引导方式);recovery
分区:供recovery
编译出的recovery.img
(kernel + dtb + ramdisk
,recovery
系统使用镜像文件);backup
分区:预留,暂时没有用;rootfs
分区:供buildroot
、debian
或yocto
编出来的rootfs.img
;oem
分区:给厂家使用,存放厂家的APP
或数据。挂载在/oem
目录;userdata
分区:供APP
临时生成文件或给最终用户使用,挂载在/userdata
目录下。
4.4 dd
烧录分区
我们也可以通过dd
命令烧写各个分区镜像;
dd if=uboot.img of=/dev/mmcblk0p1 bs=1M
dd if=boot.img of=/dev/mmcblk0p3 bs=1M
dd if=rootfs.img of=/dev/mmcblk0p6 bs=1M
dd if=oem.img of=/dev/mmcblk0p7 bs=1M
dd if=userdata.img of=/dev/mmcblk0p8 bs=1M
4.4.1 烧录userdata.img
如果要更新userdata.img
,具体流程如下。
(1) 首先将userdata.img
拷贝到tftp
根目录下(/work/tftpboot/
):
root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp$ cp rockdev/userdata.img /work/tftpboot/
busybox
内置tftp
,可以直接从ubuntu
宿主机tftp
服务器下载文件:
root@rk3588-buildroot:/opt# tftp -g -l userdata.img 192.168.0.200
从ubuntu
中的tftp
根目录下(/work/tftpboot/
),下载文件userdata.img
。
root@rk3588-buildroot:/opt# ls -l
drwxr-xr-x 6 root root 4096 Jun 11 14:52 unixbench
-rw-r--r-- 1 root root 4472832 Jun 16 04:51 userdata.img
(2) 接着我们在/userdata
目录下创建一个test.txt
文件;
root@rk3588-buildroot:/opt# touch /userdata/test.txt
root@rk3588-buildroot:/opt# ls -l /userdata/
total 279
-rw-r--r-- 1 root root 87402 Jun 9 04:58 200frames_count.h264
-rw-r--r-- 1 root root 81582 Jun 9 04:58 belle-nuit-testchart-1080p.png
drwx------ 2 root root 12288 Jun 11 15:00 lost+found
-rw-r--r-- 1 root root 101760 Jun 9 04:58 piano2-CoolEdit.mp3
-rw-r--r-- 1 root root 0 Jun 16 04:31 test.txt
(3) 重新烧写userdata
分区:
root@rk3588-buildroot:/opt# dd if=userdata.img of=/dev/mmcblk0p8 bs=1M
4+1 records in
4+1 records out
4472832 bytes (4.5 MB, 4.3 MiB) copied, 0.00915314 s, 489 MB/s
再次查看/userdata
:
root@rk3588-buildroot:/opt# ls -l /userdata/
total 278
-rw-r--r-- 1 root root 87402 Jun 9 04:58 200frames_count.h264
-rw-r--r-- 1 root root 81582 Jun 9 04:58 belle-nuit-testchart-1080p.png
drwx------ 2 root root 12288 Jun 11 15:00 lost+found
-rw-r--r-- 1 root root 101760 Jun 9 04:58 piano2-CoolEdit.mp3
可以看到该目录下已经不存在test.txt
文件了,说明分区烧录成功了。
4.4.2 烧录debian
根文件系统
从ubuntu
中的tftp
根目录下(/work/tftpboot/
),下载文件linaro-rootfs.img
。
# 耐心等待50分钟
root@rk3588-buildroot:/opt# tftp -g -l linaro-rootfs.img 192.168.0.200
root@rk3588-buildroot:/opt# ls -l
-rw-r--r-- 1 root root 3313500160 Jun 16 15:40 linaro-rootfs.img
drwxr-xr-x 6 root root 4096 Jun 11 14:52 unixbench
-rw-r--r-- 1 root root 4472832 Jun 16 04:51 userdata.img
重新烧写rootfs
分区:
root@rk3588-buildroot:/opt# dd if=linaro-rootfs.img of=/dev/mmcblk0p6 bs=1M
3160+0 records in
3160+0 records out
3313500160 bytes (3.3 GB, 3.1 GiB) copied, 13.3972 s, 247 MB/s
4.5 debain
系统测试
4.5.1 查看系统
重启开发板,查看系统信息;
root@armsom-sige7:/# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye
4.5.2 设置DNS
服务器
设置DNS
服务器:
root@armsom-sige7:/# sudo vi /etc/resolv.conf
# 追加
nameserver 114.114.114.114
root@armsom-sige7:/# sudo /etc/init.d/networking restart
4.5.3 查看磁盘空间
这里我们可以通过df -hT
查看磁盘空间信息;
root@armsom-sige7:/# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/root ext4 3.0G 3.0G 0 100% /
devtmpfs devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs tmpfs 1.6G 2.1M 1.6G 1% /run
tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
/dev/mmcblk0p7 ext4 121M 12M 103M 11% /oem
/dev/mmcblk0p8 ext4 43G 288K 42G 1% /userdata
tmpfs tmpfs 793M 28K 793M 1% /run/user/1000
tmpfs tmpfs 793M 28K 793M 1% /run/user/110
这里我们可以看到根目录挂载在/dev/root
设备节点上,文件系统格式是ext4
,/dev/root
其实就是/dev/mmcblk0p6
,也就是eMMC
设备的rootfs
分区。
但是为什么这里看到的/dev/root
大小只有3.0G
呢?rootfs
分区我们不是指定了14G
么?这主要是因为我们的根文件系统镜像制作的就是那么大,剩余的分区空间并未使用。
4.5.4 resize2fs
扩容
文件系统能通过扩充容量来利用其分区后的空闲空间。通常情况下,这甚至可以在文件系统被挂载时进行。
这里我们可以通过resize2fs
指令进行扩容:
root@armsom-sige7:/# resize2fs /dev/mmcblk0p6
resize2fs 1.46.2 (28-Feb-2021)
Filesystem at /dev/mmcblk0p6 is mounted on /; on-line resizing required
[ 1881.827893] EXT4-fs warning (device mmcblk0p6): ext4_resize_begin:82: There are errors in the filesystem, so online resizing is not allowed
old_desc_blocks = 1, new_desc_blocks = 2
resize2fs: Permission denied to resize filesystem
很明显扩容失败了,主要是因为该设备被挂载到/
,内核不支持在线调整已挂载文件系统的大小。
为此我们制作一个SD
卡启动盘,使开发板从SD
启动,此时eMMC
设备节点为/dev/mmcblk0
。
这里我们可以通过resize2fs
指令进行扩容:
zhengyang@armsom-sige7:~$ sudo e2fsck -f /dev/mmcblk0p6
e2fsck 1.46.5 (30-Dec-2021)
/dev/mmcblk0p6: recovering journal
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 3A: Optimizing directories
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong (32132, counted=9666).
Fix<y>? yes
Free inodes count wrong (130235, counted=129568).
Fix<y>? yes
/dev/mmcblk0p6: ***** FILE SYSTEM WAS MODIFIED *****
/dev/mmcblk0p6: 72832/202400 files (0.2% non-contiguous), 799294/808960 blocks
zhengyang@armsom-sige7:~$ sudo resize2fs /dev/mmcblk0p6
resize2fs 1.46.5 (30-Dec-2021)
Resizing the filesystem on /dev/mmcblk0p6 to 3670016 (4k) blocks.
The filesystem on /dev/mmcblk0p6 is now 3670016 (4k) blocks long.
开发板拔掉SD
卡,重启启动开发板,稍等一会,显示器上会进入debain
桌面系统(如果不扩容的话,由于/目录没有磁盘空间了,也就进不了debain
桌面环境的);
注意:此时需要进行应用程序 --> 设置 --> 显示进行配置,关闭调用DSI-1
。
再次查看磁盘空间:
root@armsom-sige7:/# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/root ext4 14G 3.0G 11G 23% /
devtmpfs devtmpfs 3.9G 8.0K 3.9G 1% /dev
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs tmpfs 1.6G 2.2M 1.6G 1% /run
tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
/dev/mmcblk0p7 ext4 121M 12M 103M 11% /oem
/dev/mmcblk0p8 ext4 43G 288K 42G 1% /userdata
tmpfs tmpfs 793M 40K 793M 1% /run/user/1000
五、SDK
开发
参考文章
[1] Rockchip_Developer_Guide_Linux_Software_CN.pdf
[2] repo
介绍与使用
[3] Rockchip_Developer_Guide_Linux_Upgrade_CN.pdf
[4] Rockchip RK3588 - NanoPC-T6
开发板介绍
[5] Rockchip RK3399 - NanoPC-T4
开发板介绍
[6] Buildroot
根文件系统构建
[7] Debian
根文件系统构建