I would like to cross-build some in-tree modules (capi, gigaset) that are included in the kernel source but not in the standard Raspbian kernel.

My toolchain is using the tools from https://github.com/raspberrypi/tools and the source from https://github.com/raspberrypi/linux. It works for building an image and all modules. But the process takes a long time.

Therefore, I am looking for a way to only build the required modules. I got to the point where the resulting modules can be loaded, but one of them (kernelcapi) still raises a no symbol version for module_layout.

Here is what I do: After identifying the firmware hash and subsequently the kernel hash, I checkout the source for the target kernel version, clean up (mrproper), retrieve the symbol table (e.g. Module7.symvers), rename it if necessary, install the configuration (e.g. bcm2709_defconfig), and run a configuration script that uses scripts/config to set the options for my target modules (using --enable, --disable, and --module). At that point, I can make zImage and modules.

Now, trying to save time, I disable all modules (sed -i 's/=m/=n/' .config) in the regular configuration before running my configuration script and then make modules_prepare and modules. I don't like the use of sed to disable the modules, but I don't know how else to do it.

In my first attempt to build just the required modules, I used M=<dir> to identify them. Due to interdependencies between the modules, I had to copy Module.symvers from one <dir> to the next. Unfortunately, the resulting modules were not marked as in-tree and thus tainted the kernel.

  • 1
    Are you trying to get these to work with the stock kernel? It would be better to build all of it together then don't clean the build directory, and subsequently you should be able to make modules and the stuff with sources that hasn't changed will be skipped, ie., shouldn't take long. – goldilocks Jul 23 '19 at 17:51
  • That basically was my initial approach. But every time a new kernel package came out, running make after a pull would take hours again. – maf Jul 24 '19 at 5:25
  • Hours?!? You're cross-building right? You can do it in hours natively on a Pi, so something is wrong there. I've been building kernels for years (casually, I won't claim much expertise) and would consider 15-20 minutes a long time on a modern x86-64 machine. "Hours" was 15-20 years ago, really. I haven't cross-built a pi one in a while, but even then it was the toolchain that took a long time (I really don't recommend it...); the kernel was quick enough. Once that's done, adding a couple of modules is usually done in seconds. – goldilocks Jul 24 '19 at 13:10
  • Hmm, too many layers of abstraction, may be? I'm using a VirtualBox Debian guest on a Windows 7 host that likes to stall for a minute every other minute with CPU intensive jobs. Limited RAM might be one reason for that. Plus, I'm building for both bcmrpi and bcm2709. So there is plenty of motivation to cut off all unneccesary computations... – maf Jul 24 '19 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.