我正在学习内核编程,我正在尝试创建一个打印出hello world的模块。出于某种原因,我在编译的Raspbian strech内核中包含的linux audder文件中有错误。
hello_world.c文件是
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是
KERNEL_PATH = /home/Raspberry_pi/linux
obj-m+=hello_world.o
all:
make -C $(KERNEL_PATH) M=$(PWD) modules
我得到的错误很长。最后几个是
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;
我使用以下链接来下载和编译内核 cross compile raspberry pi