Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 07-28-2008, 05:08 AM   #1
Registered: Nov 2004
Distribution: CentOS-4
Posts: 142

Rep: Reputation: 15
Device Driver Help Request

I am both a driver and Ubuntu noobe.

I have "written" a rudimentary driver with the following basic structure:
static int __init test_init(void)
{	printk("init\n.");
	return 0;}
static void __exit test_exit(void)
{	printk("exit\n.");}
I compiled it with the 2.6.26 kernel source as a module (test.ko), on an Ubuntu 8.04 machine.

However, when I try to install the module with

insmod test.ko

I get the following error:

-1 Invalid module format

If I try

modprobe test

then modprode can not find the module at all.

Any ideas where I am going wrong - or are the instructions I have not compatible with Ubuntu?
Old 07-28-2008, 06:12 AM   #2
Senior Member
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
You need a few special defines and the module version headers (generated dynamically). Have a look at one of the earlier chapters in Linux Device Drivers 3rd Edition (Corbet, Rubini, et al). You can get the electronic version for free, although I think it's divided into chapters - you can always get a dead tree version if you want one. Anyway, there is a fairly standard Makefile for each kernel module - it is designed to detect if you're compiling a module alone or as part of kernel compilation and it sets environment variables as appropriate. Have a look at the Makefile for some of the simpler device drivers for an example - but personally I think it's much easier to just look at that book. I just had a look at kernel Makefiles and many don't have that standard trick coded in them.

Last edited by pinniped; 07-28-2008 at 06:16 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Device driver from single device driver???? rickhg12hs Linux - Kernel 3 05-25-2008 01:11 AM
k3b copy CD : request for empty device tramni1980 Linux - Server 1 08-22-2006 08:21 AM
request for old ATI propietary driver for xorg 6.8 (8.12.10) bobbens Linux - Hardware 1 09-04-2005 05:46 AM
KM400 driver help request ka9qlq Linux - Hardware 0 10-02-2004 09:23 PM
driver request sjhannan Linux - Software 9 10-26-2003 02:38 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:55 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration