LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 10-11-2006, 12:04 PM   #1
xirtna
LQ Newbie
 
Registered: Oct 2006
Location: New Delhi, India
Distribution: Fedora Core 4
Posts: 2

Rep: Reputation: 0
Question Need Help in configuring and building kernel 2.6.16.18


hi,
I am reading this book Linux Device Drivers 3rd edition(alessandro rubini) ,in the second chapter about 'Building and Running Modules', the book says that :
-------------------------
% make
make[1]: Entering directory `/usr/src/linux-2.6.10'
CC [M] /home/ldd3/src/misc-modules/hello.o
Building modules, stage 2.
MODPOST
CC /home/ldd3/src/misc-modules/hello.mod.o
LD [M] /home/ldd3/src/misc-modules/hello.ko
make[1]: Leaving directory `/usr/src/linux-2.6.10'
% su
root# insmod ./hello.ko
Hello, world
root# rmmod hello
Goodbye cruel world
root#

Please note once again that , for the above sequence of commands to work,you must
have a properly configured and built kernel tree in a place where the makefile is able to
find it(/usr/src/linux-2.6.10 in the example shown).

----------------------------
what does it means to have a configured and built kernel? , does it mean that i need
to compile the kernel?
I have the source of kernel 2.6.16.18 in the /root directory,
how do i configure and build it?
Please help I am totally new to device drivers!
 
Old 10-11-2006, 12:39 PM   #2
sn68
Member
 
Registered: Oct 2005
Distribution: FC5
Posts: 338

Rep: Reputation: 30
I think "properly configured and built kernel" doesn't necessarily mean that one has to build the kernel manually form sources, I would rather say that automated installs from pkg managers (rpm, yum, apt get etc) have a much high probability of being properly configured and built
So if you are not getting any error messages, go ahead and compile whatever driver you were planning to compile/install. (At the most you may get some error messages while install, which then could be rectified depending on the error)
 
Old 10-11-2006, 05:18 PM   #3
sooty
LQ Newbie
 
Registered: Nov 2002
Location: birmingham england
Distribution: Gentoo
Posts: 26

Rep: Reputation: 15
When the book was writen they used the 2.6.10 kernel and it assumes you have the kernel source in /usr/src/linux
/usr/src/linux is usually a symlink that point to your perticular kernel tree
so it would probably point to somthing like /usr/src/linux-2.6.18-rx were x is a number
make sure the symlink exists and point to the kernel tree you want to compile

If your following the book you are best to download the 2.6.10 kernel and compile it with kernel hacking and debug support enabled.
You can use your own 2.6.18 kernel but there may be slight differences.
If you have not compiled a kernel before it may seem strange at first but there is plenty of info and howtos if you google for them once youve done it a few times it becomes quite easy and you can optimise the kernel for your perticular system.
If you use grub you can then boot to the debug kernel for testing your code or you normal kernel.
try www.kernel.org or www.kernelnewbies.org for info on building kernels

BTW Ive just stared this book and am on chapter 5 but am finding it a bit hard going because the source examples seem to be a bit under commented and although the guys who have writen it know what they are talking about, they assume to much about my knowledge and dont explain things as fully as I would like. I have had to read a couple of chapters twice in order to understand it.
what do you think about it?

Last edited by sooty; 10-11-2006 at 05:29 PM.
 
Old 10-13-2006, 09:16 AM   #4
xirtna
LQ Newbie
 
Registered: Oct 2006
Location: New Delhi, India
Distribution: Fedora Core 4
Posts: 2

Original Poster
Rep: Reputation: 0
I have placed the kernel sources in /usr/src/linux-2.6.16.18 directory.
i tried to compile the kernel using these commands :

# make xconfig
# make bzImage
# make modules
# make modules_install
# cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.16.18
# mkinitrd /boot/initrd-2.6.16.18.img 2.6.16.18
# make install

But when i boot into the OS with the new kernel, it gives an error at the boot time "Kernel Panic, attempted to kill init.........." ,and the OS doesn't boot! please tell me where i am wrong!

thanks.

@sooty, yeah it does take lot of effort to understand this book, i have already read chap-2 twice....and still some things are not clear
 
Old 10-13-2006, 09:51 AM   #5
sooty
LQ Newbie
 
Registered: Nov 2002
Location: birmingham england
Distribution: Gentoo
Posts: 26

Rep: Reputation: 15
I use
#make menuconfig

this provides a user interface for configuring the kernel if kernel panics it may be due to lack of ram disk suport so make sure it is enabled when you configure the kernel


Next I run
#make && Make modules_install
then
#make install
make install creates a symlink in /boot called "vmlinuz" this points to the full image name /boot/vilinuz-2.6.18 and beacuse the entry in grub says vmlinuz it loads the new build
to get grub to laod the old kernel I can just change the symlink vmlinuz

BTW if you have difficulty configuring the kernel you may be able to copy the old .config file form the kernel that works if you have one
hope this helps

Last edited by sooty; 10-13-2006 at 10:03 AM.
 
  


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
Configuring and building an i686/K7 kernel on an x86_64 system. Thetargos Linux - Kernel 2 07-21-2006 09:02 PM
Building kernel module from multiple source file in 2.6 kernel yogeshwar_s Programming 1 12-20-2004 09:31 AM
Problems building a simple kernel module for kernel 2.6.7 atticman Linux - Software 2 12-13-2004 03:35 PM
Building a Kernel DB03 Linux - Newbie 6 06-12-2004 08:41 AM
Building kernel mods for an existing kernel ugenn Linux - Software 2 10-06-2003 01:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 10:21 PM.

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