linux-kernelyoctobitbakeyocto-recipe

Set kernel config fragment variable from Yocto recipe


I have a Yocto layer with kernel bbappend file, that adds my own kernel configuration fragmets and dependency on linux-firmware package. I want to embed i915 firmware directly into Linux kernel. All I need to do is set two variables in my firmware.cfg fragment file:

CONFIG_EXTRA_FIRMWARE="i915/bxt_dmc_ver1_07.bin"
CONFIG_EXTRA_FIRMWARE_DIR="${WORKDIR}${base_libdir}/firmware"

The problem is that Linux configuration fragments are preprocessed in configuration step, not in recipe execution step. Path ${WORKDIR}${base_libdir}/firmware expands to /lib/firmware, so it looks like ${WORKDIR} variable is not set at this moment, but ${base_libdir} variable already contains the right value. I also tried to use ${STAGING_FIRMWARE_DIR} found in openembdded-core/meta/conf/bitbake.conf file, but this variable expands to empty value.

Is it possible to pass bitbake variable from appended kernel recipe to kernel configuration fragment in Yocto? If no, what alternative solution can be used for embedding firmware into kernel using Yocto?


Solution

  • Looks like Yocto does not support firmware embedding directly and here is my workaround:

    1. I needed to add append file to the linux-firmware recipe and make it install firmwares to sysroot;
    2. I created a custom bbclass that changes linux .config file in do_configure step using sed and added required firmwares from my append file for linux kernel.
    3. I also added build time dependency on linux-firmware recipe for kernel so it can find firmwares in sysroot.