Yocto: linux-toradex kernel recipe doesn't use defconfig

Hello,

i’m trying to use my own kernel defconfig file, but i just can’t get the linux-toradex recipe to use it.

My build config:

Build Configuration:
BB_VERSION           = "1.46.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "arm-tdx-linux-gnueabi"
MACHINE              = "apalis-imx6"
DISTRO               = "custom"
DISTRO_VERSION       = "5.3.0-devel-20220106144118+build.0"
TUNE_FEATURES        = "arm armv7a vfp thumb neon callconvention-hard"
TARGET_FPU           = "hard"
meta-toradex-nxp     = "HEAD:4a58243170331a1afb9fa0aec8fef492f87f131b"
meta-freescale       = "HEAD:0173d3f8d0cbf7844a4d23bc3fb30144abc914bb"
meta-freescale-3rdparty = "HEAD:a7b96dc91bb2818d8ed8210654db10d08d4d7890"
meta-toradex-tegra   = "HEAD:e37959a52f2cea3a2a2f0c4f165a60715c817565"
meta-toradex-bsp-common = "HEAD:869312de75c9187e02523ff2cfa806144ace949f"
meta-oe
meta-filesystems
meta-gnome
meta-xfce
meta-initramfs
meta-networking
meta-multimedia
meta-python          = "HEAD:11eae114522a6befa06c7f4021a83bc016133543"
meta-freescale-distro = "HEAD:5d882cdf079b3bde0bd9869ce3ca3db411acbf3b"
meta-toradex-demos   = "HEAD:9c277f8bf4fa3c6a0b2c10c93b66b28f440d9723"
meta-boot2qt
meta-boot2qt-distro  = "HEAD:854bcc4fae23d9459751a87b697032edb86dfcc6"
meta-qt5             = "HEAD:845a1421d10ce94a4f425915a7d008810a2f626c"
meta-toradex-distro  = "HEAD:390fb8af9c4b2b13b891df6907b96ee53d201e5f"
meta-poky            = "HEAD:134c1e9902148f907d4f9e78435fa3a827c6df03"
meta                 = "HEAD:ecd636154e7cfc1349a7cfd8026a85eafa219535"
meta-mender-core     = "HEAD:045cfcfc3649b0505cee0b56af8946ef692cd67d"
meta-mender-toradex-nxp = "HEAD:d52e47db3fadf97dfb081636c9565b4ac3ba616a"
meta-mender-demo     = "HEAD:045cfcfc3649b0505cee0b56af8946ef692cd67d"
meta-custom      = "dunfell:63373efe13d69f4767e606fd535ea94d26863f32"

I’ve created a linux-toradex bbappend and tried every defconfig file combination i can think of, but nothing is ever used:

├── recipes-kernel
│   └── linux
│       ├── linux-toradex
│       │   ├── apalis_imx6
│       │   │   └── defconfig
│       │   ├── apalis-imx6
│       │   │   └── defconfig
│       │   ├── apalis_imx6_defconfig
│       │   └── defconfig
│       └── linux-toradex_5.4-2.3.x.bbappend

Contents of file linux-toradex_5.4-2.3.x.bbappend:

FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

In each defconfig there is a different “CONFIG_LOCALVERSION” to try and find out which one is used, but none ever gets used.

Here is some debug output generated with “bitbake-layers show-appendst”:

linux-toradex_5.4-2.3.x.bb:
  /home/yocto/build/../layers/meta-mender/meta-mender-core/recipes-kernel/linux/linux-%.bbappend
  /home/yocto/build/../layers/meta-boot2qt/meta-boot2qt-distro/dynamic-layers/toradex-nxp-layer/recipes-kernel/linux/linux-toradex_5.%.bbappend
  /home/yocto/build/../layers/meta-toradex-bsp-common/recipes-kernel/linux/linux-toradex_%.bbappend
  /home/yocto/build/../layers/meta-custom/recipes-kernel/linux/linux-toradex_5.4-2.3.x.bbappend

What am i doing wrong? I deeply appreciate help on this, as it is driving me nuts.

Thank you.

Kevin

Try putting
SRC_URI += “file://defconfig”
in your bbappend file?

I tried it, i then get a warning:

WARNING: linux-toradex-5.4.115+gitAUTOINC+dbdbcabf0f-r0 do_kernel_metadata: defconfig detected in WORKDIR. apalis_imx6_defconfig skipped
WARNING: linux-toradex-5.4.115+gitAUTOINC+dbdbcabf0f-r0 do_kernel_metadata: [NOTE]: defconfig was supplied both via KBUILD_DEFCONFIG and SRC_URI. Dropping SRC_URI defconfig

I’m totally guessing btw…maybe throw an
unset KBUILD_DEFCONFIG
in there too?

I do feel like this is going down the wrong rabbit hole

I’ve tried it, the warning is gone but still the same result. Looking into the workdir, the defconfig file strangely is from my recipe, but it is not used.

I’m now just extracting the .sdimg file and looking into the /boot folder, where i find the zImage with the local name:

zImage-5.4.115-5.3.0-devel+git.dbdbcabf0f98

I’m expecting “-5.3.0-custom” because i’ve set it in my defconfig:

CONFIG_LOCALVERSION="-5.3.0-custom"

Here are my layers with priority:

layer                 path                                      priority
==========================================================================
meta-toradex-nxp      /home/yocto/build/../layers/meta-toradex-nxp  22
meta-freescale        /home/yocto/build/../layers/meta-freescale  5
meta-freescale-3rdparty  /home/yocto/build/../layers/meta-freescale-3rdparty  4
meta-toradex-tegra    /home/yocto/build/../layers/meta-toradex-tegra  22
meta-toradex-bsp-common  /home/yocto/build/../layers/meta-toradex-bsp-common  23
meta-oe               /home/yocto/build/../layers/meta-openembedded/meta-oe  6
meta-filesystems      /home/yocto/build/../layers/meta-openembedded/meta-filesystems  6
meta-gnome            /home/yocto/build/../layers/meta-openembedded/meta-gnome  7
meta-xfce             /home/yocto/build/../layers/meta-openembedded/meta-xfce  7
meta-initramfs        /home/yocto/build/../layers/meta-openembedded/meta-initramfs  8
meta-networking       /home/yocto/build/../layers/meta-openembedded/meta-networking  5
meta-multimedia       /home/yocto/build/../layers/meta-openembedded/meta-multimedia  6
meta-python           /home/yocto/build/../layers/meta-openembedded/meta-python  7
meta-freescale-distro  /home/yocto/build/../layers/meta-freescale-distro  4
meta-toradex-demos    /home/yocto/build/../layers/meta-toradex-demos  24
meta-boot2qt          /home/yocto/build/../layers/meta-boot2qt/meta-boot2qt  20
meta-boot2qt-distro   /home/yocto/build/../layers/meta-boot2qt/meta-boot2qt-distro  20
meta-qt5              /home/yocto/build/../layers/meta-qt5  7
meta-toradex-distro   /home/yocto/build/../layers/meta-toradex-distro  21
meta-poky             /home/yocto/build/../layers/meta-yocto/meta-poky  5
meta                  /home/yocto/build/../layers/openembedded-core/meta  5
meta-mender-core      /home/yocto/build/../layers/meta-mender/meta-mender-core  6
meta-mender-toradex-nxp  /home/yocto/build/../layers/meta-mender-community/meta-mender-toradex-nxp  92
meta-custom           /home/yocto/build/../layers/meta-custom  30

Hi @kkettinger !

Could you please share your whole bbappend to the linux-toradex recipe?

Seems like you are targeting BSP 5. Is that right?

Best regards,

Hello @henrique.tx,

yes, i’m targeting BSP 5.3. My bbappend file (linux-toradex_5.4-2.3.x.bbappend) just contains this line:

FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

The file structure looks like this (with my many tries of different defconfig files and folders):

recipes-kernel/
└── linux
    ├── linux-toradex
    │   ├── apalis_imx6
    │   │   └── defconfig
    │   ├── apalis-imx6
    │   │   └── defconfig
    │   ├── apalis_imx6_defconfig
    │   ├── defconfig
    └── linux-toradex_5.4-2.3.x.bbappend

This is my distro config:

require conf/distro/include/tdx-base.inc

DISTRO = "custom"
DISTRO_NAME = "Custom Distro"
DISTRO_FLAVOUR = ""

IMX_DEFAULT_BSP = "nxp"

And this is the content of my manifests file:

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <default sync-j="4"/>

  <!-- Toradex Default -->
  <remote alias="repo" fetch="https://github.com/openembedded" name="oe"/>
  <remote alias="repo" fetch="https://git.yoctoproject.org/git" name="yocto"/>

  <project name="bitbake.git" path="layers/openembedded-core/bitbake" remote="oe" revision="c2a3bda3a29e12472ef7862e424ea1552fab2959" upstream="1.46"/>
  <project name="meta-openembedded.git" path="layers/meta-openembedded" remote="oe" revision="11eae114522a6befa06c7f4021a83bc016133543" upstream="dunfell"/>
  <project name="meta-yocto" path="layers/meta-yocto" remote="yocto" revision="134c1e9902148f907d4f9e78435fa3a827c6df03" upstream="dunfell"/>
  <project name="openembedded-core.git" path="layers/openembedded-core" remote="oe" revision="ecd636154e7cfc1349a7cfd8026a85eafa219535" upstream="dunfell"/>

  <include name="bsp/pinned-nxp.xml"/>
  <include name="bsp/pinned-tdx.xml"/>

  <project name="meta-toradex-demos.git" path="layers/meta-toradex-demos" remote="tdx" revision="9c277f8bf4fa3c6a0b2c10c93b66b28f440d9723" upstream="dunfell-5.x.y"/>
  <project name="meta-toradex-distro.git" path="layers/meta-toradex-distro" remote="tdx" revision="390fb8af9c4b2b13b891df6907b96ee53d201e5f" upstream="dunfell-5.x.y">
    <copyfile dest="export" src="buildconf/export"/>
  </project>

  <!-- Qt -->
  <remote name="qt" fetch="git://code.qt.io/yocto" pushurl="ssh://codereview.qt-project.org/yocto"/>
  <remote name="gerrit" fetch="ssh://codereview.qt-project.org/yocto"/>
  <project name="meta-boot2qt" remote="qt" revision="854bcc4fae23d9459751a87b697032edb86dfcc6" upstream="lts-5.15" path="layers/meta-boot2qt"/>
  <project name="meta-qt5" remote="qt" revision="845a1421d10ce94a4f425915a7d008810a2f626c" upstream="lts-5.15" path="layers/meta-qt5"/>

  <!-- Custom -->
  <!-- ... --->

  <!-- Mender -->
  <remote fetch="https://github.com/mendersoftware" name="mender"/>
  <project name="meta-mender" remote="mender" revision="dunfell" path="layers/meta-mender"/>
  <project name="meta-mender-community" remote="mender" revision="dunfell" path="layers/meta-mender-community"/>

</manifest>

Hi @kkettinger !

If you take a look at the (downstream) linux-toradex recipe for Apalis iMX6 (layers/meta-toradex-nxp/recipes-kernel/linux/linux-toradex_5.4-2.3.x.bb), you will see that this recipe inherits the toradex-kernel-localversion.

This toradex-kernel-localversion (layers/meta-toradex-bsp-common/classes/toradex-kernel-localversion.bbclass) defines the task kernel_do_configure_append that is executed after the kernel’s configuration task.

We can see that this kernel_do_configure_append manipulates the local version and is able to actually override the local version that is set via defconfig and also append SCM related version.

So (a way) of actually getting your desired 5.4.115-5.3.0-custom version is to do the following in your linux-toradex_%.bbappend:

SCMVERSION="n"
LOCALVERSION="-5.3.0-custom"

Best regards,

Hi @henrique.tx,

thank you very much. The localversion was just a way to detect if my defconfig is beeing taken by bitbake. My primary goal was to change the kernel config via defconfig.

Do you know what needs to be done to apply my own defconfig (created via bitbake virtual/kernel -c menuconfig && bitbake virtual/kernel -c savedefconfig)?

Kevin

Hi @kkettinger !

Ohh… ok… I really thought that a custom LOCALVERSION was your actual target (although the title of your question explicitly talks about defconfig :sweat_smile: )

So, to use your own defconfig, please refer to the Custom meta layers, recipes and images in Yocto Project (hello-world examples) article. There are several customization methods (for defconfig, as well) and some good explanations about this kind of stuff. The section Customize the Kernel might be especially helpful for you.

Let me know if this helps you.

Best regards,

Hello @henrique.tx,

thank you very much, my kernel defconfig is now used :slight_smile:

My bbappend looks like this now:

FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

unset KBUILD_DEFCONFIG

SRC_URI += "file://defconfig"

SCMVERSION="n"
LOCALVERSION="-5.3.0-custom"

With this directory tree:

recipes-kernel/
└── linux
    ├── linux-toradex
    │   └── defconfig
    └── linux-toradex_5.4-2.3.x.bbappend

Booting into the system, the module is built and my kernel local version is applied:

root@localhost:~# zcat /proc/config.gz | grep LOCAL
CONFIG_LOCALVERSION="-5.3.0-custom"
# CONFIG_LOCALVERSION_AUTO is not set
root@localhost:~# uname -a
Linux localhost 5.4.115-5.3.0-custom #1 SMP Tue Jul 6 08:47:10 UTC 2021 armv7l armv7l armv7l GNU/Linux

PS:
@DaveM So unsetting KBUILD_DEFCONFIG was a really good guess :slight_smile:

Best regards,
Kevin

2 Likes

Hi @kkettinger !

Great to know that you could make it work!

And thanks a lot for the detailed feedback :slight_smile:

Best regards,