[yocto] [meta-raspberrypi][PATCH v2] linux-raspberrypi: support configuration fragments / in-tree defconfig

Alex J Lennon ajlennon at dynamicdevices.co.uk
Thu Oct 22 07:00:42 PDT 2015


Synopsis
========

Start using Yocto kernel configuration fragments[0] and the "in-tree
defconfig" solution provided in poky[1].

To specify an "in-tree" defconfig file, you may edit the recipe that
builds your kernel so that it has the following command form:

     KBUILD_DEFCONFIG_KMACHINE ?= defconfig_file

You need to append the variable with KMACHINE and then supply the
path to your "in-tree" defconfig file.

In order to achieve this meta-raspberrypi needs to:

- start using KBUILD_DEFCONFIG_KMACHINE
- remove placeholder defconfig and custom copying logic.
- avoid replacing all Yocto project configured settings in
  do_configure_prepend.

In many cases it should not be necessary to change the defconfig
file used.

Instead Yocto supports use of kernel configuration fragment files
to override the in-tree defconfig defaults[0].

For more background regarding this migration read the bugzilla bug
info[2].

[0] - http://www.yoctoproject.org/docs/1.8/kernel-dev/kernel-dev.html#changing-the-configuration
[1] - http://www.yoctoproject.org/docs/1.8/kernel-dev/kernel-dev.html#using-an-in-tree-defconfig-file
[2] - https://bugzilla.yoctoproject.org/show_bug.cgi?id=7474

Testing
=======

Poky master (#6d8ace03) core-image-sato with MACHINE=raspberrypi2

Kernels 3.18.16 / 4.1.10

(1) with no fragment files defined, using in-tree defconfig, kernels/images
    build and boot without error.

- build host kernel .config file contains CONFIG_SND_BCM2835=m.
- post boot, target aplay -l reports no sound devices until module is
  loaded.
- post modprobe, target aplay -l reports sound device.

(2) adding a test configuration fragment to build sound driver
    into the kernel.

- build host kernel .config file contains CONFIG_SND_BCM2835=y.
- post boot, target aplay -l reports sound device with no modprobe
  step.

Note: It may be necessary to clean sstate for the kernel after adding
      a new configuration fragment to the SRC_URI, e.g.

      bitbake -c cleansstate virtual/kernel

Sample Fragment Implementation
==============================

linux-raspberrypi.inc:

+SRC_URI += " \
+        file://build-in-audio.cfg \
+        "

linux-raspberrypi/build-in-audio.cfg:

+CONFIG_SND=y
+CONFIG_SND_BCM2835=y

Signed-off-by: Alex J Lennon <ajlennon at dynamicdevices.co.uk>
---
 recipes-kernel/linux/linux-raspberrypi.inc       | 12 ++++--------
 recipes-kernel/linux/linux-raspberrypi/defconfig |  1 -
 recipes-kernel/linux/linux.inc                   |  7 +++----
 3 files changed, 7 insertions(+), 13 deletions(-)
 delete mode 100644 recipes-kernel/linux/linux-raspberrypi/defconfig

diff --git a/recipes-kernel/linux/linux-raspberrypi.inc b/recipes-kernel/linux/linux-raspberrypi.inc
index 70e8bfe..d3766c4 100644
--- a/recipes-kernel/linux/linux-raspberrypi.inc
+++ b/recipes-kernel/linux/linux-raspberrypi.inc
@@ -6,10 +6,6 @@ SECTION = "kernel"
 LICENSE = "GPLv2"
 LIC_FILES_CHKSUM = "file://COPYING;md5=d7810fab7487fb0aad327b76f1be7cd7"
 
-SRC_URI += " \
-        file://defconfig \
-        "
-
 COMPATIBLE_MACHINE = "raspberrypi"
 
 PE = "1"
@@ -18,6 +14,10 @@ PV = "${LINUX_VERSION}+git${SRCPV}"
 # NOTE: For now we pull in the default config from the RPi kernel GIT tree.
 KERNEL_DEFCONFIG_raspberrypi ?= "bcmrpi_defconfig"
 KERNEL_DEFCONFIG_raspberrypi2 ?= "bcm2709_defconfig"
+KMACHINE ?= "${MACHINE}"
+KCONFIG_MODE = "--alldefconfig"
+KBUILD_DEFCONFIG_raspberrypi ?= "bcmrpi_defconfig"
+KBUILD_DEFCONFIG_raspberrypi2 ?= "bcm2709_defconfig"
 
 # CMDLINE for raspberrypi
 CMDLINE = "dwc_otg.lpm_enable=0 console=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait"
@@ -42,10 +42,6 @@ python __anonymous () {
             d.setVar("DEPENDS", depends)
 }
 
-do_kernel_configme_prepend() {
-    install -m 0644 ${S}/arch/${ARCH}/configs/${KERNEL_DEFCONFIG} ${WORKDIR}/defconfig || die "No default configuration for ${MACHINE} / ${KERNEL_DEFCONFIG} available."
-}
-
 do_install_prepend() {
     install -d ${D}/lib/firmware
 }
diff --git a/recipes-kernel/linux/linux-raspberrypi/defconfig b/recipes-kernel/linux/linux-raspberrypi/defconfig
deleted file mode 100644
index ecbf32c..0000000
--- a/recipes-kernel/linux/linux-raspberrypi/defconfig
+++ /dev/null
@@ -1 +0,0 @@
-# Dummy file to get through do_kernel_configme.
diff --git a/recipes-kernel/linux/linux.inc b/recipes-kernel/linux/linux.inc
index fae78b7..7ed80af 100644
--- a/recipes-kernel/linux/linux.inc
+++ b/recipes-kernel/linux/linux.inc
@@ -33,8 +33,7 @@ kernel_configure_variable() {
 }
 
 do_configure_prepend() {
-    # Clean .config
-    echo "" > ${B}/.config
+    mv -f ${B}/.config ${B}/.config.patched
     CONF_SED_SCRIPT=""
 
     # oabi / eabi support
@@ -109,8 +108,8 @@ do_configure_prepend() {
 
     # Keep this the last line
     # Remove all modified configs and add the rest to .config
-    sed -e "${CONF_SED_SCRIPT}" < '${WORKDIR}/defconfig' >> '${B}/.config'
-
+    sed -e "${CONF_SED_SCRIPT}" < '${B}/.config.patched' >> '${B}/.config'
+    rm -f ${B}/.config.patched
     yes '' | oe_runmake oldconfig
 }
 
-- 
1.9.1




More information about the yocto mailing list