Howto build a kernel module out of the kernel tree
Jump to navigation
Jump to search
Yocto recipe to build a kernel module out of the kernel tree
$ tree . ├── files │ ├── COPYING │ ├── hellokernel.c │ └── Makefile └── kernmodule.bb
COPYING
Copy COPYING file into your files
cp meta-skeleton/recipes-kernel/hello-mod/files/COPYING YOURPATH/kernmodule/files/
kernmodule.bb
#
# Yocto recipe to build a kernel module out of the kernel tree
# kernmodule.bb
# Marco Cavallini - KOAN sas - www.koansoftware.com
#
DESCRIPTION = "Hello kernel module out of the kernel tree"
SECTION = "examples"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e"
PR = "r0"
inherit module
SRC_URI = "file://hellokernel.c \
file://Makefile \
file://COPYING \
"
S = "${WORKDIR}"
Makefile
obj-m += hellokernel.o SRC := $(shell pwd) all: $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules modules_install: $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
hellokernel.c
/*
* hello.c - The simplest kernel module
*/
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
printk(KERN_INFO "Hello world\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world\n");
}