LinuxQuestions.org
Visit Jeremy's Blog.
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 07-14-2014, 06:32 PM   #1
neha2d
LQ Newbie
 
Registered: Jun 2014
Posts: 2

Rep: Reputation: Disabled
Help Needed : Kernel rebuild


Hi,

I have added or integrated a patch in gpiolib.c.

I am new to Driver Programming. I am extending a driver code for a wireless bridge device for which added few lines of code in existing gpiolib.c file.

I want to re build my kernel.
Can anyone help me with the steps I should follow in order to rebuild my kernel after adding/ modifying some code in one of the files like in my case gpiolib.c and some additional documentation that has also been updated for the changes done.

I can also provide additional information related to kernel or anything else if required.

Any kind of help would be appreciated.

Thank You in advance.
 
Old 07-15-2014, 07:15 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
It sounds as if you've obtained a copy of the kernel source. Ideally this source matches the kernel you're using.

In the kernel source tree, the simplest actions to do are:
Code:
make config
make
This will remake the entire kernel; including driver modules. The GPIO library may or may not be "included" in your kernel. By that I mean whether or not it is compiled as a Module or Inline with the kernel. Either of those cases, running "make" will take care of it. However if it is a module, then you can avoid performing a full make and merely make just that module.

The way to be able to tell whether it is a Module or Inline is to view your .config file. This is at the top level of your kernel source directory. You can view/edit that file and yes it does say that it is automatically generated and not to edit it. If you do manually edit the file, you're supposed to know what dangers you are risking. Viewing it of course perfectly fine. There are also varied ways to modify your config; not just manually editing, but also using a menu based modifier. When in the file, search for all instances of "gpio" and you're probably looking for CONFIG_GPIOLIB, if that says "=y" then it is INCLUDED in the kernel binary image and compiled Inline, if that says "=m" then it is a MODULE, therefore NOT included in the kernel binary image. It will be made by the make action, but it will become a load-able module; the benefit is that you can load or unload that during runtime, and you can also rebuild that module without performing a full kernel rebuild. There are other pros and cons which I'll skip right now. If it says something like "# CONFIG_GPIOLIB is not set" then it is NOT INCLUDED inline OR as a module, it's not included at all. Therefore change that line to say either "y" or "m" similar to how other lines show, via taking out the # comment and setting the text up appropriately by getting rid of the "is not set" part.

Not completely sure on this one, 50% sure that if it is specified as a module, that you can go to your "drivers" directory and then type "make gpio" and that will make the GPIO library. They keyword may be "make gpiolib" I'm not sure this isn't configured for my particular kernel. The result is that the GPIO library .ko file will be remade and you can copy that file to the same location where it is on your system, reboot, and then you'll be using your newly built module.

Some things to do to ensure you've got it right is to add a printk() in the init call to show something unique to indicate that you've not only entered the module, but also the rebuilt code you created is exactly what you're running.

NOTE that if there are issues related to "different target" for the kernel other than the system you're running on; then this subject grows by way of things like "configuration for your compilation tools so that they're set up to compile properly for your target", stuff like that. Or if things like "make" don't even work at all, then you may need to install the basic build tools. The first assumption is that you're building the kernel on the system you're working with and that build tools as well as kernel source are all set up already.

Last edited by rtmistler; 07-15-2014 at 07:18 AM.
 
1 members found this post helpful.
Old 07-15-2014, 08:08 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
I do something like this:
  1. Make a copy of the .config hidden-file into a non-hidden file in a designated directory, say within /root. Give the copy a name based on today's date. Write-protect the file and keep it forever.
  2. mv .config foobar to keep the file from being deleted in the next step ...
  3. make distclean
  4. mv foobar .config to put it back.
  5. make (several makes and make-targets might be needed)
My objective is to force everything to be recompiled ... modules and all ... and to see to it that there is no "residue" from previous times that I did that. Also, by explicitly keeping every config, even ones that turn out to be "incorrect," I am able to use diff to immediately ascetain exactly what is different between one and another.

It also helps to keep a journal of all changes ... which I do with a loose-leaf notebook and a number-two pencil. (Yes, the yellow sticks with a piece of rubber on one end.)
 
1 members found this post helpful.
  


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
[SOLVED] slackbuilds rebuild needed 14.0->14.1 ? Stuferus Slackware 14 12-31-2013 06:21 PM
[SOLVED] rebuild kernel trinityforce Solaris / OpenSolaris 3 10-12-2011 06:13 PM
[SOLVED] Error: Missing Dependency: /usr/bin/rebuild-security-providers is needed package java jsaravana87 Linux - Server 1 09-26-2011 09:13 AM
kernel name after rebuild ekdya Debian 0 09-18-2006 04:59 PM
Kernel Rebuild Nikosis Linux - Newbie 4 05-01-2006 12:40 AM

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

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