kernel 编译与更新

Qualcomm Linux 使用的 Linux 内核recipes位于 /layers/meta-qcom-hwe/recipes-kernel/linux,在该 meta-qcom-hwe 层中,有两种不同的内核方案:

  1. linux-qcom-custom_6.6.bb recipes支持 BSP 并从托管处 custom 获取内核源代码。qcom.gitgit.codelinaro.org
  2. linux-qcom-base_6.6.bb recipes支持 BSP 并从托管处 base 检索内核源代码。linux.gitgit.kernel.org

当前使用 custom 内核源码

目录结构介绍

qcm6490-idp/
├── kernel-source/       # 内核源码
└── kernel-build-artifacts/  # 构建产物

kernel-source/介绍

存放 Linux 内核的完整源码

  • 内核核心代码(arch/, drivers/, fs/, net/ 等子目录)
  • 设备树源文件(.dts/.dtsi,描述硬件配置,如 QCM6490SoC 外设)
  • 内核配置(Kconfig)和编译脚本(Makefile

目录分析

名字 描述 名字 描述
arch 架构相关的目录 scripts 内核编译、配置相关脚本的目录
block 块设备相关的目录 security 安全架构相关的目录
certs 认证和签名相关的目录 sound 音频系统相关的目录
crypto 加密相关的目录 tools 内核交互工具的目录
documentation 文档相关的目录 usr initramfs 相关的目录,用于生成 initramfs
drivers 驱动相关的目录 virt 提供虚拟机技术(KVM)的目录
fs 文件系统相关的目录 rust Rust 相关的目录
include 头文件相关的目录 Makefile 编译内核的主要文件
init 内核初始化相关的目录 Kbuild 配置内核设定的脚本
ipc 进程间通信相关的目录 Makefile 编译内核的主要文件
kernel 内核最核心相关的目录 Kbuild 配置内核设定的脚本
lib 内核核心库代码的目录 Kconfig 图形化配置界面的配置文件
mm 内存管理相关的目录 MAINTAINERS 维护者名单
net 网络协议相关目录 CREDITS Linux 贡献者
samples 内核编程范例相关的目录 COPYING 版权声明

kernel-build-artifacts/介绍

存放 内核编译后的生成文件(构建产物)

  • 内核镜像文件(Image
  • 设备树二进制文件(.dtb,由 .dts 编译生成)
  • 内核模块(.ko 文件)
  • 编译日志和配置文件(如 .config、build.log

编译内核

进入编译环境代码工作目录,配置编译环境:

source quectel_build/compile/build.sh

执行内核编译命令:

bitbake linux-qcom-custom

内核镜像生成路径:work 目录下临时缓存:build-qcom-wayland/tmp-glibc/work/qcm6490_idp-qcom-linux/linux-qcom-custom/6.6-r0/deploy-linux-qcom-custom/

Yocto 将上面目录的内核镜像文件复制到 build-qcom-wayland/tmp-glibc/deploy/images/qcm6490-idp/,为了方便打包内核镜像文件,执行后续流程,脚本会从此目录下获取内核镜像。

打包内核、设备树镜像

先安装 ukify 工具:

sudo pip install pefile

并执行以下命令打包内核镜像和设备树镜像:

do_kernel_images

注意:请忽略 ukify 的以下警告:


Kernel version not specified, starting autodetection .
Real-Mode Kernel Header magic not found
+ readelf --notes {TOPDIR}/quectel_build/alpha/tools/pack/image_temp/Image
readelf: Error: Not an ELF file - it has the wrong magic bytes at the start
Found uname version: 6.6.52-qli-1.3-ver.1.1
Wrote unsigned ${TOPDIR}/quectel_build/alpha/tools/pack/image_temp/uki.efi

${TOPDIR}/quectel_build/alpha/output/pack 路径获取更新后的镜像:efi.bin

更新镜像

1.烧录前, 进入 fastboot 模式,有下面两种方法进入:

  • a.上电前按住 vol down 键让 QuecPi Alpha 启动到 fastboot 模式。
  • b.使用 adb 方式进入 fastboot 模式。
adb reboot bootloader

2.烧写

fastboot flash efi efi.bin