使用 bitbake 为 BBB 构建 .dtbo 覆盖

时间:2021-08-01 20:13:09

标签: linux-kernel yocto beagleboneblack bitbake device-tree

我使用内核 linux-ti-staging-4.14 和自定义设备树为我的 BBB 构建了一个 yocto 发行版(rocko)。由于我需要将一个旧项目从 Debian 移植到 Yocto,我还需要在内核中启用 UIO 功能,这也能正常工作。

现在我还需要为 UIO PRUSS 创建一个附加的设备树覆盖。我使用来自 here 的 dts 文件并通过 bbappend 扩展内核配方:

inherit kernel-devicetree

FILESEXTRAPATHS_prepend := "${THISDIR}/files/dts:${THISDIR}/files/beaglebone:"

# Make custom kernel with PRU enabled
SRC_URI += " \
    file://bbb-pru-minimal.dts;subdir=git/arch/${ARCH}/boot/dts \
    file://AM335X-PRU-UIO-00A0-overlay.dts;subdir=git/arch/${ARCH}/boot/dts/overlays \
    file://0001-add-UIO-dtbo.patch \
    file://defconfig \
"

KERNEL_DEVICETREE = " \
   AM335X-PRU-UIO-00A0.dtbo \
   bbb-pru-minimal.dtb \
"

上面列出的补丁文件包含:

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 7949c213a434..fe2513074893 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -610,6 +610,7 @@ dtb-$(CONFIG_SOC_TI81XX) += \
    dm8168-evm.dtb \
    dra62x-j5eco-evm.dtb
 dtb-$(CONFIG_SOC_AM33XX) += \
+   AM335X-PRU-UIO-00A0.dtbo \
    am335x-baltos-ir2110.dtb \
    am335x-baltos-ir3220.dtb \
    am335x-baltos-ir5221.dtb \

但是,内核构建失败,因为似乎没有针对 .dtbo 目标的规则:

|   CC      scripts/mod/empty.o
|   CC      scripts/mod/devicetable-offsets.s
|   MKELF   scripts/mod/elfconfig.h
|   HOSTCC  scripts/mod/modpost.o
|   HOSTCC  scripts/mod/sumversion.o
|   CHK     scripts/mod/devicetable-offsets.h
|   HOSTCC  scripts/mod/file2alias.o
|   HOSTLD  scripts/mod/modpost
| NOTE: make -j 24 HOSTCC=gcc  -isystem[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/usr/include -O2 -pipe -L[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/usr/lib -L[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/lib -Wl,-rpath-link,[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/usr/lib -Wl,-rpath-link,[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/lib -Wl,-rpath,[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/usr/lib -Wl,-rpath,[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/lib -Wl,-O1 -Wl,--allow-shlib-undefined -Wl,--dynamic-linker=[TOPDIR]/build/tmp/sysroots-uninative/x86_64-linux/lib/ld-linux-x86-64.so.2 HOSTCPP=gcc  -E AM335X-PRU-UIO-00A0.dtbo
|   CHK     scripts/mod/devicetable-offsets.h
| make[3]: *** No rule to make target 'arch/arm/boot/dts/AM335X-PRU-UIO-00A0.dtbo'.  Stop.
| arch/arm/Makefile:345: recipe for target 'AM335X-PRU-UIO-00A0.dtbo' failed
| make[2]: *** [AM335X-PRU-UIO-00A0.dtbo] Error 2
| Makefile:146: recipe for target 'sub-make' failed
| make[1]: *** [sub-make] Error 2
| Makefile:24: recipe for target '__sub-make' failed
| make: *** [__sub-make] Error 2
| ERROR: oe_runmake failed

请注意,出于隐私原因,我将错误消息中的绝对路径替换为 [TOPDIR]。

由于我对叠加层创作还很陌生,所以我真的不知道我缺少什么或如何修复它。有什么提示吗?

先谢谢你!

更新:在上面的描述中添加了补丁文件。

2 个答案:

答案 0 :(得分:2)

以下是我在分析 Toradex 的 git 项目后发现的可以激发您解决方案的灵感:

他们有一个自定义类来处理他们的设备树文件和设备树覆盖,here

该类继承了 devicetree,它是一个官方的 poky 类 here

devicetree 类测试设备树是覆盖还是正常,然后编译所有这些。

因此,您基本上可以在自定义配方中使用 devicetree 类来编译设备树覆盖并将它们手动部署到您的 rootfs 中。

Toradex 也有类似 here 的简单配方。他们有一个 git 项目来保存他们所有的设备树覆盖。

话虽如此,我认为 Toradex 不使用自定义配方,而是使用继承自 toradex-devicetree 的自定义 devicetree 类,从他们的设备树覆盖 git 项目编译所有设备树覆盖然后将它们全部部署到 rootfs 中。

在该自定义类中,它们附加到 devicetree 类的 do_deploy 以安装 .dtbo 文件并将它们添加到引导分区下的 overlays.txt 文件中。

最后,如果您没有内核配方,您可以为您的内核配方创建一个 bbappend 文件,并尝试执行以下步骤:

  1. devicetree继承
  2. 通过本地文件或 URL 将作为叠加层的 dts 文件添加到 SRC_URI
  3. 将叠加层的路径添加到 DT_FILES_PATH 类的 devicetree
  4. 在内核配方中,附加到 do_deploy 以将它们添加到 rootfs。

现在,我的建议是逐步实现这一目标:

  1. 创建一个使用 devicetree 类和 dts 覆盖示例文件的自定义配方
  2. 检查它是否正确编译
  3. 如果您理解这一点,则可以应用上述 4 个步骤。

答案 1 :(得分:0)

感谢@BelHadjSalem 的提示,我能够管理 dtbo 构建。 类文件 devicetree.bbclass 是在 Yocto 中引入的,发布版本为“thud”,因此我将整个工作区更新为最新的 Yocto 版本 (dunfell)。之后我创建了一个新配方来构建我的 dtbo 覆盖:

inherit devicetree

FILESEXTRAPATHS_prepend := "${THISDIR}/files/dts:"

SRC_URI = " \
    file://AM335X-PRU-UIO-00A0.dts;subdir=git/overlays \
"

S = "${WORKDIR}/git/overlays"

COMPATIBLE_MACHINE = ".*(ti33x|beaglebone).*"

配方非常简单,可根据需要在我的项目中使用。

然而,一个重要的注意事项:在任何内核配方或内核 bbappend 文件中继承 devicetree.bbclass 都行不通!不确定到底发生了什么,但 devicetree.bbclass 的继承将使内核配方配置无效并以 ERROR: Nothing PROVIDES 'virtual/kernel'

失败