Concept of modprobe and module dependancies - linux-kernel

As modprobe looks through modules.dep for dependancies,is it necessary to execute depmod before modprobe?plz help me with module inserting process

It is necessary to execute depmod whenever the dependecies (might) have changed.
Usually, depmod is executed automatically when new modules are installed.

Related

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.
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.

Adding only one driver to linux kernel

I know that on the internet I can find same information about "adding one driver to linux kernel" but I can not get it working.
I need to compile an ADV7800driver. It is based on adv7180 driver code.
I put my driver file (adv7800.c) into /linux_source_folder/drivers/media/platform/mxc/capture folder. I also add
adv7800_converter-objs := adv7800.o
obj-$(CONFIG_MXC_ADV7800_CONVERTER)+=adv7800_converter.o
in makefile in the same folder and add information in Kconfigfile.
Then I go back to /linux_source_folder and do sudo make menuconfig and set adv7800 as a module and save config. Then sudo make defconfig, then sudo make -j4 modules (now waiting about 2 hours) and then sudo make modules install.
As a result I can see every module which I configure in menuconfig but I can not see my own module (only .c file exists).
How can I do this correctly and how can I build only this one module without building others (to same much time) ?
I do not remember exactly what happens in terms of instructions executed, but the idea of defconfig is to set a default configuration for a given architecture/platform.
If, as you said, you run sudo make defconfig after you configure your module to be compiled, most likely you loose your configuration. The defconfig should be executed first (once) and then you customize the configuration.
Regarding the compilation of a single module, I point you to an old answer
How to "make" existing Linux kernel module driver after modifying the driver source code.
One note: you should not use sudo to compile

Unable to compile a kernel module

I am trying to build a kernel module while compiling the kernel image, by changing the config symbol value to `'m'. But I do not see any module file generated. Please let me know if I need to take some extra steps to generated a module. If I change the flag to 'y' the code works fine.
Also, in online tutorials I have seen both of the following
>insmod temp.ko
also,
>insmod temp.o
Which one is correct type for a dynamically loadable module?
For compiling loadable kernel modules in Linux tree apply the following command
make modules
.ko is the proper kernel module extension. If .o is tried with insmod, then Invalid module format error will be displayed.
if your module has dependencies to other modules, then:
make modules to build modules
make modules_install to install them
modprobe temp.ko to load temp module and it's dependencies
if your module is simple and has no dependencies, then:
make modules to build modules
cd /path/to/module
insmod temp.ko
Wasn't using modules target in make.
First, run make menuconfig, search the module you want to build using /. Next choose 'm' or 'y' depending on when you want to compile it as a part of the kernel or build it as a module.
(If you don't want to build the entire kernel and just a single module):
Next, in the linux directory (assuming you are using vanilla kernel) run the following commands which will generate the scripts and required configuration files based on your .config
make prepare
make scripts
Now simply build the module using:
make M=<path/to/module/dir>
Finally you should have a kernel object/module (.ko) in the directory if you have selected m
hope this helps.

Do I need to specify kernel modules in a particular order while using modprobe to insert them?

I have a list of modules in a shell script variable, lets call it modulelist. Some of those modules are already loaded.
I am doing modprobe -a $modulelist and running into a segmentation fault, which is due to one of the modules that is being loaded.
My question is : Do I have to modify the order in which module names are specified in the variable modulelist ? I thought that the order of modules in the list would not make a difference since modprobe -a loads the modules and the modules they depend on.
not sure how much it will help you but maybe you should try to run with either --show-depends or -n -v options and see if more information help diagnose the issue
also you might want to check the depmod command which is concerned with creating dependency list
It shouldn't matter, and it definitely shouldn't segfault.

modprobe module error

I encounterd the problem when i try to modprobe the module. this module is modified. but the module is for the kernel 2.6.33.4, also the kernel is 2.6.33.4. When i tried to modprobe module, the error happned:"disagrees about version of symbol module_layout".
i don't know how it happened and how to solve it. i'm very confused.
Check out the address for module_layout from System.map from the /boot directory and also from the System.map generated when you compile your module. I bet it will be different. You can altogether try compiling yourself a new kernel with module versioning disabled to avoid something like this.
It sounds like you have built your module against a kernel that is different than the running kernel into which you are attempting to insert the module.

Resources