简体   繁体   中英

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. One example is the SWD/JTAG IO pins varying between the boards.

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:

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. Thus the variable can simply be read from the recipe using ${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} .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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