1

I plan to learn embedded linux and writing linux device drivers. After reading about device drivers and walking through some tutorials, I'm a little confused about the kernel-source that to be used for compilation.

I am using ubuntu 11.04 and in my /usr/src/ me find the following:

tijin@tijin-Vostro-460:/usr/src$ ls

gcc-4.4 linux-headers-2.6.38-10-generic-pae linux-headers-2.6.38-10 linux-headers-2.6.38-8

my questions:

1)do I need a kernel-source to compile the driver code or the headers are enough?

2)where can I get the kernel source code and what is the procedure to install the source code. Please let me know the details.

tijin
  • 707
  • 1
  • 6
  • 12

3 Answers3

2
  1. Headers is enough
  2. from kernel.org - or for Ubuntu specific kernels, follow the documentation

For module compilation instructions, see this question

Community
  • 1
  • 1
Kimvais
  • 38,306
  • 16
  • 108
  • 142
  • thanks for your answer. can you please add the steps to compile a sample driver code with headers? – tijin Feb 08 '12 at 12:25
  • successfully loaded hello world module. but i tried to see the logs in /var/log/messages but getting:there is no such file or directory. where i can see the logs, can you help me ? thanks in advance. – tijin Feb 15 '12 at 05:03
  • yes..its working. i found another way to see the logs: $tail -f /var/log/kern.log //Kernel logs. thanks for your help. – tijin Feb 15 '12 at 08:25
0
  1. Yes. You need not only the source but a "make"d source (a compiled kernel source).

  2. The main location to get the kernel source is: http://www.kernel.org

As you're using Ubuntu you can just download the source from the repositories. Here's the page indicated at Ubuntu's help as a guide for compiling a kernel from source on Natty (11.04): http://blog.avirtualhome.com/2011/08/03/how-to-compile-a-new-ubuntu-11-04-natty-kernel/

DallaRosa
  • 5,737
  • 2
  • 35
  • 53
0

For a fresher to device driver coding the "hello world" driver code reference is here :

http://www.linuxquestions.org/questions/linux-kernel-70/simple-makefile-error-all-nothing-need-to-be-done-600403/ . This link also discussing the issues related to the Makefile. Important idea that i got from the reference is: Never ever copy-paste the content of a document for creating Makefile.

If you are getting trouble with seeing logs then please refer the link :

http://www.cyberciti.biz/faq/linux-log-files-location-and-how-do-i-view-logs-files/

thanks.

tijin
  • 707
  • 1
  • 6
  • 12