第13课: 这一课是 Yocto BSP 开发最重要的一课。# Yocto BSP 开发第13课:linux-*.bbappend 深度解析
摘要:本文深入讲解 Yocto BSP 开发中最重要的 linux-*.bbappend 技术。通过对比错误做法与正确方法,详细解析 bbappend 的工作原理、目录结构建立、配置修改、补丁应用、设备树管理等核心内容。文章包含完整的实验指导,从确认 kernel recipe 名称到最终验证,手把手教你使用 .bbappend 修改 Kernel Config,开启 CONFIG_IKCONFIG 和 CONFIG_IKCONFIG_PROC 配置,并通过 /proc/config.gz 验证修改生效。这是所有 BSP 厂商(NXP、TI、ST、RaspberryPi、Intel)共同采用的标准方法。
前面我们已经学会了:
1.Layer(meta-myproduct)
2.Recipe(.bb)
3.Image
4.Packagegroup
5.Kernel menuconfig
6.Device Tree 基础
7.Kernel Module
到这里你已经是在使用 BSP。
而 linux-*.bbappend 才是真正开始开发 BSP。
第13课 linux-*.bbappend
目标:
不修改 Yocto 官方源码,而是修改 Linux Kernel。
这是所有 BSP 厂商(NXP、TI、ST、RaspberryPi、Intel)共同采用的方法。
一、为什么不能改 linux.bb?
例如 Raspberry Pi kernel 来自
meta-raspberrypi/ recipes-kernel/linux/ linux-raspberrypi_6.6.bb很多新手喜欢:
vimlinux-raspberrypi_6.6.bb或者
vimkernel-source这样做有几个问题:
以后 git pull
全部覆盖
别人不能复现
升级版本全部丢失
所以
永远不要改官方 layer。
正确的方法:
meta-myproduct里面增加
linux-raspberrypi_%.bbappendYocto 自动把你的修改追加进去。
这就是
bbappend
二、bbappend 工作原理
假设系统有
linux-raspberrypi_6.6.bbBitBake 找到
linux-raspberrypi_%.bbappend自动执行
linux.bb + linux.bbappend相当于
新的 linux recipe所以
bb负责原始 recipe
bbappend
负责追加。
三、建立目录
在
meta-myproduct建立
recipes-kernel/继续
linux/最终
meta-myproduct/ └── recipes-kernel └── linux ├── linux-raspberrypi_%.bbappend └── files以后所有 kernel 修改都放这里。
四、最简单的 bbappend
创建
linux-raspberrypi_%.bbappend内容
FILESEXTRAPATHS:prepend :="${THISDIR}/files:"SRC_URI+=" \ file://my.cfg \ "解释:
FILESEXTRAPATHS告诉 BitBake
去
files/找文件。
然后
SRC_URI追加文件。
五、修改 Kernel Config
例如增加一个配置
files/my.cfg内容
CONFIG_IKCONFIG=y