# problem with insmod and modprobe

This topic is 5053 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am learing how to write driver modules in linux.. but for some reason i can't load the modules ( i have written ) with insmod or modprobe. I am using Mandrake 10 ( Kernel 2.6 ). The modules that come with the kernel are all stored in ".ko.gz" format.. for example the module rivafb would be stored as "rivafb.ko.gz" That's why i even tried to gzip my modules before trying insmod but it didn't work. Does anyone know where to go from here ?

##### Share on other sites
What error message are you getting?

##### Share on other sites
are you using the SUBDIR makefile method?

pretty much nothing else works for 2.6 external modules.

##### Share on other sites
the error message i am getting is

"Error in inserting hello.o . -1 invalid object format"

And this is really getting quite frustrating for me. The book i am reading, the articles i am reading , all building their modules in the following manner

$gcc -DMODULE -D__KERNEL__ -I/usr/src/linux/include -c hello.c$ insmod ./hello.o

but IT'S not working in my system... (Mandrake 10 kernel 2.6)

as a matter of fact.. all the modules in /lib/modules/..../drivers

reside as ".ko.gz" format except for the "nvidia.ko" which is installed by the NVIDIA installer... and it works ! I did a lil of digging into the "Makefile" of NVIDIA installer and it didn't seem to have done anything special with the building process.. except for creating device entries in /dev

my hello.c , btw, doesn't contain anything more than a simple init_module and cleanup_module.

:(

##### Share on other sites
you need to use the SUBDIR build method

##### Share on other sites
Thanx C-Junkie... but could u please explain SUBDIR build a bit... a detail would be really helpful.

##### Share on other sites
http://linuxdevices.com/articles/AT4389927951.html

it's explained on that page.

##### Share on other sites
Thanx C-Junkie...
Finally i have been able to get the modules up and running :) in Kernel-2.6. Suh! they have changed quite a lot with the build process. Itz still not very clear to me yet though.. but that was a nice starting point :).

However, the damn "printk" is not working :(. I did include "" with the text :

printk(" Hello\n").

but still nothing's been displayed. Be sure that he init funtion has been properly called during insmod; i checked that in a different way ;); but just can't get the "printk" working :s.

##### Share on other sites
Thanx C-Junkie...
Finally i have been able to get the modules up and running :) in Kernel-2.6. Suh! they have changed quite a lot with the build process. Itz still not very clear to me yet though.. but that was a nice starting point :).

However, the damn "printk" is not working :(. I did include "(1)" with the text :

printk("(1)Hello\n").

but still nothing's been displayed. Be sure that he init funtion has been properly called during insmod; i checked that in a different way ;); but just can't get the "printk" working :s.

NOTE: the braces () above should actually be angle braces... sorry couldn't get the angle braces displayed on this page... itz considering the angle braces as HTML tags :s.

1. 1
2. 2
Rutin
22
3. 3
JoeJ
18
4. 4
5. 5

• 17
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631726
• Total Posts
3001910
×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!