0

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

DBB
  • 467
  • 9
  • 23
  • Documentation you refers to suggests `CROSS_COMPILE=arm-linux-gnueabihf` for specify cross-compiler in the `make` invocation. You doesn't use such option. – Tsyvarev Dec 24 '17 at 09:49
  • I don't get it . From what little understanding I have i thought the makefile would find it from the directory where the kernel is compiled. – DBB Dec 25 '17 at 01:10
  • Also the path to the tool chain has laready been updated in the $PATH variable so there should be no issue – DBB Dec 25 '17 at 03:12
  • The other question did help me solve mine. Thanks – DBB Dec 27 '17 at 18:42

0 Answers0