john s.
john s.

Reputation: 517

KBUILD_DEFCONFIG_KMACHINE ?= defconfig_file does not work as expected

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

Upvotes: 3

Views: 3751

Answers (2)

Tomas Novotny
Tomas Novotny

Reputation: 1939

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

Upvotes: 3

yoctotutor.com
yoctotutor.com

Reputation: 5521

  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.

Upvotes: 5

Related Questions