I need to compile a module with buildroot so I can debug it using QEMU+gdb, and the current guides don't work. I've tried the most basic forms according to the documentation and nothing worked. Maybe I'm missing something but I really can't see it now. I'm using the following:
Module dir contains these files:
/home/xx/git/buildroot/package/kernel_module/
Config.in
hello.c
kernel_module.mk
Makefile
Config.in
1 config BR2_PACKAGE_KERNEL_MODULE
2 bool "kernel_module"
3 depends on BR2_LINUX_KERNEL
kernel_module.mk
1 KERNEL_MODULE_SITE = $(KERNEL_MODULE_PKGDIR)
2 KERNEL_MODULE_SITE_METHOD = local
3 $(eval $(kernel-module))
4 $(eval $(generic-package))
Makefile
1 obj-m += hello.o
2 ccflags-y := -DDEBUG -g -std=gnu99 -Wno-declaration-after-statement
3
4 .PHONY: all clean
5
6 all:
7 $(MAKE) -C '$(LINUX_DIR)' M='$(PWD)' modules
8
9 clean:
10 $(MAKE) -C '$(LINUX_DIR)' M='$(PWD)' clean
hello.c
1 #include <linux/module.h>
2 #include <linux/kernel.h>
3
4 MODULE_LICENSE("GPL");
5
6 static int myinit(void)
7 {
8 printk(KERN_INFO "hello init\n");
9 return 0;
10 }
11
12 static void myexit(void)
13 {
14 printk(KERN_INFO "hello exit\n");
15 }
16
17 module_init(myinit)
18 module_exit(myexit)
I also edited the packages/Config.in to include the module path. I tried other responses on SO and none work.
Edit: To clarify, the module won't appear anywhere when I boot.
Thanks in advance for your help.