0

I have build a linux kernel for the beaglebone black using buildroot. Now I would like to develop a hello world linux kernel module application:

#include <linux/init.h>
#include <linux/module.h>

MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)
{
    printk(KERN_ALERT "Hello, world\n");
    return 0;
}

static void hello_exit(void)
{
    printk(KERN_ALERT "Goodbye, cruel world\n");
}

module_init(hello_init);
module_exit(hello_exit);

The problem is I still keep missing some header files. After finally gathering them all, I get an error that the code is not compilable (many errors, dont want to paste them all). What I was wondering is either I am really including the right files? At the moment I have:

/home/lukasz/brl/Machine/beaglebone/build/linux-headers-a75d8e93056181d512f6c818e8627bd4554aaf92/include
/home/lukasz/brl/Machine/beaglebone/build/uboot-2018.01/arch/x86/include
/home/lukasz/brl/Machine/beaglebone/build/linux-headers-a75d8e93056181d512f6c818e8627bd4554aaf92/arch/arm/include/generated
/home/lukasz/brl/Machine/beaglebone/build/linux-headers-a75d8e93056181d512f6c818e8627bd4554aaf92/arch/arm/include
/home/lukasz/brl/Machine/beaglebone/build/linux-a75d8e93056181d512f6c818e8627bd4554aaf92/include

Its a bit odd to me that the c include files and asm files are so scattered around within the directory.

My linux version:

# uname -a
Linux buildroot 4.9.59 #1 SMP Fri Oct 5 11:55:54 CEST 2018 armv7l GNU/Linux
1

You don't give enough details on how you're building your Linux kernel module. Please follow the instructions at https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/kbuild/modules.txt to learn how to build a kernel module.

  • Hi Thomas, you have already helped me with this problem over the buildroot mailing group at 20 December. In my case the problem was that I was including the linux headers instead of sources in the makefile. – Bremen Jan 1 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.