View Full Version : sample device driver

21st December 2004, 02:01 AM
I am learning how to write device drivers. I came across this tutorial my code is:

#define MODULE
#include <linux/module.h>

int init_module(void)
return 0;

void cleanup_module(void)

compiles fine useing #gcc -c hello.c

but when i did a #insmod hello.o, it complain: insmod: error inserting 'hello.o': -1 Invalid module format
so I tried to #modprobe hello.o it complained: FATAL: Module hello.o not found.
when the file is in that directory

I am just a beginner at this but I do need to know how to sucessfully do this since I am takeing a course in hardware apps in C

my OS is Fedora core 3 Linux version 2.6.9-1.667smp

any direction in this would be helpful


21st December 2004, 03:33 AM
Hi Luke... building (http://marc.free.net.ph/message/20041203.051327.20e8479b.html) a module is different (http://www.tldp.org/LDP/lkmpg/2.6/html/) for 2.6. You also might want to have a look at Porting device drivers to the 2.6 kernel (http://lwn.net/Articles/driver-porting/) (Porting 'hello world') to see what's changed.