LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-05-2005, 11:44 PM   #1
sphares
LQ Newbie
 
Registered: Sep 2005
Distribution: Red Hat
Posts: 1

Rep: Reputation: 0
compiling non-versioned kernel


Thank you in advance for any help.

I am a linux device driver newbie but have written small wintel drivers in a past life.

I am attempting to create a driver for a proprietary piece of test/measurement hardware. The proto-type is still on a buffered PCI breadboard hanging out of the back of the box.

I am running Red Hat Pro Workstation (kernel = 2.4.21-4.EL) on a Compaq/Intel Celeron.

I have successfully coded a very basic driver in User-Space just to make sure I can read/write the hardware but want the driver to ultimately be in Kernel-Space.

I have googled the topic w/multiple search criteria and most results come back w/more than one reference to "Linux Device Drivers 2nd Ed" by Alessandro Rubini which appears to be a decent book.

The 1st sample code given in the book is, what else, hello.c... as follows...
#define MODULE
#include <linux/module.h>
int init_module(void) { printk("<1>Hello, world\n"); return 0; }
void cleanup_module(void) { printk("<1>Goodbye cruel world\n"); }

to be compiled/inserted/removed w/.....
root# gcc -c hello.c
root# insmod ./hello.o
root# rmmod hello

where
root# insmod ./hello.o returns the following...
hello.o: kernel-module version mismatch
hello.o was compiled for kernel version 2.4.20
while this kernel is version 2.4.21-4.EL.

while forcing the load w/...
root# insmod -f ./hello.o
will insert the module with the following warning/output

Warning: kernel-module version mismatch
hello.o was compiled for kernel version 2.4.20
while this kernel is version 2.4.21-4.EL
Warning: loading hello.o will taint the kernel: no license
See "a web page . com" for information about tainted modules
Warning: loading hello.o will taint the kernel: forced load
Module hello loaded, with warnings

Paragraph 6, Chapter 2 of the book ends with "we strongly suggest you compile and run your own kernel (without version support) before you run the sample code.

My question is HOW ??? I have compiled Sun_OS/Solaris kernels years ago on Sparc boxes and am not allergic to doing so again on an x86 box. But when I google “kernel HOWTO”, “non-versioned kernel”, etc... no response gives an “Insert tab A into slot b” answer.

Eventually I Want to/ Will understand the internals, but for now all I NEED is a non-versioned kernal.

Any assistance/guidance/ would be greatly appreciated and Thank you again for your help.

sphares

P.S.
One last thought, the box has almost no user data on it. While I want to know how to do a re-compile, can a non-versioned version be installed from the "out of the box" GUI install?
 
Old 09-06-2005, 12:25 AM   #2
JCipriani
Member
 
Registered: Aug 2005
Location: Pittsburgh, PA, USA
Distribution: Redhat 9, OS X 10.4.x, Win2K
Posts: 85

Rep: Reputation: 15
I don't know what's up with the "non-versioned kernel" stuff; but I had a similar problem. Check a few things first before you start spending time recompiling kernels:

1) Look in /usr/include for version.h. Compare it to the version.h in your kernel source tree, which can be found in [i]source_tree_root[i]/include/linux/version.h. If the LINUX_VERSION_CODE doesn't match up; back up your /usr/include/version.h and change it to match. This is the one that got me when I was learning how to do this stuff. In all cases I've seen, the /usr/include/version.h file matches the kernel version that actually came with the distribution, and installing kernel source doesn't update this file.

2) Look in /usr/src. If your kernel source is installed there, make sure /usr/src/linux is symlinked to the correct version.

3) Make sure you're actually building your driver modules against the kernel version that you are actually running (i.e. if you're running kernel version A don't build drivers against headers or anything in the version B source tree).

That list is not complete and applies at least to Redhat. Also note that:

Quote:
Module hello loaded, with warnings
Means that your module did load succesfully. You can use lsmod to list loaded modules and verify that yours got loaded. You can ignore the version warnings while you are just learning; but I'd check your version.h thing first.

Sorry, it's been awhile since I did anything like that so I don't remember much; also I'm not sitting in front of a Linux machine right now so this is just from memory.

Jason

Last edited by JCipriani; 09-06-2005 at 12:26 AM.
 
Old 09-07-2005, 06:43 AM   #3
infinity42
Member
 
Registered: Apr 2005
Location: England
Distribution: Gentoo
Posts: 142

Rep: Reputation: 16
I think it is telling you to build your kernel without module versioning. This is an option that can be turned on/off when configuring your kernel. I don't remember where it is exactly though.

Hope that helps
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling kernel module for linux kernel 2.4 in 2.6 guam Linux - Software 0 01-13-2005 02:02 AM
Where Is Kernel Directory In Rh9(kernel 2.4.20-8), For Compiling HSP56 MR(pctel) Mode rudy3107 Linux - Software 1 07-25-2004 04:17 AM
Versioned Dependencies cootetom Mandriva 1 06-28-2004 07:06 PM
compliling the kernel to make it non-versioned manu_s Linux - Software 5 09-24-2003 08:22 PM
Kernel compiling and module compiling tarballed Linux - General 1 12-22-2002 05:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:01 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