3

KBUILD_DEFCONFIG_KMACHINE ?= defconfig_file does not work as I expected.

First lesson I learned: defconfig != .config

Bare-Kernel-Build (without yocto): A new defconfig file below arch/arm/config/xy_defconfig created by make savedefconfig is not equal to the .config file. I assume the linux kernel expand some symbols and create the final .config.

Yocto-Build: Here comes the issue: Yocto can not correctly handle the defconfig file below arch/arm/config/xy_defconfig. When building the linux-kernel with yocto.. the kernel is half size and not bootable. This results, because yocto does not expand the missing symbols in .config, which a make defconfig would do.

How do you handle the issue?

Update:

Figured out an additional make xy_defconfig do the trick and creates the correct .config file. It is a ugly hack, any better ideas are very welcome.

Added this to my custom linux-xy.bb file.

KBUILD_DEFCONFIG ?= xy_defconfig

do_makedefconfig() {
     oe_runmake -C ${B} ARCH=${ARCH} $KBUILD_DEFCONFIG
}

addtask do_makedefconfig after do_configme before do_compile
john s.
  • 476
  • 9
  • 21

2 Answers2

5
  1. First copy your defconfig to sources/meta-mylayer/recipes-kernel/linux and write a .bbappend file for linux recipe

linux-ti_%.bbappend

FILESEXTRAPATHS_prepend : "${THISDIR}:"
SRC_URI += "file://your-defconfig" 

2. open sources/meta-mylayer/conf/machine/your-machine.conf add below line, search the macro if already present or nor using grep -inr "INTREE_DEFCONFIG"

INTREE_DEFCONFIG_pn-linux-ti = "am335x_phytec_defconfig"

if the macro already present in the same file replace defconfig name.

yoctotutor.com
  • 5,145
  • 4
  • 26
  • 36
  • 1
    Thanks for your replay, but this is exactly I do not want. During development the defconfig-file could change.. so the valid defconfig-file is always in-tree and should not be delivered as a copy in the yocto-recipe. Otherwise, you always have to manually update recipe.. – john s. Jan 31 '18 at 17:42
2

kernel-yocto approach

The KBUILD_DEFCONFIG variable is handled by kernel-yocto class, so you need to inherit it. It is usually done indirectly through include file linux-yocto.inc, so you should have this line you linux recipe:

require recipes-kernel/linux/linux-yocto.inc

Please note that KBUILD_DEFCONFIG_KMACHINE consists of two parts. The first one is variable name (KBUILD_DEFCONFIG) and the second one is kernel machine override (KMACHINE). So you need to change the override to fit your machine. That's why the KMACHINE part is written in italics in the documentation [1]. There is an example for RPi from the documentation:

KBUILD_DEFCONFIG_raspberrypi2 = "bcm2709_defconfig"

The KMACHINE is set in linux-yocto.inc to the MACHINE variable by default.

handle in-tree defconfig by hand

We are using in-tree defconfig without the kernel-yocto class. linux.inc from meta-oe layer is used. I don't know if this is a best practice. Here is our linux recipe (it is reduced to a bare minimum):

require recipes-kernel/linux/linux.inc

PV = "your_version"
SRC_URI = "your_sources"

do_configure_prepend() {
    bbnote "Copying defconfig"
    cp ${S}/arch/${ARCH}/configs/YOUR_defconfig ${WORKDIR}/defconfig
}

[1] https://www.yoctoproject.org/docs/2.4/mega-manual/mega-manual.html#var-KBUILD_DEFCONFIG

Tomas Novotny
  • 1,771
  • 9
  • 11
  • Thx for the reply, but you also did not get my point. `YOUR_defconfig` is not equal to the `.config`, which results, when you first time run: `make ARCH=arm YOUR_defconfig` in a bare kernel-build. My expierience is, that Yocto is not able to expand the `defconfig` to a complete `.config` file. All those build trials result in a non-working kernel, with half size of the bare-build. Please see my update.. in the original question. – john s. Feb 03 '18 at 12:52
  • @johns. Just an idea - do you have correct KERNEL_IMAGETYPE (ie. compressed/uncompressed type)? Because half sized kernel image is really strange. BTW: the explanation why defconfig != .config is in this question: https://stackoverflow.com/questions/41885015/what-exactly-does-linux-kernels-make-defconfig-do . And one more point: see `meta-openembedded/meta-oe/recipes-kernel/linux/linux.inc` (if used) - it updates a kernel configuration a bit based on your OpenEmbedded configuration. – Tomas Novotny Feb 05 '18 at 12:04