程序项目代做,有需求私信(vue、React、Java、爬虫、电路板设计、嵌入式linux等)

Rockchip RK3588 - 移植uboot 2017.09 & linux 6.1(友善之家脚本方式)

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

开发板 :NanoPC-T6开发板
eMMC256GB
LPDDR416GB
显示屏 :15.6英寸HDMI接口显示屏
u-boot2017.09
linux6.1
----------------------------------------------------------------------------------------------------------------------------

本节将会介绍官方固件方式uboot 2017.09以及linux 6.1内核的编译过程,教程来自友善之家官方手册。

一、下载工具和固件

1.1 下载工具

root@ubuntu:/work/sambashare/rk3588/friendly# git clone https://github.com/friendlyarm/sd-fuse_rk3588.git --single-branch -b kernel-6.1.y
root@ubuntu:/work/sambashare/rk3588/friendly# git clone https://521github.com/friendlyarm/sd-fuse_rk3588.git --single-branch -b kernel-6.1.y  #同上,二选一
root@ubuntu:/work/sambashare/rk3588/friendly# cd sd-fuse_rk3588/

如果第一个下载比较慢,可以尝试使用第二个命令,切换镜像源。后面涉及到的github源码下载,均可切换为521github

1.2 下载固件

系统镜像,这里我们以debian-bullseye-desktop-arm64 为例,下载地址:https://download.friendlyelec.com/NanoPC-T6

debian-bullseye-desktop-arm64-images.tgz(位于"\03_分区镜像文件"目录下,以实际下载的文件为准)拷贝到/work/sambashare/rk3588/friendly/sd-fuse_rk3588目录下;

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# ll debian*
-rwxrw-rw- 1 root root 1590466719 Dec  3 01:49 debian-bullseye-desktop-arm64-images.tgz*
-rwxrw-rw- 1 root root         75 Nov 18 19:05 debian-bullseye-desktop-arm64-images.tgz.hash.md5*
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# tar -xvzf debian-bullseye-desktop-arm64-images.tgz

解压得到debian-bullseye-desktop-arm64文件夹;

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# ll debian-bullseye-desktop-arm64
-rw-r--r--  1 root root    8072140 May 28  2023 boot.img
-rw-r--r--  1 root root       1424 May 28  2023 dtbo.img
-rw-r--r--  1 root root     307200 Sep  8 23:33 idbloader.img
-rw-r--r--  1 root root         64 Nov 17 10:03 info.conf
-rw-r--r--  1 root root   35551252 Nov 16 16:17 kernel.img
-rw-r--r--  1 root root     471488 Sep  8 23:33 MiniLoaderAll.bin
-rw-r--r--  1 root root      49152 May 28  2023 misc.img
-rw-r--r--  1 root root        470 Nov 17 10:03 parameter.txt
-rw-r--r--  1 root root    6227456 Nov 16 16:17 resource.img
-rw-r--r--  1 root root 3992675220 Nov 17 10:03 rootfs.img
-rw-r--r--  1 root root    4194304 Sep  8 23:33 uboot.img
-rw-r--r--  1 root root     159868 Nov 17 10:03 userdata.img

1.3 安装交叉编译工具

由于x86ARM64架构最底层的指令集不同,所以两个平台的程序不能通用,需要分开编译,编译的工具链是不一样。

由于我们日常的开发习惯,ARM架构的计算机资源等等因素,我们通常会在x86架构的平台上编写代码并编译然后放到ARM上运行。 所以就需要搭建交叉编译环境。

什么是交叉编译环境呢?简单点说就是在一个架构的处理器上能编译在另一个架构上运行的程序的环境。 再简单点来说,就是在x86架构下安装ARM的编译工具。

下面我们介绍两种安装方式,实际使用中,我使用的是下面第一种方式。

1.3.1 命令安装
root@ubuntu:/opt# sudo apt install gcc-10-aarch64-linux-gnu g++-10-aarch64-linux-gnu

安装的 gcc-aarch64-linux-gnug++-aarch64-linux-gnu 工具链默认安装在 /usr/bin/ 目录下;

# 查看版本
root@ubuntu:/opt# aarch64-linux-gnu-gcc-10 -v
Using built-in specs.
COLLECT_GCC=aarch64-linux-gnu-gcc-10
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/aarch64-linux-gnu/10/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 10.5.0-1ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --without-target-system-zlib --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=aarch64-linux-gnu --program-prefix=aarch64-linux-gnu- --includedir=/usr/aarch64-linux-gnu/include --with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.5.0 (Ubuntu 10.5.0-1ubuntu1~20.04)

# 创建链接
root@ubuntu:/usr/bin# cd /usr/bin
root@ubuntu:/usr/bin# ln -s aarch64-linux-gnu-gcc-10 aarch64-linux-gnu-gcc
root@ubuntu:/usr/bin# ln -s aarch64-linux-gnu-g++-10 aarch64-linux-gnu-g++  

此外通过 apt 命令安装的 gcc-aarch64-linux-gnug++-aarch64-linux-gnu 工具链默认会安装相应的库文件和头文件。以下是它们的默认安装路径:

库文件:

  • 标准C库文件:/usr/aarch64-linux-gnu/lib
  • 标准C++库文件:/usr/aarch64-linux-gnu/lib
  • 其他第三方库文件:/usr/aarch64-linux-gnu/lib/usr/aarch64-linux-gnu/lib/<library_name>

头文件:

  • C头文件:/usr/aarch64-linux-gnu/include
  • C++头文件:/usr/aarch64-linux-gnu/include/c++/<version>

注意:这里我们的版本尽量安装高于开发板中编译器的版本,如果开发板我们安装的aarch64-none-linux-gcc版本为10.2,宿主机ubuntu 20.4就要安装10.2及其以上版本。不然在编译Qt可能会出现glibc版本问题(后面的文章会介绍到):出现这种问题就是因为编译库的编译器(编译Qt通过--sysroot指定的库)和编译Qt的编译器版本是不一样的,具体一点就是因为,当前程序的编译器的版本是比较低的。

1.3.2 脚本安装

当然你也可以从互联网上下载交叉编译器,比如野火官方提供的一键安装下载脚本build-gcc.sh

#!/bin/sh

HOST=aarch64-linux-gnu
SCRIPT_PATH=$(pwd)

#修改源码包解压后的名称
MAJOR_NAME=gcc-aarch64-none-linux-gnu

#修改需要下载的源码版本前缀和后缀
OPENSRC_VER_PREFIX=9.2
OPENSRC_VER_SUFFIX=.1

PACKAGE_NAME=${MAJOR_NAME}-${OPENSRC_VER_PREFIX}${OPENSRC_VER_SUFFIX}

#定义压缩包名称
COMPRESS_PACKAGE=gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz

#定义编译后安装--生成的文件,文件夹位置路径,可以根据实际修改到普通用户目录下,需和后面交叉编译qt源码脚本保持一致
INSTALL_PATH=/opt/${PACKAGE_NAME}

#无需修改--下载地址
DOWNLOAD_LINK=https://mirrors.aliyun.com/armbian-releases/_toolchain/${COMPRESS_PACKAGE}

#下载源码包
do_download_src () {
   echo "\033[1;33mstart download ${COMPRESS_PACKAGE}...\033[0m"
   if [ ! -f "${COMPRESS_PACKAGE}" ];then
      if [ ! -d "${PACKAGE_NAME}" ];then
      wget -c ${DOWNLOAD_LINK}
      fi
   fi
   echo "\033[1;33mdone...\033[0m"
}

#解压源码包
do_tar_package () {
   echo "\033[1;33mstart unpacking the ${PACKAGE_NAME} package ...\033[0m"
   if [ ! -d ${PACKAGE_NAME} ];then
      mkdir -p ${INSTALL_PATH}
      tar -xvf ${COMPRESS_PACKAGE} -C ${INSTALL_PATH} --strip-components=1
   fi
   echo "\033[1;33mdone...\033[0m"
}

#删除下载的文件
do_delete_file () {
   cd ${SCRIPT_PATH}
   if [ -f "${PACKAGE_NAME}" ];then
      sudo rm -f ${PACKAGE_NAME}
   fi
}

do_download_src
do_tar_package
do_delete_file

exit $?

注意:尽量安装10以及10以下的版本,不要安装高版本,比如aarch64-none-linux-gnu-11aarch64-none-linux-gnu-12

整个脚本的核心就是使用wget命令将gcc-aarch64-none-linux-gnu的文件下载到本地, 然后通过tar解压到指定的安装目录(/opt/${PACKAGE_NAME},实际上就是/opt/gcc-aarch64-none-linux-gnu-9.2.1目录下)。

我们直接运行脚本即可下载并安装gcc-aarch64-none-linux-gnu-9.2.1版本的交叉编译器,后续的编译都是要该编译器进行。

执行脚本的过程:

root@ubuntu:/opt# chmod +x ./build-gcc.sh
root@ubuntu:/opt# ./build-gcc.sh

安装完成之后,/opt/目录下就会存在gcc-aarch64-none-linux-gnu-9.2.1目录。

二、编译内核

2.1 下载内核源码

下载内核源代码:

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# git clone https://github.com/friendlyarm/kernel-rockchip --depth 1 -b nanopi6-v6.1.y kernel-rk3588

保存到当前路径kernel-rk3588文件夹中。

2.2 修改build-kernel.sh脚本

在编译内核之前我们需要修改build-kernel.sh脚本;

根据自己安装的交叉编译环境,修改CROSS_COMPILE

CROSS_COMPILE=aarch64-linux-gnu- 

并且将如下代码移除:

export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH 
if [ ! -d /opt/FriendlyARM/toolchain/11.3-aarch64 ]; then
        echo "please install aarch64-gcc-11.3 first, using these commands: "
        echo "    git clone https://github.com/friendlyarm/prebuilts.git -b master --depth 1"
        echo "    cd prebuilts/gcc-x64"
        echo "    sudo tar xvf toolchain-11.3-aarch64.tar.xz -C /"
        exit 1
fi

2.3 编译内核

执行编译内核命令,编译完成后会自动更新debian-bullseye-desktop-arm64目录下的相关镜像文件,包括文件系统中的内核模块 (rootfs.img会被解包并重新打包,即更新/lib/modules下的驱动模块);

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# KERNEL_SRC=$PWD/kernel-rk3588 ./build-kernel.sh debian-bullseye-desktop-arm64
using official logo.
using official kernel logo.
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  YACC    scripts/kconfig/zconf.tab.c
  LEX     scripts/kconfig/zconf.lex.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
#
# configuration written to .config
#
  WRAP    arch/arm64/include/generated/uapi/asm/errno.h
  WRAP    arch/arm64/include/generated/uapi/asm/ioctl.h
......
'rtl8812au.ko' -> '/work/sambashare/rk3588/friendly/sd-fuse_rk3588/out/output_rk3588_kmodules/lib/modules/6.1.25/rtl8812au.ko'
depmod /work/sambashare/rk3588/friendly/sd-fuse_rk3588/out/output_rk3588_kmodules 6.1.25 ...
building kernel ok.
debian-bullseye-desktop-arm64 found.
copying kernel module and firmware to rootfs ...
mke2fs 1.45.4 (23-Sep-2019)
Creating regular file debian-bullseye-desktop-arm64/rootfs.img
Creating filesystem with 1015808 4k blocks and 224192 inodes
Filesystem UUID: 305edcbb-a151-4560-8037-11c39b7450be
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736

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

'/work/sambashare/rk3588/friendly/sd-fuse_rk3588/prebuilt/parameter.template' -> 'debian-bullseye-desktop-arm64/parameter.txt'
generating debian-bullseye-desktop-arm64/parameter.txt done.
0
updating kernel ok.

其中:

  • KERNEL_SRC配置为内核源码所在路径;
  • $1配置为目标OS系统debian-bullseye-desktop-arm64

如果需要修改开机logo,只需要替换kernel-rockchip目录下的logo.bmplogo_kernel.bmp文件即可。

编译完成后会在./out路径下生成若干文件:logo_kernel.bmp文件即可;

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# ll out/
drwxr-xr-x  7 root root  4096 Dec  4 22:43 cryptodev-linux/
drwxr-xr-x  4 root root  4096 Dec  4 22:43 nft-fullcone/
drwxr-xr-x  3 root root  4096 Dec  4 22:42 output_rk3588_kmodules/
drwxr-xr-x  3 root root  4096 Dec  4 22:43 r8125/
drwxr-xr-x 22 root root  4096 Dec  4 22:47 rootfs_new/
drwxr-xr-x  8 root root  4096 Dec  4 22:46 rtl8812au/
drwxr-xr-x  9 root root  4096 Dec  4 22:44 rtl8821CU/
drwxr-xr-x  8 root root  4096 Dec  4 22:45 rtl8822bu/
drwxr-xr-x  8 root root  4096 Dec  4 22:45 rtl8822cs/
drwxr-xr-x  4 root root 16384 Dec  4 22:43 rtw88/

其中:

  • cryptodev-linuxrtl8812aurtl8821CUrtl8822burtl8822csrtw88cryptodev以及usb wifi驱动源码;
  • output_rk3588_kmodules:为内核驱动模块;
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# ls out/output_rk3588_kmodules/lib/modules/6.1.25/
cryptodev.ko               modules.builtin.bin      modules.softdep      rtl8821CU.ko   rtw_8723du.ko  rtw_8822bs.ko  rtw_sdio.ko
kernel                     modules.builtin.modinfo  modules.symbols      rtl8822bu.ko   rtw_8821ce.ko  rtw_8822ce.ko  rtw_usb.ko
modules.alias              modules.dep              modules.symbols.bin  rtl8822cs.ko   rtw_8821c.ko   rtw_8822c.ko
modules.alias.bin          modules.dep.bin          nft_fullcone.ko      rtw_8723de.ko  rtw_8821cs.ko  rtw_8822cs.ko
modules.builtin            modules.devname          r8125.ko             rtw_8723d.ko   rtw_8822be.ko  rtw_core.ko
modules.builtin.alias.bin  modules.order            rtl8812au.ko         rtw_8723ds.ko  rtw_8822b.ko   rtw_pci.ko
  • rootfs_new:新的根文件系统的源码;

此外debian-bullseye-desktop-arm64目录下的内核镜像和根文件系统被更新了;

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# ll debian-bullseye-desktop-arm64
总用量 3962492
drwxr-xr-x  2 root root       4096 Dec  4 22:48 ./
drwxr-xr-x 11 root root       4096 Dec  4 22:42 ../
-rw-r--r--  1 root root    8072140 May 28  2023 boot.img
-rw-r--r--  1 root root       1424 May 28  2023 dtbo.img
-rw-r--r--  1 root root     307200 Sep  8 23:33 idbloader.img
-rw-r--r--  1 root root         64 Nov 17 10:03 info.conf
-rw-r--r--  1 root root   37910548 Dec  4 22:46 kernel.img     # 更新了 
-rw-r--r--  1 root root     471488 Sep  8 23:33 MiniLoaderAll.bin
-rw-r--r--  1 root root      49152 May 28  2023 misc.img
-rw-r--r--  1 root root        470 Dec  4 22:48 parameter.txt   # 更新了
-rw-r--r--  1 root root    5785600 Dec  4 22:46 resource.img  # 更新了
-rw-r--r--  1 root root 4000600956 Dec  4 22:48 rootfs.img    # 更新了
-rw-r--r--  1 root root    4194304 Sep  8 23:33 uboot.img
-rw-r--r--  1 root root     159868 Nov 17 10:03 userdata.img

2.4 build-kernel.sh分析

如果感兴趣可以分析一下./build-kernel.sh的主要工作流程。

2.4.1 配置内核

首先配置内核:

cd ${KERNEL_SRC}
[ -d .git ] && git clean -dxf    # 如果不想每次都重新编译,将改行屏蔽
touch .scmversion

make CROSS_COMPILE=${CROSS_COMPILE} ARCH=${ARCH} ${KCFG}

其中:

  • CROSS_COMPILE被配置成aarch64-linux-gnu-
  • ARCH被配置成arm64
  • KCFG被配置成nanopi6_linux_defconfig;
2.4.2 编译内核
make CROSS_COMPILE=${CROSS_COMPILE} ARCH=${ARCH} ${KALL} -j$(nproc)

其中:

  • KALL被配置成nanopi6-images;编译规则定义在arch/arm64/Makefile文件;
  • $(nproc):用于获取系统中可用的处理器核心数;

arch/arm64/Makefile文件;

# 编译生成kernel.img      
kernel.img: Image
        $(Q)scripts/mkkrnlimg $(objtree)/arch/arm64/boot/Image $(objtree)/kernel.img >/dev/null
        @echo '  Image:  kernel.img is ready'

ifeq ($(CONFIG_VENDOR_FRIENDLYELEC),y)
DTBS := rk3*-nanopi*-rev*.dtb

# 调用scripts/mkimg编译生成resource.img(由设备树、图片资源文件组成,不包含内核)
nanopi4-images: dtbs kernel.img $(LOGO) $(LOGO_KERNEL)
        $(Q)$(srctree)/scripts/mkimg --dtb $(DTBS) --keep-dtb-name

nanopi5-images: nanopi4-images
nanopi6-images: nanopi4-images
PHONY += nanopi4-images nanopi5-images nanopi6-images
endif

因此该步骤执行完成后,会在./kernel-rk3588目录下生成kernel.imgresource.img文件 ;

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# ll ./kernel-rk3588/kernel.img
-rw-r--r-- 1 root root 37910548 Dec  4 22:54 ./kernel-rk3588/kernel.img
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# ll ./kernel-rk3588/resource.img
-rw-r--r-- 1 root root 5785600 Dec  4 22:54 ./kernel-rk3588/resource.img

这里我们简单看一下scripts/mkimg脚本,其接收参数有三个:

  • --dtb:用于指定后面跟的参数为设备树数组;
  • DTBS:名称符合 rk3*-nanopi*-rev*.dtb的设备树,有关设备树DTBS的分析可以参考:NaniPC-T6设备树
  • --keep-dtb-name:配置DTB_ARGS

有关scripts/mkimg脚本我们单独介绍。

2.4.3 编译驱动模块

执行make modules命令编译驱动模块:

rm -rf ${KMODULES_OUTDIR}
mkdir -p ${KMODULES_OUTDIR}
make CROSS_COMPILE=${CROSS_COMPILE} ARCH=${ARCH} INSTALL_MOD_PATH=${KMODULES_OUTDIR} modules -j$(nproc)
if [ $? -ne 0 ]; then
   echo "failed to build kernel modules."
   exit 1
fi

其中:

  • 内核模块路径KMODULES_OUTDIR被配置为./out/output_rk3588_kmodules
TOPPATH=$PWD
OUT=$TOPPATH/out
if [ ! -d $OUT ]; then
        echo "path not found: $OUT"
        exit 1
fi
KMODULES_OUTDIR="${OUT}/output_${SOC}_kmodules"  # out/output_rk3588_kmodules
2.4.4 安装驱动模块

执行make modules_install命令安装驱动模块:

make CROSS_COMPILE=${CROSS_COMPILE} ARCH=${ARCH} INSTALL_MOD_PATH=${KMODULES_OUTDIR} modules_install
if [ $? -ne 0 ]; then
    echo "failed to build kernel modules."
         exit 1
fi

# 用于构建并输出内核版本号
KERNEL_VER=`make CROSS_COMPILE=${CROSS_COMPILE} ARCH=${ARCH} kernelrelease`

# 如果模块依赖文件modules.dep不存在,则生成内核模块的依赖关系
[ ! -f "${KMODULES_OUTDIR}/lib/modules/${KERNEL_VER}/modules.dep" ] && depmod -b ${KMODULES_OUTDIR} -E Module.symvers -F System.map -w ${KERNEL_VER}
# 去除驱动中的符号信息
(cd ${KMODULES_OUTDIR} && find . -name \*.ko | xargs ${CROSS_COMPILE}strip --strip-unneeded)

(1) 接着编译cryptodev.ko驱动,并拷贝到内核模块路径out/output_rk3588_kmodules/lib/modules/6.1.25/

# build cryptodev-linux
(cd ${OUT} && {
	if [ ! -d cryptodev-linux ]; then
		git clone https://github.com/cryptodev-linux/cryptodev-linux.git -b master cryptodev-linux
	fi
	(cd cryptodev-linux && {
		make CROSS_COMPILE=${CROSS_COMPILE} ARCH=${ARCH} KERNEL_DIR=${KERNEL_SRC}
		cp cryptodev.ko ${KMODULES_OUTDIR}/lib/modules/${KERNEL_VER} -afv
	})
})

cryptodev-linux 是一个linux内核模块,它提供了一个加密硬件的接口,可在用户空间中使用该接口来执行加密和解密操作。

(2) 接着编译usb wifi driver

if [ ${BUILD_THIRD_PARTY_DRIVER} -eq 1 ]; then
	for (( i=0; i<${#KERNEL_3RD_DRIVERS[@]}; i++ ));
	do
		build_external_module ${KERNEL_3RD_DRIVERS[$i]} ${KERNEL_3RD_DRIVER_BRANCHES[$i]} ${KERNEL_3RD_DRIVER_NAME[$i]}
	done
fi
2.4.5 更新内核模块依赖

使用depmod命令更新内核模块依赖:

(cd ${KMODULES_OUTDIR}/lib/modules/${KERNEL_VER}/ && {
	rm -rf ./build ./source
	echo "depmod ${KMODULES_OUTDIR} ${KERNEL_VER} ..."
	depmod -a -b ${KMODULES_OUTDIR} ${KERNEL_VER}
})

其中:

  • -a 选项表示更新所有已经加载或已知的内核模块的依赖关系;
  • -b 选项用于指定内核模块所在的目录;
2.4.6 重新打包rootfs.img

执行./tools/update_kernel_bin_to_img.sh脚本解压并重新打包rootfs.img

./tools/update_kernel_bin_to_img.sh ${OUT} ${KERNEL_SRC} ${TARGET_OS} ${TOPPATH}/prebuilt

其中:

  • OUT配置为./out
  • KERNEL_SRC配置为./kernel-rk3588
  • TARGET_OS配置为debian-bullseye-desktop-arm64
  • TOPPATH配置为./

其主要工作就是:

  • 挂载根文件系统./debian-bullseye-desktop-arm64/rootfs.img到某个路径;
  • 删除原有的驱动模块,即mount_point/lib/modules/*文件
  • 使用cp -af将新编译的驱动模块拷贝到mount_point/lib/modules
  • 如果存在固件(./out/output_rk3588_kmodules/lib//lib/firmware目录下),使用cp -af将新编译的固件库拷贝到mount_point/lib/firmware
  • 重新制作根文件系统镜像文件;

update_kernel_bin_to_img.sh脚本源码如下:

点击查看代码
#!/bin/bash
set -eu

[ -f ${PWD}/mk-emmc-image.sh ] || {
        echo "Error: please run at the script's home dir"
        exit 1
}

# Automatically re-run script under sudo if not root
if [ $(id -u) -ne 0 ]; then
    echo "Re-running script under sudo..."
    sudo --preserve-env "$0" "$@"
    exit
fi

TOP=$PWD
export MKE2FS_CONFIG="${TOP}/tools/mke2fs.conf"
if [ ! -f ${MKE2FS_CONFIG} ]; then
    echo "error: ${MKE2FS_CONFIG} not found."
    exit 1
fi
true ${MKFS:="${TOP}/tools/mke2fs"}

true ${SOC:=rk3588}
ARCH=arm64
KCFG=nanopi5_linux_defconfig
KIMG=kernel.img
KDTB=resource.img
CROSS_COMPILE=aarch64-linux-gnu-
# ${OUT} ${KERNEL_SRC} ${TOPPATH}/${TARGET_OS} ${TOPPATH}/prebuilt
if [ $# -ne 4 ]; then
        echo "bug: missing arg, $0 needs four args"
        exit
fi
OUT=$1
KERNEL_BUILD_DIR=$2
TARGET_OS=$3
PREBUILT=$4
KMODULES_OUTDIR="${OUT}/output_${SOC}_kmodules"

(cd ${KERNEL_BUILD_DIR} && {
        cp ${KIMG} ${KDTB} ${TOP}/${TARGET_OS}/
})

# copy kernel modules to rootfs.img
if [ -f ${TARGET_OS}/rootfs.img ]; then           # 进入,重新打包rootfs.img
    echo "copying kernel module and firmware to rootfs ..."

    # Extract rootfs from img
    simg2img ${TARGET_OS}/rootfs.img ${TARGET_OS}/r.img
    mkdir -p ${OUT}/rootfs_mnt
    mkdir -p ${OUT}/rootfs_new
    mount -t ext4 -o loop ${TARGET_OS}/r.img ${OUT}/rootfs_mnt
    if [ $? -ne 0 ]; then
        echo "failed to mount ${TARGET_OS}/r.img."
        exit 1
    fi
    rm -rf ${OUT}/rootfs_new/*
    cp -af ${OUT}/rootfs_mnt/* ${OUT}/rootfs_new/
    umount ${OUT}/rootfs_mnt
    rm -rf ${OUT}/rootfs_mnt
    rm -f ${TARGET_OS}/r.img

    # Processing rootfs_new
    # Here s5pxx18 is different from h3/h5

    [ -d ${KMODULES_OUTDIR}/lib/firmware ] && cp -af ${KMODULES_OUTDIR}/lib/firmware/* ${OUT}/rootfs_new/lib/firmware/
    rm -rf ${OUT}/rootfs_new/lib/modules/*
    cp -af ${KMODULES_OUTDIR}/lib/modules/* ${OUT}/rootfs_new/lib/modules/

    MKFS_OPTS="-E android_sparse -t ext4 -L rootfs -M /root -b 4096"
    case ${TARGET_OS} in
    friendlywrt* | buildroot*)
        # set default uid/gid to 0
        MKFS_OPTS="-0 ${MKFS_OPTS}"
        ;;
    *)
        ;;
    esac

    # Make rootfs.img
    ROOTFS_DIR=${OUT}/rootfs_new

    case ${TARGET_OS} in
    friendlywrt*)
        echo "prepare kernel modules for friendlywrt ..."
        ${TOP}/tools/prepare_friendlywrt_kernelmodules.sh ${ROOTFS_DIR}
        ;;
    *)
        ;;
    esac

    # clean device files
    (cd ${ROOTFS_DIR}/dev && find . ! -type d -exec rm {} \;)
    # calc image size
    IMG_SIZE=$(((`du -s -B64M ${ROOTFS_DIR} | cut -f1` + 3) * 1024 * 1024 * 64))
    IMG_BLK=$((${IMG_SIZE} / 4096))
    INODE_SIZE=$((`find ${ROOTFS_DIR} | wc -l` + 128))
    # make fs
    [ -f ${TARGET_OS}/rootfs.img ] && rm -f ${TARGET_OS}/rootfs.img
    ${MKFS} -N ${INODE_SIZE} ${MKFS_OPTS} -d ${ROOTFS_DIR} ${TARGET_OS}/rootfs.img ${IMG_BLK}

    if [ ${TARGET_OS} != "eflasher" ]; then
        case ${TARGET_OS} in
        openmediavault-*)
            # disable overlayfs for openmediavault
            cp ${TOP}/prebuilt/parameter-ext4.txt ${TOP}/${TARGET_OS}/parameter.txt
            ;;
        *)
            ${TOP}/tools/generate-partmap-txt.sh ${IMG_SIZE} ${TARGET_OS}
            ;;
        esac
    fi
else
    echo "not found ${TARGET_OS}/rootfs.img"
    exit 1
fi

2.5 编译内核头文件

编译内核头文件运行如下命令:

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# MK_HEADERS_DEB=1 BUILD_THIRD_PARTY_DRIVER=0 KERNEL_SRC=$PWD/kernel-rk3588 ./build-kernel.sh debian-bullseye-desktop-arm64

这里设置了MK_HEADERS_DEB=1表示编译内核头文件;

这里我们分析一下内核头文件的编译过程,其实现代码如下:

if [ ${MK_HEADERS_DEB} -eq 1 ]; then
	# 设置内核头文件dep包路径为 ./out/linux-headers-6.1.25.deb
	KERNEL_HEADERS_DEB=${OUT}/linux-headers-${KERNEL_VER}.deb
	rm -f ${KERNEL_HEADERS_DEB}
	# 1. 重点 构建debian包
	make CROSS_COMPILE=${CROSS_COMPILE} ARCH=${ARCH} bindeb-pkg
	if [ $? -ne 0 ]; then
		echo "failed to build kernel header."
		exit 1
	fi

    # 跳转到 ./kernel-rk3588/debian/linux-headers目录下
	(cd ${KERNEL_SRC}/debian/linux-headers && {
		# 删除usr/src/linux-headers*/scripts/子目录下以 .o 结尾的文件和以 .*.cmd结尾的隐藏文件
		find usr/src/linux-headers*/scripts/ \
			-name "*.o" -o -name ".*.cmd" | xargs rm -rf

		# 2. 设置头文件脚本目录./files/linux-headers-5.10-bin_arm64/scripts
		HEADERS_SCRIPT_DIR=${TOPPATH}/files/linux-headers-5.10-bin_arm64/scripts
		if [ -d ${HEADERS_SCRIPT_DIR} ]; then
			# 拷贝脚本文件到 ./kernel-rk3588/debian/linux-headers/usr/src/linux-headers-6.1.25/scripts/
			cp -avf ${HEADERS_SCRIPT_DIR}/* ./usr/src/linux-headers-*${KERNEL_VER}*/scripts/
			if [ $? -ne 0 ]; then
				echo "failed to copy bin file to /usr/src/linux-headers-${KERNEL_VER}."
				exit 1
			fi
		else
			echo "not found files/linux-headers-x.y.z-bin_arm64, why?"
			exit 1
		fi

		find . -type f ! -path './DEBIAN/*' -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums
	})
	
	# 3. 使用dpkg工具将指定的目录打包成一个debian软件包
	dpkg-deb -Zgzip -b ${KERNEL_SRC}/debian/linux-headers ${KERNEL_HEADERS_DEB}
	if [ $? -ne 0 ]; then
		echo "failed to re-make deb package."
		exit 1
	fi

	# clean up 移除./路径下的xxx.deb文件
	(cd $TOPPATH && {
		rm -f linux-*${KERNEL_VER}*_arm64.buildinfo
		rm -f linux-*${KERNEL_VER}*_arm64.changes
		rm -f linux-headers-*${KERNEL_VER}*_arm64.deb
		rm -f linux-image-*${KERNEL_VER}*_arm64.deb
		rm -f linux-libc-dev_*${KERNEL_VER}*_arm64.deb
	})
fi

接下来我们分析一下这段代码,主要涉及三大步骤。

2.5.1 make bindeb-pkg

这里其中有一条比较重要的命令:

make CROSS_COMPILE=${CROSS_COMPILE} ARCH=${ARCH} bindeb-pkgmkae bindeb-pkg

make bindeb-pkg是一个用于构建debian包的命令,它通常用于编译linux内核并生成对应的debian软件包。

当执行make bindeb-pkg 命令时,它会读取当前目录下的linux内核源代码,并根据配置文件进行内核编译。

编译过程将包括编译内核、生成模块、创建initramfs等步骤。最后,它将生成一组二进制文件和相关的debian控制文件,用于创建 debian包。

对于kernel-rk3588执行完成会在内核源码debian目录生成以下文件;

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# ll kernel-rk3588/debian/
-rw-r--r--  1 root root    6 Dec  4 22:54 arch
-rw-r--r--  1 root root  137 Dec  4 22:54 changelog
-rw-r--r--  1 root root 1250 Dec  4 22:54 control
-rw-r--r--  1 root root  692 Dec  4 22:54 copyright
-rw-r--r--  1 root root  272 Dec  4 22:57 files
drwxr-xr-x  5 root root 4096 Dec  4 22:55 linux-headers/
drwxr-xr-x  7 root root 4096 Dec  4 22:55 linux-image/
drwxr-xr-x  4 root root 4096 Dec  4 22:56 linux-image-dbg/
drwxr-xr-x  4 root root 4096 Dec  4 22:56 linux-libc-dev/
-rwxr-xr-x  1 root root  384 Dec  4 22:54 rules*
drwxr-xr-x  2 root root 4096 Dec  4 22:54 source/

同时会在kernel-rk3588上一级目录下生成如下deb包:

  • linux-image-<version>.deb:内核镜像文件,用于安装和引导新的内核;
  • linux-headers-<version>.deb:内核头文件,用于开发其他软件或编译内核模块;
  • linux-libc-dev_<version>.deb:用于构建用户空间软件的头文件和静态库;

这些生成的debian包可以在 debian或基于debian的系统上安装和使用;

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# ll ./
-rw-r--r--  1 root root  8547400 Dec  4 22:56 linux-headers-6.1.25_6.1.25-3_arm64.deb
-rw-r--r--  1 root root 32745044 Dec  4 22:56 linux-image-6.1.25_6.1.25-3_arm64.deb
-rw-r--r--  1 root root 84501592 Dec  4 22:57 linux-image-6.1.25-dbg_6.1.25-3_arm64.deb
-rw-r--r--  1 root root  1319152 Dec  4 22:56 linux-libc-dev_6.1.25-3_arm64.deb
-rw-r--r--  1 root root     5660 Dec  4 22:57 linux-upstream_6.1.25-3_arm64.buildinfo
......

需要注意的是:这些deb文件在脚本执行的最后会被删除。

2.5.2 工具拷贝

拷贝./files/linux-headers-5.10-bin_arm64/scripts/下的编译相关的工具到./kernel-rk3588/debian/linux-headers/usr/src/linux-headers-6.1.25/scripts下;

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# ll ./files/linux-headers-5.10-bin_arm64/scripts/
-rwxr-xr-x 1 root root 32688 Dec  4 21:13 asn1_compiler*
drwxr-xr-x 2 root root  4096 Dec  4 21:13 basic/
drwxr-xr-x 2 root root  4096 Dec  4 21:13 dtc/
-rwxr-xr-x 1 root root 15096 Dec  4 21:13 extract-cert*
drwxr-xr-x 2 root root  4096 Dec  4 21:13 genksyms/
-rwxr-xr-x 1 root root 23896 Dec  4 21:13 kallsyms*
drwxr-xr-x 2 root root  4096 Dec  4 21:13 kconfig/
drwxr-xr-x 2 root root  4096 Dec  4 21:13 mod/
-rwxr-xr-x 1 root root 29896 Dec  4 21:13 recordmcount*
drwxr-xr-x 4 root root  4096 Dec  4 21:13 selinux/
-rwxr-xr-x 1 root root 18792 Dec  4 21:13 sorttable*
-rwxr-xr-x 1 root root 43096 Dec  4 21:13 unifdef*
2.5.3 dpkg-deb

使用dpkg-deb工具将指定的目录打包成一个debian软件包;

dpkg-deb -Zgzip -b ${KERNEL_SRC}/debian/linux-headers ${KERNEL_HEADERS_DEB}

dpkg-deb命令的含义:

  • dpkg-deb: 这是一个debian软件包管理工具,用于创建、操作和管理debian软件包;
  • -Zgzip: 这是一个选项,表示使用 gzip 压缩格式来压缩数据;
  • -b ${KERNEL_SRC}/debian/linux-headers ${KERNEL_HEADERS_DEB}: 这部分指定了要打包的目录以及输出的软件包路径;
    • ${KERNEL_SRC}/debian/linux-headers 是要打包的目录,即./kernel-rk3588/debian/linux-headers目录;
    • ${KERNEL_HEADERS_DEB} 是输出的debian软件包路径,即./out/linux-headers-6.1.25.deb目录;

这里将./kernel-rk3588/debian/linux-headers打包成debian软件包,软件包名称为./out/linux-headers-6.1.25.deb

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# ll out/
drwxr-xr-x  7 root root     4096 Dec  4 22:54 cryptodev-linux/
-rw-r--r--  1 root root 11283434 Dec  4 22:57 linux-headers-6.1.25.deb # 生成的dep软件包 
drwxr-xr-x  4 root root     4096 Dec  4 22:43 nft-fullcone/
drwxr-xr-x  3 root root     4096 Dec  4 22:54 output_rk3588_kmodules/
drwxr-xr-x  3 root root     4096 Dec  4 22:54 r8125/
drwxr-xr-x 22 root root     4096 Dec  4 22:58 rootfs_new/
drwxr-xr-x  8 root root     4096 Dec  4 22:46 rtl8812au/
drwxr-xr-x  9 root root     4096 Dec  4 22:44 rtl8821CU/
drwxr-xr-x  8 root root     4096 Dec  4 22:45 rtl8822bu/
drwxr-xr-x  8 root root     4096 Dec  4 22:45 rtl8822cs/
drwxr-xr-x  4 root root    16384 Dec  4 22:54 rtw88/

2.6 scripts/mkimg

scripts/mkimg脚本内容如下:

点击查看代码
set -e -x

usage() {
        cat >&2 << USAGE
usage: $0 [-h] --dtb DTB

optional arguments:
  -h, --help            show this help message and exit
  --dtb DTB             the dtb file name
USAGE
}

# Parse command-line arguments
while [ $# -gt 0 ]; do
        case $1 in
                --dtb)
                        DTB=$2
                        shift 2
                        ;;
                --keep-dtb-name)
                        DTB_ARGS="--dtbname"; shift 1;;
                -h)
                        usage
                        exit 0
                        ;;
                --help)
                        usage
                        exit 0
                        ;;
                *)
                        shift
                        ;;
        esac
done

srctree=${srctree-"."}
objtree=${objtree-"."}
if [ "${ARCH}" == "" ]; then
        if [ "$($srctree/scripts/config --state CONFIG_ARM)" == "y" ]; then
                ARCH=arm
        else
                ARCH=arm64
        fi
fi

LOGO_PATH=${srctree}/logo.bmp
[ -f ${LOGO_PATH} ] && LOGO=logo.bmp

LOGO_KERNEL_PATH=${srctree}/logo_kernel.bmp
[ -f ${LOGO_KERNEL_PATH} ] && LOGO_KERNEL=logo_kernel.bmp

KERNEL_IMAGE_PATH=${objtree}/arch/${ARCH}/boot/Image
KERNEL_IMAGE_ARG="--kernel ${KERNEL_IMAGE_PATH}"
if [ "${ARCH}" == "arm" ]; then
        DTB_PATH=${objtree}/arch/arm/boot/dts/${DTB}
        ZIMAGE=zImage
else
        DTB_PATH=${objtree}/arch/arm64/boot/dts/rockchip/${DTB}
        ZIMAGE=Image.lz4
fi
KERNEL_ZIMAGE_PATH=${objtree}/arch/${ARCH}/boot/${ZIMAGE}
KERNEL_ZIMAGE_ARG="--kernel ${KERNEL_ZIMAGE_PATH}"
if ! find ${DTB_PATH} >/dev/null; then
        echo "No dtb" >&2
        usage
        exit 1
fi

OUT=out
ITB=${BOOT_IMG}
ITS=${OUT}/boot.its
MKIMAGE=${MKIMAGE-"mkimage"}
MKIMAGE_ARG="-E -p 0x800"

make_boot_img()
{
        RAMDISK_IMG_PATH=${objtree}/ramdisk.img
        [ -f ${RAMDISK_IMG_PATH} ] && RAMDISK_IMG=ramdisk.img && RAMDISK_ARG="--ramdisk ${RAMDISK_IMG_PATH}"

        ${srctree}/scripts/mkbootimg \
                ${KERNEL_IMAGE_ARG} \
                ${RAMDISK_ARG} \
                --second resource.img \
                -o boot.img && \
        echo "  Image:  boot.img (with Image ${RAMDISK_IMG} resource.img) is ready";
        [ -f ${KERNEL_ZIMAGE_PATH} ] || return 0
        ${srctree}/scripts/mkbootimg \
                ${KERNEL_ZIMAGE_ARG} \
                ${RAMDISK_ARG} \
                --second resource.img \
                -o zboot.img && \
        echo "  Image:  zboot.img (with ${ZIMAGE} ${RAMDISK_IMG} resource.img) is ready"
}

repack_boot_img()
{
        ${srctree}/scripts/repack-bootimg \
                --boot_img ${BOOT_IMG} --out ${OUT} \
                ${KERNEL_IMAGE_ARG} \
                --second resource.img \
                --dtb ${DTB_PATH} \
                -o boot.img &&
        echo "  Image:  boot.img (${BOOT_IMG} + Image) is ready";
        ${srctree}/scripts/repack-bootimg \
                --boot_img ${BOOT_IMG} --out ${OUT} \
                ${KERNEL_ZIMAGE_ARG} \
                --second resource.img \
                --dtb ${DTB_PATH} \
                -o zboot.img && \
        echo "  Image:  zboot.img (${BOOT_IMG} + ${ZIMAGE}) is ready"
}

# 检查和设置mkimg命令的路径及其参数 /usr/bin/mkimage
check_mkimage()
{
		# 查找mkimg命令的完整路径  /usr/bin/mkimage
        MKIMAGE=$(type -p ${MKIMAGE} || true)
        # 检查变量是否为空
        if [ -z "${MKIMAGE}" ]; then
                # Doesn't exist
                echo '"mkimage" command not found - U-Boot images will not be built' >&2
                exit 1;
        fi
        # 检查命令是否支持-B size参数
        if ${MKIMAGE} 2>&1 | grep -q "\[-B size\]"; then
                MKIMAGE_ARG="-B 0x200 ${MKIMAGE_ARG}"
        fi
}

# 解析boot.img文件得到各个节点的原始文件,保存到out目录
unpack_itb()
{
        rm -rf ${OUT}
        mkdir -p ${OUT}

		# 根据dtb文件布局规则解析boot.img文件,获取每个节点的名字
        for NAME in $(fdtget -l ${ITB} /images)
        do
                # generate image
                NODE="/images/${NAME}"
                OFFS=$(fdtget -ti ${ITB} ${NODE} data-position)
                SIZE=$(fdtget -ti ${ITB} ${NODE} data-size)
                if [ -z ${OFFS} ]; then
                        continue;
                fi

                if [ ${SIZE} -ne 0 ]; then
                		# 从boot.img文件获取当前节点的内容,并输出到out/${NAME}
                        dd if=${ITB} of=${OUT}/${NAME} bs=${SIZE} count=1 skip=${OFFS} iflag=skip_bytes >/dev/null 2>&1
                else
                        touch ${OUT}/${NAME}
                fi
        done

        [ ! -f ${OUT}/kernel ] && echo "FIT ${ITB} no kernel" >&2 && exit 1 || true
}

# 解析boot.img生成out/boot.its文件
gen_its()  
{
        TMP_ITB=${OUT}/boot.tmp

        # add placeholder   boot.img => out/boot.tmp
        cp ${ITB} ${TMP_ITB}
        # 根据dtb文件布局规则解析boot.img文件,获取每个节点的名字
        for NAME in $(fdtget -l ${ITB} /images); do
        		# 将/INCBIN/(${NAME})写入out/boot.tmp的/images/${NAME}节点的data属性中
                fdtput -t s ${TMP_ITB} /images/${NAME} data "/INCBIN/(${NAME})"
        done
        # 解析out/boot.tmp生成out/boot.its文件
        dtc -I dtb -O dts ${TMP_ITB} -o ${ITS} >/dev/null 2>&1
        rm -f ${TMP_ITB}

        # fixup placeholder: data = "/INCBIN/(...)"; -> data = /incbin/("...");
        sed -i "s/\"\/INCBIN\/(\(.*\))\"/\/incbin\/(\"\1\")/" ${ITS}

        # remove  删除包含特定模式的行
        sed -i "/memreserve/d"          ${ITS}
        sed -i "/timestamp/d"           ${ITS}
        sed -i "/data-size/d"           ${ITS}
        sed -i "/data-position/d"       ${ITS}
        sed -i "/value/d"               ${ITS}
        sed -i "/hashed-strings/d"      ${ITS}
        sed -i "/hashed-nodes/d"        ${ITS}
        sed -i "/signer-version/d"      ${ITS}
        sed -i "/signer-name/d"         ${ITS}
}

# 使用新编译生成的设备树、resource.img、kernel镜像覆盖out目录下的对应文件,根据out/boot.its描述打包镜像生成boot.img文件
gen_itb()
{
		# 使用新的dtb覆盖out/fdt
        [ -f ${OUT}/fdt ] && cp -a ${DTB_PATH} ${OUT}/fdt && FDT=" + ${DTB}"
		# 使用新的resource覆盖out/resource
        [ -f ${OUT}/resource ] && cp -a resource.img ${OUT}/resource && RESOURCE=" + resource.img"
        # 获取kernel节点压缩方式
        COMP=$(fdtget ${ITB} /images/kernel compression)
        case "${COMP}" in
                gzip)   EXT=".gz";;
                lz4)    EXT=".lz4";;
                bzip2)  EXT=".bz2";;
                lzma)   EXT=".lzma";;
                lzo)    EXT=".lzo";;
        esac
        # 使用新的内核镜像覆盖out/kernel
        cp -a ${KERNEL_IMAGE_PATH}${EXT} ${OUT}/kernel && \
        # /usr/bin/mkimage -E -p 0x800 -f out/boot.its boot.img
        ${MKIMAGE} ${MKIMAGE_ARG} -f ${ITS} boot.img >/dev/null && \
        echo "  Image:  boot.img (FIT ${BOOT_IMG} + Image${EXT}${FDT}${RESOURCE}) is ready";
        if [ "${EXT}" == "" ] && [ -f ${KERNEL_ZIMAGE_PATH} ]; then
                cp -a ${KERNEL_ZIMAGE_PATH} ${OUT}/kernel && \
                ${MKIMAGE} ${MKIMAGE_ARG} -f ${ITS} zboot.img >/dev/null && \
                echo "  Image:  zboot.img (FIT ${BOOT_IMG} + zImage${FDT}${RESOURCE}) is ready";
        fi
}

repack_itb()
{
        check_mkimage
        unpack_itb
        gen_its
        gen_itb
}
# Create U-Boot FIT Image use ${BOOT_ITS}
make_fit_boot_img()
{
        ITS=${OUT}/boot.its

        check_mkimage
        mkdir -p ${OUT}
        rm -f ${OUT}/fdt ${OUT}/kernel ${OUT}/resource ${ITS}

        cp -a ${BOOT_ITS} ${ITS}
        cp -a ${DTB_PATH} ${OUT}/fdt
        cp -a ${KERNEL_ZIMAGE_PATH} ${OUT}/kernel
        cp -a resource.img ${OUT}/resource

        if [ "${ARCH}" == "arm64" ]; then
                sed -i -e 's/arch = ""/arch = "arm64"/g' -e 's/compression = ""/compression = "lz4"/' ${ITS}
        else
                sed -i -e 's/arch = ""/arch = "arm"/g' -e 's/compression = ""/compression = "none"/' ${ITS}
        fi
        FIT_DESC=$(${MKIMAGE} ${MKIMAGE_ARG} -f ${ITS} boot.img | grep "FIT description" | sed 's/FIT description: //')
        echo "  Image:  boot.img (${FIT_DESC}) is ready";
}

if [ -x ${srctree}/scripts/bmpconvert ]; then
        if [ -f ${LOGO_PATH} ]; then
                ${srctree}/scripts/bmpconvert ${LOGO_PATH};
        fi
        if [ -f ${LOGO_KERNEL_PATH} ]; then
                ${srctree}/scripts/bmpconvert ${LOGO_KERNEL_PATH};
        fi
fi

if [ "${srctree}" != "${objtree}" ]; then
        if [ -f ${LOGO_PATH} ]; then
                cp -a ${LOGO_PATH} ${objtree}/;
        fi
        if [ -f ${LOGO_KERNEL_PATH} ]; then
                cp -a ${LOGO_KERNEL_PATH} ${objtree}/;
        fi
fi

scripts/resource_tool ${DTB_ARGS} ${DTB_PATH} ${LOGO} ${LOGO_KERNEL} >/dev/null
echo "  Image:  resource.img (with ${DTB} ${LOGO} ${LOGO_KERNEL}) is ready"

if [ -f "${BOOT_IMG}" ]; then
        if file -L -p -b ${BOOT_IMG} | grep -q 'Device Tree Blob' ; then
                repack_itb;
        elif [ -x ${srctree}/scripts/repack-bootimg ]; then
                repack_boot_img;
        fi
elif [ -f "${BOOT_ITS}" ]; then
        make_fit_boot_img;
elif [ -x ${srctree}/scripts/mkbootimg ]; then
        make_boot_img;
fi
2.6.1 解析入参

首先解析传递的参数:

# Parse command-line arguments
while [ $# -gt 0 ]; do		
        case $1 in
                --dtb)
                        DTB=$2
                        shift 2
                        ;;
                --keep-dtb-name)
                        DTB_ARGS="--dtbname"; shift 1;;
                -h)
                        usage
                        exit 0
                        ;;
                --help)
                        usage
                        exit 0
                        ;;
                *)
                        shift
                        ;;
        esac
done

比如我们传入:

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/kernel-rk3588$ sudo scripts/mkimg --dtb rk3*-nanopi*-rev*.dtb --keep-dtb-name

由于第一个参数是--dtb,因此走--dtb分支,设置DTB=rk3*-nanopi*-rev*.dtb,然后将参数左移2位;

再次解析参数第一个参数为--keep-dtb-name,因此走--keep-dtb-name分支,设置DTB_ARGS=--dtbname,然后就昂参数左移1位。

2.6.2 变量初始化

接下来是初始化一堆变量:

srctree=${srctree-"."}
objtree=${objtree-"."}
if [ "${ARCH}" == "" ]; then
        if [ "$($srctree/scripts/config --state CONFIG_ARM)" == "y" ]; then
                ARCH=arm
        else
                ARCH=arm64
        fi
fi

LOGO_PATH=${srctree}/logo.bmp
[ -f ${LOGO_PATH} ] && LOGO=logo.bmp

LOGO_KERNEL_PATH=${srctree}/logo_kernel.bmp
[ -f ${LOGO_KERNEL_PATH} ] && LOGO_KERNEL=logo_kernel.bmp

KERNEL_IMAGE_PATH=${objtree}/arch/${ARCH}/boot/Image
KERNEL_IMAGE_ARG="--kernel ${KERNEL_IMAGE_PATH}"

if [ "${ARCH}" == "arm" ]; then
        DTB_PATH=${objtree}/arch/arm/boot/dts/${DTB}
        ZIMAGE=zImage
else
        DTB_PATH=${objtree}/arch/arm64/boot/dts/rockchip/${DTB}
        ZIMAGE=Image.lz4
fi
KERNEL_ZIMAGE_PATH=${objtree}/arch/${ARCH}/boot/${ZIMAGE}
KERNEL_ZIMAGE_ARG="--kernel ${KERNEL_ZIMAGE_PATH}"
# 查找dtb文件
if ! find ${DTB_PATH} >/dev/null; then
        echo "No dtb" >&2
        usage
        exit 1
fi

OUT=out
ITB=${BOOT_IMG}
ITS=${OUT}/boot.its
MKIMAGE=${MKIMAGE-"mkimage"}
MKIMAGE_ARG="-E -p 0x800"

执行完毕:

srctree=.
objtree=.
ARCH=arm64
LOGO_PATH=./logo.bmp
LOGO=logo.bmp
LOGO_KERNEL_PATH=./logo_kernel.bmp
LOGO_KERNEL=logo_kernel.bmp
KERNEL_IMAGE_PATH=./arch/arm64/boot/Image
KERNEL_IMAGE_ARG='--kernel ./arch/arm64/boot/Image'
DTB_PATH='./arch/arm64/boot/dts/rockchip/rk3*-nanopi*-rev*.dtb'
ZIMAGE=Image.lz4
KERNEL_ZIMAGE_PATH=./arch/arm64/boot/Image.lz4
KERNEL_ZIMAGE_ARG='--kernel ./arch/arm64/boot/Image.lz4'
OUT=out
ITB=   # 可以指定为boot.img
ITS=out/boot.its
MKIMAGE=mkimage
2.6.3 图片转换

接着是图片转换:

if [ -x ${srctree}/scripts/bmpconvert ]; then
		# ./scripts/bmpconvert ./logo.bmp
        if [ -f ${LOGO_PATH} ]; then
                ${srctree}/scripts/bmpconvert ${LOGO_PATH};
        fi
        #  ./scripts/bmpconvert ./logo_kernel.bmp	
        if [ -f ${LOGO_KERNEL_PATH} ]; then
                ${srctree}/scripts/bmpconvert ${LOGO_KERNEL_PATH};
        fi
fi

if [ "${srctree}" != "${objtree}" ]; then
        if [ -f ${LOGO_PATH} ]; then
                cp -a ${LOGO_PATH} ${objtree}/;
        fi
        if [ -f ${LOGO_KERNEL_PATH} ]; then
                cp -a ${LOGO_KERNEL_PATH} ${objtree}/;
        fi
fi
2.6.4 生成resource.img

接着执行如下命令:

scripts/resource_tool ${DTB_ARGS} ${DTB_PATH} ${LOGO} ${LOGO_KERNEL} >/dev/null
# 替换参数
scripts/resource_tool --dtbname  \
	./arch/arm64/boot/dts/rockchip/rk3399-nanopi4-rev00.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3399-nanopi4-rev01.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3399-nanopi4-rev04.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3399-nanopi4-rev06.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3399-nanopi4-rev07.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3399-nanopi4-rev09.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3399-nanopi4-rev0a.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3399-nanopi4-rev0b.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3399-nanopi4-rev21.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3399-nanopi4-rev22.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3568-nanopi5-rev01.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3568-nanopi5-rev02.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3568-nanopi5-rev03.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3568-nanopi5-rev04.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3568-nanopi5-rev07.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3588-nanopi6-rev01.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3588-nanopi6-rev02.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3588-nanopi6-rev03.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3588-nanopi6-rev04.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3588-nanopi6-rev05.dtb  \
	./arch/arm64/boot/dts/rockchip/rk3588-nanopi6-rev09.dtb  \
	logo.bmp logo_kernel.bmp

这里调用scripts/resource_tool工具由设备树、图片资源文件编译生成resource.imgscripts/resource_tool工具是由scripts/resource_tool.c源码编译生成的。

2.6.5 生成boot.img

这里会根据入参不同调用不同的方法来生成boot.img

if [ -f "${BOOT_IMG}" ]; then
		# 如果是FIT uImage格式镜像,是可以搜索到Device Tree Blo字符串的
        if file -L -p -b ${BOOT_IMG} | grep -q 'Device Tree Blob' ; then
                repack_itb;
        # Android bootimg格式
        elif [ -x ${srctree}/scripts/repack-bootimg ]; then
                repack_boot_img;
        fi
elif [ -f "${BOOT_ITS}" ]; then
        make_fit_boot_img;
elif [ -x ${srctree}/scripts/mkbootimg ]; then
        make_boot_img;
fi

无论走的哪个分支,最终都是为了生存boot.img,只不过生成的镜像格式不同;

  • FIT uImage:使用于fit启动方式;
  • Android bootimg:适用于 android启动方式。
2.6.5.1 repack_itb

如果指定了BOOT_IMG=boot.img,并且当前目录下有boot.img文件;

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/kernel-rk3588$ ll boot.img
-rw-r--r-- 1 root root 41482240  7月 15 20:53 boot.img

假设满足第一个条件,会进入repack_itb分支;

repack_itb()
{
		# 检查和设置mkimg命令的路径及其参数 /usr/bin/mkimage
        check_mkimage
        # 根据itb文件布局,解析boot.img中每个节点的信息,并将每个节点中的数据解析到out/节点名称
        # 由于boot.img是FIT uImage,是由若干文件按照its描述打包生成的,这里实际上就是把原始镜像文件解析到out目录
        unpack_itb
        # 解析boot.img生成out/boot.its文件
        gen_its
        # 使用新编译生成的设备树、resource.img、kernel镜像覆盖out目录下的对应文件,使用/usr/bin/mkimage工具根据out/boot.its描述打包镜像生成boot.img文件
        gen_itb
}

这里我大概看了一下是通过调用mkimage工具,根据its文件中的描述来打包镜像生成boot.img文件(FIT uImage格式)。由于代码比较多,就不深究了。

2.6.5.2 make_fit_boot_img

如果未指定BOOT_IMG,但是指定了BOOT_IMG=boot.img,并且当前目录下有boot.its文件;

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/kernel-rk3588$ ll boot.its
-rw-r--r-- 1 root root 1410 12月  4  2023 boot.its

这里会通过make_fit_boot_img生成boot.itb镜像;

# Create U-Boot FIT Image use ${BOOT_ITS}
make_fit_boot_img()
{
	    # out/boot.its
        ITS=${OUT}/boot.its

        check_mkimage
        # 目录不存在创建out目录
        mkdir -p ${OUT}
        # 删除out目录下文件
        rm -f ${OUT}/fdt ${OUT}/kernel ${OUT}/resource ${ITS}
		
		# 拷贝boot.its -> out/boot.its
        cp -a ${BOOT_ITS} ${ITS}
		# 拷贝./arch/arm64/boot/dts/rockchip/rk3*-nanopi*-rev*.dtb -> out/fdt,这里应该有点问题 应该是一个具体的dtb文件
        cp -a ${DTB_PATH} ${OUT}/fdt
		# 拷贝./arch/arm64/boot/Image.lz4  -> out/kernel
        cp -a ${KERNEL_ZIMAGE_PATH} ${OUT}/kernel
		# 拷贝resource.img -> out/resource
        cp -a resource.img ${OUT}/resource

		# 替换out/boot.its文件中的arch = "" 为arch = "arm64"
		# 替换out/boot.compression = "" 为compression = "lz4"
        if [ "${ARCH}" == "arm64" ]; then
                sed -i -e 's/arch = ""/arch = "arm64"/g' -e 's/compression = ""/compression = "lz4"/' ${ITS}
        else
                sed -i -e 's/arch = ""/arch = "arm"/g' -e 's/compression = ""/compression = "none"/' ${ITS}
        fi
        # /usr/bin/mkimage -E -p 0x800 -f out/boot.its boot.img
        FIT_DESC=$(${MKIMAGE} ${MKIMAGE_ARG} -f ${ITS} boot.img | grep "FIT description" | sed 's/FIT description: //')
        echo "  Image:  boot.img (${FIT_DESC}) is ready";
}

可以看到这里就是调用mkimage工具,根据boot.its文件中的描述来打包镜像生成boot.img文件(FIT uImage格式);

/dts-v1/;
/ {
    description = "FIT image with Linux kernel, FDT blob and resource";

    images {
        fdt {
            data = /incbin/("fdt");
            type = "flat_dt";
            arch = "arm64";
            compression = "lz4";
            load = <0xffffff00>;

            hash {
                algo = "sha256";
            };
        };

        kernel {
            data = /incbin/("kernel");
            type = "kernel";
            arch = "arm64";
            os = "linux";
            compression = "lz4";
            entry = <0xffffff01>;
            load = <0xffffff01>;

            hash {
                algo = "sha256";
            };
        };

        resource {
            data = /incbin/("resource");
            type = "multi";
            arch = "arm64";
            compression = "lz4";

            hash {
                algo = "sha256";
            };
        };
    };

    configurations {
        default = "conf";

        conf {
            rollback-index = <0x00>;
            fdt = "fdt";
            kernel = "kernel";
            multi = "resource";

            signature {
                algo = "sha256,rsa2048";
                padding = "pss";
                key-name-hint = "dev";
                sign-images = "fdt", "kernel", "multi";
            };
        };
    };
};
2.6.5.3 make_boot_img

如果以上两种都无法满足,则执行make_boot_img

make_boot_img()
{
        RAMDISK_IMG_PATH=${objtree}/ramdisk.img
        [ -f ${RAMDISK_IMG_PATH} ] && RAMDISK_IMG=ramdisk.img && RAMDISK_ARG="--ramdisk ${RAMDISK_IMG_PATH}"

        ${srctree}/scripts/mkbootimg \
                ${KERNEL_IMAGE_ARG} \
                ${RAMDISK_ARG} \
                --second resource.img \
                -o boot.img && \
        echo "  Image:  boot.img (with Image ${RAMDISK_IMG} resource.img) is ready";
        [ -f ${KERNEL_ZIMAGE_PATH} ] || return 0
        ${srctree}/scripts/mkbootimg \
                ${KERNEL_ZIMAGE_ARG} \
                ${RAMDISK_ARG} \
                --second resource.img \
                -o zboot.img && \
        echo "  Image:  zboot.img (with ${ZIMAGE} ${RAMDISK_IMG} resource.img) is ready"
}

这里调用了mkbootimg脚本生成boot.img,而该脚本内部又调用了scripts/mkbootimg脚本,scripts/mkbootimgpython实现的而且代码很长,这里就不深究了;

./scripts/mkbootimg --kernel ./arch/arm64/boot/Image --second resource.img -o boot.img

需要注意的是通过这种方式打包生成的镜像并不是FIT uImage格式;

# 查看不到任何节点
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/kernel-rk3588$ fdtget boo.img /images
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/kernel-rk3588$ file boot.img
boot.img: Android bootimg, kernel (0x10008000), second stage (0x10f00000), page size: 2048

三、编译uboot

3.1 下载uboot

下载uboot源代码:

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# git clone https://github.com/friendlyarm/uboot-rockchip --depth 1 -b nanopi6-v2017.09

3.2 修改脚本

3.2.1 修改build-uboot.sh脚本

在编译内核之前我们需要修改build-uboot.sh脚本;将如下代码移除:

export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH 

if [ ! -d /opt/FriendlyARM/toolchain/11.3-aarch64 ]; then
        echo "please install aarch64-gcc-11.3 first, using these commands: "
        echo "    git clone https://github.com/friendlyarm/prebuilts.git -b master --depth 1"
        echo "    cd prebuilts/gcc-x64"
        echo "    sudo tar xvf toolchain-11.3-aarch64.tar.xz -C /"
        exit 1
fi
3.2.2 修改./uboot-rockchip/make.sh脚本

根据自己安装的交叉编译环境,修改make.sh设置交叉编译工具路径::

PREBUILTS_GCC_ARM32=/usr/bin
PREBUILTS_GCC_ARM64=/usr/bin    

3.3 编译uboot

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# rm -rf rkbin  # 删除的目的,是为了重新下载rkbin
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# UBOOT_SRC=$PWD/uboot-rockchip ./build-uboot.sh debian-bullseye-desktop-arm64

编译完成后debian-bullseye-desktop-arm64目录下的uboot.img被更新了;

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# ll out/ll debian-bullseye-desktop-arm64
-rw-r--r--  1 root root    8072140 May 28  2023 boot.img
-rw-r--r--  1 root root       1424 May 28  2023 dtbo.img
-rw-r--r--  1 root root     307200 Sep  8 23:33 idbloader.img
-rw-r--r--  1 root root         64 Nov 17 10:03 info.conf
-rw-r--r--  1 root root   37910548 Dec  4 22:57 kernel.img
-rw-r--r--  1 root root     471488 Dec  4 23:26 MiniLoaderAll.bin  # 更新了
-rw-r--r--  1 root root      49152 May 28  2023 misc.img
-rw-r--r--  1 root root        470 Dec  4 22:59 parameter.txt
-rw-r--r--  1 root root    5785600 Dec  4 22:57 resource.img
-rw-r--r--  1 root root 3986211708 Dec  4 22:59 rootfs.img
-rw-r--r--  1 root root    4194304 Dec  4 23:26 uboot.img  # 更新了
-rw-r--r--  1 root root     159868 Nov 17 10:03 userdata.img

3.4 build-uboot.sh分析

如果感兴趣可以分析一下./build-uboot.sh的主要工作流程。

3.4.1 make.sh nanopi6

进入uboot-rockchip目录下执行如下命令 :

cd ${UBOOT_SRC}
make distclean
./make.sh nanopi6

其中:UBOOT_SRC./uboot-rockchip,即uboot源码目录。

有关make.sh文件我们在博客Rockchip RK3399 - TPL/SPL方式加载uboot中有提及到,这是官方提供的一个自动构建的脚本。

我们在命令行输入:

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/uboot-rockchip# ./make.sh help

查看具体编译指令,如下图:

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/uboot-rockchip# ./make.sh help

Usage:
        ./make.sh [board|sub-command]

         - board:        board name of defconfig
         - sub-command:  elf*|loader|trust|uboot|--spl|--tpl|itb|map|sym|<addr>
         - ini:          ini file to pack trust/loader

Output:
         When board built okay, there are uboot/trust/loader images in current directory

Example:

1. Build:
        ./make.sh evb-rk3588               --- build for evb-rk3588_defconfig
        ./make.sh firefly-rk3288           --- build for firefly-rk3288_defconfig
        ./make.sh EXT_DTB=rk-kernel.dtb    --- build with exist .config and external dtb
        ./make.sh                          --- build with exist .config
        ./make.sh env                      --- build envtools

2. Pack:
        ./make.sh uboot                    --- pack uboot.img
        ./make.sh trust                    --- pack trust.img
        ./make.sh trust <ini>              --- pack trust img with assigned ini file
        ./make.sh loader                   --- pack loader bin
        ./make.sh loader <ini>             --- pack loader img with assigned ini file
        ./make.sh --spl                    --- pack loader with u-boot-spl.bin
        ./make.sh --tpl                    --- pack loader with u-boot-tpl.bin
        ./make.sh --tpl --spl              --- pack loader with u-boot-tpl.bin and u-boot-spl.bin

3. Debug:
        ./make.sh elf                      --- dump elf file with -D(default)
        ./make.sh elf-S                    --- dump elf file with -S
        ./make.sh elf-d                    --- dump elf file with -d
        ./make.sh elf-*                    --- dump elf file with -*
        ./make.sh <no reloc_addr>          --- unwind address(no relocated)
        ./make.sh <reloc_addr-reloc_off>   --- unwind address(relocated)
        ./make.sh map                      --- cat u-boot.map
        ./make.sh sym                      --- cat u-boot.sym

因此当执行./make.sh nanopi6时,实际上编译使用的defonfig文件为configs/nanopi6_defconfig。由于该脚本内容较多,这里就不去分析其编译流程了。

编译完成后会在./uboot-rockchip目录下生成uboot.imgrk3588_spl_loader_v1.08.111.bin文件;

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# ll uboot-rockchip/uboot.img
-rw-r--r-- 1 root root 4194304 Dec  4 23:26 uboot-rockchip/uboot.img
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# ll uboot-rockchip/rk3588_spl_loader_v1.12.112.bin
-rw-r--r-- 1 root root 471488 Dec  4 23:26 uboot-rockchip/rk3588_spl_loader_v1.12.112.bin
3.4.2 update_uboot_bin.sh

update_uboot_bin.sh脚本用于更新./debian-bullseye-desktop-arm64目录下的MiniLoaderAll.binuboot.img

./tools/update_uboot_bin.sh ${UBOOT_SRC} ${TOPPATH}/${TARGET_OS}

其中:

  • UBOOT_SRC./uboot-rockchip,即uboot源码目录;
  • ${TOPPATH}/${TARGET_OS}./debian-bullseye-desktop-arm64

update_uboot_bin.sh 源码如下:

#!/bin/bash
set -eu

[ -f ${PWD}/mk-emmc-image.sh ] || {
        echo "Error: please run at the script's home dir"
        exit 1
}

if [ $# -ne 2 ]; then
        echo "number of args must be 2"
        exit 1
fi

# LOADER_DOT_BIN=./uboot-rockchip/rk3588_spl_loader_v1.12.112.bin
LOADER_DOT_BIN==`ls $1/rk3588_spl_loader_*.bin 2>/dev/null | sort -n | tail -1`
if [ -f ${LOADER_DOT_BIN} ]; then
    cp -f ${LOADER_DOT_BIN} $2/MiniLoaderAll.bin   # 拷贝 1
else
    echo "not found $1/rk3588_spl_loader_*.bin, pls build u-boot first."
    exit 1
fi
cp -f $1/uboot.img $2/  # 拷贝 2

exit $?

四、制作SD卡固件

固件文件一般有两种:

  • 单个统一固件:统一固件是由分区表、bootloaderubootkernelsystem等所有文件打包合并成的单个文件。一般官方正式发布的固件都是采用统一固件格式,升级统一固件将会更新主板上所有分区的数据和分区表,并且擦除主板上所有数据;
  • 多个分区镜像:即各个功能独立的文件,如分区表、bootloaderkernel等,在开发阶段生成。独立分区镜像可以只更新指定的分区,而保持其它分区数据不被破坏,在开发过程中会很方便调试;

通过统一固件解包/打包工具,可以把统一固件解包为多个分区镜像,也可以将多个分区镜像合并为一个统一固件。

4.1 生成统一固件

debian-bullseye-desktop-arm64目录下的镜像文件重新打包成SD卡固件:

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# ./mk-sd-image.sh debian-bullseye-desktop-arm64
Creating RAW image: out/rk3588-sd-debian-bullseye-desktop-6.1-arm64-20231205.img (7800 MB)
---------------------------------
记录了0+0 的读入
记录了0+0 的写出
0字节已复制,0.000145548 s,0.0 kB/s
----------------------------------------------------------------
[out/rk3588-sd-debian-bullseye-desktop-6.1-arm64-20231205.img] capacity = 7438MB, 7799999488 bytes
current out/rk3588-sd-debian-bullseye-desktop-6.1-arm64-20231205.img partition:
----------------------------------------------------------------
parsing ./debian-bullseye-desktop-arm64/parameter.txt:
create new GPT 9:
----------------------------------------------------------------
copy from: ./debian-bullseye-desktop-arm64 to out/rk3588-sd-debian-bullseye-desktop-6.1-arm64-20231205.img
 [RAW. 0]:      300 KB | ./debian-bullseye-desktop-arm64/idbloader.img  > 100% : done.
 [RAW. 1]:     4096 KB | ./debian-bullseye-desktop-arm64/uboot.img      > 100% : done.
 [RAW. 2]:       48 KB | ./debian-bullseye-desktop-arm64/misc.img       > 100% : done.
 [RAW. 3]:        1 KB | ./debian-bullseye-desktop-arm64/dtbo.img       > 100% : done.
 [RAW. 4]:     5650 KB | ./debian-bullseye-desktop-arm64/resource.img   > 100% : done.
 [RAW. 5]:    37022 KB | ./debian-bullseye-desktop-arm64/kernel.img     > 100% : done.
 [RAW. 6]:     7882 KB | ./debian-bullseye-desktop-arm64/boot.img       > 100% : done.
 [RAW. 8]:  3892784 KB | ./debian-bullseye-desktop-arm64/rootfs.img     > 100% : done.
 [RAW. 9]:      156 KB | ./debian-bullseye-desktop-arm64/userdata.img   > 100% : done.
----------------------------------------------------------------
---------------------------------
RAW image successfully created (00:04:45).
-rw-r--r-- 1 root root 7799999488 Dec  5 00:04 out/rk3588-sd-debian-bullseye-desktop-6.1-arm64-20231205.img
Tip: You can compress it to save disk space.

sh脚本内部调用了Rockchip官方提供的打包工具生成的统一固件,由于打包工具并不开源,所以无法研究源码。

不过我们大致可以猜测出应该就是做了一个镜像文件,然后按照parameter.txt进行划分分区,并将各个分区镜像依次烧录进去。

命令完成后,生成的统一固件位于out目录,可以用dd命令制作SD启动卡。

4.2 制作SD启动卡

我们将SD卡插入PC上,在虚拟机ubuntu中运行demsg查看新接入的设备;

[32908.310364] loop7: detected capacity change from 0 to 8257536
[32909.079216] EXT4-fs (loop7): mounted filesystem with ordered data mode. Opts: (null). Quota mode: none.
[33991.894980] loop7: detected capacity change from 0 to 8126464
[33991.948702] EXT4-fs (loop7): mounted filesystem with ordered data mode. Opts: (null). Quota mode: none.
[35745.808031] usb 1-1: new high-speed USB device number 2 using ehci-pci
[35746.078673] usb 1-1: New USB device found, idVendor=14cd, idProduct=1212, bcdDevice= 1.00
[35746.078714] usb 1-1: New USB device strings: Mfr=1, Product=3, SerialNumber=2
[35746.078716] usb 1-1: Product: Mass Storage Device
[35746.078717] usb 1-1: Manufacturer: Generic
[35746.078718] usb 1-1: SerialNumber: 121220160204
[35747.340887] usb-storage 1-1:1.0: USB Mass Storage device detected
[35747.341582] scsi host33: usb-storage 1-1:1.0
[35747.342608] usbcore: registered new interface driver usb-storage
[35747.403944] usbcore: registered new interface driver uas
[35748.377640] scsi 33:0:0:0: Direct-Access     Mass     Storage Device   1.00 PQ: 0 ANSI: 0 CCS
[35748.378504] sd 33:0:0:0: Attached scsi generic sg3 type 0
[35748.522897] sd 33:0:0:0: [sdc] 31211520 512-byte logical blocks: (16.0 GB/14.9 GiB)
[35748.526150] sd 33:0:0:0: [sdc] Write Protect is off
[35748.526152] sd 33:0:0:0: [sdc] Mode Sense: 03 00 00 00
[35748.528185] sd 33:0:0:0: [sdc] No Caching mode page found
[35748.528254] sd 33:0:0:0: [sdc] Assuming drive cache: write through
[35748.551595]  sdc: sdc1 sdc2
[35748.571109] sd 33:0:0:0: [sdc] Attached SCSI removable disk
[35802.517787] rfkill: input handler enabled

可以看到SD卡对应的设备节点为/dev/sdc,对应两个分区sdc1sdc2

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# ls /dev/sdc*
/dev/sdc  /dev/sdc1  /dev/sdc2
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# df -hT
文件系统       类型      容量  已用  可用 已用% 挂载点
udev           devtmpfs  3.9G     0  3.9G    0% /dev
tmpfs          tmpfs     791M  3.6M  787M    1% /run
/dev/sda5      ext4       98G   69G   24G   75% /
tmpfs          tmpfs     3.9G     0  3.9G    0% /dev/shm
tmpfs          tmpfs     5.0M  4.0K  5.0M    1% /run/lock
tmpfs          tmpfs     3.9G     0  3.9G    0% /sys/fs/cgroup
/dev/sda1      vfat      511M  4.0K  511M    1% /boot/efi
/dev/loop15    squashfs  497M  497M     0  100% /snap/gnome-42-2204/132
tmpfs          tmpfs     791M     0  791M    0% /run/user/0
tmpfs          tmpfs     791M   36K  791M    1% /run/user/1000
/dev/sdc2      ext4       11G  311M  9.8G    4% /media/zhengyang/userdata
/dev/sdc1      ext4      4.5G  4.4G   35M  100% /media/zhengyang/rootfs

开始制作SD启动卡:

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# dd if=out/rk3588-sd-debian-bullseye-desktop-6.1-arm64-20231205.img of=/dev/sdc bs=1M

五、Linux下烧录固件

Linux下烧录固件到eMMC有多种方法:

  • 其一是将RK3588进入到MASKROM升级模式或者LOADER升级模式,然后通过upgrade_tool工具进行烧录,这个是Rockchip官方提供的linux环境下的烧录工具;
  • 通过dd命令将image文件烧写至image对应的分区;
  • 通过搭建TFTP服务器,通过tftp命令进行下载,这个我们后面的文章会涉及;

注:upgrade_toolRockchip提供的Linux下的命令行工具(Linux_Upgrade_Tool),需要使用v2以上版本。

5.1 upgrade_tool工具烧录

5.1.1 安装upgrade_tool_v2.17_for_linux

下载 upgrade_tool_v2.17_for_linux.zip(位于"05_工具软件"目录下), 并按以下方法安装到系统中,方便调用:

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# unzip upgrade_tool_v2.17_for_linux.zip
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# cd upgrade_tool_v2.17_for_linux
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo cp upgrade_tool /usr/local/bin
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo chown root:root /usr/local/bin/upgrade_tool
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo chmod a+x /usr/local/bin/upgrade_tool
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo apt-get install lib32stdc++6
5.1.2 进入升级模式

将开发板连接上电源,并且通过HDMI接口连接到显示设备,连接Type-C数据线到PC

(1) 进入MASKROM模式

硬件方式:按住Mask键再长按Power键开机(保持按下Mask键5秒以上),将强制进入MASKROM模式;

软件方式:这一步的前提是eMMC已经烧录过固件,比如debian-bullseye-desktop,具体参考上一篇文章:Rockchip RK3588 - NanoPC-T6开发板介绍有关Windows下通过RKDevTool.exe工具烧录的内容。按下Power键开发板启动,串口终端按下CRTL+C进入uboot命令行,通过在串口调试终端输入reboot loader进入MASKROM模式;

=> reboot loader                     #  进入uboot,输入该命令
## Reboot mode: loader(5242c301)

(2) 进入LOADER模式

由于我使用的开发板不支持硬件进入LOADER模式,因此只能通过软件方式进入LOADER模式;

这一步的前提是eMMC已经烧录过固件,比如debian-bullseye-desktop,具体参考上一篇文章:Windows下通过RKDevTool.exe工具烧录。

按下Power键开发板启动,根文件系统加载完成后,通过在桌面终端输入reboot loader进入LOADER模式;

pi@NanoPC-T6:~$ sudo reboot loader
         Stopping Session 1 of user pi.
         Stopping Session 3 of user pi.
         .....

注意:必须从桌面终端输入reboot loader才会进入LOADER模式,如果是在串口调试终端输入reboot loader那么将进入MASKROM模式。

5.1.3 烧写统一固件

按住Mask键再长按Power键开机(保持按下Mask键5秒以上),将强制进入MASKROM模式;

进入MASKROM模式后,运行upgrade_tool后可以看到连接设备中有个Maskrom的提示:

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588# sudo upgrade_tool LD
List of rockusb connected(1)
DevNo=1 Vid=0x2207,Pid=0x350b,LocationID=11     Mode=Maskrom    SerialNo=

烧写统一固件update.img

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo upgrade_tool uf update.img

由于我没有统一固件,这里就不演示了。

5.1.4 烧写分区镜像

我们在开发过程中,经常会对内核、根文件系统、uboot进行修改,在这种情况下我们只需要替换我们修改的镜像文件即可。

这里我们可以尝试在MASKROM模式以及LOADER模式下烧录分区镜像。

(1) 按住Mask键再长按Power键开机(保持按下Mask键5秒以上),将强制进入MASKROM模式,在ubuntu宿主机烧写分区镜像;

root@ubuntu:/work/sambashare/rk3399/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo upgrade_tool ul MiniLoaderAll.bin -noreset
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo upgrade_tool di -p parameter.txt
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo upgrade_tool di -uboot uboot.img
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo upgrade_tool di -misc misc.img 
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo upgrade_tool di -dtbo dtbo.img 
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo upgrade_tool di -resource resource.img
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo upgrade_tool di -k kernel.img      
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo upgrade_tool di -boot boot.img        
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo upgrade_tool di -rootfs rootfs.img    
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo upgrade_tool di -userdata userdata.img 
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo upgrade_tool RD

对于MASKROM模式,其中前两步和最后一步是必须的,中间的步骤根据实际情况进行调整。

由于SoC进入到MASKROM模式后,目标板子会运行Rockusb驱动程序。在MASKROM模式下,烧写镜像需要使用到DDR,因此需要下载固件进行DDR的初始化,所以升级之前第一步要做的就是执行sudo upgrade_tool ul MiniLoaderAll.bin

注意:如果在测试的时候发现,烧录完MiniLoaderAll.bin之后,系统自动重启了,是由于其命令后没有追加 -noreset

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo upgrade_tool ul MiniLoaderAll.bin -noreset
Loading loader...
Support Type:RK3588     Loader ver:1.0b Loader Time:2023-12-04 23:26:21
Start to upgrade loader...
Download Boot Start
Download Boot Success
Wait For Maskrom Start
Wait For Maskrom Success
Test Device Start
Test Device Success
Check Chip Start
Check Chip Success
Get FlashInfo Start
Get FlashInfo Success
Prepare IDB Start
Prepare IDB Success
Download IDB Start
Download IDB Success
Upgrade loader ok.

(2) 按照前面介绍的方法尝试软件方式进入LOADER模式,然后烧录除了MiniLoaderAll.bin之后的所有镜像文件;

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo upgrade_tool LD
List of rockusb connected(1)
DevNo=1 Vid=0x2207,Pid=0x350b,LocationID=11     Mode=Loader     SerialNo=1f0bee682f135e89
root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo upgrade_tool di -p parameter.txt
......

注意:采用这种方式烧录各个分区,在完成烧录之后,测试发现ubootlinux内核均能正常加载,但是挂载根文件系统的时候却失败了,相关错误详情如下,具体原因尚不可知;

Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... done.
[    6.219797] EXT4-fs error (device mmcblk2p8): ext4_get_journal_inode:5728: inode #8: comm mount: iget: bad extra_isize 1487 (inode size 256)
[    6.219971] EXT4-fs (mmcblk2p8): no journal found
mount: mounting /dev/mmcblk2p8 on /root failed: Invalid argument
Begin: Will now check userdata file system ... fsck from util-linux 2.37.2
[/usr/sbin/fsck.ext4 (1) -- /dev/mmcblk2p9] fsck.ext4 -a -C0 /dev/mmcblk2p9
userdata: clean, 11/12800 files, 4958/51200 blocks
done.
[    6.305282] EXT4-fs (mmcblk2p9): mounted filesystem with ordered data mode. Quota mode: none.
[    6.308585] EXT4-fs (mmcblk2p9): unmounting filesystem.
Begin: Resizing ext4 file system on /dev/mmcblk2p9 ... Model: MMC A3A444 (sd/mmc)
Disk /dev/mmcblk2: 100%
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start  End    Size   File system  Name      Flags
 1      0.00%  0.01%  0.00%               uboot
 2      0.01%  0.01%  0.00%               misc
 3      0.01%  0.01%  0.00%               dtbo
 4      0.01%  0.02%  0.01%               resource
 5      0.02%  0.03%  0.02%               kernel
 6      0.03%  0.05%  0.01%               boot
 7      0.05%  0.06%  0.01%               recovery
 8      0.06%  1.74%  1.68%  ext4         rootfs
 9      1.74%  100%   98.3%  ext4         userdata

[    6.473741]  mmcblk2: p1 p2 p3 p4 p5 p6 p7 p8 p9
[    6.477599]  mmcblk2: p1 p2 p3 p4 p5 p6 p7 p8 p9
resize2fs 1.46.5 (30-Dec-2021)
Resizing the filesystem on /dev/mmcblk2p9 to 59364347 (4k) blocks.
The filesystem on /dev/mmcblk2p9 is now 59364347 (4k) blocks long.

done.
[    6.693921] EXT4-fs (mmcblk2p9): mounted filesystem with ordered data mode. Quota mode: none.
[    6.708138] overlayfs: fs on '/root' does not support file handles, falling back to index=off,nfs_export=off.
done.
[    6.708159] overlayfs: fs on '/root' does not support file handles, falling back to xino=off.
Begin: Running /scripts/local-bottom ... done.
Begin: Running /scripts/init-bottom ... mount: mounting /dev on /overlay/dev failed: No such file or directory
mount: mounting /dev on /overlay/dev failed: No such file or directory
done.
mount: mounting /run on /overlay/run failed: No such file or directory
run-init: can't execute '/sbin/init': No such file or directory
Target filesystem doesn't have requested /sbin/init.
run-init: can't execute '/sbin/init': No such file or directory
run-init: can't execute '/etc/init': No such file or directory
run-init: can't execute '/bin/init': No such file or directory
run-init: can't execute '/bin/sh': No such file or directory
run-init: can't execute '': No such file or directory
No init found. Try passing init= bootarg.
[    6.845429] rk_hdmirx fdee0000.hdmirx-controller: hdmirx_cancel_cpu_limit_freq freq qos nod add


BusyBox v1.30.1 (Ubuntu 1:1.30.1-7ubuntu3) built-in shell (ash)
Enter 'help' for a list of built-in commands.

(initramfs) [    7.177250] rk-pcie fe150000.pcie: PCIe Link Fail
[    7.177285] rk-pcie fe150000.pcie: failed to initialize host
[    7.687244] rk-pcie fe180000.pcie: PCIe Link Fail
[    7.687271] rk-pcie fe180000.pcie: failed to initialize host
[   14.941768] platform mtd_vendor_storage: deferred probe pending

(initramfs)

后来我将rootfs.img单独拷贝到Windows系统后,通过RKDevTool.exe工具单独烧录根文件系统之后,系统可以正常启动起来。因此我猜测可能是upgrade_tool烧录过程中出现了什么问题。

(3) 如果想查看分区情况,执行如下命令,该命令会读取设备上的分区表信息,支持parametergpt

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# sudo upgrade_tool pl
Partition Info(gpt):
NO  LBA        Size       Name
01  0x00004000 0x00002000 uboot
02  0x00006000 0x00002000 misc
03  0x00008000 0x00002000 dtbo
04  0x0000a000 0x00008000 resource
05  0x00012000 0x00014000 kernel
06  0x00026000 0x00010000 boot
07  0x00036000 0x00010000 recovery
08  0x00046000 0x007c0000 rootfs
09  0x00806000 0x1c4e9fc0 userdata

此时rootfs占用0x007c0000个扇区,每个扇区512字节,一共4,160,749,568字节,大于rootfs.img的大小。

5.2 dd命令烧录

由于RK3588OS默认均采用GPT分区, 可以用dd命令将image文件烧写至image对应的分区,SD卡与eMMC的设备节点如下:

  • SD/TF Card设备节点为/dev/mmcblk0
  • eMMC设备节点为/dev/mmcblk2

下面步骤的前提是eMMC已经烧录过固件,比如debian-bullseye-desktop,具体参考上一篇文章:《Rockchip RK3588 - NanoPC-T6开发板介绍》有关Windows下通过RKDevTool.exe工具烧录的内容。

下面将演示如何将内核更新到eMMC,开发板上电进入操作系统终端命令行,使用parted命令查看分区布局;

pi@NanoPC-T6:~$ sudo parted /dev/mmcblk2 print
Model: MMC A3A444 (sd/mmc)
Disk /dev/mmcblk2: 247GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name      Flags
 1      8389kB  12.6MB  4194kB               uboot
 2      12.6MB  16.8MB  4194kB               misc
 3      16.8MB  21.0MB  4194kB               dtbo
 4      21.0MB  37.7MB  16.8MB               resource
 5      37.7MB  79.7MB  41.9MB               kernel
 6      79.7MB  113MB   33.6MB               boot
 7      113MB   147MB   33.6MB               recovery
 8      147MB   4308MB  4161MB  ext4         rootfs
 9      4308MB  247GB   243GB   ext4         userdata

其中:

  • uboot分区的序号为1,对应的设备节点为/dev/mmcblk2p1
  • resource分区的序号为4,对应的设备节点为/dev/mmcblk2p4
  • kernel分区的序号为5,对应的设备节点为/dev/mmcblk2p5
  • rootfs分区的序号为8,对应的设备节点为/dev/mmcblk2p8

dd命令如下:

dd if=uboot.img of=/dev/mmcblk2p1 bs=1M
dd if=resource.img of=/dev/mmcblk2p4 bs=1M
dd if=kernel.img of=/dev/mmcblk2p5 bs=1M

如果要更新kernel.img

root@NanoPC-T6:/opt# sudo scp root@192.168.0.200://work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64/kernel.img ./

root@NanoPC-T6:/opt# sudo dd if=kernel.img of=/dev/mmcblk2p5 bs=1M
36+1 records in
36+1 records out
37910548 bytes (38 MB, 36 MiB) copied, 0.296491 s, 128 MB/s

但是这种方式烧录的rootfs.img是无法正常工作的;

dd if=rootfs.img of=/dev/mmcblk2p8 bs=1M

ext4镜像通常使用的有两种格式:

  • raw ext4 image:其特点是完整的ext4分区镜像(如果未使用满则使用0进行填充),可以直接使用mount进行挂载,也可以直接烧写,因此比较大;
  • sparse ext4 image:它是将raw ext4进行稀疏描述,因此尺寸比较小(制作目录有多少文件就计算多少,没有全零填充)。不能直接挂载,在linux下也不能直接烧写,需要还原为raw image格式;

rootfs.img就是sparse ext4 image

root@ubuntu:/work/sambashare/rk3588/friendly/sd-fuse_rk3588/debian-bullseye-desktop-arm64# file rootfs.img
rootfs.img: Android sparse image, version: 1.0, Total of 1015808 4096-byte output blocks in 72 input chunks.

如果要烧写根文件系统,需要使用simg2imgsimgsparse ext4 image)还原为raw ext4 image,再像raw ext4 image那样烧写;

mv rootfs.img rootfs.simg
simg2img rootfs.simg rootfs.ext4

六、调试

6.1 串口连接

使用准备好的USB转串口适配器和连接线(需另购),连接开发板,其使用的是RK3588UART2

引脚 开发板接口 USB转串口
1 GND GND
2 UART2_TX_M0_DEBUG RX
3 UART2_RX_M0_DEBUG TX

其电路原理图如下:

6.2 MobaXterm

这里我使用的串口调试工具是MobaXterm,选择串口端口,设置波特率为1500000,8位数据位,1位停止位。

img

6.3 上电测试

点击查看代码
DDR V1.12 52218f4949 cym 23/07/06-19:46:50
LPDDR4X, 2112MHz
channel[0] BW=16 Col=10 Bk=8 CS0 Row=17 CS1 Row=17 CS=2 Die BW=8 Size=4096MB
channel[1] BW=16 Col=10 Bk=8 CS0 Row=17 CS1 Row=17 CS=2 Die BW=8 Size=4096MB
channel[2] BW=16 Col=10 Bk=8 CS0 Row=17 CS1 Row=17 CS=2 Die BW=8 Size=4096MB
channel[3] BW=16 Col=10 Bk=8 CS0 Row=17 CS1 Row=17 CS=2 Die BW=8 Size=4096MB
Manufacturer ID:0x1
CH0 RX Vref:27.1%, TX Vref:21.8%,21.8%
CH1 RX Vref:25.8%, TX Vref:23.8%,22.8%
CH2 RX Vref:27.9%, TX Vref:21.8%,21.8%
CH3 RX Vref:27.9%, TX Vref:20.8%,22.8%
change to F1: 528MHz
change to F2: 1068MHz
change to F3: 1560MHz
change to F0: 2112MHz
out
U-Boot SPL board init
U-Boot SPL 2017.09-g5f53abfa1e-221223 #zzz (Dec 26 2022 - 09:10:09)
Trying to boot from MMC2
MMC: no card present
mmc_init: -123, time 0
spl: mmc init failed with error: -123
Trying to boot from MMC1
SPL: A/B-slot: _a, successful: 0, tries-remain: 7
Trying fit image at 0x4000 sector
## Verified-boot: 0
## Checking atf-1 0x00040000 ... sha256(b40ce543bb...) + OK
## Checking uboot 0x00200000 ... sha256(9b34bfecc5...) + OK
## Checking fdt 0x00333140 ... sha256(a3ef1c0929...) + OK
## Checking atf-2 0x000f0000 ... sha256(f202de33d9...) + OK
## Checking atf-3 0xff100000 ... sha256(af08976afd...) + OK
## Checking optee 0x08400000 ... sha256(6193f4aac7...) + OK
Jumping to U-Boot(0x00200000) via ARM Trusted Firmware(0x00040000)
Total: 514.190 ms

INFO:    Preloader serial: 2
NOTICE:  BL31: v2.3():v2.3-616-gdc1125f48:finley.xiao
NOTICE:  BL31: Built : 16:41:17, Jul 13 2023
INFO:    spec: 0x1
INFO:    ext 32k is not valid
INFO:    ddr: stride-en 4CH
INFO:    GICv3 without legacy support detected.
INFO:    ARM GICv3 driver initialized in EL3
INFO:    valid_cpu_msk=0xff bcore0_rst = 0x0, bcore1_rst = 0x0
INFO:    system boots from cpu-hwid-0
INFO:    idle_st=0x21fff, pd_st=0x11fff9, repair_st=0xfff70001
INFO:    dfs DDR fsp_params[0].freq_mhz= 2112MHz
INFO:    dfs DDR fsp_params[1].freq_mhz= 528MHz
INFO:    dfs DDR fsp_params[2].freq_mhz= 1068MHz
INFO:    dfs DDR fsp_params[3].freq_mhz= 1560MHz
INFO:    BL31: Initialising Exception Handling Framework
INFO:    BL31: Initializing runtime services
INFO:    BL31: Initializing BL32
I/TC:
I/TC: OP-TEE version: 3.13.0-698-g7f1ea6d6e #hisping.lin (gcc version 10.2.1 20201103 (GNU Toolchain for the A-profile Architecture 10.2-2020.11 (arm-10.16))) #53 Wed Apr 19 14:30:22 CST 2023 aarch64
I/TC: Primary CPU initializing
I/TC: Primary CPU switching to normal world boot
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x200000
INFO:    SPSR = 0x3c9


U-Boot 2017.09-g8241716-dirty #root (Dec 17 2023 - 13:44:36 +0800)

Board: NanoPi R6S
PreSerial: 2, raw, 0xfeb50000
DRAM:  16 GiB
Sysmem: init
Relocation Offset: eda2b000
Relocation fdt: eb9f9e20 - eb9fece0
CR: M/C/I
Using default environment

DM: v2
mmc@fe2c0000: 1, mmc@fe2e0000: 0
Repair the backup gpt table OK!
Bootdev(atags): mmc 0
MMC0: HS400 Enhanced Strobe, 200Mhz
PartType: EFI
boot mode: normal
RESC: 'resource', blk@0x0000a000
optee api revision: 2.0
TEEC: Waring: Could not find security partition
lib/avb/libavb_user/avb_ops_user.c: trusty_read_lock_state failed
Error determining whether device is unlocked.
Device is: UNLOCKED
DTB: rk3588-nanopi6-rev01.dtb (270114)
HASH(c): OK
ANDROID: fdt overlay OK
I2c0 speed: 100000Hz
vsel-gpios- not found!
en-gpios- not found!
vdd_cpu_big0_s0 800000 uV
vsel-gpios- not found!
en-gpios- not found!
vdd_cpu_big1_s0 800000 uV
I2c2 speed: 100000Hz
vsel-gpios- not found!
en-gpios- not found!
vdd_npu_s0 800000 uV
spi2: RK806: 2
ON=0x00, OFF=0x00
vdd_gpu_s0 750000 uV
vdd_cpu_lit_s0 750000 uV
vdd_log_s0 750000 uV
vdd_vdenc_s0 init 750000 uV
vdd_ddr_s0 850000 uV
get vp0 plane mask:0x7, primary id:0, cursor_plane:2, from dts
get vp1 plane mask:0x148, primary id:6, cursor_plane:3, from dts
get vp2 plane mask:0x280, primary id:7, cursor_plane:9, from dts
Could not find baseparameter partition
I2c6 speed: 200000Hz
Rockchip UBOOT DRM driver version: v1.0.1
vp0 have layer nr:3[0 1 2 ], primary plane: 0
vp1 have layer nr:3[3 6 8 ], primary plane: 6
vp2 have layer nr:2[7 9 ], primary plane: 7
vp3 have layer nr:0[], primary plane: 0
Could not find baseparameter partition
color_format:1
hdmi_select_link_config use tmds mode
mode:1920x1080 bus_format:0x2025
hdmi@fde80000:  detailed mode clock 148500 kHz, flags[5]
    H: 1920 2008 2052 2200
    V: 1080 1084 1089 1125
bus_format: 2025
VOP update mode to: 1920x1080p60, type: HDMI0 for VP0
dclk:148500,if_pixclk_div;2,if_dclk_div:4
VP0 set crtc_clock to 148500KHz
VOP VP0 enable Cluster0[800x480->800x480@560x300] fmt[1] addr[0xee01a000]
CEA mode used vic=16
mtmdsclock:148500000
hdptx_ropll_cmn_config bus_width:16a8c8 rate:1485000
hdptx phy pll locked!
dw_hdmi_setup HDMI mode
don't use dsc mode
dw hdmi qp use tmds mode
bus_width:0x16a8c8,bit_rate:1485000
hdptx phy lane locked!
CLK: (sync kernel. arm: enter 1008000 KHz, init 1008000 KHz, kernel 0N/A)
  b0pll 24000 KHz
  b1pll 24000 KHz
  lpll 24000 KHz
  v0pll 24000 KHz
  aupll 786431 KHz
  cpll 1500000 KHz
  gpll 1188000 KHz
  npll 850000 KHz
  ppll 1100000 KHz
  aclk_center_root 702000 KHz
  pclk_center_root 100000 KHz
  hclk_center_root 396000 KHz
  aclk_center_low_root 500000 KHz
  aclk_top_root 750000 KHz
  pclk_top_root 100000 KHz
  aclk_low_top_root 396000 KHz
vdd_usbc 12611 mV

Net:   No ethernet found.
Hit key to stop autoboot('CTRL+C'):  0
## Booting FIT Image FIT: No fit blob
FIT: No FIT image
ANDROID: reboot reason: "(none)"
Not AVB images, AVB skip
No valid android hdr
Android image load failed
Android boot failed, error -1.

## Booting Rockchip Format Image
fdt      @ 0x08300000 (0x000421c2)
kernel   @ 0x00400000 (0x021c7808)
ramdisk  @ 0x0a200000 (0x007b2bc0)
Fdt Ramdisk skip relocation
## Flattened Device Tree blob at 0x08300000
   Booting using the fdt blob at 0x08300000
   Using Device Tree in place at 0000000008300000, end 00000000083451c1
## reserved-memory:
  cma: addr=10000000 size=8000000
  drm-logo@00000000: addr=edf00000 size=468000
  vendor-storage-rm@00000000: addr=ebcd4000 size=10000
  ramoops@110000: addr=110000 size=e0000
Adding bank: 0x00200000 - 0x08400000 (size: 0x08200000)
Adding bank: 0x09400000 - 0xf0000000 (size: 0xe6c00000)
Adding bank: 0x100000000 - 0x3fc000000 (size: 0x2fc000000)
Adding bank: 0x3fc500000 - 0x3fff00000 (size: 0x03a00000)
Adding bank: 0x4f0000000 - 0x500000000 (size: 0x10000000)
Total: 1858.779/2614.247 ms

Starting kernel ...

[    2.625053] Booting Linux on physical CPU 0x0000000000 [0x412fd050]
[    2.625077] Linux version 6.1.25 (root@ubuntu) (aarch64-linux-gnu-gcc (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #5 SMP Sun Dec 17 13:16:14 CST 2023
[    2.632180] Machine model: FriendlyElec NanoPC-T6
[    2.639345] earlycon: uart8250 at MMIO32 0x00000000feb50000 (options '')
[    2.642490] printk: bootconsole [uart8250] enabled
[    2.645283] OF: fdt: Reserved memory: failed to reserve memory for node 'drm-cubic-lut@00000000': base 0x0000000000000000, size 0 MiB
[    2.646449] Reserved memory: created CMA memory pool at 0x0000000010000000, size 128 MiB
[    2.647192] OF: reserved mem: initialized node cma, compatible id shared-dma-pool
[    2.879667] Zone ranges:
[    2.879910]   DMA      [mem 0x0000000000200000-0x00000000ffffffff]
[    2.880484]   DMA32    empty
[    2.880751]   Normal   [mem 0x0000000100000000-0x00000004ffffffff]
[    2.881321] Movable zone start for each node
[    2.881712] Early memory node ranges
[    2.882041]   node   0: [mem 0x0000000000200000-0x00000000083fffff]
[    2.882618]   node   0: [mem 0x0000000009400000-0x00000000efffffff]
[    2.883196]   node   0: [mem 0x0000000100000000-0x00000003fbffffff]
[    2.883776]   node   0: [mem 0x00000003fc500000-0x00000003ffefffff]
[    2.884352]   node   0: [mem 0x00000004f0000000-0x00000004ffffffff]
[    2.884928] Initmem setup node 0 [mem 0x0000000000200000-0x00000004ffffffff]
[    2.886326] On node 0, zone DMA: 512 pages in unavailable ranges
[    2.906996] On node 0, zone DMA: 4096 pages in unavailable ranges
[    2.975784] On node 0, zone Normal: 1280 pages in unavailable ranges
[    2.977819] On node 0, zone Normal: 256 pages in unavailable ranges
[    2.978564] psci: probing for conduit method from DT.
[    2.979609] psci: PSCIv1.1 detected in firmware.
[    2.980034] psci: Using standard PSCI v0.2 function IDs
[    2.980516] psci: Trusted OS migration not required
[    2.981000] psci: SMC Calling Convention v1.2
[    2.981754] percpu: Embedded 28 pages/cpu s75256 r8192 d31240 u114688
[    2.982543] Detected VIPT I-cache on CPU0
[    2.982949] CPU features: detected: GIC system register CPU interface
[    2.983541] CPU features: detected: Virtualization Host Extensions
[    2.984114] CPU features: detected: Qualcomm erratum 1009, or ARM erratum 1286807, 2441009
[    2.984872] CPU features: detected: ARM errata 1165522, 1319367, or 1530923
[    2.985512] alternatives: applying boot alternatives
[    2.987592] Built 1 zonelists, mobility grouping on.  Total pages: 4122720
[    2.988231] Kernel command line: storagemedia=emmc androidboot.storagemedia=emmc androidboot.mode=normal androidboot.dtbo_idx=0 androidboot.verifiedbootstate=orange earlycon=uart8250,mmio32,0xfeb50000 console=ttyFIQ0 coherent_pool=1m irqchip.gicv3_pseudo_nmi=0 rw root=/dev/mmcblk2p8 rootfstype=ext4 rootflags=discard data=/dev/mmcblk2p9 consoleblank=0 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1
[    2.991906] The swapaccount= commandline option is deprecated. Please report your usecase to linux-mm@kvack.org if you depend on this functionality.
[    2.993136] Unknown kernel command line parameters "storagemedia=emmc data=/dev/mmcblk2p9 cgroup_enable=memory cgroup_memory=1", will be passed to user space.
[    2.995990] Dentry cache hash table entries: 2097152 (order: 12, 16777216 bytes, linear)
[    2.997508] Inode-cache hash table entries: 1048576 (order: 11, 8388608 bytes, linear)
[    2.998238] mem auto-init: stack:off, heap alloc:off, heap free:off
[    2.998815] software IO TLB: area num 8.
[    3.011672] software IO TLB: mapped [mem 0x00000000e7cd4000-0x00000000ebcd4000] (64MB)
[    3.121014] Memory: 16185192K/16752640K available (17728K kernel code, 3486K rwdata, 6008K rodata, 7232K init, 925K bss, 436376K reserved, 131072K cma-reserved)
[    3.122454] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=8, Nodes=1
[    3.123085] ftrace: allocating 58496 entries in 229 pages
[    3.209696] ftrace: allocated 229 pages with 5 groups
[    3.210252] trace event string verifier disabled
[    3.210862] rcu: Hierarchical RCU implementation.
[    3.211299] rcu:     RCU event tracing is enabled.
[    3.211716]  Rude variant of Tasks RCU enabled.
[    3.212132]  Tracing variant of Tasks RCU enabled.
[    3.212572] rcu: RCU calculated value of scheduler-enlistment delay is 30 jiffies.
[    3.218144] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    3.221327] GICv3: GIC: Using split EOI/Deactivate mode
[    3.221811] GICv3: 480 SPIs implemented
[    3.222164] GICv3: 0 Extended SPIs implemented
[    3.222601] Root IRQ handler: gic_handle_irq
[    3.223006] GICv3: GICv3 features: 16 PPIs
[    3.223422] GICv3: CPU0: found redistributor 0 region 0:0x00000000fe680000
[    3.224367] ITS [mem 0xfe640000-0xfe65ffff]
[    3.224798] ITS@0x00000000fe640000: allocated 8192 Devices @1000e0000 (indirect, esz 8, psz 64K, shr 0)
[    3.225681] ITS@0x00000000fe640000: allocated 32768 Interrupt Collections @1000f0000 (flat, esz 2, psz 64K, shr 0)
[    3.226637] ITS: using cache flushing for cmd queue
[    3.227114] ITS [mem 0xfe660000-0xfe67ffff]
[    3.227535] ITS@0x00000000fe660000: allocated 8192 Devices @100110000 (indirect, esz 8, psz 64K, shr 0)
[    3.228417] ITS@0x00000000fe660000: allocated 32768 Interrupt Collections @100120000 (flat, esz 2, psz 64K, shr 0)
[    3.229372] ITS: using cache flushing for cmd queue
[    3.230033] GICv3: using LPI property table @0x0000000100130000
[    3.230687] GIC: using cache flushing for LPI property table
[    3.231210] GICv3: CPU0: using allocated LPI pending table @0x0000000100140000
[    3.231922] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[    3.345458] arch_timer: cp15 timer(s) running at 24.00MHz (phys).
[    3.346020] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
[    3.346998] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[    3.348941] Console: colour dummy device 80x25
[    3.349380] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=80000)
[    3.350313] pid_max: default: 32768 minimum: 301
[    3.350782] LSM: Security Framework initializing
[    3.351291] Mount-cache hash table entries: 32768 (order: 6, 262144 bytes, linear)
[    3.352008] Mountpoint-cache hash table entries: 32768 (order: 6, 262144 bytes, linear)
[    3.354287] cblist_init_generic: Setting adjustable number of callback queues.
[    3.354946] cblist_init_generic: Setting shift to 3 and lim to 1.
[    3.355576] cblist_init_generic: Setting shift to 3 and lim to 1.
[    3.356298] rcu: Hierarchical SRCU implementation.
[    3.356733] rcu:     Max phase no-delay instances is 1000.
[    3.357937] Platform MSI: msi-controller@fe640000 domain created
[    3.358496] Platform MSI: msi-controller@fe660000 domain created
[    3.359376] PCI/MSI: /interrupt-controller@fe600000/msi-controller@fe640000 domain created
[    3.360178] PCI/MSI: /interrupt-controller@fe600000/msi-controller@fe660000 domain created
[    3.361533] smp: Bringing up secondary CPUs ...
I/TC: Secondary CPU 1 initializing
I/TC: Secondary CPU 1 switching to normal world boot
I/TC: Secondary CPU 2 initializing
I/TC: Secondary CPU 2 switching to normal world boot
I/TC: Secondary CPU 3 initializing
I/TC: Secondary CPU 3 switching to normal world boot
I/TC: Secondary CPU 4 initializing
I/TC: Secondary CPU 4 switching to normal world boot
I/TC: Secondary CPU 5 initializing
I/TC: Secondary CPU 5 switching to normal world boot
I/TC: Secondary CPU 6 initializing
I/TC: Secondary CPU 6 switching to normal world boot
I/TC: Secondary CPU 7 initializing
I/TC: Secondary CPU 7 switching to normal world boot
[    3.363107] Detected VIPT I-cache on CPU1
[    3.363185] GICv3: CPU1: found redistributor 100 region 0:0x00000000fe6a0000
[    3.363203] GICv3: CPU1: using allocated LPI pending table @0x0000000100150000
[    3.363240] CPU1: Booted secondary processor 0x0000000100 [0x412fd050]
[    3.364459] Detected VIPT I-cache on CPU2
[    3.364533] GICv3: CPU2: found redistributor 200 region 0:0x00000000fe6c0000
[    3.364550] GICv3: CPU2: using allocated LPI pending table @0x0000000100160000
[    3.364584] CPU2: Booted secondary processor 0x0000000200 [0x412fd050]
[    3.365777] Detected VIPT I-cache on CPU3
[    3.365849] GICv3: CPU3: found redistributor 300 region 0:0x00000000fe6e0000
[    3.365865] GICv3: CPU3: using allocated LPI pending table @0x0000000100170000
[    3.365898] CPU3: Booted secondary processor 0x0000000300 [0x412fd050]
[    3.367045] CPU features: detected: Spectre-v4
[    3.367048] CPU features: detected: Spectre-BHB
[    3.367051] Detected PIPT I-cache on CPU4
[    3.367091] GICv3: CPU4: found redistributor 400 region 0:0x00000000fe700000
[    3.367100] GICv3: CPU4: using allocated LPI pending table @0x0000000100180000
[    3.367120] CPU4: Booted secondary processor 0x0000000400 [0x414fd0b0]
[    3.368285] Detected PIPT I-cache on CPU5
[    3.368331] GICv3: CPU5: found redistributor 500 region 0:0x00000000fe720000
[    3.368340] GICv3: CPU5: using allocated LPI pending table @0x0000000100190000
[    3.368361] CPU5: Booted secondary processor 0x0000000500 [0x414fd0b0]
[    3.369488] Detected PIPT I-cache on CPU6
[    3.369532] GICv3: CPU6: found redistributor 600 region 0:0x00000000fe740000
[    3.369541] GICv3: CPU6: using allocated LPI pending table @0x00000001001a0000
[    3.369561] CPU6: Booted secondary processor 0x0000000600 [0x414fd0b0]
[    3.370698] Detected PIPT I-cache on CPU7
[    3.370744] GICv3: CPU7: found redistributor 700 region 0:0x00000000fe760000
[    3.370753] GICv3: CPU7: using allocated LPI pending table @0x00000001001b0000
[    3.370773] CPU7: Booted secondary processor 0x0000000700 [0x414fd0b0]
[    3.370824] smp: Brought up 1 node, 8 CPUs
[    3.387634] SMP: Total of 8 processors activated.
[    3.388064] CPU features: detected: 32-bit EL0 Support
[    3.388530] CPU features: detected: Data cache clean to the PoU not required for I/D coherence
[    3.389307] CPU features: detected: Common not Private translations
[    3.389874] CPU features: detected: CRC32 instructions
[    3.390339] CPU features: detected: RCpc load-acquire (LDAPR)
[    3.390858] CPU features: detected: LSE atomic instructions
[    3.391361] CPU features: detected: Privileged Access Never
[    3.391870] CPU features: detected: RAS Extension Support
[    3.392360] CPU features: detected: Speculative Store Bypassing Safe (SSBS)
[    3.393053] CPU: All CPU(s) started at EL2
[    3.393424] alternatives: applying system-wide alternatives
[    3.401122] devtmpfs: initialized
[    3.411801] Registered cp15_barrier emulation handler
[    3.412261] Registered setend emulation handler
[    3.412725] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 6370867519511994 ns
[    3.413601] futex hash table entries: 2048 (order: 5, 131072 bytes, linear)
[    3.415028] pinctrl core: initialized pinctrl subsystem
[    3.415913] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    3.416867] DMA: preallocated 1024 KiB GFP_KERNEL pool for atomic allocations
[    3.417673] DMA: preallocated 1024 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
[    3.418499] DMA: preallocated 1024 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[    3.419229] audit: initializing netlink subsys (disabled)
[    3.419781] audit: type=2000 audit(0.066:1): state=initialized audit_enabled=0 res=1
[    3.420157] Registered FIQ tty driver
[    3.420900] thermal_sys: Registered thermal governor 'fair_share'
[    3.420902] thermal_sys: Registered thermal governor 'step_wise'
[    3.421453] thermal_sys: Registered thermal governor 'user_space'
[    3.422004] cpuidle: using governor menu
[    3.422994] hw-breakpoint: found 6 breakpoint and 4 watchpoint registers.
[    3.423682] ASID allocator initialised with 65536 entries
[    3.425619] ramoops: dmesg-0 0x18000@0x0000000000110000
[    3.426091] ramoops: dmesg-1 0x18000@0x0000000000128000
[    3.426585] ramoops: console 0x80000@0x0000000000140000
[    3.427060] ramoops: pmsg    0x30000@0x00000000001c0000
[    3.427719] printk: console [ramoops-1] enabled
[    3.428229] pstore: Registered ramoops as persistent store backend
[    3.428783] ramoops: using 0xe0000@0x110000, ecc: 0
[    3.453240] platform fdd90000.vop: Fixed dependency cycle(s) with /dp@fde50000
[    3.454149] platform fdd90000.vop: Fixed dependency cycle(s) with /hdmi@fde80000
[    3.459259] platform fed80000.phy: Fixed dependency cycle(s) with /i2c@fec80000/fusb302@22/connector
[    3.465062] rockchip-gpio fd8a0000.gpio: probed /pinctrl/gpio@fd8a0000
[    3.465811] rockchip-gpio fec20000.gpio: probed /pinctrl/gpio@fec20000
[    3.466541] rockchip-gpio fec30000.gpio: probed /pinctrl/gpio@fec30000
[    3.467269] rockchip-gpio fec40000.gpio: probed /pinctrl/gpio@fec40000
[    3.468051] rockchip-gpio fec50000.gpio: probed /pinctrl/gpio@fec50000
[    3.468683] rockchip-pinctrl pinctrl: probed pinctrl
[    3.470144] platform fdd90000.vop: Fixed dependency cycle(s) with /hdmi@fdea0000
[    3.473614] KASLR disabled due to lack of seed
[    3.477303] HugeTLB: registered 1.00 GiB page size, pre-allocated 0 pages
[    3.477916] HugeTLB: 0 KiB vmemmap can be freed for a 1.00 GiB page
[    3.478479] HugeTLB: registered 32.0 MiB page size, pre-allocated 0 pages
[    3.479091] HugeTLB: 0 KiB vmemmap can be freed for a 32.0 MiB page
[    3.479655] HugeTLB: registered 2.00 MiB page size, pre-allocated 0 pages
[    3.480264] HugeTLB: 0 KiB vmemmap can be freed for a 2.00 MiB page
[    3.480830] HugeTLB: registered 64.0 KiB page size, pre-allocated 0 pages
[    3.481437] HugeTLB: 0 KiB vmemmap can be freed for a 64.0 KiB page
[    3.482276] cryptd: max_cpu_qlen set to 1000
[    3.483445] fiq_debugger fiq_debugger.0: error -ENXIO: IRQ fiq not found
[    3.484051] fiq_debugger fiq_debugger.0: error -ENXIO: IRQ wakeup not found
[    3.484678] fiq_debugger_probe: could not install nmi irq handler
[[    3.485261] printk: console [ttyFIQ0] enabled
    3.485261] printk: console [ttyFIQ0] enabled
[    3.486046] printk: bootconsole [uart8250] disabled
[    3.486046] printk: bootconsole [uart8250] disabled
[    3.486552] Registered fiq debugger ttyFIQ0
[    3.496236] iommu: Default domain type: Translated
[    3.496242] iommu: DMA domain TLB invalidation policy: strict mode
[    3.496357] SCSI subsystem initialized
[    3.496417] usbcore: registered new interface driver usbfs
[    3.496429] usbcore: registered new interface driver hub
[    3.496442] usbcore: registered new device driver usb
[    3.496558] mc: Linux media interface: v0.10
[    3.496572] videodev: Linux video capture interface: v2.00
[    3.496595] pps_core: LinuxPPS API ver. 1 registered
[    3.496599] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    3.496605] PTP clock support registered
[    3.496768] arm-scmi firmware:scmi: Enabled polling mode TX channel - prot_id:16
[    3.496808] arm-scmi firmware:scmi: SCMI Notifications - Core Enabled.
[    3.496833] arm-scmi firmware:scmi: SCMI Protocol v2.0 'rockchip:' Firmware version 0x0
[    3.497679] Advanced Linux Sound Architecture Driver Initialized.
[    3.497877] Bluetooth: Core ver 2.22
[    3.497888] NET: Registered PF_BLUETOOTH protocol family
[    3.497892] Bluetooth: HCI device and connection manager initialized
[    3.497898] Bluetooth: HCI socket layer initialized
[    3.497902] Bluetooth: L2CAP socket layer initialized
[    3.497909] Bluetooth: SCO socket layer initialized
[    3.497917] NetLabel: Initializing
[    3.497920] NetLabel:  domain hash size = 128
[    3.497923] NetLabel:  protocols = UNLABELED CIPSOv4 CALIPSO
[    3.497944] NetLabel:  unlabeled traffic allowed by default
[    3.499165] rockchip-cpuinfo cpuinfo: SoC            : 35880000
[    3.499171] rockchip-cpuinfo cpuinfo: Serial         : 1f0bee682f135e89
[    4.243339] clocksource: Switched to clocksource arch_sys_counter
[    4.243448] VFS: Disk quotas dquot_6.6.0
[    4.243465] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[    4.243503] FS-Cache: Loaded
[    4.247376] NET: Registered PF_INET protocol family
[    4.247552] IP idents hash table entries: 262144 (order: 9, 2097152 bytes, linear)
[    4.253172] tcp_listen_portaddr_hash hash table entries: 8192 (order: 6, 262144 bytes, linear)
[    4.253273] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    4.253299] TCP established hash table entries: 131072 (order: 8, 1048576 bytes, linear)
[    4.253972] TCP bind hash table entries: 65536 (order: 10, 4194304 bytes, linear)
[    4.255738] TCP: Hash tables configured (established 131072 bind 65536)
[    4.255793] UDP hash table entries: 8192 (order: 7, 786432 bytes, linear)
[    4.256081] UDP-Lite hash table entries: 8192 (order: 7, 786432 bytes, linear)
[    4.256422] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    4.256624] RPC: Registered named UNIX socket transport module.
[    4.256629] RPC: Registered udp transport module.
[    4.256633] RPC: Registered tcp transport module.
[    4.256636] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    4.256721] PCI: CLS 0 bytes, default 64
[    4.256870] Trying to unpack rootfs image as initramfs...
[    4.257183] rockchip-thermal fec00000.tsadc: Missing rockchip,grf property
[    4.257763] rockchip-thermal fec00000.tsadc: tsadc is probed successfully!
[    4.267530] hw perfevents: enabled with armv8_pmuv3 PMU driver, 7 counters available
[    4.268410] Initialise system trusted keyrings
[    4.268492] workingset: timestamp_bits=46 max_order=22 bucket_order=0
[    4.270038] zbud: loaded
[    4.270454] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    4.270695] NFS: Registering the id_resolver key type
[    4.270710] Key type id_resolver registered
[    4.270713] Key type id_legacy registered
[    4.270738] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    4.270744] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering...
[    4.270810] fuse: init (API version 7.37)
[    4.291528] Key type asymmetric registered
[    4.291535] Asymmetric key parser 'x509' registered
[    4.291557] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 242)
[    4.291608] io scheduler mq-deadline registered
[    4.291613] io scheduler kyber registered
[    4.291647] io scheduler bfq registered
[    4.299152] rockchip-hdptx-phy-hdmi fed60000.hdmiphy: hdptx phy init success
[    4.299753] rockchip-hdptx-phy-hdmi fed70000.hdmiphy: hdptx phy init success
[    4.301778] rk-pcie fe180000.pcie: invalid prsnt-gpios property in node
[    4.301921] rk-pcie fe150000.pcie: invalid prsnt-gpios property in node
[    4.302125] iep: Module initialized.
[    4.302158] mpp_service mpp-srv: 889af935b author: jensen 2023-11-16 ARM64: dts: rockchip: Fix PCI bus dtc warnings for nanopi5/6
[    4.302164] mpp_service mpp-srv: probe start
[    4.303244] mpp_vepu2 jpege-ccu: probing start
[    4.303250] mpp_vepu2 jpege-ccu: probing finish
[    4.303906] mpp_rkvdec2 fdc30000.rkvdec-ccu: rkvdec-ccu, probing start
[    4.303957] mpp_rkvdec2 fdc30000.rkvdec-ccu: ccu-mode: 1
[    4.303962] mpp_rkvdec2 fdc30000.rkvdec-ccu: probing finish
[    4.304192] mpp_rkvenc2 rkvenc-ccu: probing start
[    4.304199] mpp_rkvenc2 rkvenc-ccu: probing finish
[    4.304503] mpp_service mpp-srv: probe success
[    4.311949] dma-pl330 fea10000.dma-controller: Loaded driver for PL330 DMAC-241330
[    4.311960] dma-pl330 fea10000.dma-controller:       DBUFF-128x8bytes Num_Chans-8 Num_Peri-32 Num_Events-16
[    4.312580] dma-pl330 fea30000.dma-controller: Loaded driver for PL330 DMAC-241330
[    4.312587] dma-pl330 fea30000.dma-controller:       DBUFF-128x8bytes Num_Chans-8 Num_Peri-32 Num_Events-16
[    4.313206] dma-pl330 fed10000.dma-controller: Loaded driver for PL330 DMAC-241330
[    4.313212] dma-pl330 fed10000.dma-controller:       DBUFF-128x8bytes Num_Chans-8 Num_Peri-32 Num_Events-16
[    4.313498] rockchip-pvtm fda40000.pvtm: pvtm@0 probed
[    4.313541] rockchip-pvtm fda50000.pvtm: pvtm@1 probed
[    4.313581] rockchip-pvtm fda60000.pvtm: pvtm@2 probed
[    4.313619] rockchip-pvtm fdaf0000.pvtm: pvtm@3 probed
[    4.313654] rockchip-pvtm fdb30000.pvtm: pvtm@4 probed
[    4.314034] rockchip-system-monitor rockchip-system-monitor: system monitor probe
[    4.314695] Serial: 8250/16550 driver, 10 ports, IRQ sharing disabled
[    4.315053] feb90000.serial: ttyS6 at MMIO 0xfeb90000 (irq = 35, base_baud = 1500000) is a 16550A
[    4.317968] random: crng init done
[    4.318035] rk-pcie fe150000.pcie: host bridge /pcie@fe150000 ranges:
[    4.318078] rk-pcie fe150000.pcie:       IO 0x00f0100000..0x00f01fffff -> 0x00f0100000
[    4.318107] rk-pcie fe150000.pcie:      MEM 0x00f0200000..0x00f0ffffff -> 0x00f0200000
[    4.318128] rk-pcie fe150000.pcie:      MEM 0x0900000000..0x093fffffff -> 0x0900000000
[    4.318189] rk-pcie fe150000.pcie: iATU unroll: enabled
[    4.318203] rk-pcie fe150000.pcie: iATU regions: 8 ob, 8 ib, align 64K, limit 8G
[    4.320197] rk_iommu fdca0000.iommu: av1d iommu enabled
[    4.321131] rockchip-vop2 fdd90000.vop: Adding to iommu group 15
[    4.326935] rockchip-vop2 fdd90000.vop: [drm:vop2_bind] vp0 assign plane mask: 0x7, primary plane phy id: 0
[    4.326956] rockchip-vop2 fdd90000.vop: [drm:vop2_bind] vp1 assign plane mask: 0x148, primary plane phy id: 6
[    4.326966] rockchip-vop2 fdd90000.vop: [drm:vop2_bind] vp2 assign plane mask: 0x280, primary plane phy id: 7
[    4.326976] rockchip-vop2 fdd90000.vop: [drm:vop2_bind] vp3 assign plane mask: 0x0, primary plane phy id: -1
[    4.327039] rockchip-vop2 fdd90000.vop: [drm:vop2_bind] Esmart0-win0 as cursor plane for vp0
[    4.327108] rockchip-vop2 fdd90000.vop: [drm:vop2_bind] Esmart1-win0 as cursor plane for vp1
[    4.327165] rockchip-vop2 fdd90000.vop: [drm:vop2_bind] Esmart3-win0 as cursor plane for vp2
[    4.335070] rockchip-drm display-subsystem: bound fdd90000.vop (ops 0xffffffc0092763b0)
[    4.335428] dwhdmi-rockchip fde80000.hdmi: registered ddc I2C bus driver
[    4.335749] rockchip-drm display-subsystem: bound fde80000.hdmi (ops 0xffffffc009288d10)
[    4.336076] dwhdmi-rockchip fdea0000.hdmi: registered ddc I2C bus driver
[    4.336344] rockchip-drm display-subsystem: bound fdea0000.hdmi (ops 0xffffffc009288d10)
[    4.336502] rockchip-drm display-subsystem: bound fde50000.dp (ops 0xffffffc00928bcd8)
[    4.441785] dwhdmi-rockchip fde80000.hdmi: i2c read err!
[    4.443207] [drm] Initialized rockchip 3.0.0 20140818 for display-subsystem on minor 0
[    4.490061] Freeing initrd memory: 7880K
[    4.524479] rk-pcie fe150000.pcie: PCIe Linking... LTSSM is 0x0
[    4.550043] rk-pcie fe150000.pcie: PCIe Linking... LTSSM is 0x1
[    4.576704] rk-pcie fe150000.pcie: PCIe Linking... LTSSM is 0x1
[    4.580400] Console: switching to colour frame buffer device 240x67
[    4.597073] rockchip-drm display-subsystem: [drm] fb0: rockchipdrmfb frame buffer device
[    4.599807] SPI driver panel-simple-spi has no spi_device_id for simple-panel-spi
[    4.603303] brd: module loaded
[    4.603359] rk-pcie fe150000.pcie: PCIe Linking... LTSSM is 0x0
[    4.605516] loop: module loaded
[    4.605621] lkdtm: No crash points registered, enable through debugfs
[    4.606359] SPI driver spidev has no spi_device_id for rockchip,spidev
[    4.607147] rockchip-spi feb20000.spi: no high_speed pinctrl state
[    4.608040] rk806 spi2.0: chip id: RK806,ver:0x2, 0x1
[    4.608170] rk806 spi2.0: ON: 0x80 OFF:0x80
[    4.620457] rk806 spi2.0: no sleep-setting state
[    4.620466] rk806 spi2.0: no reset-setting pinctrl state
[    4.620471] rk806 spi2.0: no dvs-setting pinctrl state
[    4.621748] rockchip-spi feb20000.spi: probed, poll=0, rsd=0, cs-inactive=0, ready=0
[    4.623058] PPP generic driver version 2.4.2
[    4.623143] usbcore: registered new interface driver asix
[    4.623166] usbcore: registered new interface driver ax88179_178a
[    4.623178] usbcore: registered new interface driver cdc_ether
[    4.623190] usbcore: registered new interface driver rndis_host
[    4.623203] usbcore: registered new interface driver qmi_wwan
[    4.623500] platform fc000000.usb: Fixed dependency cycle(s) with /i2c@fec80000/fusb302@22
[    4.630029] rk-pcie fe150000.pcie: PCIe Linking... LTSSM is 0x0
[    4.634960] phy phy-fd5d4000.syscon:usb2-phy@4000.3: illegal mode
[    4.634973] xhci-hcd xhci-hcd.9.auto: xHCI Host Controller
[    4.634983] xhci-hcd xhci-hcd.9.auto: new USB bus registered, assigned bus number 1
[    4.635064] xhci-hcd xhci-hcd.9.auto: hcc params 0x0220fe64 hci version 0x110 quirks 0x0000200002010010
[    4.635090] xhci-hcd xhci-hcd.9.auto: irq 73, io mem 0xfc400000
[    4.635156] xhci-hcd xhci-hcd.9.auto: xHCI Host Controller
[    4.635163] xhci-hcd xhci-hcd.9.auto: new USB bus registered, assigned bus number 2
[    4.635170] xhci-hcd xhci-hcd.9.auto: Host supports USB 3.0 SuperSpeed
[    4.635246] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 6.01
[    4.635255] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    4.635260] usb usb1: Product: xHCI Host Controller
[    4.635266] usb usb1: Manufacturer: Linux 6.1.25 xhci-hcd
[    4.635271] usb usb1: SerialNumber: xhci-hcd.9.auto
[    4.635511] hub 1-0:1.0: USB hub found
[    4.635525] hub 1-0:1.0: 1 port detected
[    4.635654] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[    4.635686] usb usb2: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 6.01
[    4.635693] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    4.635699] usb usb2: Product: xHCI Host Controller
[    4.635703] usb usb2: Manufacturer: Linux 6.1.25 xhci-hcd
[    4.635708] usb usb2: SerialNumber: xhci-hcd.9.auto
[    4.635869] hub 2-0:1.0: USB hub found
[    4.635881] hub 2-0:1.0: 1 port detected
[    4.636006] usbcore: registered new interface driver cdc_acm
[    4.636011] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[    4.636024] usbcore: registered new interface driver cdc_wdm
[    4.636119] usbcore: registered new interface driver uas
[    4.636145] usbcore: registered new interface driver usb-storage
[    4.636173] usbcore: registered new interface driver usbserial_generic
[    4.636182] usbserial: USB Serial support registered for generic
[    4.636195] usbcore: registered new interface driver ch341
[    4.636203] usbserial: USB Serial support registered for ch341-uart
[    4.636216] usbcore: registered new interface driver cp210x
[    4.636225] usbserial: USB Serial support registered for cp210x
[    4.636241] usbcore: registered new interface driver ftdi_sio
[    4.636250] usbserial: USB Serial support registered for FTDI USB Serial Device
[    4.636277] usbcore: registered new interface driver option
[    4.636285] usbserial: USB Serial support registered for GSM modem (1-port)
[    4.636321] usbcore: registered new interface driver pl2303
[    4.636329] usbserial: USB Serial support registered for pl2303
[    4.636343] usbcore: registered new interface driver qcserial
[    4.636351] usbserial: USB Serial support registered for Qualcomm USB modem
[    4.636545] mousedev: PS/2 mouse device common for all mice
[    4.636551] ehci-platform fc800000.usb: EHCI Host Controller
[    4.636556] ohci-platform fc840000.usb: Generic Platform OHCI controller
[    4.636565] ohci-platform fc840000.usb: new USB bus registered, assigned bus number 3
[    4.636569] ehci-platform fc800000.usb: new USB bus registered, assigned bus number 4
[    4.636597] ehci-platform fc880000.usb: EHCI Host Controller
[    4.636610] ohci-platform fc8c0000.usb: Generic Platform OHCI controller
[    4.636613] ehci-platform fc880000.usb: new USB bus registered, assigned bus number 5
[    4.636632] ohci-platform fc840000.usb: irq 76, io mem 0xfc840000
[    4.636633] ohci-platform fc8c0000.usb: new USB bus registered, assigned bus number 6
[    4.636644] ehci-platform fc800000.usb: irq 74, io mem 0xfc800000
[    4.636697] ehci-platform fc880000.usb: irq 75, io mem 0xfc880000
[    4.636742] ohci-platform fc8c0000.usb: irq 77, io mem 0xfc8c0000
[    4.636865] .. rk pwm remotectl v2.0 init
[    4.636967] input: fd8b0030.pwm as /devices/platform/fd8b0030.pwm/input/input0
[    4.637158] remotectl-pwm fd8b0030.pwm: pwm version is 0x2130000
[    4.637192] remotectl-pwm fd8b0030.pwm: Controller support pwrkey capture
[    4.637995] input: rk805 pwrkey as /devices/platform/feb20000.spi/spi_master/spi2/spi2.0/rk805-pwrkey.7.auto/input/input1
[    4.638151] i2c_dev: i2c /dev entries driver
[    4.646683] ehci-platform fc800000.usb: USB 2.0 started, EHCI 1.00
[    4.646801] usb usb4: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 6.01
[    4.646811] usb usb4: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    4.646817] usb usb4: Product: EHCI Host Controller
[    4.646822] usb usb4: Manufacturer: Linux 6.1.25 ehci_hcd
[    4.646827] usb usb4: SerialNumber: fc800000.usb
[    4.647033] hub 4-0:1.0: USB hub found
[    4.647054] hub 4-0:1.0: 1 port detected
[    4.656697] rk-pcie fe150000.pcie: PCIe Linking... LTSSM is 0x0
[    4.660012] ehci-platform fc880000.usb: USB 2.0 started, EHCI 1.00
[    4.660151] usb usb5: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 6.01
[    4.660161] usb usb5: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    4.660166] usb usb5: Product: EHCI Host Controller
[    4.660172] usb usb5: Manufacturer: Linux 6.1.25 ehci_hcd
[    4.660177] usb usb5: SerialNumber: fc880000.usb
[    4.660383] hub 5-0:1.0: USB hub found
[    4.660404] hub 5-0:1.0: 1 port detected
[    4.662327] rtc-hym8563 6-0051: rtc information is valid
[    4.666086] rtc-hym8563 6-0051: registered as rtc0
[    4.666597] rtc-hym8563 6-0051: setting system clock to 2023-12-17T05:56:21 UTC (1702792581)
[    4.673841] IR NEC protocol handler initialized
[    4.678445] rk_hdmirx fdee0000.hdmirx-controller: No reserved memory for HDMIRX, use default CMA
[    4.678499] rk_hdmirx fdee0000.hdmirx-controller: hdmirx_probe: cpu_aff:0x400, Bound_cpu:4, wdt_cfg_bound_cpu:5
[    4.679050] rk_hdmirx fdee0000.hdmirx-controller: hdmirx_audio_interrupts_setup: 0
[    4.680157] rk_hdmirx fdee0000.hdmirx-controller: rk_hdmirx_hdcp_register success
[    4.680212] rk_hdmirx fdee0000.hdmirx-controller: fdee0000.hdmirx-controller driver probe ok!
[    4.682290] __power_supply_register: Expected proper parent device for 'test_ac'
[    4.682522] __power_supply_register: Expected proper parent device for 'test_battery'
[    4.682925] __power_supply_register: Expected proper parent device for 'test_usb'
[    4.683361] rk-pcie fe150000.pcie: PCIe Linking... LTSSM is 0x0
[    4.684559] device-mapper: uevent: version 1.0.3
[    4.684783] device-mapper: ioctl: 4.47.0-ioctl (2022-07-28) initialised: dm-devel@redhat.com
[    4.685973] cpu cpu0: bin=0
[    4.686177] cpu cpu0: leakage=8
[    4.687761] cpu cpu0: pvtm=1403
[    4.688006] cpu cpu0: pvtm-volt-sel=0
[    4.690469] cpu cpu4: bin=0
[    4.690668] cpu cpu4: leakage=7
[    4.694075] usb usb3: New USB device found, idVendor=1d6b, idProduct=0001, bcdDevice= 6.01
[    4.694085] usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    4.694091] usb usb3: Product: Generic Platform OHCI controller
[    4.694096] usb usb3: Manufacturer: Linux 6.1.25 ohci_hcd
[    4.694101] usb usb3: SerialNumber: fc840000.usb
[    4.694279] hub 3-0:1.0: USB hub found
[    4.694292] hub 3-0:1.0: 1 port detected
[    4.697403] usb usb6: New USB device found, idVendor=1d6b, idProduct=0001, bcdDevice= 6.01
[    4.697414] usb usb6: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    4.697420] usb usb6: Product: Generic Platform OHCI controller
[    4.697425] usb usb6: Manufacturer: Linux 6.1.25 ohci_hcd
[    4.697431] usb usb6: SerialNumber: fc8c0000.usb
[    4.697457] cpu cpu4: pvtm=1637
[    4.697613] hub 6-0:1.0: USB hub found
[    4.697627] hub 6-0:1.0: 1 port detected
[    4.701665] cpu cpu4: pvtm-volt-sel=2
[    4.704866] cpu cpu6: bin=0
[    4.705065] cpu cpu6: leakage=7
[    4.710025] rk-pcie fe150000.pcie: PCIe Linking... LTSSM is 0x0
[    4.711850] cpu cpu6: pvtm=1632
[    4.716056] cpu cpu6: pvtm-volt-sel=2
[    4.719199] cpu cpu0: avs=0
[    4.721704] cpu cpu4: avs=0
[    4.724037] cpu cpu6: avs=0
[    4.724269] cpu cpu0: l=10000 h=85000 hyst=5000 l_limit=0 h_limit=1608000000 h_table=0
[    4.724953] cpu cpu0: EM: created perf domain
[    4.726146] cpu cpu4: l=10000 h=85000 hyst=5000 l_limit=0 h_limit=2208000000 h_table=0
[    4.735081] cpu cpu4: EM: created perf domain
[    4.736277] cpu cpu6: l=10000 h=85000 hyst=5000 l_limit=0 h_limit=2208000000 h_table=0
[    4.736677] rk-pcie fe150000.pcie: PCIe Linking... LTSSM is 0x0
[    4.748344] cpu cpu6: EM: created perf domain
[    4.749679] sdhci: Secure Digital Host Controller Interface driver
[    4.749690] sdhci: Copyright(c) Pierre Ossman
[    4.749697] Synopsys Designware Multimedia Card Interface Driver
[    4.750154] sdhci-pltfm: SDHCI platform and OF driver helper
[    4.751753] ledtrig-cpu: registered to indicate activity on CPUs
[    4.751776] arm-scmi firmware:scmi: Failed. SCMI protocol 17 not active.
[    4.751812] SMCCC: SOC_ID: ARCH_SOC_ID not implemented, skipping ....
[    4.751838] hid: raw HID events driver (C) Jiri Kosina
[    4.752007] usbcore: registered new interface driver usbhid
[    4.752013] usbhid: USB HID core driver
[    4.758184] optee: probing for conduit method.
[    4.758201] optee: revision 3.13 (7f1ea6d6)
[    4.758594] optee: dynamic shared memory is enabled
[    4.758675] optee: initialized driver
[    4.766751] rk-pcie fe150000.pcie: PCIe Linking... LTSSM is 0x0
[    4.778595] rockchip-i2s-tdm fddf0000.i2s: CLK-ALWAYS-ON: mclk: 12288000, bclk: 3072000, fsync: 48000
[    4.779909] rockchip-i2s-tdm fddf4000.i2s: CLK-ALWAYS-ON: mclk: 12288000, bclk: 3072000, fsync: 48000
[    4.782683] mmc2: SDHCI controller on fe2e0000.mmc [fe2e0000.mmc] using ADMA
[    4.783990] debugfs: File 'Capture' in directory 'dapm' already present!
[    4.785869] debugfs: File 'Capture' in directory 'dapm' already present!
[    4.794343] input: rockchip,hdmiin rockchip,hdmiin as /devices/platform/hdmiin-sound/sound/card3/input2
[    4.795263] Initializing XFRM netlink socket
[    4.795280] IPsec XFRM device driver
[    4.795583] NET: Registered PF_INET6 protocol family
[    4.796760] Segment Routing with IPv6
[    4.796783] In-situ OAM (IOAM) with IPv6
[    4.798011] bpfilter: Loaded bpfilter_umh pid 157
[    4.798447] NET: Registered PF_PACKET protocol family
[    4.798630] Bluetooth: RFCOMM TTY layer initialized
[    4.798657] Bluetooth: RFCOMM socket layer initialized
[    4.798671] Bluetooth: RFCOMM ver 1.11
[    4.798681] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[    4.798690] Bluetooth: HIDP socket layer initialized
[    4.798724] [BT_RFKILL]: Enter rfkill_rk_init
[    4.798730] [WLAN_RFKILL]: Enter rfkill_wlan_init
[    4.799088] Key type dns_resolver registered
[    4.800255] registered taskstats version 1
[    4.800298] Loading compiled-in X.509 certificates
[    4.801304] zswap: loaded using pool lzo/zbud
[    4.802590] pstore: Using crash dump compression: deflate
[    4.811925] rga3_core0 fdb60000.rga: Adding to iommu group 2
[    4.812254] rga: rga3_core0, irq = 40, match scheduler
[    4.812513] rga: rga3_core0 hardware loaded successfully, hw_version:3.0.76831.
[    4.812616] rga: rga3_core0 probe successfully
[    4.813085] rga3_core1 fdb70000.rga: Adding to iommu group 3
[    4.813262] rga: rga3_core1, irq = 41, match scheduler
[    4.813512] rga: rga3_core1 hardware loaded successfully, hw_version:3.0.76831.
[    4.813565] rga: rga3_core1 probe successfully
[    4.814081] rga: rga2, irq = 97, match scheduler
[    4.814414] rga: rga2 hardware loaded successfully, hw_version:3.2.63318.
[    4.814480] rga: rga2 probe successfully
[    4.814725] rga_iommu: IOMMU binding successfully, default mapping core[0x1]
[    4.814955] rga: Module initialized. v1.2.27
[    4.817518] rk-pcie fe180000.pcie: host bridge /pcie@fe180000 ranges:
[    4.817557] rk-pcie fe180000.pcie:       IO 0x00f3100000..0x00f31fffff -> 0x00f3100000
[    4.817585] rk-pcie fe180000.pcie:      MEM 0x00f3200000..0x00f3ffffff -> 0x00f3200000
[    4.817605] rk-pcie fe180000.pcie:      MEM 0x09c0000000..0x09ffffffff -> 0x09c0000000
[    4.817672] rk-pcie fe180000.pcie: iATU unroll: enabled
[    4.817684] rk-pcie fe180000.pcie: iATU regions: 8 ob, 8 ib, align 64K, limit 8G
[    4.850620] friendlyelec-board board: Serial         : 1f0bee682f135e89
[    4.853899] rk-pcie fe190000.pcie: invalid prsnt-gpios property in node
[    4.854539] rk-pcie fe170000.pcie: invalid prsnt-gpios property in node
[    4.854736] mpp_vdpu1 fdb51000.avsd-plus: Adding to iommu group 1
[    4.855007] rk-pcie fe190000.pcie: host bridge /pcie@fe190000 ranges:
[    4.855067] mpp_vdpu1 fdb51000.avsd-plus: probe device
[    4.855068] rk-pcie fe190000.pcie:       IO 0x00f4100000..0x00f41fffff -> 0x00f4100000
[    4.855115] rk-pcie fe190000.pcie:      MEM 0x00f4200000..0x00f4ffffff -> 0x00f4200000
[    4.855148] rk-pcie fe190000.pcie:      MEM 0x0a00000000..0x0a3fffffff -> 0x0a00000000
[    4.855245] rk-pcie fe190000.pcie: iATU unroll: enabled
[    4.855265] rk-pcie fe190000.pcie: iATU regions: 8 ob, 8 ib, align 64K, limit 8G
[    4.855277] mpp_vdpu1 fdb51000.avsd-plus: reset_group->rw_sem_on=0
[    4.855288] mpp_vdpu1 fdb51000.avsd-plus: reset_group->rw_sem_on=0
[    4.855689] mpp_vdpu1 fdb51000.avsd-plus: probing finish
[    4.855925] mpp_vdpu2 fdb50400.vdpu: Adding to iommu group 1
[    4.855995] mpp_vdpu2 fdb50400.vdpu: probe device
[    4.856136] mpp_vdpu2 fdb50400.vdpu: reset_group->rw_sem_on=0
[    4.856147] mpp_vdpu2 fdb50400.vdpu: reset_group->rw_sem_on=0
[    4.856318] mpp_vdpu2 fdb50400.vdpu: probing finish
[    4.856487] mpp_vepu2 fdba0000.jpege-core: Adding to iommu group 5
[    4.856585] mpp_vepu2 fdba0000.jpege-core: probing start
[    4.856846] mpp_vepu2 fdba0000.jpege-core: attach ccu success
[    4.857240] mpp_vepu2 fdba0000.jpege-core: probing finish
[    4.857487] mpp_vepu2 fdba4000.jpege-core: Adding to iommu group 6
[    4.857589] mpp_vepu2 fdba4000.jpege-core: probing start
[    4.857777] mpp_vepu2 fdba4000.jpege-core: attach ccu success
[    4.858082] mpp_vepu2 fdba4000.jpege-core: probing finish
[    4.858360] mpp_vepu2 fdba8000.jpege-core: Adding to iommu group 7
[    4.858468] mpp_vepu2 fdba8000.jpege-core: probing start
[    4.858660] mpp_vepu2 fdba8000.jpege-core: attach ccu success
[    4.858948] mpp_vepu2 fdba8000.jpege-core: probing finish
[    4.859156] mpp_vepu2 fdbac000.jpege-core: Adding to iommu group 8
[    4.859244] mpp_vepu2 fdbac000.jpege-core: probing start
[    4.859436] mpp_vepu2 fdbac000.jpege-core: attach ccu success
[    4.859773] mpp_vepu2 fdbac000.jpege-core: probing finish
[    4.859968] mpp-iep2 fdbb0000.iep: Adding to iommu group 9
[    4.860159] mpp-iep2 fdbb0000.iep: probe device
[    4.860340] mpp-iep2 fdbb0000.iep: allocate roi buffer failed
[    4.860952] mpp-iep2 fdbb0000.iep: probing finish
[    4.861229] mpp_jpgdec fdb90000.jpegd: Adding to iommu group 4
[    4.861493] mpp_jpgdec fdb90000.jpegd: probe device
[    4.862493] mpp_jpgdec fdb90000.jpegd: probing finish
[    4.862773] mpp_rkvdec2 fdc38100.rkvdec-core: Adding to iommu group 12
[    4.863192] mpp_rkvdec2 fdc38100.rkvdec-core: rkvdec-core, probing start
[    4.863455] mpp_rkvdec2 fdc38100.rkvdec-core: shared_niu_a is not found!
[    4.863466] rkvdec2_init:982: No niu aclk reset resource define
[    4.863476] mpp_rkvdec2 fdc38100.rkvdec-core: shared_niu_h is not found!
[    4.863483] rkvdec2_init:985: No niu hclk reset resource define
[    4.863544] mpp_rkvdec2 fdc38100.rkvdec-core: no regulator, devfreq is disabled
[    4.863646] mpp_rkvdec2 fdc38100.rkvdec-core: core_mask=00010001
[    4.863656] mpp_rkvdec2 fdc38100.rkvdec-core: attach ccu as core 0
[    4.863982] mpp_rkvdec2 fdc38100.rkvdec-core: sram_start 0x00000000ff001000
[    4.863992] mpp_rkvdec2 fdc38100.rkvdec-core: rcb_iova 0x00000000fff00000
[    4.864000] mpp_rkvdec2 fdc38100.rkvdec-core: sram_size 491520
[    4.864009] mpp_rkvdec2 fdc38100.rkvdec-core: rcb_size 1048576
[    4.864018] mpp_rkvdec2 fdc38100.rkvdec-core: min_width 512
[    4.864028] mpp_rkvdec2 fdc38100.rkvdec-core: rcb_info_count 20
[    4.864036] mpp_rkvdec2 fdc38100.rkvdec-core: [136, 24576]
[    4.864045] mpp_rkvdec2 fdc38100.rkvdec-core: [137, 49152]
[    4.864053] mpp_rkvdec2 fdc38100.rkvdec-core: [141, 90112]
[    4.864061] mpp_rkvdec2 fdc38100.rkvdec-core: [140, 49152]
[    4.864068] mpp_rkvdec2 fdc38100.rkvdec-core: [139, 180224]
[    4.864077] mpp_rkvdec2 fdc38100.rkvdec-core: [133, 49152]
[    4.864084] mpp_rkvdec2 fdc38100.rkvdec-core: [134, 8192]
[    4.864093] mpp_rkvdec2 fdc38100.rkvdec-core: [135, 4352]
[    4.864101] mpp_rkvdec2 fdc38100.rkvdec-core: [138, 13056]
[    4.864108] mpp_rkvdec2 fdc38100.rkvdec-core: [142, 291584]
[    4.864157] mpp_rkvdec2 fdc38100.rkvdec-core: probing finish
[    4.864392] mpp_rkvdec2 fdc48100.rkvdec-core: Adding to iommu group 13
[    4.864726] mpp_rkvdec2 fdc48100.rkvdec-core: rkvdec-core, probing start
[    4.864924] mpp_rkvdec2 fdc48100.rkvdec-core: shared_niu_a is not found!
[    4.864934] rkvdec2_init:982: No niu aclk reset resource define
[    4.864943] mpp_rkvdec2 fdc48100.rkvdec-core: shared_niu_h is not found!
[    4.864950] rkvdec2_init:985: No niu hclk reset resource define
[    4.865001] mpp_rkvdec2 fdc48100.rkvdec-core: no regulator, devfreq is disabled
[    4.865066] mpp_rkvdec2 fdc48100.rkvdec-core: core_mask=00020002
[    4.865093] mpp_rkvdec2 fdc48100.rkvdec-core: attach ccu as core 1
[    4.865484] mpp_rkvdec2 fdc48100.rkvdec-core: sram_start 0x00000000ff079000
[    4.865494] mpp_rkvdec2 fdc48100.rkvdec-core: rcb_iova 0x00000000ffe00000
[    4.865502] mpp_rkvdec2 fdc48100.rkvdec-core: sram_size 487424
[    4.865509] mpp_rkvdec2 fdc48100.rkvdec-core: rcb_size 1048576
[    4.865519] mpp_rkvdec2 fdc48100.rkvdec-core: min_width 512
[    4.865528] mpp_rkvdec2 fdc48100.rkvdec-core: rcb_info_count 20
[    4.865536] mpp_rkvdec2 fdc48100.rkvdec-core: [136, 24576]
[    4.865544] mpp_rkvdec2 fdc48100.rkvdec-core: [137, 49152]
[    4.865552] mpp_rkvdec2 fdc48100.rkvdec-core: [141, 90112]
[    4.865560] mpp_rkvdec2 fdc48100.rkvdec-core: [140, 49152]
[    4.865568] mpp_rkvdec2 fdc48100.rkvdec-core: [139, 180224]
[    4.865575] mpp_rkvdec2 fdc48100.rkvdec-core: [133, 49152]
[    4.865583] mpp_rkvdec2 fdc48100.rkvdec-core: [134, 8192]
[    4.865591] mpp_rkvdec2 fdc48100.rkvdec-core: [135, 4352]
[    4.865599] mpp_rkvdec2 fdc48100.rkvdec-core: [138, 13056]
[    4.865607] mpp_rkvdec2 fdc48100.rkvdec-core: [142, 291584]
[    4.865651] mpp_rkvdec2 fdc48100.rkvdec-core: probing finish
[    4.865893] mpp_rkvenc2 fdbd0000.rkvenc-core: Adding to iommu group 10
[    4.866129] mpp_rkvenc2 fdbd0000.rkvenc-core: probing start
[    4.867045] mpp_rkvenc2 fdbd0000.rkvenc-core: leakage=11
[    4.867067] mpp_rkvenc2 fdbd0000.rkvenc-core: leakage-volt-sel=1
[    4.868266] mpp_rkvenc2 fdbd0000.rkvenc-core: avs=0
[    4.868289] mpp_rkvenc2 fdbd0000.rkvenc-core: l=-2147483648 h=2147483647 hyst=0 l_limit=0 h_limit=0 h_table=0
[    4.868956] mpp_rkvenc2 fdbd0000.rkvenc-core: attach ccu as core 0
[    4.869519] mpp_rkvenc2 fdbd0000.rkvenc-core: probing finish
[    4.869752] mpp_rkvenc2 fdbe0000.rkvenc-core: Adding to iommu group 11
[    4.870013] mpp_rkvenc2 fdbe0000.rkvenc-core: probing start
[    4.870753] mpp_rkvenc2 fdbe0000.rkvenc-core: leakage=11
[    4.870790] mpp_rkvenc2 fdbe0000.rkvenc-core: leakage-volt-sel=1
[    4.872358] mpp_rkvenc2 fdbe0000.rkvenc-core: avs=0
[    4.872447] mpp_rkvenc2 fdbe0000.rkvenc-core: l=-2147483648 h=2147483647 hyst=0 l_limit=0 h_limit=0 h_table=0
[    4.873120] mpp_rkvenc2 fdbe0000.rkvenc-core: attach ccu as core 1
[    4.873931] mpp_rkvenc2 fdbe0000.rkvenc-core: probing finish
[    4.874332] mpp_av1dec fdc70000.av1d: Adding to iommu group 14
[    4.874820] mpp_av1dec fdc70000.av1d: probing start
[    4.875893] mmc2: Host Software Queue enabled
[    4.875908] mmc2: new HS400 Enhanced strobe MMC card at address 0001
[    4.876041] mpp_av1dec fdc70000.av1d: probing finish
[    4.876542] mmcblk2: mmc2:0001 A3A444 230 GiB
[    4.877963] mali fb000000.gpu: Kernel DDK version g18p0-01eac0
[    4.878348] rockchip-dmc dmc: bin=0
[    4.878560] dwmmc_rockchip fe2c0000.mmc: No normal pinctrl state
[    4.878570] rockchip-dmc dmc: leakage=27
[    4.878575] dwmmc_rockchip fe2c0000.mmc: No idle pinctrl state
[    4.878640] rockchip-dmc dmc: leakage-volt-sel=0
[    4.878682] dwmmc_rockchip fe2c0000.mmc: IDMAC supports 32-bit address mode.
[    4.878704] dwmmc_rockchip fe2c0000.mmc: Using internal DMA controller.
[    4.878715] dwmmc_rockchip fe2c0000.mmc: Version ID is 270a
[    4.878747] dwmmc_rockchip fe2c0000.mmc: DW MMC controller at irq 117,32 bit host data width,256 deep fifo
[    4.879825] mali fb000000.gpu: bin=0
[    4.880036] mali fb000000.gpu: leakage=11
[    4.880135] debugfs: Directory 'fb000000.gpu-mali' with parent 'vdd_gpu_s0' already present!
[    4.880819] rockchip-dmc dmc: avs=0
[    4.880854] rockchip-dmc dmc: current ATF version 0x100
[    4.881062] rockchip-dmc dmc: normal_rate = 1560000000
[    4.881077] rockchip-dmc dmc: reboot_rate = 2112000000
[    4.881090] rockchip-dmc dmc: suspend_rate = 528000000
[    4.881101] rockchip-dmc dmc: video_4k_rate = 1560000000
[    4.881113] rockchip-dmc dmc: video_4k_10b_rate = 1560000000
[    4.881125] rockchip-dmc dmc: video_svep_rate = 1560000000
[    4.881137] rockchip-dmc dmc: boost_rate = 2112000000
[    4.881148] rockchip-dmc dmc: fixed_rate(isp|cif0|cif1|dualview) = 2112000000
[    4.881161] rockchip-dmc dmc: performance_rate = 2112000000
[    4.881174] rockchip-dmc dmc: hdmirx_rate = 2112000000
[    4.881191] rockchip-dmc dmc: failed to get vop bandwidth to dmc rate
[    4.881202] rockchip-dmc dmc: failed to get vop pn to msch rl
[    4.881698] mali fb000000.gpu: pvtm=825
[    4.881871]  mmcblk2: p1 p2 p3 p4 p5 p6 p7 p8 p9
[    4.881895] mali fb000000.gpu: pvtm-volt-sel=1
[    4.881907] rockchip-dmc dmc: l=10000 h=2147483647 hyst=5000 l_limit=0 h_limit=0 h_table=0
[    4.882004] debugfs: Directory 'fb000000.gpu-mali' with parent 'vdd_gpu_s0' already present!
[    4.883369] usb 1-1: new high-speed USB device number 2 using xhci-hcd
[    4.883398] mmcblk2boot0: mmc2:0001 A3A444 4.00 MiB
[    4.883606] mali fb000000.gpu: avs=0
[    4.883664] W : [File] : drivers/gpu/arm/bifrost/platform/rk/mali_kbase_config_rk.c; [Line] : 144; [Func] : kbase_platform_rk_init(); power-off-delay-ms not available.
[    4.884159] mali fb000000.gpu: r0p0 status 5 not found in HW issues table;
[    4.884177] mali fb000000.gpu: falling back to closest match: r0p0 status 0
[    4.884189] mali fb000000.gpu: Execution proceeding normally with fallback match
[    4.884200] mali fb000000.gpu: GPU identified as 0x7 arch 10.8.6 r0p0 status 0
[    4.884261] mali fb000000.gpu: No priority control manager is configured
[    4.884303] mmcblk2boot1: mmc2:0001 A3A444 4.00 MiB
[    4.884573] mali fb000000.gpu: No memory group manager is configured
[    4.884607] mali fb000000.gpu: Protected memory allocator not available
[    4.885112] mmcblk2rpmb: mmc2:0001 A3A444 4.00 MiB, chardev (236:0)
[    4.885811] mali fb000000.gpu: Capping CSF_FIRMWARE_TIMEOUT to CSF_FIRMWARE_PING_TIMEOUT
[    4.886400] mali fb000000.gpu: EM: created perf domain
[    4.887049] mali fb000000.gpu: l=10000 h=85000 hyst=5000 l_limit=0 h_limit=800000000 h_table=0
[    4.887794] mali fb000000.gpu: Probed as mali0
[    4.894002] mmc_host mmc0: Bus speed (slot 0) = 400000Hz (slot req 400000Hz, actual 400000HZ div = 0)
[    4.898315] input: realtek,rt5616-codec Headphone Jack as /devices/platform/rt5616-sound/sound/card4/input3
[    4.902713] RKNPU fdab0000.npu: Adding to iommu group 0
[    4.902930] RKNPU fdab0000.npu: RKNPU: rknpu iommu is enabled, using iommu mode
[    4.904429] RKNPU fdab0000.npu: can't request region for resource [mem 0xfdab0000-0xfdabffff]
[    4.904471] RKNPU fdab0000.npu: can't request region for resource [mem 0xfdac0000-0xfdacffff]
[    4.904497] RKNPU fdab0000.npu: can't request region for resource [mem 0xfdad0000-0xfdadffff]
[    4.905236] [drm] Initialized rknpu 0.9.2 20231018 for fdab0000.npu on minor 1
[    4.908941] rockchip-pm rockchip-suspend: not set pwm-regulator-config
[    4.908978] rockchip-suspend not set sleep-mode-config for mem-lite
[    4.908990] rockchip-suspend not set wakeup-config for mem-lite
[    4.909005] rockchip-suspend not set sleep-mode-config for mem-ultra
[    4.909016] rockchip-suspend not set wakeup-config for mem-ultra
[    4.909985] ALSA device list:
[    4.909997]   #0: rockchip,hdmi0
[    4.910034]   #1: rockchip,dp0
[    4.910044]   #2: rockchip,hdmi1
[    4.910054]   #3: rockchip,hdmiin
[    4.910064]   #4: realtek,rt5616-codec
[    4.917153] Freeing unused kernel memory: 7232K
[    4.937129] Run /init as init process
Loading, please wait...
[    4.961238] rk-pcie fe170000.pcie: host bridge /pcie@fe170000 ranges:
[    4.961290] rk-pcie fe170000.pcie:       IO 0x00f2100000..0x00f21fffff -> 0x00f2100000
[    4.961320] rk-pcie fe170000.pcie:      MEM 0x00f2200000..0x00f2ffffff -> 0x00f2200000
[    4.961341] rk-pcie fe170000.pcie:      MEM 0x0980000000..0x09bfffffff -> 0x0980000000
[    4.961469] rk-pcie fe170000.pcie: iATU unroll: enabled
[    4.961482] rk-pcie fe170000.pcie: iATU regions: 8 ob, 8 ib, align 64K, limit 8G
[    4.961537] vendor storage:20190527 ret = 0
[    5.025276] usb 1-1: New USB device found, idVendor=14cd, idProduct=8601, bcdDevice= 0.00
[    5.025316] usb 1-1: New USB device strings: Mfr=1, Product=3, SerialNumber=0
[    5.025333] usb 1-1: Product: USB 2.0 Hub
[    5.025346] usb 1-1: Manufacturer: USB Device
Starting version 249.11-0ubuntu3.7
[    5.086310] hub 1-1:1.0: USB hub found
[    5.086513] hub 1-1:1.0: 4 ports detected
[    5.116797] rk-pcie fe190000.pcie: PCIe Link up, LTSSM is 0x130011
[    5.116859] rk-pcie fe190000.pcie: PCIe Gen.2 x1 link up
[    5.117086] rk-pcie fe190000.pcie: PCI host bridge to bus 0004:40
[    5.117103] pci_bus 0004:40: root bus resource [bus 40-4f]
[    5.117119] pci_bus 0004:40: root bus resource [io  0x200000-0x2fffff] (bus address [0xf4100000-0xf41fffff])
[    5.117131] pci_bus 0004:40: root bus resource [mem 0xf4200000-0xf4ffffff]
[    5.117142] pci_bus 0004:40: root bus resource [mem 0xa00000000-0xa3fffffff pref]
[    5.117188] pci 0004:40:00.0: [1d87:3588] type 01 class 0x060400
[    5.117218] pci 0004:40:00.0: reg 0x38: [mem 0x00000000-0x0000ffff pref]
[    5.117286] pci 0004:40:00.0: supports D1 D2
[    5.117297] pci 0004:40:00.0: PME# supported from D0 D1 D3hot
[    5.127077] pci 0004:40:00.0: Primary bus is hard wired to 0
[    5.127109] pci 0004:40:00.0: bridge configuration invalid ([bus 01-ff]), reconfiguring
[    5.127346] pci 0004:41:00.0: [10ec:8125] type 00 class 0x020000
[    5.127414] pci 0004:41:00.0: reg 0x10: [io  0x0000-0x00ff]
[    5.127486] pci 0004:41:00.0: reg 0x18: [mem 0x00000000-0x0000ffff 64bit]
[    5.127537] pci 0004:41:00.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit]
[    5.127900] pci 0004:41:00.0: supports D1 D2
[    5.127910] pci 0004:41:00.0: PME# supported from D0 D1 D2 D3hot D3cold
[    5.136827] pci_bus 0004:41: busn_res: [bus 41-4f] end is updated to 41
[    5.136882] pci 0004:40:00.0: BAR 8: assigned [mem 0xf4200000-0xf42fffff]
[    5.136898] pci 0004:40:00.0: BAR 6: assigned [mem 0xf4300000-0xf430ffff pref]
[    5.136912] pci 0004:40:00.0: BAR 7: assigned [io  0x200000-0x200fff]
[    5.136930] pci 0004:41:00.0: BAR 2: assigned [mem 0xf4200000-0xf420ffff 64bit]
[    5.136974] pci 0004:41:00.0: BAR 4: assigned [mem 0xf4210000-0xf4213fff 64bit]
[    5.137016] pci 0004:41:00.0: BAR 0: assigned [io  0x200000-0x2000ff]
[    5.137038] pci 0004:40:00.0: PCI bridge to [bus 41]
[    5.137050] pci 0004:40:00.0:   bridge window [io  0x200000-0x200fff]
[    5.137063] pci 0004:40:00.0:   bridge window [mem 0xf4200000-0xf42fffff]
[    5.140477] pcieport 0004:40:00.0: PME: Signaling with IRQ 131
[    5.223547] rk-pcie fe170000.pcie: PCIe Link up, LTSSM is 0x130011
[    5.223590] rk-pcie fe170000.pcie: PCIe Gen.2 x1 link up
[    5.223855] rk-pcie fe170000.pcie: PCI host bridge to bus 0002:20
[    5.223875] pci_bus 0002:20: root bus resource [bus 20-2f]
[    5.223894] pci_bus 0002:20: root bus resource [io  0x300000-0x3fffff] (bus address [0xf2100000-0xf21fffff])
[    5.223909] pci_bus 0002:20: root bus resource [mem 0xf2200000-0xf2ffffff]
[    5.223923] pci_bus 0002:20: root bus resource [mem 0x980000000-0x9bfffffff pref]
[    5.223966] pci 0002:20:00.0: [1d87:3588] type 01 class 0x060400
[    5.223996] pci 0002:20:00.0: reg 0x38: [mem 0x00000000-0x0000ffff pref]
[    5.224060] pci 0002:20:00.0: supports D1 D2
[    5.224073] pci 0002:20:00.0: PME# supported from D0 D1 D3hot
[    5.236733] pci 0002:20:00.0: Primary bus is hard wired to 0
[    5.236756] pci 0002:20:00.0: bridge configuration invalid ([bus 01-ff]), reconfiguring
[    5.237005] pci 0002:21:00.0: [10ec:8125] type 00 class 0x020000
[    5.237070] pci 0002:21:00.0: reg 0x10: [io  0x0000-0x00ff]
[    5.237143] pci 0002:21:00.0: reg 0x18: [mem 0x00000000-0x0000ffff 64bit]
[    5.237195] pci 0002:21:00.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit]
[    5.237558] pci 0002:21:00.0: supports D1 D2
[    5.237570] pci 0002:21:00.0: PME# supported from D0 D1 D2 D3hot D3cold
[    5.246943] pci_bus 0002:21: busn_res: [bus 21-2f] end is updated to 21
[    5.247000] pci 0002:20:00.0: BAR 8: assigned [mem 0xf2200000-0xf22fffff]
[    5.247022] pci 0002:20:00.0: BAR 6: assigned [mem 0xf2300000-0xf230ffff pref]
[    5.247038] pci 0002:20:00.0: BAR 7: assigned [io  0x300000-0x300fff]
[    5.247057] pci 0002:21:00.0: BAR 2: assigned [mem 0xf2200000-0xf220ffff 64bit]
[    5.247102] pci 0002:21:00.0: BAR 4: assigned [mem 0xf2210000-0xf2213fff 64bit]
[    5.247145] pci 0002:21:00.0: BAR 0: assigned [io  0x300000-0x3000ff]
[    5.247171] pci 0002:20:00.0: PCI bridge to [bus 21]
[    5.247184] pci 0002:20:00.0:   bridge window [io  0x300000-0x300fff]
[    5.247198] pci 0002:20:00.0:   bridge window [mem 0xf2200000-0xf22fffff]
[    5.250293] pcieport 0002:20:00.0: PME: Signaling with IRQ 141
[    5.366717] usb 1-1.2: new full-speed USB device number 3 using xhci-hcd
[    5.464268] usb 1-1.2: New USB device found, idVendor=046d, idProduct=c52b, bcdDevice=24.11
[    5.464309] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    5.464318] usb 1-1.2: Product: USB Receiver
[    5.464325] usb 1-1.2: Manufacturer: Logitech
[    5.564195] Freeing drm_logo memory: 4512K
[    5.570287] input: Logitech USB Receiver as /devices/platform/usbdrd3_1/fc400000.usb/xhci-hcd.9.auto/usb1/1-1/1-1.2/1-1.2:1.0/0003:046D:C52B.0001/input/input4
[    5.628808] hid-generic 0003:046D:C52B.0001: input,hidraw0: USB HID v1.11 Keyboard [Logitech USB Receiver] on usb-xhci-hcd.9.auto-1.2/input0
[    5.636708] input: Logitech USB Receiver Mouse as /devices/platform/usbdrd3_1/fc400000.usb/xhci-hcd.9.auto/usb1/1-1/1-1.2/1-1.2:1.1/0003:046D:C52B.0002/input/input5
[    5.694023] input: Logitech USB Receiver Consumer Control as /devices/platform/usbdrd3_1/fc400000.usb/xhci-hcd.9.auto/usb1/1-1/1-1.2/1-1.2:1.1/0003:046D:C52B.0002/input/input6
[    5.694705] input: Logitech USB Receiver System Control as /devices/platform/usbdrd3_1/fc400000.usb/xhci-hcd.9.auto/usb1/1-1/1-1.2/1-1.2:1.1/0003:046D:C52B.0002/input/input7
[    5.696302] hid-generic 0003:046D:C52B.0002: input,hiddev96,hidraw1: USB HID v1.11 Mouse [Logitech USB Receiver] on usb-xhci-hcd.9.auto-1.2/input1
[    5.703260] hid-generic 0003:046D:C52B.0003: hiddev97,hidraw2: USB HID v1.11 Device [Logitech USB Receiver] on usb-xhci-hcd.9.auto-1.2/input2
[    5.776861] usb 1-1.4: new low-speed USB device number 4 using xhci-hcd
[    5.873798] usb 1-1.4: New USB device found, idVendor=1a2c, idProduct=4d7e, bcdDevice= 1.10
[    5.873859] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    5.873894] usb 1-1.4: Product: USB Keyboard
[    5.873925] usb 1-1.4: Manufacturer: SEMICO
[    5.956593] input: SEMICO USB Keyboard as /devices/platform/usbdrd3_1/fc400000.usb/xhci-hcd.9.auto/usb1/1-1/1-1.4/1-1.4:1.0/0003:1A2C:4D7E.0004/input/input9
[    6.015612] hid-generic 0003:1A2C:4D7E.0004: input,hidraw3: USB HID v1.10 Keyboard [SEMICO USB Keyboard] on usb-xhci-hcd.9.auto-1.4/input0
[    6.026089] input: SEMICO USB Keyboard Consumer Control as /devices/platform/usbdrd3_1/fc400000.usb/xhci-hcd.9.auto/usb1/1-1/1-1.4/1-1.4:1.1/0003:1A2C:4D7E.0005/input/input10
[    6.081001] input: SEMICO USB Keyboard System Control as /devices/platform/usbdrd3_1/fc400000.usb/xhci-hcd.9.auto/usb1/1-1/1-1.4/1-1.4:1.1/0003:1A2C:4D7E.0005/input/input11
[    6.081879] input: SEMICO USB Keyboard as /devices/platform/usbdrd3_1/fc400000.usb/xhci-hcd.9.auto/usb1/1-1/1-1.4/1-1.4:1.1/0003:1A2C:4D7E.0005/input/input13
[    6.083836] hid-generic 0003:1A2C:4D7E.0005: input,hiddev98,hidraw4: USB HID v1.10 Keyboard [SEMICO USB Keyboard] on usb-xhci-hcd.9.auto-1.4/input1
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... done.
[    6.202145] EXT4-fs (mmcblk2p8): mounted filesystem with ordered data mode. Quota mode: none.
Begin: Will now check userdata file system ... fsck from util-linux 2.37.2
[/usr/sbin/fsck.ext4 (1) -- /dev/mmcblk2p9] fsck.ext4 -a -C0 /dev/mmcblk2p9
userdata: clean, 11/12800 files, 4958/51200 blocks
done.
[    6.275152] EXT4-fs (mmcblk2p9): mounted filesystem with ordered data mode. Quota mode: none.
[    6.278128] EXT4-fs (mmcblk2p9): unmounting filesystem.
Begin: Resizing ext4 file system on /dev/mmcblk2p9 ... Model: MMC A3A444 (sd/mmc)
Disk /dev/mmcblk2: 100%
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start  End    Size   File system  Name      Flags
 1      0.00%  0.01%  0.00%               uboot
 2      0.01%  0.01%  0.00%               misc
 3      0.01%  0.01%  0.00%               dtbo
 4      0.01%  0.02%  0.01%               resource
 5      0.02%  0.03%  0.02%               kernel
 6      0.03%  0.05%  0.01%               boot
 7      0.05%  0.06%  0.01%               recovery
 8      0.06%  1.74%  1.68%  ext4         rootfs
 9      1.74%  100%   98.3%  ext4         userdata

resize2fs 1.46.5 (30-Dec-2021)
Resizing the filesystem on /dev/mmcblk2p9 to 59364347 (4k) blocks.
The filesystem on /dev/mmcblk2p9 is now 59364347 (4k) blocks long.

done.
[    6.625252] EXT4-fs (mmcblk2p9): mounted filesystem with ordered data mode. Quota mode: none.
[    6.637735] overlayfs: "xino" feature enabled using 32 upper inode bits.
done.
Begin: Running /scripts/local-bottom ... done.
Begin: Running /scripts/init-bottom ... done.

Welcome to Debian GNU/Linux 11 (bullseye)!

[    6.886271] rk_hdmirx fdee0000.hdmirx-controller: hdmirx_audio_interrupts_setup: 1
Configuration file /lib/systemd/system/rkaiq_3A.service is marked world-writable. Please remove world writability permission bits. Proceeding anyway.
/lib/systemd/system/bootanim.service:9: Unit configured to use KillMode=none. This is unsafe, as it disables systemd's process lifecycle management for the service. Please update your service to use a safer KillMode=, such as 'mixed' or 'control-group'. Support for KillMode=none is deprecated and will eventually be removed.
[  OK  ] Created slice system-getty.slice.
[  OK  ] Created slice system-modprobe.slice.
[  OK  ] Created slice system-serial\x2dgetty.slice.
[  OK  ] Created slice User and Session Slice.
[  OK  ] Started Dispatch Password …ts to Console Directory Watch.
[  OK  ] Started Forward Password R…uests to Wall Directory Watch.
[  OK  ] Set up automount Arbitrary…s File System Automount Point.
[  OK  ] Reached target Local Encrypted Volumes.
[  OK  ] Reached target Remote File Systems.
[  OK  ] Reached target Slices.
[    6.981729] fdee0000.hdmirx-controller: Vertical Sync threshold reached interrupt 0x2
[  OK  ] Reached target Swap.
[    7.123063] fdee0000.hdmirx-controller: hdmirx_wait_lock_and_get_timing signal lock ok, i:31!
[  OK  ] Listening on Syslog Socket.
[  OK  ] Listening on initctl Compatibility Named Pipe.
[  OK  ] Listening on Journal Audit Socket.
[  OK  ] Listening on Journal Socket (/dev/log).
[  OK  ] Listening on Journal Socket.
[  OK  ] Listening on udev Control Socket.
[  OK  ] Listening on udev Kernel Socket.
         Mounting Huge Pages File System...
         Mounting POSIX Message Queue File System...
         Mounting Kernel Debug File System...
         Mounting Kernel Trace File System...
         Starting Set the console keyboard layout...
         Starting Create list of st…odes for the current kernel...
         Starting Load Kernel Module configfs...
         Starting Load Kernel Module drm...
         Starting Load Kernel Module fuse...
[  OK  ] Started Nameserver information manager.
[  OK  ] Reached target Network (Pre).
         Starting Enable Rockchip camera engine rkaiq...
         Starting Journal Service...
         Starting Load Kernel Modules...
         Starting Remount Root and Kernel File Systems...
         Starting Coldplug All udev Devices...
[  OK  ] Mounted Huge Pages File System.
[  OK  ] Mounted POSIX Message Queue File System.
[  OK  ] Mounted Kernel Debug File System.
[  OK  ] Mounted Kernel Trace File System.
[  OK  ] Finished Create list of st… nodes for the current kernel.
[  OK  ] Finished Load Kernel Module configfs.
[  OK  ] Finished Load Kernel Module drm.
[  OK  ] Finished Load Kernel Module fuse.
[  OK  ] Started Enable Rockchip camera engine rkaiq.
         Mounting FUSE Control File System...
         Mounting Kernel Configuration File System...
[  OK  ] Mounted Kernel Configuration File System.
[  OK  ] Finished Remount Root and Kernel File Systems.
         Starting Platform Persistent Storage Archival...
         Starting Load/Save Random Seed...
         Starting Create System Users...
[  OK  ] Mounted FUSE Control File System.
[    7.183724] r8125: loading out-of-tree module taints kernel.
[    7.185892] r8125 2.5Gigabit Ethernet driver 9.010.01-NAPI loaded
[    7.185975] r8125 0004:41:00.0: enabling device (0000 -> 0003)
[    7.206923] r8125: This product is covered by one or more of the following patents: US6,570,884, US6,115,776, and US6,327,625.
[    7.208959] r8125  Copyright (C) 2022 Realtek NIC software team <nicfae@realtek.com>
[  OK  ] Finished Platform Persistent Storage Archival.
[    7.208959]  This program comes with ABSOLUTELY NO WARRANTY; for details, please see <http://www.gnu.org/licenses/>.
[    7.208959]  This is free software, and you are welcome to redistribute it under certain conditions; see <http://www.gnu.org/licenses/>.
[    7.209122] r8125 2.5Gigabit Ethernet driver 9.010.01-NAPI loaded
[    7.209177] r8125 0002:21:00.0: enabling device (0000 -> 0003)
[  OK  ] Finished Create System Users.
[  OK  ] Finished Load/Save Random Seed.
         Starting Create Static Device Nodes in /dev...
[    7.226683] rk-pcie fe150000.pcie: PCIe Link Fail
[    7.226696] rk-pcie fe150000.pcie: failed to initialize host
[    7.228904] r8125: This product is covered by one or more of the following patents: US6,570,884, US6,115,776, and US6,327,625.
[    7.230939] r8125  Copyright (C) 2022 Realtek NIC software team <nicfae@realtek.com>
[    7.230939]  This program comes with ABSOLUTELY NO WARRANTY; for details, please see <http://www.gnu.org/licenses/>.
[  OK  ] Finished Create Static Device Nodes in /dev.
[    7.230939]  This is free software, and you are welcome to redistribute it under certain conditions; see <http://www.gnu.org/licenses/>.
         Starting Rule-based Manage…for Device Events and Files...
[  OK  ] Finished Load Kernel Modules.
         Starting Apply Kernel Variables...
[  OK  ] Finished Apply Kernel Variables.
[  OK  ] Started Rule-based Manager for Device Events and Files.
[  OK  ] Started Journal Service.
         Starting Flush Journal to Persistent Storage...
[    7.324959] systemd-journald[421]: Received client request to flush runtime journal.
[  OK  ] Finished Flush Journal to Persistent Storage.
[    7.410027] fdee0000.hdmirx-controller: hdmirx_format_change: New format: 1920x1080p59.99 (2200x1125)
[  OK  ] Finished Coldplug All udev Devices.
         Starting Helper to synchronize boot up for ifupdown...
[  OK  ] Finished Helper to synchronize boot up for ifupdown.
[    7.461782] cryptodev: driver 1.12 loaded.
[    7.465799] rk-crypto fe370000.crypto: invalid resource
[    7.471741] rk-crypto fe370000.crypto: register to cryptodev ok!
[    7.471792] rk-crypto fe370000.crypto: CRYPTO V2.0.0.0 Accelerator successfully registered
[    7.483349] rk_hdmirx fdee0000.hdmirx-controller: hdmirx_delayed_work_audio: enable audio
[    7.505934] at24 6-0053: supply vcc not found, using dummy regulator
[  OK  ] Found device /dev/ttyFIQ0.
[  OK  ] Reached target Hardware activated USB gadget.
         Starting Enable Rockchip camera engine rkaiq...
[  OK  ] Started Enable Rockchip camera engine rkaiq.
[  OK  ] Listening on Load/Save RF …itch Status /dev/rfkill Watch.
[  OK  ] Finished Set the console keyboard layout.
[  OK  ] Reached target Local File Systems (Pre).
[  OK  ] Reached target Local File Systems.
[    7.730010] rk-pcie fe180000.pcie: PCIe Link Fail
[    7.730021] rk-pcie fe180000.pcie: failed to initialize host
         Starting Enable support fo…l executable binary formats...
         Starting Boot time animation...
         Starting Set console font and keymap...
         Starting Raise network interfaces...
         Starting Create Volatile Files and Directories...
         Starting Manage USB device functions...
         Mounting Arbitrary Executable File Formats File System...
[  OK  ] Finished Create Volatile Files and Directories.
         Starting Update UTMP about System Boot/Shutdown...
[  OK  ] Mounted Arbitrary Executable File Formats File System.
[  OK  ] Finished Enable support fo…nal executable binary formats.
[  OK  ] Finished Update UTMP about System Boot/Shutdown.
[  OK  ] Reached target System Initialization.
[  OK  ] Started ACPI Events Check.
[  OK  ] Started Trigger anacron every hour.
[  OK  ] Started Daily apt download activities.
[  OK  ] Started Daily apt upgrade and clean activities.
[  OK  ] Started Periodic ext4 Onli…ata Check for All Filesystems.
[  OK  ] Started Discard unused blocks once a week.
[  OK  ] Started Daily man-db regeneration.
[  OK  ] Started Daily Cleanup of Temporary Directories.
[  OK  ] Reached target Paths.
[  OK  ] Reached target Timers.
[  OK  ] Listening on ACPID Listen Socket.
[  OK  ] Listening on D-Bus System Message Bus Socket.
[  OK  ] Listening on triggerhappy.socket.
[  OK  ] Reached target Sockets.
[  OK  ] Reached target Basic System.
[  OK  ] Started ACPI event daemon.
         Starting Save/Restore Sound Card State...
[  OK  ] Started Run anacron jobs.
         Starting enable ASYNC for Debian Display...
         Starting Bluetooth management mechanism...
[  OK  ] Started D-Bus System Message Bus.
         Starting Network Manager...
         Starting Remove Stale Onli…t4 Metadata Check Snapshots...
         Starting Init board...
         Starting Init Onboard LEDs...
         Starting LSB: Load kernel …d to enable cpufreq scaling...
         Starting LSB: Run /etc/rc.local if it exist...
         Starting rkisp 3A engine...
         Starting System Logging Service...
         Starting User Login Management...
         Starting triggerhappy global hotkey daemon...
         Starting Disk Manager...
         Starting WPA supplicant...
[  OK  ] Started Boot time animation.
[  OK  ] Finished Save/Restore Sound Card State.
[  OK  ] Reached target Sound Card.
         Starting Daily man-db regeneration...
[  OK  ] Started rkisp 3A engine.
[  OK  ] Finished Init Onboard LEDs.
[  OK  ] Started triggerhappy global hotkey daemon.
[  OK  ] Started System Logging Service.
[  OK  ] Finished Raise network interfaces.
[  OK  ] Started LSB: Load kernel m…ded to enable cpufreq scaling.
         Starting LSB: set CPUFreq kernel parameters...
[  OK  ] Started LSB: Run /etc/rc.local if it exist.
[  OK  ] Started User Login Management.
[  OK  ] Started WPA supplicant.
         Starting Authorization Manager...
[  OK  ] Started Authorization Manager.
[  OK  ] Started Network Manager.
[  OK  ] Started LSB: set CPUFreq kernel parameters.
         Starting Hostname Service...
[  OK  ] Finished Remove Stale Onli…ext4 Metadata Check Snapshots.
[    8.031695] logitech-djreceiver 0003:046D:C52B.0003: hiddev96,hidraw0: USB HID v1.11 Device [Logitech USB Receiver] on usb-xhci-hcd.9.auto-1.2/input2
[  OK  ] Started Hostname Service.
[  OK  ] Started Disk Manager.
[    8.125412] eth0: 0xffffffc00d8b0000, 7a:03:14:91:cd:b6, IRQ 142
         Starting Network Manager Script Dispatcher Service...
[    8.142644] file system registered
[    8.146620] input: Logitech Wireless Device PID:4052 Mouse as /devices/platform/usbdrd3_1/fc400000.usb/xhci-hcd.9.auto/usb1/1-1/1-1.2/1-1.2:1.2/0003:046D:C52B.0003/0003:046D:4052.0006/input/input14
[    8.147037] hid-generic 0003:046D:4052.0006: input,hidraw1: USB HID v1.11 Mouse [Logitech Wireless Device PID:4052] on usb-xhci-hcd.9.auto-1.2/input2:1
[  OK  ] Started Network Manager Script Dispatcher Service.
[    8.173671] read descriptors
[    8.173703] read strings
[    8.175305] eth1: 0xffffffc00d880000, 7e:03:14:91:cd:b6, IRQ 174
[  OK  ] Started Manage USB device functions.
[    8.309994] input: Logitech M545/M546 as /devices/platform/usbdrd3_1/fc400000.usb/xhci-hcd.9.auto/usb1/1-1/1-1.2/1-1.2:1.2/0003:046D:C52B.0003/0003:046D:4052.0006/input/input18
[    8.310299] logitech-hidpp-device 0003:046D:4052.0006: input,hidraw1: USB HID v1.11 Mouse [Logitech M545/M546] on usb-xhci-hcd.9.auto-1.2/input2:1
[    8.398731] dwc3 fc000000.usb: device reset
[  OK  ] Started Bluetooth management mechanism.
[    8.445883] android_work: sent uevent USB_STATE=CONNECTED
[  OK  ] Finished Set console font and keymap.
[  OK  ] Finished Daily man-db regeneration.
[  OK  ] Finished Init board.
[  OK  ] Reached target Network.
[  OK  ] Reached target Network is Online.
[  OK  ] Started lcd2usb.
         Starting Network Time Service...
         Starting OpenVPN service...
         Starting /etc/rc.local Compatibility...
         Starting Sets network devices IRQ and RPS...
         Starting OpenBSD Secure Shell server...
[  OK  ] Started strongSwan IPsec I…IKEv2 daemon using ipsec.conf.
         Starting Permit User Sessions...
         Starting LSB: layer 2 tunelling protocol daemon...
[  OK  ] Finished OpenVPN service.
[  OK  ] Finished Permit User Sessions.
[  OK  ] Started Network Time Service.
         Starting Light Display Manager...
[  OK  ] Started /etc/rc.local Compatibility.
[  OK  ] Started Getty on tty1.
[  OK  ] Started Serial Getty on ttyFIQ0.
[  OK  ] Reached target Login Prompts.
[    9.267206] NET: Registered PF_PPPOX protocol family
[    9.276244] l2tp_core: L2TP core driver, V2.0
[    9.276963] l2tp_netlink: L2TP netlink interface
[  OK  ] Started Light Display Manager.
[    9.278277] l2tp_ppp: PPPoL2TP kernel driver, V2.0
[  OK  ] Started LSB: layer 2 tunelling protocol daemon.
[  OK  ] Finished Sets network devices IRQ and RPS.
[  OK  ] Started OpenBSD Secure Shell server.
[    9.437647] mali fb000000.gpu: Loading Mali firmware 0x1010000
[    9.439245] mali fb000000.gpu: Mali firmware git_sha: ee476db42870778306fa8d559a605a73f13e455c
[    9.741142] r8125: eth0: link up
[    9.741166] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[  OK  ] Started enable ASYNC for Debian Display.
[  OK  ] Reached target Multi-User System.
[  OK  ] Reached target Graphical Interface.
[  OK  ] Started Setup rockchip platform environment.
         Starting Update UTMP about System Runlevel Changes...
[  OK  ] Finished Update UTMP about System Runlevel Changes.
[   10.953862] ttyFIQ ttyFIQ0: tty_port_close_start: tty->count = 1 port count = 2
[   11.709975] rk_hdmirx fdee0000.hdmirx-controller: hdmirx_audio_startup: device is no connected or audio is off

Debian GNU/Linux 11 NanoPC-T6 ttyFIQ0

NanoPC-T6 login: [   12.167474] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   12.167498] Bluetooth: BNEP filters: protocol multicast
[   12.167512] Bluetooth: BNEP socket layer initialized
[   18.336995] platform mtd_vendor_storage: deferred probe pending
[   38.476575] dwc3 fc000000.usb: device reset
[   38.535504] android_work: sent uevent USB_STATE=CONFIGURED

NanoPC-T6 login: pi
Password:
Linux NanoPC-T6 6.1.25 #5 SMP Sun Dec 17 13:16:14 CST 2023 aarch64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
pi@NanoPC-T6:~$

6.4 磁盘测试

6.4.1 查看块设备

查看eMMC块设备文件:

pi@NanoPC-T6:~$ ls /dev/mmc* -l
brw-rw---- 1 root disk 179,  0 Dec  6 14:33 /dev/mmcblk2
brw-rw---- 1 root disk 179, 32 Dec  6 13:47 /dev/mmcblk2boot0
brw-rw---- 1 root disk 179, 64 Dec  6 13:47 /dev/mmcblk2boot1
brw-rw---- 1 root disk 179,  1 Dec  6 14:33 /dev/mmcblk2p1
brw-rw---- 1 root disk 179,  2 Dec  6 14:33 /dev/mmcblk2p2
brw-rw---- 1 root disk 179,  3 Dec  6 14:33 /dev/mmcblk2p3
brw-rw---- 1 root disk 179,  4 Dec  6 14:33 /dev/mmcblk2p4
brw-rw---- 1 root disk 179,  5 Dec  6 14:33 /dev/mmcblk2p5
brw-rw---- 1 root disk 179,  6 Dec  6 14:33 /dev/mmcblk2p6
brw-rw---- 1 root disk 179,  7 Dec  6 14:33 /dev/mmcblk2p7
brw-rw---- 1 root disk 179,  8 Dec  6 14:33 /dev/mmcblk2p8
brw-rw---- 1 root disk 179,  9 Dec  6 14:33 /dev/mmcblk2p9
crw------- 1 root root 236,  0 Dec  6 13:47 /dev/mmcblk2rpmb

这里一共有12个块设备节点和1个字符设备节点;其中:

  • /dev/mmcblk2表示的是eMMC这个设备,其主设备号为179,次设备号为0;
  • mmcblk2boot0mmcblk2boot1对应两个Boot Area Partition;每一个Boot Area Partition大小都是4MB
  • mmcblk2rpmb则为RPMB Partition;大小为4MB
  • mmcblk2pxUser Data Area划分出来的SW Partitions;实际上就是通过解析GPT分区表创建的分区,分区编号依次为1,2,3,4,5,6,7,8,9;

使用cat /proc/partitions,可以查看全部分区信息:

pi@NanoPC-T6:~$ cat /proc/partitions
major minor  #blocks  name

   1        0       4096 ram0
   1        1       4096 ram1
   1        2       4096 ram2
   1        3       4096 ram3
   1        4       4096 ram4
   1        5       4096 ram5
   1        6       4096 ram6
   1        7       4096 ram7
 179        0  241664000 mmcblk2
 179        1       4096 mmcblk2p1
 179        2       4096 mmcblk2p2
 179        3       4096 mmcblk2p3
 179        4      16384 mmcblk2p4
 179        5      40960 mmcblk2p5
 179        6      32768 mmcblk2p6
 179        7      32768 mmcblk2p7
 179        8    4063232 mmcblk2p8
 179        9  237457391 mmcblk2p9
 179       32       4096 mmcblk2boot0
 179       64       4096 mmcblk2boot1

其中blocks表示分区的容量,每个blocks1KB。这里:

  • mmcblk2p1对应uboot分区,大小为4MB
  • mmcblk2p2对应misc分区,大小为4MB
  • mmcblk2p3对应dtbo分区,大小为4MB
  • mmcblk2p4对应resource分区,大小为16MB
  • mmcblk2p5对应kernel分区,大小为40MB
  • mmcblk2p6对应boot分区,大小为32MB
  • mmcblk2p7对应recovery分区,大小为32MB
  • mmcblk2p8对应rootfs分区,大小为3968MB
  • mmcblk2p9对应userdata分区,大小为剩余所有空间;
6.4.2 查看磁盘空间

这里我们可以通过df -hT查看磁盘空间信息;

pi@NanoPC-T6:~$ df -hT
Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs  7.8G  8.0K  7.8G   1% /dev
tmpfs          tmpfs     1.6G  2.0M  1.6G   1% /run
overlay        overlay   224G   28M  213G   1% /
tmpfs          tmpfs     7.8G     0  7.8G   0% /dev/shm
tmpfs          tmpfs     5.0M  4.0K  5.0M   1% /run/lock
tmpfs          tmpfs     1.6G   52K  1.6G   1% /run/user/1000

显示内容参数说明:

  • Filesystem:文件系统;
  • Type:文件系统类型;
  • Size: 分区大小;
  • Used: 已使用容量;
  • Avail: 还可以使用的容量;
  • Use%: 已用百分比;
  • Mounted on: 挂载点; 

udevtmpfs是虚拟文件系统,它们通常用于设备和临时文件系统,并且占用的空间很小。

overlay是一个联合文件系统,挂载在根目录/,总容量为224GB,已使用空间为28MB,剩余可用空间为213GB,已使用空间占总容量的比例为1%

其他的 tmpfs 文件系统用于临时存储,例如 /dev/shm/run/lock/run/user/1000

6.5 ssh远程连接

查看网络服务状态:

pi@NanoPC-T6:~$ sudo systemctl status NetworkManager.service
● NetworkManager.service - Network Manager
     Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendo>
     Active: active (running) since Wed 2023-12-06 15:17:24 UTC; 19min ago
       Docs: man:NetworkManager(8)
   Main PID: 748 (NetworkManager)
      Tasks: 3 (limit: 18964)
     Memory: 14.0M
        CPU: 374ms
     CGroup: /system.slice/NetworkManager.service
             └─748 /usr/sbin/NetworkManager --no-daemon

Dec 06 15:17:26 NanoPC-T6 NetworkManager[748]: <info>  [1701875846.1472] device>
Dec 06 15:17:26 NanoPC-T6 NetworkManager[748]: <info>  [1701875846.1478] device>
Dec 06 15:17:26 NanoPC-T6 NetworkManager[748]: <info>  [1701875846.1491] manage>
Dec 06 15:17:26 NanoPC-T6 NetworkManager[748]: <info>  [1701875846.1519] manage>
Dec 06 15:17:26 NanoPC-T6 NetworkManager[748]: <info>  [1701875846.1522] policy>
Dec 06 15:17:26 NanoPC-T6 NetworkManager[748]: <info>  [1701875846.1531] dns-mg>
Dec 06 15:17:26 NanoPC-T6 NetworkManager[748]: <info>  [1701875846.2094] device>
Dec 06 15:17:26 NanoPC-T6 NetworkManager[748]: <info>  [1701875846.2126] manage>
Dec 06 15:17:30 NanoPC-T6 NetworkManager[748]: <info>  [1701875850.5638] manage>
Dec 06 15:17:32 NanoPC-T6 NetworkManager[748]: <info>  [1701875852.6026] agent->

输入ifconfig命令后,可以看到网络配置信息,其中包含了两个有线网卡;

pi@NanoPC-T6:~$ sudo ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.101  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::a761:1d58:f857:735b  prefixlen 64  scopeid 0x20<link>
        ether 7a:03:14:91:cd:b6  txqueuelen 1000  (Ethernet)
        RX packets 454  bytes 44063 (43.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 256  bytes 19362 (18.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 142

eth1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 7e:03:14:91:cd:b6  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 174

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

我们可以看到开发板的ip地址为192.168.0.101,因此我们可以使用ping测试和我们宿主机之间的网络通不通;

pi@NanoPC-T6:~$ sudo ping 192.168.0.200
PING 192.168.0.200 (192.168.0.200) 56(84) bytes of data.
64 bytes from 192.168.0.200: icmp_seq=1 ttl=64 time=1.63 ms
64 bytes from 192.168.0.200: icmp_seq=2 ttl=64 time=0.976 ms
64 bytes from 192.168.0.200: icmp_seq=3 ttl=64 time=0.905 ms
^C
--- 192.168.0.200 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.905/1.169/1.628/0.325 ms

既然网络是通过的,那么我们就可以通过ssh远程连接工具连接我们的开发板,这里我使用的是MobaXtermdebain系统默认账号密码如下:

普通用户:
    用户名: pi
    密码: pi

Root用户:
    默认没有设置root密码,可通过sudo passwd root命令配置root密码

这里我们使用Mobaxterm工具以root用户登录,登录之后如下所示;

     ┌────────────────────────────────────────────────────────────────────┐
     │                        • MobaXterm 11.1 •                          │
     │            (SSH client, X-server and networking tools)             │
     │                                                                    │
     │ ➤ SSH session to pi@192.168.0.101                                  │
     │   • SSH compression : ✔                                            │
     │   • SSH-browser     : ✔                                            │
     │   • X11-forwarding  : ✔  (remote display is forwarded through SSH) │
     │   • DISPLAY         : ✔  (automatically set on remote server)      │
     │                                                                    │
     │ ➤ For more info, ctrl+click on help or visit our website           │
     └────────────────────────────────────────────────────────────────────┘

Linux NanoPC-T6 6.1.25 #2 SMP Mon Dec  4 22:42:15 CST 2023 aarch64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Dec  6 15:17:52 2023
pi@NanoPC-T6:~$

通过sudo passwd root命令配置root密码:

pi@NanoPC-T6:~$ sudo passwd root
New password:
Retype new password:
passwd: password updated successfully

这里我将root密码设置为123456,我们可以使用su命令切换到root用户:

pi@NanoPC-T6:~$ su root
Password:
root@NanoPC-T6:/home/pi#

6.6 安装编译器

root@NanoPC-T6:/opt#  sudo apt install gcc g++ gdb gdbserver
6.6.1 查看gcc版本
pi@NanoPC-T6:/$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/10/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.1 20210110 (Debian 10.2.1-6)

此处安装的gcc版本为10.2.1

6.6.2 查看g++版本

我们查看一下g++版本:

pi@NanoPC-T6:/$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/10/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.1 20210110 (Debian 10.2.1-6)
6.6.3 查看gdb版本

查看一下gdb版本:

pi@NanoPC-T6:/$ gdb --version
GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
6.6.4 查看gdbserver版本

查看一下gdbserver版本:

pi@NanoPC-T6:/$ gdbserver --version
GNU gdbserver (Debian 10.1-1.7) 10.1.90.20210103-git
Copyright (C) 2021 Free Software Foundation, Inc.
gdbserver is free software, covered by the GNU General Public License.
This gdbserver was configured as "aarch64-linux-gnu"

6.7 安装内核头文件

在根文件系统/opt目录下存放着linux-header安装包,可以直接安装;

root@NanoPC-T6:/home/pi# cd /opt/
root@NanoPC-T6:/opt# ls -l
-rw-r--r-- 1 root root 7765064 Jun 27 10:12 linux-headers-5.10.160-1.deb
-rw-r--r-- 1 root root 8436016 Nov  9 11:38 linux-headers-6.1.25-1.deb
root@NanoPC-T6:/opt# rm -rf *

当然我们也可以安装我们编译生成的linux-header安装包;

root@NanoPC-T6:/opt# scp root@192.168.0.200://work/sambashare/rk3588/friendly/sd-fuse_rk3588/out/linux-headers-6.1.25.deb ./
root@192.168.0.200's password:
linux-headers-6.1.25.deb   100%   11MB  11.2MB/s   00:00
root@NanoPC-T6:/opt# sudo dpkg -i /opt/linux-headers-*.deb

安装完成后,我们可以看一下/usr/src目录下是否创建了linux-headers-$(uname-r)文件;

root@NanoPC-T6:/opt#  ls -l /usr/src/
drwxr-xr-x 5 pi pi 4096 Dec  6 15:48 linux-headers-6.1.25
root@NanoPC-T6:/opt#  ls -l /usr/src/linux-headers-6.1.25/
-rw-r--r--  1 root root   71902 Dec  4 13:48 Makefile
-rw-r--r--  1 root root 1124563 Dec  4 14:55 Module.symvers
drwxr-xr-x  3 pi   pi      4096 Dec  6 15:43 arch
drwxr-xr-x 33 pi   pi      4096 Dec  6 15:43 include
drwxr-xr-x 17 pi   pi     24576 Dec  6 15:48 scripts

在开发版测试编译内核模块并安装:

pi@NanoPC-T6:/opt$ sudo apt update
pi@NanoPC-T6:/opt$ sudo apt install make bc git
pi@NanoPC-T6:/opt$ git clone https://github.com/RinCat/RTL88x2BU-Linux-Driver.git
pi@NanoPC-T6:/opt$ cd RTL88x2BU-Linux-Driver
pi@NanoPC-T6:/opt$ sudo make -j$(nproc)
pi@NanoPC-T6:/opt$ sudo make install
pi@NanoPC-T6:/opt$ sudo modprobe 88x2bu

如果内核使用了高版本进行编译,比如我最初在宿主机ubuntu系统使用aarch64-linux-gnu-gcc-12.2.1进行编译内核,出现了内核编译gcc版本和debiangcc版本不一致问题;可以按照接下来的教程升级debiangcc版本即可,如果不存在该问题,请忽略下面升级gcc的步骤;

warning: the compiler differs from the one used to build the kernel
  The kernel was built by: aarch64-linux-gcc (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
  You are using:           gcc (Debian 10.2.1-6) 10.2.1 20210110
6.7.1 安装aptitude

安装aptitudeaptitudeapt-get一样,是debian及其衍生系统中功能极其强大的包管理工具。

aptitude整合了dselectapt-get的所有功能, 并提供的更多特性,特别是在依赖关系处理上。

pi@NanoPC-T6:/$ sudo apt-get update
pi@NanoPC-T6:/$ sudo apt-get install aptitude

常用命令:

aptitude update     更新可用的包列表
aptitude upgrade    升级可用的包
aptitude dist-upgrade   将系统升级到新的发行版
aptitude install pkgname    安装包
aptitude remove pkgname     删除包
aptitude purge pkgname  删除包及其配置文件
aptitude search string  搜索包
aptitude show pkgname   显示包的详细信息
aptitude clean  删除下载的包文件
aptitude autoclean  仅删除过期的包文件
6.7.2 配置软件源

配置软件源:

pi@NanoPC-T6:/$ sudo vim /etc/apt/sources.list

这里需要把原内容删除,全部替换为:

# 默认注释了源码镜像以提高 apt update 速度
# 官方  sid表示最新的,每天都更新  如果要升级gcc配置这个,否者不要配置,因为这个在下载包的时候会下载最新版本,导致所有依赖整体升级
#deb http://ftp.cn.debian.org/debian/ sid main contrib non-free
#deb-src http://ftp.cn.debian.org/debian/ sid main contrib non-free
#deb http://ftp.de.debian.org/debian/ sid main contrib non-free
#deb-src http://ftp.de.debian.org/debian/ sid main contrib non-free

# 清华大学的软件源
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free 
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free 
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free 
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free 
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free 
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free 
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free 
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

# 阿里云的软件源
deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
# deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
# deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
# deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
# deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib

# 中科大的软件源
deb https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free 
# deb-src https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free 
deb https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free 
# deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free 
deb https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free 
# deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free 
deb https://mirrors.ustc.edu.cn/debian-security bullseye-security main contrib non-free 
# deb-src https://mirrors.ustc.edu.cn/debian-security bullseye-security main contrib non-free

# 腾讯的软件源
deb http://mirrors.cloud.tencent.com/debian bullseye main contrib non-free
#deb-src http://mirrors.cloud.tencent.com/debian bullseye main contrib non-free
deb http://mirrors.cloud.tencent.com/debian bullseye-updates main contrib non-free
#deb-src http://mirrors.cloud.tencent.com/debian bullseye-updates main contrib non-free
deb http://mirrors.cloud.tencent.com/debian bullseye-backports main contrib non-free
#deb-src http://mirrors.cloud.tencent.com/debian bullseye-backports main contrib non-free
deb http://mirrors.cloud.tencent.com/debian-security/ bullseye-security main contrib non-free
#deb-src http://mirrors.cloud.tencent.com/debian-security/ bullseye-security main contrib non-free

更新库:

pi@NanoPC-T6:/$ sudo aptitude clean
pi@NanoPC-T6:/$ sudo aptitude update 
6.7.3 升级gcc版本

升级gcc版本,配置源中要配置:

deb http://ftp.cn.debian.org/debian/ sid main contrib non-free
#deb-src http://ftp.cn.debian.org/debian/ sid main contrib non-free
deb http://ftp.de.debian.org/debian/ sid main contrib non-free
#deb-src http://ftp.de.debian.org/debian/ sid main contrib non-free

aptitude search可以看到aptitude库里边有了:

pi@NanoPC-T6:/$ sudo aptitude update 
pi@NanoPC-T6:/$ sudo aptitude search gcc-12
p   gcc-12                                                             - GNU C compiler
p   gcc-12-aarch64-linux-gnueabi                                           - GNU C compiler (cross compiler for armel architecture)
......

Linux系统下,可以通过安装不同的gcc版本实现版本切换。首先,需要安装需要的gcc版本。

pi@NanoPC-T6:/$ sudo aptitude install gcc-12 g++-12   # 第一次执行
....          # 前面一直选择n

The following actions will resolve these dependencies:

      Remove the following packages:
1)      binutils [2.35.2-2 (now, oldstable)]
2)      binutils-aarch64-linux-gnu [2.35.2-2 (now, oldstable)]
3)      gcc [4:10.2.1-1 (now, oldstable)]
4)      gcc-10 [10.2.1-6 (now, oldstable)]
5)      libbinutils [2.35.2-2 (now, oldstable)]
6)      libctf0 [2.35.2-2 (now, oldstable)]
7)      libgcc-10-dev [10.2.1-6 (now, oldstable)]
8)      libubsan1 [10.2.1-6 (now, oldstable)]

      Keep the following packages at their current version:
9)      cpp-12 [Not Installed]
10)     g++-12 [Not Installed]
11)     gcc-12 [Not Installed]
12)     libasan8 [Not Installed]
13)     libc-bin [2.31-13+deb11u6 (now, oldstable)]
14)     libc6 [2.31-13+deb11u6 (now, oldstable)]
15)     libgcc-12-dev [Not Installed]
16)     libgcc-s1 [10.2.1-6 (now, oldstable)]
17)     libgomp1 [10.2.1-6 (now, oldstable)]
18)     libgprofng0 [Not Installed]
19)     libhwasan0 [Not Installed]
20)     libitm1 [10.2.1-6 (now, oldstable)]
21)     liblsan0 [10.2.1-6 (now, oldstable)]
22)     libstdc++-12-dev [Not Installed]
23)     libstdc++6 [10.2.1-6 (now, oldstable)]
24)     libtsan2 [Not Installed]
25)     libzstd1 [1.4.8+dfsg-2.1 (now, oldstable)]
26)     locales [2.31-13+deb11u6 (now, oldstable)]


Accept this solution? [Y/n/q/?] y             # 最后一次设置为y(如何判断最后一次呢,next一直未发生改变)

pi@NanoPC-T6:/$ sudo aptitude install gcc-12 g++-12   # 第二次执行
root@NanoPC-T6:/# sudo aptitude install gcc-12 g++-12
The following NEW packages will be installed:
  binutils{a} binutils-aarch64-linux-gnu{a} binutils-common{a} cpp-12{a} g++-12 gcc-12 gcc-12-base{a} libasan8{a} libbinutils{a} libcc1-0{a}
  libctf-nobfd0{a} libctf0{a} libgcc-12-dev{a} libgprofng0{a} libhwasan0{a} libitm1{a} liblsan0{a} libsframe1{a} libstdc++-12-dev{a} libtsan2{a}
  libubsan1{a}
The following packages will be upgraded:
  libc-bin libc6 libgcc-s1 libgomp1 libstdc++6 libzstd1 locales
The following packages are RECOMMENDED but will NOT be installed:
  manpages
7 packages upgraded, 21 newly installed, 0 to remove and 1161 not upgraded.
Need to get 59.4 MB of archives. After unpacking 234 MB will be used.
The following packages have unmet dependencies:
 libc-dev-bin : Depends: libc6 (< 2.32) but 2.37-13 is to be installed
 libc6-dev : Depends: libc6 (= 2.31-13+deb11u6) but 2.37-13 is to be installed
The following actions will resolve these dependencies:

     Install the following packages:
1)     libffi8 [3.4.4-2 (unstable)]
2)     rpcsvc-proto [1.4.3-1 (unstable)]

     Upgrade the following packages:
3)     libc-dev-bin [2.31-13+deb11u6 (now, oldstable) -> 2.37-13 (unstable)]
4)     libc6-dev [2.31-13+deb11u6 (now, oldstable) -> 2.37-13 (unstable)]
5)     libglib2.0-0 [2.66.8-1 (now, oldstable) -> 2.78.2-1 (unstable)]
6)     libglib2.0-bin [2.66.8-1 (now, oldstable) -> 2.78.2-1 (unstable)]
7)     libglib2.0-dev [2.66.8-1 (now, oldstable) -> 2.78.2-1 (unstable)]
8)     libglib2.0-dev-bin [2.66.8-1 (now, oldstable) -> 2.78.2-1 (unstable)]



Accept this solution? [Y/n/q/?] y  # 第一次选择y

安装完后,可以在终端中使用下面的命令查看已安装的gcc版本:

root@NanoPC-T6:/# dpkg --list | grep gcc
ii  gcc-10-base:arm64                           10.2.1-6                        arm64        GCC, the GNU Compiler Collection (base package)
ii  gcc-12                                      12.3.0-12                       arm64        GNU C compiler
ii  gcc-12-base:arm64                           12.3.0-12                       arm64        GCC, the GNU Compiler Collection (base package)
ii  gcc-13-base:arm64                           13.2.0-8                        arm64        GCC, the GNU Compiler Collection (base package)
ii  gcc-9-base:arm64                            9.3.0-22                        arm64        GCC, the GNU Compiler Collection (base package)
ii  libgcc-12-dev:arm64                         12.3.0-12                       arm64        GCC support library (development files)
ii  libgcc-s1:arm64                             13.2.0-8                        arm64        GCC support library

如果安装多个gcc版本后,可以使用update-alternatives工具切换版本。

使用下面的命令添加gcc-12g++-12为备选项:

pi@NanoPC-T6:/$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 60 
update-alternatives: using /usr/bin/gcc-12 to provide /usr/bin/gcc (gcc) in auto mode
pi@NanoPC-T6:/$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 60
update-alternatives: using /usr/bin/g++-12 to provide /usr/bin/g++ (g++) in auto mode

同样,数字60表示优先级,数字越大优先级越高。这里为了便于理解,将优先级设置为了不同的数字。

使用下面的命令查看gccg++相关的备选项:

pi@NanoPC-T6:/$ sudo update-alternatives --config gcc
There is only one alternative in link group gcc (providing /usr/bin/gcc): /usr/bin/gcc-12
Nothing to configure.
pi@NanoPC-T6:/$ sudo update-alternatives --config g++
There is only one alternative in link group g++ (providing /usr/bin/g++): /usr/bin/g++-12
Nothing to configure.

查看gcc版本,并创建cc的软链接;

pi@NanoPC-T6:/$ gcc -v        # 命令1
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/12/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 12.3.0-12' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-12 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.3.0 (Debian 12.3.0-12)

pi@NanoPC-T6:/$ sudo ln -s /usr/bin/gcc /usr/bin/cc # 命令2

然后可以按照前文介绍的流程继续编译RTL88x2BU-Linux-Driver,编译后安装88x2bu.ko驱动;

pi@NanoPC-T6:/opt/RTL88x2BU-Linux-Driver$ sudo modprobe 88x2bu
pi@NanoPC-T6:/opt/RTL88x2BU-Linux-Driver$ lsmod
Module                  Size  Used by
88x2bu               3092480  0
cfg80211              749568  1 88x2bu      # 这里
nfnetlink              20480  1
hid_logitech_hidpp     45056  0
hid_logitech_dj        28672  0
hid_multitouch         28672  0
bnep                   28672  2
l2tp_ppp               28672  0
l2tp_netlink           24576  1 l2tp_ppp
l2tp_core              40960  2 l2tp_ppp,l2tp_netlink
ip6_udp_tunnel         16384  1 l2tp_core
udp_tunnel             20480  1 l2tp_core
pppox                  20480  1 l2tp_ppp
joydev                 32768  0
at24                   24576  0
r8169                  86016  0
rk_crypto             147456  0
cryptodev              81920  1 rk_crypto
uio_pdrv_genirq        20480  0
uio                    24576  1 uio_pdrv_genirq
binfmt_misc            24576  1
r8125                 163840  0
ledtrig_netdev         16384  0
ip_tables              32768  0

6.8 安装libusb-1.0-0-dev

root@SOM-RK3399v2:/opt# sudo apt install libusb-dev libusb-1.0-0-dev

在使用libusb库的时候需要指定:

  • 头文件libusb.h安装到了/usr/include/libusb-1.0路径;
  • 动态库libusb-1.0.so安装到了/usr/lib/aarch64-linux-gnu/路径;

/opt/libusb目录下编写测试应用程序listdev.c

#include <stdio.h>
#include <sys/types.h>
#include <libusb.h>

static void print_devs(libusb_device **devs)
{
    libusb_device *dev;
    int i = 0;

    while ((dev = devs[i++]) != NULL) {
        struct libusb_device_descriptor desc;
        int r = libusb_get_device_descriptor(dev, &desc);
        if (r < 0) {
            fprintf(stderr, "failed to get device descriptor");
            return;
        }

        printf("%04x:%04x (bus %d, device %d)\n",
            desc.idVendor, desc.idProduct,
            libusb_get_bus_number(dev), libusb_get_device_address(dev));
    }
}

int main(void)
{
    libusb_device **devs;
    int r;
    ssize_t cnt;

    r = libusb_init(NULL);
    if (r < 0)
        return r;

    cnt = libusb_get_device_list(NULL, &devs);
    if (cnt < 0)
        return (int) cnt;

    print_devs(devs);
    libusb_free_device_list(devs, 1);

    libusb_exit(NULL);
    return 0;
}

编译并运行:

pi@NanoPC-T6:/opt/libusb$ sudo gcc  -o listdev listdev.c  -I/usr/include/libusb-1.0   -lusb-1.0
pi@NanoPC-T6:/opt/libusb$ ./listdev
1d6b:0003 (bus 2, device 1)
1a2c:4d7e (bus 1, device 5)
046d:c52b (bus 1, device 4)
03eb:8a6e (bus 1, device 3)
14cd:8601 (bus 1, device 2)
1d6b:0002 (bus 1, device 1)
1d6b:0001 (bus 6, device 1)
1d6b:0002 (bus 5, device 1)
1d6b:0001 (bus 4, device 1)
1d6b:0002 (bus 3, device 1)

6.9 安装x11vnc远程桌面

x11vnc是一个VNC服务器,安装后我们可以不依赖外部的显示设备,,通过网络远程登debia桌面。

6.9.1 安装x11vnc
pi@NanoPC-T6:/$ sudo aptitude install -y x11vnc
# 一直选择y

设置VNC客户端登录密码,这里我设置为123456

pi@NanoPC-T6:/$ sudo x11vnc -storepasswd /etc/x11vnc.pwd

设置x11vnc在开机时自动启动,新建如下文件:

pi@NanoPC-T6:/$ sudo vi /lib/systemd/system/x11vnc.service

内容如下:

[Unit]
Description=Start x11vnc at startup.
Requires=display-manager.service
After=syslog.target network-online.target
Wants=syslog.target network-online.target
 
[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -display :0 -forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc.pwd -rfbport 5900 -shared -capslock -nomodtweak
ExecStop=/usr/bin/x11vnc -R stop
Restart=on-failure
 
[Install]
WantedBy=multi-user.target

设置systemd服务:

pi@NanoPC-T6:/$ sudo systemctl daemon-reload
pi@NanoPC-T6:/$ sudo systemctl enable x11vnc.service
pi@NanoPC-T6:/$ sudo systemctl start x11vnc
6.9.2 测试远程桌面

Windows电脑上安装VNC Viewe,下载地址Download VNC Viewer for Windows | VNC® Connect

安装完成后启动VNC客户端软件, 在地址栏输入: IP地址:5900连接即可,效果如下图所示;

图中设备IP地址为192.168.0.101, 使用端口5900进行连接。

6.9.3 禁止用户自动休眠

执行如下命令查看休眠模式的情况:

pi@NanoPC-T6:/$ sudo systemctl status sleep.target
● sleep.target - Sleep
     Loaded: loaded (/lib/systemd/system/sleep.target; static)
     Active: inactive (dead)
       Docs: man:systemd.special(7)

可以看出,sleep状态是loaded,也就是处于开启状态。接下来,执行如下命令关闭系统的自动休眠开关:

pi@NanoPC-T6:/$ sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
Created symlink /etc/systemd/system/sleep.target → /dev/null.
Created symlink /etc/systemd/system/suspend.target → /dev/null.
Created symlink /etc/systemd/system/hibernate.target → /dev/null.
Created symlink /etc/systemd/system/hybrid-sleep.target → /dev/null.

再次执行如下命令,查看休眠设置:

pi@NanoPC-T6:/$ sudo systemctl status sleep.target
○ sleep.target
     Loaded: masked (Reason: Unit sleep.target is masked.)
     Active: inactive (dead)

可以看到sleep的状态已经变成了masked,也就是关闭了。

虽然吧,这个解决方案看上去挺合理的。但实际上,它也无效,后来电脑还是会每晚自动休眠。

尝试如下命令;

pi@NanoPC-T6:/$ sudo gsettings set org.gnome.desktop.screensaver lock-enabled false
pi@NanoPC-T6:/$ sudo gsettings set org.gnome.desktop.session idle-delay 0

七、debain系统设置

7.1 更改时区

检查当前时区:

pi@NanoPC-T6:/$ timedatectl
               Local time: Fri 2023-12-08 15:06:08 UTC
           Universal time: Fri 2023-12-08 15:06:08 UTC
                 RTC time: Fri 2023-12-08 15:06:08
                Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
              NTP service: n/a
          RTC in local TZ: no

列出所有时区:

pi@NanoPC-T6:/$ timedatectl list-timezones

设置时区 (比如上海):

pi@NanoPC-T6:/$ sudo timedatectl set-timezone Asia/Shanghai
pi@NanoPC-T6:/$ timedatectl
               Local time: Fri 2023-12-08 23:06:34 CST
           Universal time: Fri 2023-12-08 15:06:34 UTC
                 RTC time: Fri 2023-12-08 15:06:34
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
              NTP service: n/a
          RTC in local TZ: no

7.2 更换桌面墙纸

修改如下配置文件:

pi@NanoPC-T6:/$ vim /home/pi/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml

7.3 设置中文语言与输入法

7.3.1 设置中文语言

输入以下命令:

pi@NanoPC-T6:/$ sudo dpkg-reconfigure locales
Generating locales (this might take a while)...
  zh_CN.UTF-8... done
Generation complete.

执行之后可以使用空格选择,Tab键跳转光标,这里用空格选中 zh_CN.UTF-8

添加环境变量到.bashrc,这个文件主要用于设置系统的locale

pi@NanoPC-T6:/$ echo "export LC_ALL=zh_CN.UTF-8" >> ~/.bashrc
pi@NanoPC-T6:/$ echo "export LANG=zh_CN.UTF-8" >> ~/.bashrc
pi@NanoPC-T6:/$ echo "export LANGUAGE=zh_CN.UTF-8" >> ~/.bashrc

使配置立即生效:

pi@NanoPC-T6:/$ source ~/.bashrc
-bash: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8): No such file or directory

根据上面登录警告提示可知,系统已经设置了默认地区_语言,字符集为zh_CN.UTF-8,但是在系统中没有定义对应的locale文件。

查看系统所有可用的locale

pi@NanoPC-T6:/$ sudo locale -a
C
C.utf8
POSIX
zh_CN.utf8

但是看到zh_CN.utf8已经安装,因此我们忽略上面那个警告。

使用locale命令可以查询当前环境中所有的本地化信息,包括语言、字符集、货币格式等,具体操作如下:

pi@NanoPC-T6:/$ locale
LANG=zh_CN.UTF-8
LANGUAGE=zh_CN.UTF-8
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=zh_CN.UTF-8
7.3.2 安装中文输入法

Fcitx (Flexible Input Method Framework) :即小企鹅输入法,它是一个以GPL方式发布的输入法平台(即原来的G五笔),包括五笔、拼音(全拼和双拼)、二笔、区位等输入模块,支持简入繁出,是在Linux操作系统中常用的中文输入法。它的优点是,短小精悍、跟程序的兼容性比较好。

输入如下命令安装fcitx

pi@NanoPC-T6:/$ sudo aptitude install -y fcitx
pi@NanoPC-T6:/$ sudo aptitude install -y im-config
pi@NanoPC-T6:/$ sudo aptitude install -y fcitx-ui-classic fcitx-ui-light
pi@NanoPC-T6:/$ sudo aptitude install -y fcitx-frontend-gtk2 fcitx-frontend-gtk3 

听说搜狗输入法很多Bug,还占性能。所以选择Google,终端输入以下:

pi@NanoPC-T6:/$ sudo apt install -y fcitx-googlepinyin

重启后,在桌面环境按Ctrl+Space即可切换中英文输入法, 右上角也出现了输入法图标,左击右上角的输入法图标,,在弹出菜单中可以切换输入法, 如下图所示:

7.4 测试OpenGL ES性能

glmark2是一款比较出名的GPU benchmark测试程序,支持OpenGL 2.0OpenGL ES 2.0

进入debain桌面环境打开命令行终端,输入以下命令即可测试:

pi@NanoPC-T6:/$ glmark2-es2
arm_release_ver: g13p0-01eac0, rk_so_ver: 10
=======================================================
    glmark2 2021.12
=======================================================
    OpenGL Information
    GL_VENDOR:      ARM
    GL_RENDERER:    Mali-G610
    GL_VERSION:     OpenGL ES 3.2 v1.g13p0-01eac0.a8b6f0c7e1f83c654c60d1775112dbe4
    Surface Config: buf=32 r=8 g=8 b=8 a=8 depth=24 stencil=0
    Surface Size:   800x600 windowed
=======================================================
[build] use-vbo=false: FPS: 1122 FrameTime: 0.891 ms
[build] use-vbo=true: FPS: 1191 FrameTime: 0.840 ms
[texture] texture-filter=nearest: FPS: 1189 FrameTime: 0.841 ms
[texture] texture-filter=linear: FPS: 1221 FrameTime: 0.819 ms
[texture] texture-filter=mipmap: FPS: 1210 FrameTime: 0.826 ms
[shading] shading=gouraud: FPS: 1124 FrameTime: 0.890 ms
[shading] shading=blinn-phong-inf: FPS: 1272 FrameTime: 0.786 ms
[shading] shading=phong: FPS: 1194 FrameTime: 0.838 ms
[shading] shading=cel: FPS: 1244 FrameTime: 0.804 ms
[bump] bump-render=high-poly: FPS: 852 FrameTime: 1.174 ms
[bump] bump-render=normals: FPS: 1426 FrameTime: 0.701 ms
[bump] bump-render=height: FPS: 1415 FrameTime: 0.707 ms
[effect2d] kernel=0,1,0;1,-4,1;0,1,0;: FPS: 1406 FrameTime: 0.711 ms
[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;: FPS: 1088 FrameTime: 0.919 ms
[pulsar] light=false:quads=5:texture=false: FPS: 1335 FrameTime: 0.749 ms
[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4: FPS: 640 FrameTime: 1.562 ms
[desktop] effect=shadow:windows=4: FPS: 1203 FrameTime: 0.831 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 278 FrameTime: 3.597 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=subdata: FPS: 258 FrameTime: 3.876 ms
[buffer] columns=200:interleave=true:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 485 FrameTime: 2.062 ms
[ideas] speed=duration: FPS: 713 FrameTime: 1.403 ms
[jellyfish] <default>: FPS: 1053 FrameTime: 0.950 ms
[terrain] <default>: FPS: 256 FrameTime: 3.906 ms
[shadow] <default>: FPS: 1207 FrameTime: 0.829 ms
[refract] <default>: FPS: 375 FrameTime: 2.667 ms
[conditionals] fragment-steps=0:vertex-steps=0: FPS: 1293 FrameTime: 0.773 ms
[conditionals] fragment-steps=5:vertex-steps=0: FPS: 1178 FrameTime: 0.849 ms
[conditionals] fragment-steps=0:vertex-steps=5: FPS: 1185 FrameTime: 0.844 ms
[function] fragment-complexity=low:fragment-steps=5: FPS: 1167 FrameTime: 0.857 ms
[function] fragment-complexity=medium:fragment-steps=5: FPS: 1265 FrameTime: 0.791 ms
[loop] fragment-loop=false:fragment-steps=5:vertex-steps=5: FPS: 1264 FrameTime: 0.791 ms
[loop] fragment-steps=5:fragment-uniform=false:vertex-steps=5: FPS: 1282 FrameTime: 0.780 ms
[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5: FPS: 1310 FrameTime: 0.763 ms
=======================================================
                                  glmark2 Score: 1051 
=======================================================

可以看到这个跑分比RK3399421高多了。

7.5 HDMI设置

7.5.1 设置HDMI/DP屏幕分辨率

进入桌面系统左上角菜单Settings -> Display界面进行设置即可;

7.5.2 设置HiDPI屏幕缩放

Xfce支持HiDPI缩放,可以使用设置管理器启用。

进入桌面系统左上角菜单Settings >Settings Manager >Appearance > Settings > Window Scaling,选择2作为缩放系数。

或者编辑文件~/.config/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml

7.5.3 查看当前分辨率

在桌面系统打开终端,运行如下命令查看当前分辨率:

pi@NanoPC-T6:~$ xrandr -q
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
HDMI-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1920x1080     60.00*+  60.00    50.00  
   1280x1024     60.02  
   1280x720      60.00  
   800x600       56.25  
   720x576       50.00  
   720x480       59.94    59.94  
HDMI-2 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
7.5.5 设置分辨率

如果要设置分辨率为1920x1080@60Hz,在桌面系统终端运行如下命令:

pi@NanoPC-T6:/$  xrandr --output HDMI-1 --mode 1920x1080 --refresh 60
7.5.6 设节HDMI输出边界

For example, the transformation scaling horizontal coordinates by 0.8, vertical coordinates by 1.04 and moving the screen by 35 pixels right and 19 pixels down:

pi@NanoPC-T6:/$ xrandr --output HDMI-1 --transform 0.80,0,-35,0,1.04,-19,0,0,1
7.5.7 开机自动调整

编辑~/.config/autostart/lxrandr-autostart.desktop,将完整的xrandr命令写入到Exec=开头的键中,如下所示:

[Desktop Entry]
Type=Application
Name=LXRandR autostart
Comment=Start xrandr with settings done in LXRandR
Exec=sh -c 'xrandr --output HDMI-1 --mode 1920x1080 --refresh 50 --transform 1.04,0,-35,0,1.05,-30,0,0,1'

7.6 chromium网页浏览器

7.6.1 GPU支持情况

系统预装的Chromium网页浏览器已经默认启用硬件加速,支持WebGL,可以通过输入网址chrome://gpu了解硬件加速情况,如下图所示:

7.6.2 VPU支持情况

在浏览器上播放一个视频,查看CPU的利用率:

然后在命令行使用fuser查看mpp设备节点的使用情况来确认已经调用了vpu:

pi@NanoPC-T6:~$ sudo fuser /dev/mpp_service
/dev/mpp_service:     1754

如果fuser命令没有内容输出, 则表示当前是软解。

7.6.3 查看支持的硬解格式

在浏览器地址栏输入about://gpu,翻页到页面最底部,查看 Video Acceleration Information表格;

播放一个视频后,再在浏览器地址栏输入about://media-internals,可以查看最近播放的视频是否启用了硬解;

7.7 测试mpp视频硬件编码

在桌面环境运行如下命令:

pi@NanoPC-T6:/$ sudo mpi_enc_test -w 1920 -h 1080 -t 7 -f 0 -o test.h264 -n 300
pi@NanoPC-T6:/$ export XDG_RUNTIME_DIR=/run/user/0
pi@NanoPC-T6:/$ sudo ffplay test.h264
Input #0, h264, from 'test.h264':  0KB vq=    0KB sq=    0B f=0/0   
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080, 30 fps, 30 tbr, 1200k tbn, 60 tbc
    nan M-V:    nan fd=  92 aq=    0KB vq=    0KB sq=    0B f=0/0   

7.8 HDMI-IN的使用

找一台主机或者开发板,将其HDMI输出连接到NandPC-T6开发板HDMI-IN输入接口,这里我是将NandPC-T4开发板作为HDMI输出源。

7.8.1 使用脚本

debian集成了hdmirx_preview.sh测试脚本,直接运行该脚本即可,可以看到NandPC-T4开发板ubuntu的界面;

pi@NanoPC-T6:/$ hdmirx_preview.sh
HDMI-In info:
-------------------------
    device: /dev/video0
     width: 1920
     heigh: 1080
    format: BGR3

设置暂停管道 ...
管道正在实用且不需要 REBOOT ...
管道被 PREROLLED ...
设置播放管道 ...
New clock: GstAudioSrcClock
重新分配延迟时间...
重新分配延迟时间...
重新分配延迟时间...
^Chandling interrupt.
中断:中止管道 ...
Execution ended after 0:05:05.634882586
设置 NULL 管道 ...
Ctrl+C is captured

脚本路径:/usr/local/bin/hdmirx_preview.sh;源码如下:

#!/bin/bash

trap 'onCtrlC' INT
function onCtrlC () {
    echo 'Ctrl+C is captured'
    killall gst-launch-1.0
    exit 0
}

device_id=$(v4l2-ctl --list-devices | grep -A1 hdmirx | grep -v hdmirx | awk -F ' ' '{print $NF}')
v4l2-ctl -d $device_id --set-dv-bt-timings query 2>&1 > /dev/null
width=$(v4l2-ctl -d $device_id --get-dv-timings | grep "Active width" |awk -F ' ' '{print $NF}')
heigh=$(v4l2-ctl -d $device_id --get-dv-timings | grep "Active heigh" |awk -F ' ' '{print $NF}')
format=$(v4l2-ctl -d $device_id -V -D | grep "Pixel Format" | cut -d ':' -f 2 | cut -d "'" -f 2)
status=$(cat /sys/class/hdmirx/hdmirx/status)

if [ "$status" = "disconnected" ]; then
    echo "Please connect a device to the HDMI-IN port."
    exit 1
fi

echo "HDMI-In info:"
echo "-------------------------"
echo "    device: $device_id"
echo "     width: $width"
echo "     heigh: $heigh"
echo "    format: $format"
echo ""

rt5616_card=$(aplay -l | grep "rt5616" | cut -d ':' -f 1 | cut -d ' ' -f 2)
hdmi0_card=$(aplay -l | grep "hdmi0" | cut -d ':' -f 1 | cut -d ' ' -f 2)
hdmi1_card=$(aplay -l | grep "hdmi1" | cut -d ':' -f 1 | cut -d ' ' -f 2)
hdmiin_card=$(arecord -l | grep "hdmiin" | cut -d ":" -f 1 | cut -d ' ' -f 2)

[ -e /usr/lib/aarch64-linux-gnu/libGLdispatch.so.0 ] && \
        export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libGLdispatch.so.0:$LD_PRELOAD

case $format in
NV12)
    DISPLAY=:0.0 gst-launch-1.0 v4l2src device=${device_id} ! video/x-raw,format=${format},width=${width},height=${heigh},framerate=60/1 \
        ! queue ! xvimagesink 2>&1 > /dev/null &
    ;;
BGR3)
    DISPLAY=:0.0 gst-launch-1.0 v4l2src device=${device_id} ! video/x-raw,format=BGR,width=${width},height=${heigh},framerate=60/1 \
        ! queue ! glimagesink 2>&1 > /dev/null &
    ;;
*)
    echo "Warning: the pixel format is not NV12, possible poor performance."
    DISPLAY=:0.0 gst-launch-1.0 v4l2src device=${device_id} ! video/x-raw,format=${format},width=${width},height=${heigh},framerate=15/1 \
        ! videoconvert ! video/x-raw,width=${width},height=${heigh},format=NV12,framerate=15/1 ! queue ! xvimagesink 2>&1 > /dev/null &
    ;;
esac

gst-launch-1.0 alsasrc device=hw:${hdmiin_card},0 ! audioconvert ! audioresample ! queue \
    ! tee name=t ! queue ! alsasink device="hw:${hdmi0_card},0" \
    t. ! queue ! alsasink device="hw:${rt5616_card},0" &

while true
do
    sleep 10
done

请留意:只有NV12格式才能达到最佳性能,有关图像格式可以参考《linux驱动移植-USB摄像头采集图像实时显示(v4l2应用)》第四节。

7.8.2 使用V4L2命令

HDMI-IN设备的节点为:/dev/video0,可以通过v4l2的命令来操作它。

(1) 使用命令列出所有摄像头设备:

pi@NanoPC-T6:/$ v4l2-ctl --list-devices
rk_hdmirx (fdee0000.hdmirx-controller):
        /dev/video0

其中/dev/video0就是这个HDMI-IN的设备。

(2) 查看设备的预览支持格式:

pi@NanoPC-T6:/$ v4l2-ctl -d0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture Multiplanar

        [0]: 'BGR3' (24-bit BGR 8-8-8)
        [1]: 'NV24' (Y/UV 4:4:4)
        [2]: 'NV16' (Y/UV 4:2:2)
        [3]: 'NV12' (Y/UV 4:2:0)

(3) 查看设备的信息:

pi@NanoPC-T6:/$ v4l2-ctl -d /dev/video0  -V -D
Driver Info:
        Driver name      : rk_hdmirx
        Card type        : rk_hdmirx
        Bus info         : fdee0000.hdmirx-controller
        Driver version   : 6.1.25
        Capabilities     : 0x84201000
                Video Capture Multiplanar
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps      : 0x04201000
                Video Capture Multiplanar
                Streaming
                Extended Pix Format
Format Video Capture Multiplanar:
        Width/Height      : 1920/1080
        Pixel Format      : 'BGR3' (24-bit BGR 8-8-8)
        Field             : None
        Number of planes  : 1
        Flags             :
        Colorspace        : sRGB
        Transfer Function : Default
        YCbCr/HSV Encoding: Default
        Quantization      : Limited Range
        Plane 0           :
           Bytes per Line : 5760
           Size Image     : 6220800

(4) 查看当前连接的设备的分辨率与图像格式:

pi@NanoPC-T6:/$ v4l2-ctl -d /dev/video0 --get-fmt-video
Format Video Capture Multiplanar:
        Width/Height      : 1920/1080
        Pixel Format      : 'BGR3' (24-bit BGR 8-8-8)
        Field             : None
        Number of planes  : 1
        Flags             :
        Colorspace        : sRGB
        Transfer Function : Default
        YCbCr/HSV Encoding: Default
        Quantization      : Limited Range
        Plane 0           :
           Bytes per Line : 5760
           Size Image     : 6220800

(5) 使用v4l2-ctl抓一帧图片:

pi@NanoPC-T6:/$ v4l2-ctl  -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat='BGR3' --stream-mmap=4 --stream-skip=10  --stream-to=/home/pi/1080p_bgr24.yuv --stream-count=1 --stream-poll

其中:

  • -d: 摄像头对应设备文件;
  • --set-fmt-video:指定了帧宽高及pxielformat
  • --stream-mmap:指定buffer的类型为mmap(内存映射方式),即将内核空间的缓存映射到用户空间;
  • --stream-to:指定帧数据保存的文件路径;
  • --stream-skip:指定丢弃(不保存到文件)前10帧;
  • --stream-count:指定抓取的帧数,不包括--stream-skip丢弃的数量;

(6) 使用v4l2-ctl录制视频:

pi@NanoPC-T6:/$ v4l2-ctl  -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat='BGR3' --stream-mmap=4 --set-selection=target=crop,flags=0,top=0,left=0,width=1920,height=1080 --stream-to=/home/pi/video.yuv
7.8.3 ffplay

使用ffplay预览抓取的一帧图片,ffplayFFmpeg提供的一个极为简单的音视频媒体播放器(由ffmpeg库和SDL库开发),可以用于音视频播放、可视化分析 ,提供音视频显示和播放相关的图像信息、音频的波形等信息,也可以用作FFmpeg API的测试工具使用。

(1) 使用ffplay非常简单,只需在终端中运行以下命令来播放媒体文件:

pi@NanoPC-T6:/$ ffplay -f rawvideo -video_size 1920x1080 -pixel_format bgr24 /home/pi/1080p_bgr24.yuv
[rawvideo @ 0x7f10000bb0] Estimating duration from bitrate, this may be inaccurate
Input #0, rawvideo, from '/home/pi/1080p_bgr8.yuv':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 1244160 kb/s
    Stream #0:0: Video: rawvideo (BGR[24] / 0x18524742), bgr24, 1920x1080, 1244160 kb/s, 25 tbr, 25 tbn, 25 tbc
   2.18 M-V:  0.000 fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0

其中:

  • -video_size显示图片大小;
  • -pixel_format指定像素格式,非常重要,我这里的图片格式为BGR24

关于pix_fmt参数可以使用如下命令查看,并找到与图像对应的:

pi@NanoPC-T6:/$ ffmpeg -pix_fmts | grep bgr
Pixel formats:
I.... = Supported Input  format for conversion
.O... = Supported Output format for conversion
..H.. = Hardware accelerated format
...P. = Paletted format
....B = Bitstream format
FLAGS NAME            NB_COMPONENTS BITS_PER_PIXEL
IO... bgr24                  3            24
IO... bgr8                   3             8
.O..B bgr4                   3             4
IO... bgr4_byte              3             4
IO... abgr                   4            32
IO... bgra                   4            32
IO... bgr565be               3            16
IO... bgr565le               3            16
IO... bgr555be               3            15
IO... bgr555le               3            15
IO... bgr444le               3            12
IO... bgr444be               3            12
IO... bgr48be                3            48
IO... bgr48le                3            48
IO... bgra64be               4            64
IO... bgra64le               4            64
IO... 0bgr                   3            24
IO... bgr0                   3            24

显示效果如下:

(2) 使用ffplay播放录制的视频:

pi@NanoPC-T6:/$ ffplay -f rawvideo -video_size 1920x1080 -pixel_format bgr24 /home/pi/video.yuv
7.8.4 HDMI-IN音频

查看HDMI-IN音频设备

pi@NanoPC-T6:/$ cat /proc/asound/card*
cat: /proc/asound/card0: 是一个目录
cat: /proc/asound/card1: 是一个目录
cat: /proc/asound/card2: 是一个目录
cat: /proc/asound/card3: 是一个目录
cat: /proc/asound/card4: 是一个目录
 0 [rockchiphdmi0  ]: rockchip_hdmi0 - rockchip,hdmi0
                      rockchip,hdmi0
 1 [rockchipdp0    ]: rockchip_dp0 - rockchip,dp0
                      rockchip,dp0
 2 [rockchiphdmi1  ]: rockchip_hdmi1 - rockchip,hdmi1
                      rockchip,hdmi1
 3 [rockchiphdmiin ]: rockchip_hdmiin - rockchip,hdmiin
                      rockchip,hdmiin
 4 [realtekrt5616co]: simple-card - realtek,rt5616-codec
                      realtek,rt5616-codec

可以看到,rockchiphdmiin的声卡号为3。

录制音频(录制10秒):

pi@NanoPC-T6:/$ sudo arecord -D hw:3,0 -f cd /home/pi/test.wav -d 10

其中:

  • -D hw:3,0:指定录音使用的声卡设备;
  • -d:录音的持续时间,以秒为单位;
  • -f:录音的格式,可以根据实际情况选择;这里设置录制的音频格式为CD音质,即16比特、44.1kHz采样率;
  • test.wav:指定保存音频的文件名为 test.wav

回放所录制的音频(输出到HDMI-IN):

pi@NanoPC-T6:/$ sudo aplay /home/pi/test.wav -D 'hw:rockchiphdmiin'
7.8.5 使用GStreamer

GStreamer是一种多媒体框架,你可以使用它来构建自定义的多媒体应用程序,捕获摄像头视频,进行处理和展示。

你可以使用以下GStreamer管道捕获视频:

pi@NanoPC-T6:/$ DISPLAY=:0.0 gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=BGR,width=1920,height=1080,framerate=60/1 ! queue ! glimagesink

其中:

  • DISPLAY=:0.0DISPLAY 环境变量允许用户指定应用程序应在哪个显示和屏幕上运行,格式如 hostname:display.screen;在这个设置中,:0.0 表示X Window System中的第一个显示和第一个屏幕;更多有关DISPLAY的内容可以参考《快速理解X server, DISPLAYX11 Forwarding》;
  • v4l2srcv4l2src 是一个GStreamer插件,用于从V4L2设备(比如摄像头、HDMI-IN)读取视频数据;
  • device=/dev/video0: 指定了要使用的设备文件路径;
  • video/x-raw:指定输出数据格式为原始视频,format参数设置为BGRwidth设置为1920height设置为1080framerate设置为60fps
  • queue:是一个GStreamer插件,用于在管道中创建一个缓冲区队列,以平衡数据流的处理速度;
  • glimagesink:是一个GStreamer插件,用于将视频数据显示在图形界面上;

实时捕获HDMI-IN(声卡3)音频,并通过声卡0、声卡4输出:

pi@NanoPC-T6:/$ gst-launch-1.0 alsasrc device=hw:3,0 ! audioconvert ! audioresample ! queue ! tee name=t ! queue ! alsasink device="hw:0,0" t. ! queue ! alsasink device="hw:4,0" 

音视频录制:

pi@NanoPC-T6:/$ DISPLAY=:0.0 gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=BGR,width=1920,height=1080,framerate=60/1 ! queue ! mpph265enc ! h265parse ! queue ! mux. alsasrc device=hw:3,0 ! audio/x-raw,channels=2 ! audioconvert ! voaacenc ! queue ! mux. matroskamux name=mux ! filesink location=/home/pi/1080p60.mkv

参考文章:

[1] Rockchip RK3399 - 移植uboot 2017.09 & linux 4.19(友善之家脚本方式)

[2] NanoPC-T6开发手册

[3] gcc/c++ 版本不一致问题导致的

[4] 软件包:gcc-1212.3.0-12 以及其他的)

[5] ArmSom--摄像头开发指南(二)

posted @ 2023-12-05 00:13  大奥特曼打小怪兽  阅读(4642)  评论(0编辑  收藏  举报
如果有任何技术小问题,欢迎大家交流沟通,共同进步