0

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.

Motheus
  • 533
  • 5
  • 21
  • It's not clear from the question what the problem is. Does the module not build? Does it not appear in the target rootfs? Does it fail to load? – Arnout Feb 11 '20 at 08:00
  • Ok. I added a clarification. The module won't appear anywhere in the target rootfs. No build errors or anything that guides me towards the problem. – Motheus Feb 12 '20 at 15:27
  • 1
    Is it even built? Is there a directory output/build/kernel-module? When you run `make kernel-module`, what output do you get? – Arnout Feb 13 '20 at 09:21
  • The module wasn't built, and `make kernel_module` worked. Interesting. Thanks. – Motheus Feb 17 '20 at 17:40
  • You didn't select it in 'make menuconfig' then. – Arnout Feb 18 '20 at 07:58

0 Answers0