inserting kernel module after make mrproper - linux-kernel

I download the kernel source, compile it and run the new kernel. I am making some change to kvm kernel module and testing it.
So this is what I do after making some change in the kernel source.
make M=arch/x86/kvm
After this I am able to successfully insert the kernel module.
By mistake I did make mrproper which cleans all the binaries and byproducts on a linux compile.
So, is there a way now to make my kernel module only and insert it into current booted kernel or should I compile the whole kernel again and replace the new vmlinuz with vmlinuz file in /boot.
I can do the second option but it takes time and is not the most intelligent way for this small problem.

If the kernel is currently running you can try running make cloneconfig. This should configure the kernel tree exactly like the running kernel.
The compiled module should then match your kernel.

Related

Add a line in Linux Kernel

I should add a line in the file linux/drivers/pci/quirks.c of the Linux Kernel. I never modified/compiled the Linux Kernel, what is the best way to do that? I need to compile the entire Kernel to add a single line? Or can I write only a patch to apply to the current Kernel? And what happens if a new kernel version will be released?

What is the difference between make nconfig & make linux-nconfig?

I am using buildroot and did not see a difference between:
make nconfig
and
make linux-nconfig
Is there a difference?
make nconfig runs the configuration of Buildroot itself (i.e. selecting which packages to build, which architecture, which toolchain, etc). make linux-nconfig runs the configuration of the Linux kernel. It will first download and extract the kernel, and then run the kernel Kconfig infrastructure. It allows you to select CPU, drivers, filesystems etc.

How can I generate kernel headers for an "unknown" embedded ARM system?

I have an (old) embedded system for which I want to compile programs. I don't have the toolchain, so I want to create one.
The embedded system has an "ARM926EJ-S rev 5 (v5l)" CPU and "cat /proc/version" says that it runs "Linux version 2.6.20.7" with GCC 4.0.2.
I have heard that I have to include the kernel headers in the build process. I download the Linux kernel version 2.6.20 from kernel.org, extract all files and run "make headers_install ARCH=arm INSTALL_HDR_PATH=~/headers". Is this the correct way or do I need the header files of the specific kernel?
untar the kernel.
make mrproper
make ARCH=${arch} headers_check
e.g make ARCH=arm headers_check
make ARCH=${CLFS_ARCH} INSTALL_HDR_PATH=dest headers_install
This are the steps to get headers from kernel.
The purpose of kernel headers is -->C library and compiled programs needs to interact with the kernel
i.e for Available system calls and their numbers, Constant definitions, Data structures, etc.
Therefore, compiling the C library requires kernel headers, and many applications also require them.
do I need the header files of the specific kernel?
The kernel-to-userspace ABI is backward compatible
--> 1)Binaries generated with a toolchain using kernel headers older
than the running kernel will work without problem, but won't
be able to use the new system calls, data structures, etc.
-->2)Binaries generated with a toolchain using kernel headers newer
than the running kernel might work on if they don't use the
recent features, otherwise they will break.
--->3)Using the latest kernel headers is not necessary, unless access
to the new kernel features is needed
So in your case kernel version is "Linux version 2.6.20.7"
You can use kernel headers of Linux kernel version 2.6.20 or 2.6.21 from kernel.org.
does not create any problem in this case.
That should be fine if you're using the headers to build a libc
You should probably run make ARCH=arm headers_check beforehand too.

Linux l2TPv3 support

I use CentOS and it does not have support for L2TPv3 which was introduced in 2.6.35.
CentOS is at 2.6.32. How do I selectively patch just the L2TPv3 changes to my kernel?
Also, these are kernel modules. Would I need to run the modified kernel to be able to insmod these KOs?
Back porting features is a very non trivial task, not something that can easily be done casually. Thus, your best option is to look around whether somebody created the necessary patches for your kernel version.
Also, Linux kernel has no strict interface definitions when modules are concerned, thus it is very desirable that kernel and modules are compiled from the same source. Sometimes it is possible to successfully use "mismatched" modules with a given kernel, but rather frequently an attempt to do so results in various problems.
But if you will adventurous, try using modprobe -f. This will disable the module version checking and modprobe will try to squeeze the module in (even at a cost of crashing the system on spot).

How .ko file is built

I am trying to port my own driver to a Beagle board xm arm-cortex-A8. While porting I am trying to figuring out how the .ko file actually builds. In our Makefile we only have a command to build an.o file.
How is a .ko file built?
Using linux-2.6.38.8 kernel and trying to configure my driver for my kernel.
The kernel kbuild module document has lots of information on how to build an external module. If you have Raspberian or some other embedded ARM Linux, you will need to get the source package for your kernel. The process differs based on whether you are compiling on the same machine the module will run on, or if you are trying to build it on a PC (hopefully a Linux PC).
Please specify which way you need to build, if the kbuild module document doesn't explain things well enough.

Resources