LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions
User Name
Password
Linux - Distributions This forum is for Distribution specific questions.
Red Hat, Slackware, Debian, Novell, LFS, Mandriva, Ubuntu, Fedora - the list goes on and on... Note: An (*) indicates there is no official participation from that distribution here at LQ.

Notices


Reply
  Search this Thread
Old 07-27-2004, 06:56 AM   #1
rocketdude
LQ Newbie
 
Registered: Jul 2004
Distribution: SUSE
Posts: 8

Rep: Reputation: 0
Angry 'Invalid module format' loading simple module on Suse Linux Professional 9.1


--- I actually have 2 issues ---

1) Whenever I try to load a simple module on Suse Linux Professional 9.1 I get the following message:

insmod: error inserting 'mydev.o': -1 Invalid module format

2) In my source why do I have to have CONFIG_M486 defined? With my RedHat installation at the office I do not have to do this.

Thanks,

Rocket

Below is the source for the simple module followed by the gcc command line:

#include <linux/kernel.h>
#define CONFIG_M486
#include <linux/module.h>
int init_module()
{
/* code to init the module */
return 0;
}
void cleanup_module()
{
/* code to close the module */
}

gcc -D__KERNEL__ -DMODULE -c mydev.c
 
Old 07-27-2004, 09:25 AM   #2
Vlad-A
Member
 
Registered: May 2004
Location: Vienna, Austria
Distribution: Open SuSE 11, Mac OS X 10.5
Posts: 299

Rep: Reputation: 33
The error message indicates that your module was not build properly.
The compiler call like you have given it, is the one used for 2.4.x kernels.

With the 2.6.x kernels (SuSE 9.1 has an 2.6.x kernel) things are a little bit different, although easier.

The kernel modules with 2.6.x have a .ko (Kernel Object) ending, and
not .o .

First of all you shall add the Licence Macro to your module source.

MODULE_LICENSE("GPL");


Otherwise you will get a error message when loading the module, telling that the
module is tainted.

You *need* to have write access to the kernel source tree. So compile as root.

cd into the directory with the module source

Create a Makefile

with following entry:

obj-m := mydev.o

e.g.
cat "obj-m := mydev.o" > Makefile

then compile the module with

make -C /lib/modules/$(uname -r)/build SUBDIRS=$PWD modules

After that you can try to load the module with
insmod mydev.ko

Check with lsmod if the module is loaded.

Wirth
modprobe -r mydev
you can remove the module.

Last edited by Vlad-A; 07-27-2004 at 11:52 AM.
 
Old 07-27-2004, 08:46 PM   #3
rocketdude
LQ Newbie
 
Registered: Jul 2004
Distribution: SUSE
Posts: 8

Original Poster
Rep: Reputation: 0
Talking

Hi Vlad,

You're my hero! Thanks!

I searched a couple of days for this answer before posting. Can you point me to where this is documented?

Regards,

Rocket
 
Old 07-27-2004, 11:40 PM   #4
Vlad-A
Member
 
Registered: May 2004
Location: Vienna, Austria
Distribution: Open SuSE 11, Mac OS X 10.5
Posts: 299

Rep: Reputation: 33
Hi,
the kernel build system documentation shall be a good start
http://lxr.linux.no/source/Documenta...build/?v=2.6.0

Check also:
http://lwn.net/Articles/driver-porting/
http://lwn.net/Articles/21823/
 
  


Reply



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
Gentoo says Invalid Module Format baldy3105 Linux - General 8 08-16-2007 05:46 AM
Invalid module format king111 Linux - Newbie 4 07-19-2005 01:14 AM
fglrx --> Invalid module format Ezzy Linux - Hardware 1 05-10-2005 02:16 AM
insmod invalid module format csfalcon Linux - Hardware 6 01-24-2005 11:03 AM
invalid module format powadha Slackware 5 12-25-2003 04:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions

All times are GMT -5. The time now is 08:53 AM.

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