linux-kernelkernel-moduleyoctobsp

How to do a clean rebuild of Linux kernel modules in Yocto?


I can rm -rf tmp/ sstate-cache/ cache/ and run a whole Yocto build from scratch just fine, but I'd rather not rebuild everything (especially as packages like Qt can take some time).

I've tried:

bitbake -c cleansstate linux-iwg15 kernel-module-imx-gpu-viv cryptodev-module

Note: I've also tried cleanall, but it has the same result:

Either one of the kernel modules end up throwing this error once they get to do_compile:

  ERROR: Kernel configuration is invalid.
         include/generated/autoconf.h or include/config/auto.conf are missing.
         Run 'make oldconfig && make prepare' on kernel src to fix it.

The {build_dir}/tmp/work-shared/{MACHINE}/kernel-build-artifacts folder actually contains include/generated/autoconf.h

I tried copying the contents of kernel-build-artifacts to {build_dir}/tmp/work-shared/{MACHINE}/kernel-source but still get the errors.

The linux-iwg15 BitBake recipe is here.

Is there anything else that I should be cleaning before rebuilding the Linux kernel modules?

After a clean build, I did notice that kernel-build-artifacts contains kernel and scripts folders (as well as a symlink of source to ..\kernel-source) that I don't remember being there when attempting to rebuild after running bitbake -c cleansstate.


Solution

  • Is there anything else that I should be cleaning before rebuilding the Linux kernel modules?

    Yes. bitbake -c cleansstate make-mod-scripts

    Any kernel module recipe will contain inherit module. This references meta/classes/module.bbclass which contains inherit module-base. This references meta/classes/module-base.bbclass which contains:

    # We do the dependency this way because the output is not preserved
    # in sstate, so we must force do_compile to run (once).
    do_configure[depends] += "make-mod-scripts:do_compile"
    

    The make-mod-scripts recipe (at meta/recipes-kernel/make-mod-scripts/make-mod-scripts.bb) adds files to the {build_dir}/tmp/work-shared/{MACHINE}/kernel-build-artifacts directory. (This is referenced as STAGING_KERNEL_BUILDDIR which is set in conf/bitbake.conf.)

    Unfortunately, the kernel recipe will remove everything in the STAGING_KERNEL_BUILDDIR directory, since that directory is added to the do_shared_workdir[cleandirs] variable in meta/classes/kernel.bbclass. This ends up removing files that make-mod-scripts put there as well.