Discussion:
[yocto] kconfig variables not being included in yocto build.
Sakib Sajal
2018-11-19 19:13:49 UTC
Permalink
Hello,

I have been trying to patch the linux kernel and add some kernel configuration but I am failing to add kconfig fragments to be included in the final build.

Initially I tried patching the kernel with hardcoded values in the patch.

I am building for qemu to minimize the variables I have to worry about.

Build Configuration:
BB_VERSION = "1.38.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "ubuntu-16.04"
TARGET_SYS = "i586-poky-linux"
MACHINE = "qemux86"
DISTRO = "poky"
DISTRO_VERSION = "2.5.1" // branch "sumo"
TUNE_FEATURES = "m32 i586"
TARGET_FPU = ""


My initial project structure:

-poky
--meta
--meta-poky
--meta-yocto-bsp
--meta-my-layer
---recipes-kernel
----linux
-----linux-yocto
------my-patch.patch
-----linux-yocto_4%.bbappend
---conf
----layer.conf

Content of the bbappend file:
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

SRC_URI += "file://my-patch.patch"

I enabled my-layer by adding the layer in the build/conf/bblayers.conf file. I was able to build an image and test my changes with the hardcoded valued in my patch.

However I want the values to be configurable through kernel configuration. Since I knew what variables I have introduced, I put them in a .cfg file with their desired values in the linux-yocto folder.

New project structure:

-poky
--meta-my-layer
---recipes-kernel
----linux
-----linux-yocto
------my-conf-frag.cfg

(other files and directories are same as before)

Added the following line to the .bbappend file:
SRC_URI += "file://my-conf-frag.cfg"

Content of my-conf-frag.cfg:
CONFIG_MY_FIRST_VAR="MY-NAME"
CONFIG_MY_SECOND_VAR=y

Then I run:
bitbake core-image-base

and get the following error:

ERROR: Task (<work_dir>/poky/meta/recipes-kernel/linux/linux-yocto_4.14.bb:do_compile) failed with exit code '1'

The kernel isn't being compiled since it does not know what "CONFIG_MY_FIRST_VAR" is.

I checked for .config files in the build directory and found one in "poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/cfg/.config" which contained the two variables I defined in my cfg file. But that file is a kernel configuration fragment file itself. The final config file which is used to build the image is located, I believe, in "poky/build/tmp/work/qemux86-poky-linux/linux-yocto/4.14.67+gitAUTOINC+c43c9e19a2_084af9624d-r0/linux-qemux86-standard-build/.config" but i do not see the variables there in the final .config file. I was also able to locate the cfg and the patch file in "/poky/build/tmp/work/qemux86-poky-linux/linux-yocto/4.14.67+gitAUTOINC+c43c9e19a2_084af9624d-r0/"directory. Therefore the files are being picked up by the build system but the fragments are not being applied to make the final .config file used to build the kernel.

I went through yocto mailing list for similar problems and followed the steps provided with no success. I also went through yocto's mega-manual and kernel development manual as well as the yocto-lab pdfs and followed all the different steps but i always get the compilation error.

Can someone please help me. Thanks in advance!

Sakib Sajal
Bruce Ashfield
2018-11-19 20:19:53 UTC
Permalink
Post by Sakib Sajal
Hello,
I have been trying to patch the linux kernel and add some kernel
configuration but I am failing to add kconfig fragments to be included
in the final build.
Initially I tried patching the kernel with hardcoded values in the patch.
I am building for qemu to minimize the variables I have to worry about.
BB_VERSION           = "1.38.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "ubuntu-16.04"
TARGET_SYS           = "i586-poky-linux"
MACHINE              = "qemux86"
DISTRO               = "poky"
DISTRO_VERSION       = "2.5.1"         // branch "sumo"
TUNE_FEATURES        = "m32 i586"
TARGET_FPU           = ""
-poky
--meta
--meta-poky
--meta-yocto-bsp
--meta-my-layer
---recipes-kernel
----linux
-----linux-yocto
------my-patch.patch
-----linux-yocto_4%.bbappend
---conf
----layer.conf
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://my-patch.patch"
I enabled my-layer by adding the layer in the build/conf/bblayers.conf
file. I was able to build an image and test my changes with the
hardcoded valued in my patch.
However I want the values to be configurable through kernel
configuration. Since I knew what variables I have introduced, I put them
in a .cfg file with their desired values in the linux-yocto folder.
-poky
--meta-my-layer
---recipes-kernel
----linux
-----linux-yocto
------my-conf-frag.cfg
(other files and directories are same as before)
SRC_URI += "file://my-conf-frag.cfg"
CONFIG_MY_FIRST_VAR="MY-NAME"
CONFIG_MY_SECOND_VAR=y
bitbake core-image-base
ERROR: Task
(<work_dir>/poky/meta/recipes-kernel/linux/linux-yocto_4.14.bb:do_compile)
failed with exit code '1'
The kernel isn't being compiled since it does not know what
"CONFIG_MY_FIRST_VAR" is.
I checked for .config files in the build directory and found one in
"poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/cfg/.config"
which contained the two variables I defined in my cfg file. But that
file is a kernel configuration fragment file itself. The final config
file which is used to build the image is located, I believe, in
"poky/build/tmp/work/qemux86-poky-linux/linux-yocto/4.14.67+gitAUTOINC+c43c9e19a2_084af9624d-r0/linux-qemux86-standard-build/.config"
but i do not see the variables there in the final .config file. I was
also able to locate the cfg and the patch file in
"/poky/build/tmp/work/qemux86-poky-linux/linux-yocto/4.14.67+gitAUTOINC+c43c9e19a2_084af9624d-r0/"directory.
Therefore the files are being picked up by the build system but the
fragments are not being applied to make the final .config file used to
build the kernel.
Without being able to see the code that defines those CONFIG_
symbols, I can't say for sure. But if the fragment was located
and added to the config queue, then the only real way that they
wouldn't be in the final .config is a missing dependency for the
option.

If there's any way that you could make the specific layers available
to me for a test build, I could offer more specific suggestions.

Bruce
Post by Sakib Sajal
I went through yocto mailing list for similar problems and followed the
steps provided with no success. I also went through yocto's mega-manual
and kernel development manual as well as the yocto-lab pdfs and followed
all the different steps but i always get the compilation error.
Can someone please help me. Thanks in advance!
Sakib Sajal
--

Loading...