embedded-linux - 如何创建特定于机器的配方?

标签 embedded-linux yocto recipe bitbake

我想知道是否有机会仅通过文件名创建机器特定的配方,以便我具有类似的层结构:

\-> recipes-example
     \-> example
         \-> example_1.0.bb_machine1
         \-> example_1.0.bb_machine2

不久前,我几乎阅读了完整的 Yocto Documentation,并以为我曾经偶然发现这个机会来创建机器特定的食谱,但无法重新找到它。

替代方案也很受欢迎,但是我知道像这个例子这样的 bash 解决方案:
do_install() {
   case ${MACHINE} in
      < case statements [...] >
}

最佳答案

不,无法仅通过名称创建特定于机器的配方。

假设只有几个不同的文件/补丁,最常见的方法是在机器特定的目录中添加不同的文件,例如:

\-> recipes-example
  \-> example
    \-> example
      \-> machine1
        \-> defconfig
        \-> mach1.patch
      \-> machine2
        \-> defconfig
    \-> defconfig

这将允许您编写以下内容:(请注意,在我的示例中,有一个通用 defconfig 文件和两个特定于机器的文件。由于 MACHINEOVERRIDES ,将自动选择正确的一个)
SRC_URI += "file://defconfig"
SRC_URI_machine1 += "file://mach1.patch"

在这个例子中, mach1.patch 将只应用于 machine1

如果您需要为机器做一些特别的事情,例如do_install ,你可以使用:
do_install_append_machine1 () {
    do something here
}

更新:(在graugans评论之后)

是的,也可以使用 COMPATIBLE_MACHINE。一种方法是创建 example-mach1.bbexample-mach2.bbexampe-machs.bb ,其中包括几行,例如:
PROVIDES += "virtual/example"
COMPATIBLE_MACHINE = "machine1"

对于`example-machs.bb"
PROVIDES += "virtual/example"
COMPATIBLE_MACHINE = "(machine3|machine4)"

在您的图像配方中,然后添加 IMAGE_INSTALL += "virtual/example"

关于embedded-linux - 如何创建特定于机器的配方?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34870544/

相关文章:

embedded-linux - 在嵌入式 Linux 中只有一种 --hash 样式。为什么?

c++ - 将自上周日午夜以来的秒数转换为日期和时间

linux - NFS rootfs 上的 Busybox SUID

linux - 如何在 Yocto 中为评估板(具有制造商的预设内核)设置抢占式实时内核?

linux - pi3 类似设备上的 WLan0 连接[yocto]

linux - 如何在 bitbake 中连接食谱

c - __asm__ __volatile__ 的工作 ("": : : "memory")

yocto - 如何将 ldd 实用程序添加到 bitbake 图像

patch - Bitbake 配方未按预期应用补丁

chef-infra - 如何在 Chef Recipe 中自动执行用户交互命令