[yocto] Kernel module depedency (header+symbols)

Guy Morand guy at guy-morand.ch
Thu Mar 15 06:03:49 PDT 2018


Hallo Yocto developpers,

I have been struggling a little to write recipe with kernel modules 
depedency. It seems that this is not well documented and picked up some 
solution across the mailing list and by reading the source. That is why 
I'm wondering if my approach is correct or hopefully will help someone 
else who tries to achieve the same thing...

First I have a modules that provides an header file with exported symbols:
---[base-module.h]---
extern int base_module_something(void);
---[/base-module.h]---

Where the function is exported in the c file:
---[base-module.c]---
int base_module_something(void)
{
   /* something */
   return 0;
}
EXPORT_SYMBOL(base_module_something);
---[/base-module.c]---

Now it seems that I have to prepend my recipe name with "kernel-module-" 
(cf.later) and add the header file installation:
---[kernel-module-base-module.bb]---
do_install_append() {
   install -m 0664 ${S}/base-module.h ${D}/${includedir}/${PN}
}
---[/kernel-module-base-module.bb]---

In the second module, I added an argument to find the path to the base 
module header file:
---[Kbuild second module]---
ccflags-y += -I$(BASE_MODULE_PATH)
---[/Kbuild second module]---

In the recipe of the second module, I give the dependency to my 
base-module and pass the variable to find the header file:
---[second-module.bb]---
DEPENDS = "kernel-module-base-module"

do_compile_prepend() {
   export BASE_MODULE_PATH=${STAGING_INCDIR}/kernel-module-base-module/"
}
---[/second-module.bb]---

The reason to have the first module prepended with "kernel-module" is 
that the bbclass looks for Module.symvers file for depedency with that 
name and adapt the KBUILD_EXTRA_SYMBOLS consequently:
https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/classes/module.bbclass#n12

Despite this solution works for me, I was wondering if this is the right 
approach and if there is a more "yocto way"?

Best regards,

Guy



More information about the yocto mailing list