When I have a kernel module that uses multiple source files bitbake doesn't seem to build them appropriately. This example module just performs a printk on loading and unloading the module. When it is built with the comments in the code in place as shown below, I see the printks when loading and unloading the module. When I remove the comments and effectively enable the second source code file, testprint.c/h, I no longer see anything at all when I load and unload the module. Bitbake also runs as expected and I don't see any errors or warnings from the build.
When I un-comment the lines in hello.c
but leave the hello-objs
line commented out in the makefile bitbake fails (understandably) to build the module with the ERROR that testprint
is undefined.
Am I doing something wrong here?
Test module folder hierarchy,
test-mod
|- files
|--- COPYING
|--- Makefile
|--- hello.c
|--- testprint.c
|--- testprint.h
|- test-mod_0.1.bb
hello.c,
// works when the below /* */ comments are in place
#include <linux/module.h>
/* #include "testprint.h" */
int init_module(void)
{
printk("Hello World!\n");
/* testprint(); */
return 0;
}
void cleanup_module(void)
{
printk("Goodbye Cruel World!\n");
}
MODULE_LICENSE("GPL");
testprint.h,
void testprint(void);
testprint.c,
#include "testprint.h"
#include <linux/module.h>
MODULE_LICENSE("GPL");
void testprint(void)
{
printk("howdy\n");
}
makefile,
obj-m := hello.o
# hello-objs := testprint.o
SRC := $(shell pwd)
all:
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) I=$(INC)
modules_install:
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) I=$(INC) modules_install
clean:
rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
test-mod_0.1.bb,
SUMMARY = "Example of how to build an external Linux kernel module"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e"
inherit module
SRC_URI = "file://Makefile \
file://hello.c \
file://testprint.c \
file://testprint.h \
file://COPYING \
"
S = "${WORKDIR}"