Yocto kernel tooling - behind the scenes
Introduction
This work is sponsored by Reliable Embedded Systems. You can find more information about our training/consulting services here.
Objectives
The goal of this blog post is to show you how you can figure out why kernel configuration fragments from you .scc/.cfg files are not applied/or not applied as you expected.
Prerequisites
So you read your daily dose of the Yocto Mega Manual and came across chapters like Adding Recipe-Space Kernel Features and Working with Advanced Metadata (yocto-kernel-cache).
Issue
You start to play around with it, but .scc
files are not applied as you expected.
Now what?
Bruce promised a new and improved way in the next release, but for now he says: "The config.queue
and merge-config
logs are
the files of most interest (in the current state of things, there will be better files soon).
config.queue
is in work-shared/$MACHINE/kernel-source/.kmeta/
and the
merge-config
artifacts are one directory deeper under cfg/
"
Let's inspect some of the files under work-shared/$MACHINE/kernel-source/.kmeta/
bsp_definition
bsp_definition
bsp_definition
is where my kernel type
(arm64-ml-std
) is defined and it looks like this:
<where-ever>/tmp/work/<MACHINE>-<DISTRO>-linux/<PREFERRED_PROVIDER_virtual/kernel>/5.8.5-custom-ml-std+gitAUTOINC+9ece50d8a4-r0/arm64-ml-common/bsp/arm64-ml/arm64-ml-std.scc
config.queue
The config.queue
of my arm64-ml-std
kernel looks like this:
configs///defconfig # non-hardware
configs//ktypes/std/std.cfg # non-hardware
configs//features/ikconfig/ikconfig.cfg # non-hardware
configs//features/posix-mqueue/posix-mqueue.cfg # non-hardware
configs//features/ramdisk/ramdisk.cfg # non-hardware
configs//features/mtd/mtd.cfg # non-hardware
configs//features/snvs-rtc/snvs-rtc.cfg # non-hardware
configs//features/tun/tun.cfg # non-hardware
configs//features/btrfs/btrfs.cfg # non-hardware
configs//features/tracepoints/tracepoints.cfg # non-hardware
configs//features/syn-cookies/syn-cookies.cfg # non-hardware
Which looks promising.
So my kernel type
, .scc
files and .cfg
files were picked up. In case they are not picked up you should know that in a file called meta-series
those variables show up (meaning they need to be defined somewhere)
meta-series
# _mark arm64-ml-std.scc start
# _define KMACHINE 'arm64-ml'
# _define KTYPE 'std'
# _define KARCH 'aarch64'
# _mark std.scc start
The file above is quite useful, since you see in which order .scc
files and patches
are applied as you can see with the next excerpt of meta-series
:
kconf /workdir/build/phyboard-polis-imx8mm-wic/tmp/work/phyboard_polis_imx8mm-resy-linux/linux-yocto-custom/5.8.5-custom-ml-std+gitAUTOINC+9ece50d8a4-r0/arm64-ml-base/features/tracepoints/tracepoints.cfg # non-hardware
# _mark tracepoints.scc end
# _mark syn-cookies.scc start
# _define KFEATURE_DESCRIPTION 'Enable CONFIG_SYN_COOKIES support'
# _define KFEATURE_COMPATIBILITY 'all'
kconf /workdir/build/phyboard-polis-imx8mm-wic/tmp/work/phyboard_polis_imx8mm-resy-linux/linux-yocto-custom/5.8.5-custom-ml-std+gitAUTOINC+9ece50d8a4-r0/arm64-ml-base/features/syn-cookies/syn-cookies.cfg # non-hardware
# _mark syn-cookies.scc end
# _mark std-collection.scc end
# _mark std.scc end
# _mark arm64-ml-std.scc end
# _mark arm64-ml-user-patches.scc start
patch patches//patches/phyboard-polis-imx8mm/dts/0001-freescale-imx8mm-phyboard-polis-rdk.dts-dependencies.patch
# _mark arm64-ml-user-patches.scc end
You can see one patch
at the end after processing the .scc
files in the order they appear in my top level kernel type
(arm64-ml-std
) file.
tree .kernel-meta/
I guess you got the idea. Here is the tree with all files:
student@e450-tr1:/workdir$ tree .kernel-meta/ .kernel-meta/ ├── bsp_definition ├── cfg │ ├── merge_config_build.log │ └── scratch ├── config.queue ├── configs │ ├── defconfig │ ├── features │ │ ├── btrfs │ │ │ └── btrfs.cfg │ │ ├── ikconfig │ │ │ └── ikconfig.cfg │ │ ├── mtd │ │ │ └── mtd.cfg │ │ ├── posix-mqueue │ │ │ └── posix-mqueue.cfg │ │ ├── ramdisk │ │ │ └── ramdisk.cfg │ │ ├── snvs-rtc │ │ │ └── snvs-rtc.cfg │ │ ├── syn-cookies │ │ │ └── syn-cookies.cfg │ │ ├── tracepoints │ │ │ └── tracepoints.cfg │ │ └── tun │ │ └── tun.cfg │ └── ktypes │ └── std │ └── std.cfg ├── meta-series ├── non-hardware_frags.txt ├── patches │ └── patches │ └── phyboard-polis-imx8mm │ └── dts │ └── 0001-freescale-imx8mm-phyboard-polis-rdk.dts-dependencies.patch ├── patch.queue └── series -> patch.queue 19 directories, 19 files
cfg/merge_config_build.log
In case some configuration fragments are not applied as you expected you might also have a look at cfg/merge_config_build.log
:
Using .kernel-meta/configs///defconfig as base
Merging .kernel-meta/configs//ktypes/std/std.cfg
Merging .kernel-meta/configs//features/ikconfig/ikconfig.cfg
Merging .kernel-meta/configs//features/posix-mqueue/posix-mqueue.cfg
Merging .kernel-meta/configs//features/ramdisk/ramdisk.cfg
Merging .kernel-meta/configs//features/mtd/mtd.cfg
Value of CONFIG_MTD_CFI_ADV_OPTIONS is redefined by fragment .kernel-meta/configs//features/mtd/mtd.cfg:
Previous value: CONFIG_MTD_CFI_ADV_OPTIONS=y
New value: # CONFIG_MTD_CFI_ADV_OPTIONS is not set
Merging .kernel-meta/configs//features/snvs-rtc/snvs-rtc.cfg
Merging .kernel-meta/configs//features/tun/tun.cfg
Value of CONFIG_TUN is redefined by fragment .kernel-meta/configs//features/tun/tun.cfg:
Previous value: CONFIG_TUN=y
New value: CONFIG_TUN=m
Merging .kernel-meta/configs//features/btrfs/btrfs.cfg
Value of CONFIG_BTRFS_FS is redefined by fragment .kernel-meta/configs//features/btrfs/btrfs.cfg:
Previous value: CONFIG_BTRFS_FS=m
New value: CONFIG_BTRFS_FS=y
Merging .kernel-meta/configs//features/tracepoints/tracepoints.cfg
Value of CONFIG_FTRACE is redefined by fragment .kernel-meta/configs//features/tracepoints/tracepoints.cfg:
Previous value: # CONFIG_FTRACE is not set
New value: CONFIG_FTRACE=y
Merging .kernel-meta/configs//features/syn-cookies/syn-cookies.cfg
make[1]: Entering directory '/workdir/build/phyboard-polis-imx8mm-wic/tmp/work/phyboard_polis_imx8mm-resy-linux/linux-yocto-custom/5.8.5-custom-ml-std+gitAUTOINC+9ece50d8a4-r0/linux-phyboard_polis_imx8mm-std-build'
GEN Makefile
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/confdata.o
HOSTCC scripts/kconfig/expr.o
LEX scripts/kconfig/lexer.lex.c
YACC scripts/kconfig/parser.tab.[ch]
HOSTCC scripts/kconfig/lexer.lex.o
HOSTCC scripts/kconfig/parser.tab.o
HOSTCC scripts/kconfig/preprocess.o
HOSTCC scripts/kconfig/symbol.o
HOSTCC scripts/kconfig/util.o
HOSTLD scripts/kconfig/conf
scripts/kconfig/conf --alldefconfig Kconfig
#
# configuration written to .config
#
make[1]: Leaving directory '/workdir/build/phyboard-polis-imx8mm-wic/tmp/work/phyboard_polis_imx8mm-resy-linux/linux-yocto-custom/5.8.5-custom-ml-std+gitAUTOINC+9ece50d8a4-r0/linux-phyboard_polis_imx8mm-std-build'
Value requested for CONFIG_ACPI_APEI_PCIEAER not in final .config
Requested value: CONFIG_ACPI_APEI_PCIEAER=y
Actual value:
Value requested for CONFIG_USB_CONN_GPIO not in final .config
Requested value: CONFIG_USB_CONN_GPIO=m
Actual value: CONFIG_USB_CONN_GPIO=y
Value requested for CONFIG_BUILD_BIN2C not in final .config
Requested value: CONFIG_BUILD_BIN2C=y
Actual value:
Value requested for CONFIG_MTD_IMPA7 not in final .config
Requested value: # CONFIG_MTD_IMPA7 is not set
Actual value:
Conclusion
I hope this helps. If you still don't see your configuration changes, you could also try KERNEL_FEATURES_append e.g. to conditionally include kernel meta data and those happen after all the kernel tooling so it should work.
Maybe like that:
# --> EW-7811UN USB/Wifi dongle # USB realtek wifi # # conditionally include kernel fragment: KERNEL_FEATURES_append = " ${@bb.utils.contains('MACHINE_FEATURES', 'wifi', ' features/rtl8xxxu/rtl8xxxu.scc', '', d)}" # which seems to work # # conditionally automatically load the kernel module KERNEL_MODULE_AUTOLOAD += " ${@bb.utils.contains("MACHINE_FEATURES", "wifi", "rtl8xxxu", "",d)}" # # make sure 'wifi' is also set in DISTRO_FEATURES to install various extra things # and make wifi work out of the box # # <-- EW-7811UN USB/Wifi dongle
Comments
Post a Comment