Skip to content

Instantly share code, notes, and snippets.

@attie
Last active February 4, 2020 21:56
Show Gist options
  • Save attie/e47055eaca1f28074e2858e9fe8225ab to your computer and use it in GitHub Desktop.
Save attie/e47055eaca1f28074e2858e9fe8225ab to your computer and use it in GitHub Desktop.
Yocto Out-of-Tree Kernel Module Issues

This is a basic incremental change to the hello-mod example provided here:

At runtime, on insertion, I see the following output:

root@board:~# modprobe hello
[   41.741181] hello: Unknown symbol __class_create (err 0)
[   41.746530] hello: Unknown symbol class_destroy (err 0)
modprobe: ERROR: could not insert 'hello': Unknown symbol in module, or unknown parameter (see dmesg)

This is on an i.MX8 SOM, provided by KaRo

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://COPYING \
"
S = "${WORKDIR}"
# The inherit of module.bbclass will automatically name module packages with
# "kernel-module-" prefix as required by the oe-core build environment.
RPROVIDES_${PN} += "kernel-module-hello"
/******************************************************************************
*
* Copyright (C) 2011 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*****************************************************************************/
#include <linux/module.h>
#include <linux/device.h>
static struct class *dev_class = NULL;
int init_module(void)
{
printk("Hello World!\n");
dev_class = class_create(THIS_MODULE, "hello");
return 0;
}
void cleanup_module(void)
{
class_destroy(dev_class);
printk("Goodbye Cruel World!\n");
}
MODULE_LICENSE("GPL");
obj-m := hello.o
SRC := $(shell pwd)
all:
$(MAKE) -C $(KERNEL_SRC) M=$(SRC)
modules_install:
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
clean:
rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
rm -f Module.markers Module.symvers modules.order
rm -rf .tmp_versions Modules.symvers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment