LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices

Reply
 
LinkBack Search this Thread
Old 11-23-2009, 12:01 AM   #1
arn_ml
LQ Newbie
 
Registered: May 2009
Posts: 16

Rep: Reputation: 0
Linux Device Driver Programming (unable to find headers)


Hi Everybody,
I am very new to device driver programming and for that i am referring to
O'Reilly's LDD Programming.
And I am doing this on Fedora Core 11 which i had got with a Linux magazine(Linux For You).

1)After writing my hello_world module i was unable to compile the module using gcc to get a ".ko" object file.
From the errors it showed it could be seen that it was unable to find
<linux/module.h>,<linux/init.h> and respective macros.

2)After searching on it a bit ,i installed the kernel-devel* and kernel-headers* packages which came along with the dvd.
Even after that i was unable to compile.

3)So, i decided to compile the kernel 2.6.27.39 manuallyhttp://www.kernel.org/

To compile the kernel i followed the instructions given in the sitehttp://www.cyberciti.biz/tips/compil...kernel-26.html

I replaced the /usr/src mentioned in the site to /usr/src/kernels, as all my kernels were listed in the directory.
I think every step were done without errors , but when i booted with that kernel the booting process hanged at the last stage and many things regarding SS,DS,ES were shown on the screen.

So, I am stuck with it.

Thanks in advance for any kind of help.
 
Old 11-23-2009, 12:54 AM   #2
Anisha Kaul
Senior Member
 
Registered: Dec 2008
Location: Gurgaon, India
Distribution: Slackware 13.37, OpenSuse 11.3
Posts: 4,359
Blog Entries: 21

Rep: Reputation: 705Reputation: 705Reputation: 705Reputation: 705Reputation: 705Reputation: 705Reputation: 705
Quote:
After writing my hello_world module i was unable to compile the module using gcc to get a ".ko" object file.
U can't compile a kernel module using gcc. U need to write a makefile for it. Below is an example of writing a makefile for a kernel module.

Code:
obj-m += moduleName.o

all:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
Quote:
After searching on it a bit ,i installed the kernel-devel* and kernel-headers* packages which came along with the dvd.
Even after that i was unable to compile.
First u try to compile the kernel module through the above shown makefile, then tell us the errors generated.

And there is no need to compile the linux kernel yet ! Work on a normal pre-compiled kernel !

Last edited by Anisha Kaul; 11-23-2009 at 01:27 AM.
 
Old 11-23-2009, 01:26 AM   #3
arn_ml
LQ Newbie
 
Registered: May 2009
Posts: 16

Original Poster
Rep: Reputation: 0
thanks for the reply.
I forgot to mention that i did make the Makefile.
<hello1>=
obj-m := hello.o

But since i didnt knew how to make it i tried it next with gcc(simple `make` command doesnt work)

The book which i refer says something about kernel-source tree and i have no idea of it.
I will paste a few lines from the book:

"Regardless of the origin of your kernel, building modules for 2.6.x requires that you have a configured and built kernel tree on your system. This requirement is a change from previous versions of the kernel, where a current set of header files was sufficient. 2.6 modules are linked against object files found in the kernel source tree; the result is a more robust module loader, but also the requirement that those object files be available. So your first order of business is to come up with a kernel source tree (either from the kernel.org network or your distributor's kernel source package), build a new kernel, and install it on your system. "

Can you explain this thing to me?
Again thanks for replying.
 
1 members found this post helpful.
Old 11-23-2009, 01:34 AM   #4
Anisha Kaul
Senior Member
 
Registered: Dec 2008
Location: Gurgaon, India
Distribution: Slackware 13.37, OpenSuse 11.3
Posts: 4,359
Blog Entries: 21

Rep: Reputation: 705Reputation: 705Reputation: 705Reputation: 705Reputation: 705Reputation: 705Reputation: 705
First please tell me have u written the makefile exactly the way i told u. If not write it in that way and then tell me the results. Meanwhile I'll study the para u have copied from the book !

Kindly show all the code u are trying to compile !

Last edited by Anisha Kaul; 11-23-2009 at 02:03 AM.
 
Old 11-23-2009, 02:24 AM   #5
arn_ml
LQ Newbie
 
Registered: May 2009
Posts: 16

Original Poster
Rep: Reputation: 0
I dont think i understood that correctly.I would be glad if you could link me up to a good tutorial for understanding makefiles.
Anyways the out put i got is:

bash: PWD: command not found
make: Entering directory `/usr/src/kernels/2.6.29.4-167.fc11.i586'
CHK include/linux/version.h
CHK include/linux/utsrelease.h
SYMLINK include/asm -> include/asm-x86
make[1]: *** No rule to make target `missing-syscalls'. Stop.
make: *** [prepare0] Error 2
make: Leaving directory `/usr/src/kernels/2.6.29.4-167.fc11.i586'
 
1 members found this post helpful.
Old 11-23-2009, 02:29 AM   #6
Anisha Kaul
Senior Member
 
Registered: Dec 2008
Location: Gurgaon, India
Distribution: Slackware 13.37, OpenSuse 11.3
Posts: 4,359
Blog Entries: 21

Rep: Reputation: 705Reputation: 705Reputation: 705Reputation: 705Reputation: 705Reputation: 705Reputation: 705
Have u included tabs instead of spaces in u r makefile. Check it twice because it is required.

Secondly u have not shown u r device driver code.
Kindly show all codes including the makefile u have written!

filename: Makefile
Code:
obj-m += moduleName.o

all:
<TAB>make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
<TAB>make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
Quote:
(simple `make` command doesnt work)
make command executes the makefile, since u have not written it, it is not supposed to work !

Last edited by Anisha Kaul; 11-23-2009 at 03:31 AM.
 
Old 11-23-2009, 03:47 AM   #7
arn_ml
LQ Newbie
 
Registered: May 2009
Posts: 16

Original Poster
Rep: Reputation: 0
Ok.i had earlier provided spaces instead of tab.Problem Solved.
Thank you very much madam.
It would be very nice if you could provide me with some tutorial so that i can understand what exactly does the above makefile do and how does make command resolve the dependencies.

Again,Thank You very much.
 
1 members found this post helpful.
Old 01-04-2010, 11:53 PM   #8
Anisha Kaul
Senior Member
 
Registered: Dec 2008
Location: Gurgaon, India
Distribution: Slackware 13.37, OpenSuse 11.3
Posts: 4,359
Blog Entries: 21

Rep: Reputation: 705Reputation: 705Reputation: 705Reputation: 705Reputation: 705Reputation: 705Reputation: 705
Quote:
Originally Posted by arn_ml
It would be very nice if you could provide me with some tutorial so that i can understand what exactly does the above makefile do and how does make command resolve the dependencies.
Try the following links, see if they help u !

1. http://makepp.sourceforge.net/1.19/makepp_tutorial.html

2. http://www.cs.colby.edu/maxwell/cour...als/maketutor/
 
Old 01-10-2010, 07:12 AM   #9
arn_ml
LQ Newbie
 
Registered: May 2009
Posts: 16

Original Poster
Rep: Reputation: 0
thank you.
i will surely go through these links.
 
  


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux USB device driver programming? redarrow Programming 6 02-03-2008 02:54 AM
Unable to find device driver dev/dsp in Fedora core linux 3 vsraditya Linux - Hardware 7 12-11-2007 11:21 AM
Linux device driver programming iammisc Programming 1 11-26-2005 10:46 AM
linux device driver programming chandansingh Programming 1 03-26-2005 07:30 AM


All times are GMT -5. The time now is 11:22 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration