How to add kernel module to LTIB target image - linux-kernel

I have create a new Kernel Module following The Linux Kernel Module Programming Guide.I want to add my module to the [config -> Package selection -> package List]
and distribute my module with target image
â–ºDevelopment Environment
boundary device sabrelite board
LTIB (i.MX6 kernel 4.1.0)
I put my kernel module's source on [/home/USER/ltib/rpm/BUILD/myModule] path. (just like hello_mod example module which explained in "The Linux Kernel Module Programming Guide")
but when i build target image it does not compile.
hello_mod example module can be selected in configuration mode(./ltib -m config).
How can I add my module to this config -> Package selection -> package List

If you want to build from make menuconfig, that you probably should change the makefiles.
Check this documentation from the linux kernel. Taken from it:
Normal developers are people who work on features such as device drivers, file systems, and network protocols. These people need to
maintain the kbuild Makefiles for the subsystem they are working on.
In order to do this effectively, they need some overall knowledge
about the kernel Makefiles, plus detailed knowledge about the public
interface for kbuild.

Related

Force Kernel Dependencies Not Inlcude Certain Module

I have a kernel module modA.ko that depends upon exported symbols.
exported_func1(void)
exported_func2(void)
And I have two other modules modB.ko and modC.ko that has the definitions for exported functions separately. Function signature is the same but functionality is different. Only one of the modB.ko or modC.ko is supposed to be loaded at the same time. Every time the kbuild determines that modA.ko is dependent on modB.ko. I don't want that. I want to dynamically load the appropriate modules before using modA.ko according to the need.
Is there a way to force the kernel build system to not add dependencies just for this particular module.
I am using Buildroot to build the Linux image but no dependencies are defined in buildroot-config for these modules. In the Buildroot output/, both modB.ko and modC.ko have exported functions listed in the .symvers files.

Yocto: patch kernel module Makefile

I have a Linux kernel for NXP i.MX6. There are some capture kernel modules in /driver/media/platform/mxc/capture.
One of the files called mxc_v4l2_capture.c. I had to change this file for using it with my own new kernel driver.
I created a repository with my driver and the sources for mxc_v4l2_capture. Then I made a new Yocto recipe in my layer recipies-kernel -> kernel-modules->my-kernel-module.bb
Yocto can build these two kernel modules (my-kernel-module.ko and mxc_v4l2_capture.ko).
Okay, now there is a problem because the kernel recipe already builds the mxc_v4l2_capture module. Therefore I want to manipulate the Makefile for the original kernel modules and exclude the make of mxc_v4l2_capture.
I have created the patch but I don't know how to use the patch with Yocto. Where to place it and how can I call it?
Normally I put a patch into a .bbappend file and finish but I don't know the name of the recipe that build the kernel modules.
It would be great if there is a way without manipulating this Makefile.
Is there a way to solve this with my kernel module recipe?
mxc_v4l2_capture.c is in-tree kernel driver. If you want to change the in-tree driver code and compile, it's highly recommended to patch the kernel and compile the kernel with usual recipe.
Having additional bitbake recipe for the in-tree kernel module is not necessary. To patch the kernel and compile, you can use .bbappend or .bb itself. For example,
if you have recipes-kernel/linux/linux-stable_4.19.75.bb in your Yocto BSP layer, you can add the patch to SRC_URI as below.
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:"
SRC_URI += "file://mxc_v4l2_capture.patch"
Now, you create recipes-kernel/linux/linux-stable-4.19.75/ and copy the mxc_v4l2_capture.patch file inside.
Or if you don't have permission or not possible to modify the Kernel recipe in BSP layer, you can create .bbappend in your custom layer. For the above example, you can create linux-stable_4.19.75.bbappend (specific version) or linux-stable_%.bbappend (any version). Then place the same content as mentioned above.
Yocto supports various patch formats, refer here for more details.
Look at this answer I wrote some days ago. The steps are basically the same. Using
devtool modify virtual/kernel
will create a working copy in build/workspace where you can do the work you want. Commiting those changes to the local branch and running
devtool finish linux-mainline <path-to-your-layer>
will create a .bbappend file with the patches already created and put to the correct location for you.
If you want to learn how to do it manually follow the advice #Parthiban gave.

Unable to build in AMD-GPU kernel module: This feature depends on another which has been configured as a module

I am trying to build-in the AMD-GPU kernel module to my custom kernel. However, I am only able to build it as a module. When I press y in order to build it a text box appears that reads:
This feature depends on another which has been configured as a module. As a result, this feature will be built as a module.
My question is, what kernel modules does the AMD-GPU module depend on so that I can build it into the kernel?
Apologies for my wording and formatting, and thanks for the help.
if you type modinfo amdgpu modinfo gives you all the info about the kernel object.
AMDGPU depends: drm,drm_kms_helper,ttm,i2c-algo-bit

How do I recompile a single Linux kernel module?

I need to build mmc_block.ko but with MMC_BLOCK_MINORS=16. I do not wish to build the entire kernel. I am using Ubuntu 15.10. How do I do this?
Dpending on how the Makefile has been written, a module can be compiled out of the kernel tree or in the kernel tree.
Concerning your specific example, I assume the module is the one shipped with the kernel and therefore the Makefile has been written for in-tree compilation. In this case, you can just type make modules to rebuild the module, provided that the kernel has been already compiled (which is a mandatory condition also for out-of-the-tree compilation).

Partitioning kernel modules

I am working on a project which consists of multiple kernel modules. There is some shared functionality between the different modules, but I don't want to include the same code in each module. Does the Linux kernel have a "shared object library" or does the common code go into a separate module?
Typically, you would put the functionality common to the modules in a separate module itself. A good example of this is the drivers/scsi/libsas module used by other SAS (Serial Attached SCSI) device drivers. If you go this route, see the kernel documentation in section 6.3 of Documentation/kbuild/modules.txt for suggestions on referencing symbols from other external modules.
If you're looking for a way to share functions between modules you should take a look at EXPORT_SYMBOL macro. A simple example:
file super.c
void call_me(){
printk("Hello from super.\n");
}
EXPORT_SYMBOL(call_me);
file super.h
extern void call_me();
file base.c
#include "super.h"
void call_super(){
call_me();
}
Here super.c and base.c are different modules.
If this is what you're looking for let me know. I can send you a more complex example with makefiles and stuff. Hope it helps.
Note: I've used this in many distros... however each time I did it I needed to copy the file Modules.symvers to each other module directory.
Supose you have a module A and a module B, which uses functions from A. Upon compiling A, a file named Modules.symvers is created. I've needed to copy that file to B's folder before compiling it. Just don't issue make clean in B's folder after copying Modules.symvers, or it will get deleted.

Resources