[Buildroot] how can i implement my kernel module and debug it
Esaïe Ledoux NJONGSSI KOUAM
kouamdoux at gmail.com
Tue Oct 19 14:34:19 UTC 2021
so i have develop my kernel module and it is working very well.
there is my folder :
hello.c :
#include <linux/module.h> // included for all kernel modules
#include <linux/kernel.h> // included for KERN_INFO
#include <linux/init.h> // included for __init and __exit macros
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Lakshmanan");
MODULE_DESCRIPTION("A Simple Hello World module");
static int __init hello_init(void)
{
printk(KERN_INFO "Hello world!\n");
return 0; // Non-zero return means that the module couldn't be
loaded.
}
static void __exit hello_cleanup(void)
{
printk(KERN_INFO "Cleaning up module.\n");
}
module_init(hello_init);
module_exit(hello_cleanup);
> Makefile :
obj-m += helloKernelModule.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
when i run make , it generate some files like hello.o , hello.ko , ...
> integrate the package into Buildroot (see comments below)
But , i'm not understanding very well when you said i integrate the package
on buildroot. Is it only the Makefile and the hello.c code or Makefile ,
hello.c code , hello.o , hello.ko , ... ?
> check if the package builds correctly within Buildroot and gets
deployed to target/lib/modules
Okay , i have put the project on one folder kernel_module_test in buildroot
tree
external.desc :
name: BR2_PACKAGE_KERNEL_MODULE_TEST
external.mk :
include $(sort $(wildcard $(BR2_EXTERNAL_KERNEL_MODULE_TEST_PATH)/*/*.mk))
Config.in :
config BR2_PACKAGE_KERNEL_MODULE_TEST
bool "kernel_module_test"
depends on BR2_LINUX_KERNEL
help
Linux Kernel Module Cheat.
kernel_module_test.mk :
KERNEL_MODULE_VERSION = 1.0
KERNEL_MODULE_SITE =
$(BR2_EXTERNAL_KERNEL_MODULE_TEST_PATH)/kernel_module_test
KERNEL_MODULE_SITE_METHOD = local
$(eval $(kernel_module_test))
$(eval $(generic-package))
As you can see , i want to use a BR2_EXTERNAL directory structure.
So i have make it by typing :
/buildroot# make BR2_EXTERNAL=kernel_module_test menuconfig
Go ahead into External Options , and fortunatly , i have see my package
inside, .. so i have saved it and exit.
After that i have type make.
i have seen my package on output/build , looks like kernel_module_test
folder that contains some files.
Finaly , i have seen some files on
output/target/lib/modules/${BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE} but not
my module.
So i think that it means that my modules/package was not loaded and i can't
exploit it.
please where i have mistaken ??
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.buildroot.org/pipermail/buildroot/attachments/20211019/95c75b50/attachment.html>
More information about the buildroot
mailing list