I am learning kernel programming and I am trying to create a Module that prints out hello world. For some reason I have errors in the linux hearder file I included from the compiled Raspbian strech kernel.
The hello_world.c file is
enter code here
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.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);
Makefile is
KERNEL_PATH = /home/Raspberry_pi/linux
obj-m+=hello_world.o
all:
make -C $(KERNEL_PATH) M=$(PWD) modules
The error I am getting is a long list. the last few ones are
In file included from ./include/linux/elf.h:4:0,
from ./include/linux/module.h:15,
from /home/Raspberry_pi/drivers/hello_world.c:2:
./arch/x86/include/asm/elf.h: At top level:
./arch/x86/include/asm/elf.h:364:1: error: requested alignment is not an
integer constant
} ____cacheline_aligned;
^
In file included from ./include/linux/module.h:25:0,
from /home/Raspberry_pi/drivers/hello_world.c:2:
./arch/x86/include/asm/module.h:57:2: error: #error unknown processor family
#error unknown processor family
^
In file included from /home/Raspberry_pi/drivers/hello_world.c:2:0:
./include/linux/module.h:396:9: error: requested alignment is not an integer
constant
struct module_layout core_layout __module_layout_align;
^
./include/linux/module.h:400:27: error: field ‘arch’ has incomplete type
struct mod_arch_specific arch;
^
./include/linux/module.h:481:1: error: requested alignment is not an integer
constant
} ____cacheline_aligned;
I used the following link to donwload and compile the kernel cross compile raspberry pi