程序项目代做,有需求私信(小程序、网站、爬虫、电路板设计、驱动、应用程序开发、毕设疑难问题处理等)

Rockchip RK3588 - Rockchip Linux SDK编译

----------------------------------------------------------------------------------------------------------------------------

开发板 :ArmSoM-Sige7开发板
eMMC64GB
LPDDR48GB
显示屏 :15.6英寸HDMI接口显示屏
u-boot2017.09
linux5.10
----------------------------------------------------------------------------------------------------------------------------

一、SDK软件架构

1.1 SDK工程目录介绍

一个通用Linux SDK工程目录包含有buildrootdebianappkernelu-bootdeviceexternal等目录;

  • app:存放上层应用APP,主要是一些应用Demo
  • buildroot:存放Buildroot开发的根文件系统;
  • debian:存放Debian开发的根文件系统;
  • device/rockchip:存放芯片板级配置以及一些编译和打包固件的脚本和文件;
  • docs:存放通用开发指导文档、Linux系统开发指南、芯片平台相关文档等;
  • external:存放第三方相关仓库,包括显示、音视频、摄像头、网络、安全、recovery 等;
  • kernel:存放Kernel开发的代码;
  • output:存放每次生成的固件信息、编译信息、XML、主机环境等;
  • prebuilts:存放外部交叉编译工具链;
  • rkbin:存放Rockchip相关二进制和工具;
  • rockdev:存放编译输出固件,实际软链接到output/firmware
  • tools:存放LinuxWindow操作系统下常用工具;
  • 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 SDKBuildroot系统,其包含了基于Linux系统开发用到的各种系统源码,驱动,工具,应用软件包。BuildrootLinux平台上一个开源的嵌入式Linux系统自动构建框架。整个Buildroot是由Makefile脚本和Kconfig配置文件构成的。可通过Buildroot配置,编译出一个完整的可以直接烧写到机器上运行的Linux系统软件。

Buildroot有以下几点优势:

  • 通过源码构建,有很大的灵活性;
  • 方便的交叉编译环境,可以进行快速构建,容易上手;
  • 提供系统各组件的配置,方便定制开发。

使用Buildrootproject最出名的就是Openwrt。可以看到,由它制作出的镜像可以跑在搭载16 Mb SPINOR的路由器上,系统基本没包含多余的东西。 这就是得益于Buildroot的简单化。整个Buildroot工程在一个git维护。

Buildroot使用kconfigmake,一个defconfig配置代表一种BSP支持。Buildroot 本身不具备扩展能力,用户需要自己通过脚本来完成工作。这些列出来的特点,都是和Yocto不同的地方。

注意:Buildroot实际上使用Busybox来制作根文件系统。

1.2.2 Yocto

YoctoBuildroot一样, 是一套构建嵌入式系统的工具,但是两者的风格完全不同。

Yocto工程是通过一个个单独的包(meta)来维护,比如有的包负责核心,有的包负责外围。有的包用于跑Rockchip的芯片,有的包用于安装上weston, 有的包是则是用于跑debian, 同样采用类似机制的nodejs,社区膨胀非常厉害,活跃度很高,每个人都可分享自己的成果到github上,这样的机制保证了我们可从互联网复用别人的工作成果,相当有价值。

相比Buildroot系统,Yocto有其更强的编译机制,比如第三方包的依赖和重编,都会自动处理。缺点相对复杂、需VPN网络。

Yocto是一个非常灵活的构建系统,允许用户使用shellPython来处理各种特殊情况。目前,该系统主要针对国外客户。如果您需要更多关于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发行版,例如UbuntuKnoppixPureOSSteamOS以及 Tails,都选择了Debian作为它们的软件基础。Debian提供了所有工具,因此每个人都可以用能满足自己需求的软件包来扩展 Debian档案库中的软件包;
  • Debian项目是一个社区:Debian不只是一个Linux操作系统。该软件由来自世界各地的数百名志愿者共同制作。即使您不是一个程序员或系统管理员,也可以成为Debian社区的一员;

Rockchip定制版的Debian系统是通过Shell脚本来达到获取构建Linux Debian发行版源码,编译和安装适配Rockchip硬加速包的操作系统。

1.3 SDK软件框图

SDK软件框图如下图所示:

从下至上分为启动层、内核层、库、应用层四个层次。各层次内容如下:

  • 启动层主要提供系统启动,如BootROMU-BootATF等相关支持;
  • 内核层主要提供Linux Kernel的标准实现,Linux也是一个开放的操作系统,Rockchip平台的Linux核心为标准的Linux4.4/4.19/5.10内核,提供安全性,内存管理,进程管理,网络协议栈等基础支持;主要是通过Linux内核管理设备硬件资源,如CPU调度、缓存、内存、I/O等;
  • 库层对应一般嵌入式系统,相当于中间件层次。包含了各种系统基础库,及第三方开源程序库支持,对应用层提供API接口,系统定制者和应用开发者可以基于Libraries层的API开发新的应用;
  • 应用层主要是实现具体的产品功能及交互逻辑,需要一些系统基础库及第三方程序库支持,开发者可以开发实现自己的应用程序,提供系统各种能力给到最终用户。

SDK系统启动流程是指系统上电到系统启动完成的一个软件流程,下面是linux系统启动流程:

注意:

  • APMCU内部都有集成一个 BootROM,系统上电时先会运行BootROM代码,然后BootROM代码会探测外设存储器并加载Loader代码;
  • PreLoader 前有3个: miniloader(非开源), uboot tpluboot spl loader

1.4 SDK开发流程

Rockchip Linux系统是基于Buildroot/Yocto/Debian系统,,内核基于kernel 4.4/4.19/5.10开发,针对多种不同产品形态开发的SDK。可以基于本SDK,有效地实现系统定制和应用移植开发。

如图所示,开发者可以遵循上述开发流程,在本地快速构建Rockchip Linux系统的开发环境和编译代码。下面将简单介绍下该流程:

  • 检查系统需求:在下载代码和编译前,需确保本地的开发设备能够满足需求,包括机器的硬件能力,软件系统,工具链等。目前SDK支持Linux操作系统环境下编译,并仅提供Linux环境下的工具链支持,其他如MacOSWindows等系统暂不支持;
  • 搭建编译环境:介绍开发机器需要安装的各种软件包和工具,详见第二节SDK开发坏境搭建。
  • 选择设备:在开发过程中,需要开发者根据自己的需求,选择对应的硬件板型;
  • 下载源代码:选定设备类型后,需要安装repo工具用于批量下载源代码;
  • 系统定制:开发者可以根据使用的硬件板子、产品定义,定制u-bootkernelrootfs,详见第五节SDK开发;
  • 编译与打包:介绍具备源代码后,选择产品及初始化相关的编译环境,而后执行编译命令,包括整体或模块编译以及编译清理等工作,进一步内容详见第三节SDK编译说明。
  • 烧录并运行:继生成镜像文件后,将介绍如何烧录镜像并运行在硬件设备,进一步内容详见第四节SDK固件升级;

二、SDK开发环境搭建

2.1 概述

本节主要介绍了如何在本地搭建编译环境来编译Rockchip Linux SDK源代码,当前SDK只支持在Linux环境下编译和进行二次开发。

一个典型的嵌入式开发环境通常包括Linux服务器、PC和目标硬件版,典型开发环境如下图所示;

其中:

  • Linux服务器上建立交叉编译环境,为软件开发提供代码、更新下载和进行编译等服务;
  • PCLinux服务器共享程序,并安装PuttyMinicom,通过网络远程登陆到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.shSDK编译脚本;
  • envsetup.sh :指向buildroot/build/envsetup.sh,配置Buildroot编译环境脚本;
2.2.1 u-bootkernel编译工具链

鉴于Rockchip Linux SDK目前只在Linux PC环境下编译,SDK提供了Linux下的交叉编译工具链。prebuilt目录下的工具链是u-bootkernel使用;

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.33GLIBC_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 全自动编译

进入工程根目录执行以下命令自动完成所有的编译,如果只编译模块代码(ubootkernelrootfsrecovery),运行:

root@ubuntu:/work/sambashare/rk3588/armsom/armsom-rk3588-bsp# ./build.sh all

输出内容如下:

View Code
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指定不同rootfsRK_ROOTFS_SYSTEM目前可设定三种系统:buildrootdebianyocto

比如需要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.imgrk3588_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

输出详情如下:

View Code
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.imgMiniLoaderAll.bin,同时更新rockdev目录下uboot.imgMiniLoaderAll.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

输出详情如下:

View Code
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

输出详情如下:

View Code
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

输出详情如下:

View Code
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.imgrootfs.img。此外由于我们执行了./build.sh debian,此时output/.config中默认系统已经设置为了debian

编译完成会在debian目录下生成:linaro-buster-alip-xxxxx-1.tar.gzxxxxx 表示生成时间戳)。

因此我们将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模式正常启动系统。

img

亲爱的读者和支持者们,自动博客加入了打赏功能,陆陆续续收到了各位老铁的打赏。在此,我想由衷地感谢每一位对我们博客的支持和打赏。你们的慷慨与支持,是我们前行的动力与源泉。

日期姓名金额
2023-09-06*源19
2023-09-11*朝科88
2023-09-21*号5
2023-09-16*真60
2023-10-26*通9.9
2023-11-04*慎0.66
2023-11-24*恩0.01
2023-12-30I*B1
2024-01-28*兴20
2024-02-01QYing20
2024-02-11*督6
2024-02-18一*x1
2024-02-20c*l18.88
2024-01-01*I5
2024-04-08*程150
2024-04-18*超20
2024-04-26.*V30
2024-05-08D*W5
2024-05-29*辉20
2024-05-30*雄10
2024-06-08*:10
2024-06-23小狮子666
2024-06-28*s6.66
2024-06-29*炼1
2024-06-30*!1
2024-07-08*方20
2024-07-18A*16.66
2024-07-31*北12
2024-08-13*基1
2024-08-23n*s2
2024-09-02*源50
2024-09-04*J2
2024-09-06*强8.8
2024-09-09*波1
2024-09-10*口1
2024-09-10*波1
2024-09-12*波10
2024-09-18*明1.68
2024-09-26B*h10
2024-09-3010
2024-10-02M*i1
2024-10-14*朋10
2024-10-22*海10
2024-10-23*南10
2024-10-26*节6.66
2024-10-27*o5
2024-10-28W*F6.66
2024-10-29R*n6.66
2024-11-02*球6
2024-11-021*鑫6.66
2024-11-25*沙5
2024-11-29C*n2.88
posted @   大奥特曼打小怪兽  阅读(4818)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2023-06-08 Rockchip RK3399 - ALC5651 & I2S基础
2021-06-08 Mini2440裸机开发之点亮LED
2018-06-08 第二十四节,TensorFlow下slim库函数的使用以及使用VGG网络进行预训练、迁移学习(附代码)
2018-06-08 第二十三节,迁移学习和数据扩充(附代码)
如果有任何技术小问题,欢迎大家交流沟通,共同进步

公告 & 打赏

>>

欢迎打赏支持我 ^_^

最新公告

程序项目代做,有需求私信(小程序、网站、爬虫、电路板设计、驱动、应用程序开发、毕设疑难问题处理等)。

了解更多

点击右上角即可分享
微信分享提示