简体   繁体   English

在 yocto 中从机器配置自定义配方选项

[英]Configuring custom recipe options from machine in yocto

We are building a poky/oe based system to run on a few different versions of a board, which have some minor differences.我们正在构建一个基于 poky/oe 的系统,以在几个不同版本的板上运行,它们有一些细微的差异。 One example is the SWD/JTAG IO pins varying between the boards.一个示例是 SWD/JTAG IO 引脚在板之间有所不同。

I'd like to be able to configure these pins per machine, which the answer to this question basically answers.我希望能够为每台机器配置这些引脚, 这个问题的答案基本上可以回答。

However, I'd rather be able to set these options from the machine than having to do per-machine config in the recipe.但是,我宁愿能够从机器上设置这些选项,也不愿在配方中进行每台机器的配置。 Ie, id like to be able to do something like this:即,我喜欢能够做这样的事情:

# /conf/machine/my_machine_v1.conf
OPENOCD_SWCLK_PIN = "25"
OPENOCD_SWDIO_PIN = "24"
OPENOCD_SRST_PIN  = "23"

And then something like this in my recipe that installs the openocd config file:然后在我的安装 openocd 配置文件的配方中类似这样的东西:

SWCLK_PIN = ".... get machine config SWCLK_PIN ..."

etc.等等

This would make it so i don't have to modify the recipe for each new machine.这样就可以了,所以我不必为每台新机器修改配方。 Is it possible?可能吗?

Any variables set in .conf files are global, ie available in all recipes. .conf文件中设置的任何变量都是全局的,即在所有配方中都可用。 Thus the variable can simply be read from the recipe using ${OPENOCD_SWCLK_PIN}因此,可以使用${OPENOCD_SWCLK_PIN}从配方中简单地读取变量

What caught me off guard was that bitbake expands the variables in inline shell scripts instead of setting them in the environment, and bitbake requires the braces in ${XXX} .让我措手不及的是,bitbake 扩展了内联 shell 脚本中的变量,而不是在环境中设置它们,并且 bitbake 需要${XXX}中的大括号。

do_install() {
  # echo "$OPENOCD_SWCLK_PIN" >> ${D}/some_file.cfg # WONT WORK
  echo "${OPENOCD_SWCLK_PIN}" >> ${D}/some_file.cfg # Works,
  # OPENOCD_CWCLK_PIN can be set in the recipe file, distro.conf or machine.conf etc.
}

Thanks to paulbarker on irc for explaining the issue.感谢 irc 上的 paulbarker 解释了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM