Kernel module depedency (header+symbols)

Guy Morand <guy@...>

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:
extern int base_module_something(void);

Where the function is exported in the c file:
int base_module_something(void)
/* something */
return 0;

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

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:
DEPENDS = "kernel-module-base-module"

do_compile_prepend() {
export BASE_MODULE_PATH=${STAGING_INCDIR}/kernel-module-base-module/"

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:

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,


Join to automatically receive all group messages.