How to extract kernel headers for compiling kernel module later - linux-kernel

I compiled various Linux kernel from git repositories. There are times when I copied the kernel to other system and need the kernel header to compile external module.
I tried to run "make headers_install" but it only generated a include/ folder. When I tried to point external module to that folder, it complains it cannot find Makefile.
What is the proper way to package kernel-header for deployment?
Thanks.

Create kernel packages instead, that's "make deb-pkg" for dpkg based distros and "make rpm-pkg" for RPM based ones. These create multiple packages, one of those is a package usable for external modules building. That should be linux-headers-* for the Debian packages and a "devel" package for he RPM versions.

In some ways this is just an expansion of the previous answer. If you look at the file scripts/package/builddeb in the kernel sources you will find script code which selects the files needed for building external modules from a kernel build and puts them into /usr/src/linux-headers-$version. I can find that script code in my local kernel version by searching for the string "# Build kernel header package" in the builddeb file. If you want to do things by hand you could execute that script code manually.

Related

Install additional kernel modules

I need pwm-bl.ko kernel module for my Raspberry Pi, but it is not present in my /lib/modules directory. Sure, I can download kernel sources for my kernel version, select necessary modules to build, build and put it into this directory. But how to automate this process? I've found module-assistant utility, but it looks like a list of modules is very limited.

Building a Linux kernel using Travis CI

How can I build a Linux kernel in Travis CI. I have added script: make menuconfig to my Travis config and it doesn't work and says
No output has been received in the last 10 minutes
How can I fix this?
Link to GitHub repo : https://github.com/ProjectPolyester/tegra_kernel and submit fixes in PRs if possible
Travis monitors your build process and if there is no output for about 10 minutes, it assumes that your process is stuck somewhere for unknown reasons, and then kills it.
Solution in your case :
You need to provide with the actual build command.
make menuconfig
actually just allows you to configure the kernel. It doesn't really starts the kernel build process. So there is no output of this command.
Also, the kernel should already be configured or you can download the appropriate .config file if its available some where online. And then there will be no need to execute:
make menuconfig
The build command
It can be simply
make
or something like
make -j3 modules ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOCALVERSION=-$SOURCE_VERSION
The second one is actually to perform cross compilation.
You also need to set all the prerequisites like downloading the header file etc
You may want to take a look at this script , it crosscompiles the modules only, not the entire kernel.
If you want to use the old config for a new kernel, you can use make olddefconfig. Here is my example how to compile and boot a new kernel in travis: https://github.com/avagin/criu/blob/linux-next/scripts/travis/kexec.sh#L54
I know that this is an old thread but I was recently able to get Travis CI working on building a Linux kernel
https://github.com/GlassROM-devices/android_kernel_oneplus_msm8994/commit/6ed484812bbd4a25c3b22e730b7489eaaf668da1
GCC fix is for toolchains compiled on Debian unstable, arch, gentoo, etc. These toolchains will fail to compile on Ubuntu so you'll have to use the GCC fix for these toolchains
And you really want to upgrade GCC before you even try building a kernel. Travis CI has a very old GCC that will fail if you try to compile the kernel
In my commit I'm building it with GCC 8 linaro built by myself

including python in openembedded

I want to develop a web app for an embedded system. It is very easy to do so in python or java. However, I have two major problems:
I have a very limited space available on my embedded device
I cannot figure out how to include a python interpreter in the openembedded
framework.
Does anyone know how to cross compile python with openembedded?
If you have already got an openembedded project running, in arago-oe-dev project, the arago-oe-dev/recipes/ directory includes python.
Then you need to include python into your own dependency tree of recipes. Normally on the top level of dependency tree is the "Images" recipe in which you define what are included into you embedded firmware image to be running on your embedded device.
In the .bb file of "Images" recipe, you normally find a variable of IMAGE_INSTALL. You can add your app recipe into IMAGE_INSTALL.
Then in your recipe of you app, in its .bb file, you should add python to something like "RDEPENDS_${PN}" to add it to run-level dependency. Don't forget to inherit the pkgconfig bbclass so that the runtime linking is properly managed. Then the python library (.h and .so or .a files) will be built into your firmware image in something link /usr/lib and /urs/incluce and be linked by the embedded apps you develope.
You need to edit the image recipe to include python and any needed modules in the image. python is the package name for the python interpreter.

Should I care that the symbol version dump is missing? How do I get one?

I am trying to compile a driver that we have from source and I am working through the issues with a new target environment. One of the slightly disturbing things I see is the following warning:
WARNING: Symbol version dump /usr/src/linux-2.6.38/Module.symvers
is missing; modules will have no dependencies and modversions.
I spent a fair amount of time looking on the web and this is shown in output frequently when other questions are asked, but I didn't see any commentary about whether or not this is an issue.
In any case, how would I tell linux/ubuntu to generate Module.symvers?
Module.symvers is generated when the kernel itself is compiled and ought to be provided to the user as part of the kernel build environment package, however that may look on Ubuntu (possibly broken there?) Fedora and openSUSE for example ship one or more “kernel-devel” (and/or similarly-named) packages that ship this build environment and make the file reachable through /lib/modules/<version>/build/Module.symvers. When using a self-compiled kernel, substitue /lib/modules/version/build for the appropriate path to the build directory (where all the .o files are).

How to prepare modules.dep and ld.so.cache while cross-compiling?

I'm cross-compiling kernel modules and some libraries on x86 for ppc.
Is it possible to create ld.so.cache and modules.dep on my host system?
P.S I'm using ELDK tools.
modules.dep should be generated when the modules are built. It's also a text file so is readable on either architecture.
I'm pretty sure it'd be hard to generate ld.so.cache on anything but the system target system. It's a binary file that built up given the specific libraries available on your rootfs and configuration in /etc/ld.so.conf.
depmod can run just fine against foreign architecture modules. Assuming you've built your kernel and deployed your modules (eg 3rd party modules) to your system-root:
/sbin/depmod -ae -F /path/to/System.map -b /path/to/system/root <kernel-version-name>
Haven't found a solution for ldconfig, yet.

Resources