How to build Kernel Modules
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi,
I don't know if this is the right place to ask...
I have OMAP 5912OSK with a 2.6.15 kernel cross compiled from SUSE 9.2 using GCC 3.4.1. That works and I am happy with it. I can build my own tasks and include them into my RAM disk image.
The next challenge is to build a kernel module. I followed the guidelines in Peter Salzman's book/FAQ/tutorial and tried to adapt it for cross compiling:
Arm-linux-gcc -c hellomod.c -Wall
This produced hellomod.o but when I tried to insmod it on my target I got an error:
/ # ls
ascii etc lib proc sys var bin hello linuxrc sbin tmp dev hellomod.o lost+found sieve usr
/ # insmod ./hellomod.o
Using ./hellomod.o
No module found in object
insmod: cannot insert `./hellomod.o': Invalid module format (-1): Exec format error
/ # _
I suspect I haven't done something right in the build stage for my KO.
My source code is simple and looks like this:
#define __KERNEL__
#define MODULE
#include "/usr/local/arm/3.4.1/arm-linux/include/linux/module.h" #include "/usr/local/arm/3.4.1/arm-linux/include/linux/kernel.h"
#include "/usr/local/arm/3.4.1/arm-linux/include/linux/tty.h"
int init_module()
{
console_print("Hello World from Rico\n");
return 0;
}void cleanup_module()
{
console_print("Goodbye from Rico!\n");
}Can somebody point me at an FAQ or how to for cross compiling Kernel Modules please?
TIA,
Richard.