- Run with a new installed Raspbian, wheezy, 2014-01-07.
- Download and transfer the source code of Raspberry Pi
- Create hello.c and Makefile follow "The Linux Kernel Module Programming Guide", 2.3. Hello World (part 2).
hello.c#include
#include
#include
static int __init hello_init(void)
{
printk(KERN_INFO "Hello Raspberry Pi!\n");
return 0;
}
static void __exit hello_exit(void)
{
printk(KERN_INFO "Bye Raspberry Pi!\n");
}
module_init(hello_init);
module_exit(hello_exit);
Makefileobj-m += hello.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean - Then make it, without error.
- When I try to insert the module hello.ko, error of invalid module format reported.
$ sudo insmod ./hello.ko
Error: could not insert module ./hello.ko: Invalid module format - "disagrees about version of symbol module_layout" logged in /var/log/messages'. I assume it is something mis-match between the kernel version in my source and the running system.
- Then I update Raspberry Pi to most update with:
$ sudo rpi-update
$ sudo apt-get update
$ sudo apt-get upgrade
and reboot - I try to insmod again, but fail with "Unable to handle NULL pointer dereference at virtual address 00000004", and the system hang-up.
"Unable to handle NULL pointer dereference at virtual address 00000004"
I'm a newbies in Linux programming, and ask for help. Please leave me comment for any advice.
0 تعليقات