Search code examples
yoctobitbake

How can I deactivate a kernel option?


I want to deactivate a kernel option during my build:

In a .bbappend file for the kernel recipe I fetch via SRC_URI a .cfg kernel fragment file no_usb.cfg with this content:

CONFIG_USB=n
CONFIG_USB_TEST=y

The first entry is supposed to turn USB off in the kernel configuration, the second entry is for testing the reverse case.

This didn't work: Neither the test entry appeared nor the USB was deactivated. I have also seen in the yocto sources *.scc files and I created one for my no_usb.cfg:

kconf hardware no_usb.cfg

But I found only less in the documentation and couldn't turn USB off. So how can I deactivate CONFIG_USB?

This is my kernel recipe (from freescale SDK) linux-qoriq_3.12.bb:

require recipes-kernel/linux/linux-qoriq.inc
SRC_URI = "git://git.freescale.com/ppc/sdk/linux.git;branch=sdk-v1.9.x"
SRCREV = "43cecda943a6c40a833b588801b0929e8bd48813"

I have a layer with this append file linux-qoriq_3.12.bbappend:

SRC_URI += "file://no_usb.cfg"

The directory structure of the layer is following:

meta-layer
└── recipes-kernel
    └── linux
        ├── linux-qoriq
        │   └── no_usb.cfg
        └── linux-qoriq_3.12.bbappend

Solution

  • As long as your kernel recipe had the following line

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

    a SRC_URI referencing a .cfg should work.

    However, the way to disable a kernel option is not to set it to =0. Rather, it should be set to

    # CONFIG_USB is not set 
    

    In other words, that's the line you should have in your .cfg file. Also, make sure that you don't have contradicting options in the .cfg file.

    Update:

    Note again that this requires that your kernel recipe includes the line

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

    in order to have the yocto kernel tooling working. As far as I can see from meta-fsl-ppc: linux-qoriq.inc this recipe doesn't include that line.

    Update: See kergoth's answer, it is actually possible to use .cfg files in linux-qoriq. You just need to name them in the DELTA_KERNEL_DEFCONFIG variable.