LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-16-2014, 06:13 AM   #1
JayminD
LQ Newbie
 
Registered: Jun 2014
Location: INDIA
Distribution: UBUNTU, LINUX MINT, LXLE, KUBUNTU, ELEMENT OS, DEBIAN, FEDORA, MAJARO OS, LUBUNTU and many more
Posts: 11

Rep: Reputation: Disabled
Question how edit usb driver and compile it again in linux kernel?


Hello All,

I want to edit some source in exciting USB driver of my kernel of UBUNTU..

So where can I found it ??
(`/lib/modules/3.13.0-29-generic/kernel/drivers/usb`... Is this correct ????? )

and at where(mean at where particular lines) can I do changes that make effect ??

and after all that how can I recompile it??

Please help me in this editing and compilation issue..

Thanks in advance..

Reply me please.

Regards
Jaymin D
 
Old 07-16-2014, 07:10 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
That I believe is the location of the compiled binary. Firstly you have to determine if the module is compiled as part of the kernel, or compiled as a standalone module. If you're looking at a file with a .ko extension and know that this is the driver, then likely it is a module. However merely because you found a .ko file that has the term USB within it, doesn't mean it's exactly the module in question.

If you go to www.kernel.org you can download source versions of the kernel to build. I'd highly suggest you read some of the information about how to recompile your Ubuntu distribution however because one doesn't just go grab either the latest, or some arbitrary kernel source from kernel.org and assume that this matches what Ubuntu used for your kernel or drivers.

You'll have to determine if the particular code in question is compiled as a module or inline with the kernel.

As a module, you can compile just the module and then replace the ko file and reboot. In many cases you can also load or unload the module.

Inline with the kernel, then you'll have to replace your kernel and reboot.

EITHER case, there are things which you can do or prepare yourself for in the event that your attempts do not work properly, or at all. For instance the kernel, you can prepare by saving your original and becoming familiar with grub so that you can enter into grub, cause it to load your new kernel; if it fails, be capable of causing it to boot back into your original kernel so that you don't end up with a disabled system where you then "have" to learn that stuff or deal with a re-install. With a module, it's less hobbling because it will be specific functionality; however if say your mouse and keyboard are USB and you modify that part of the driver and thus disable keyboard, same sort of problem; you'll need to be able to stop the system prior to loading that driver, or manually load that driver, and then understand how to avoid having the module changes you made cause you similar grief.

Probably a large part of this is being able to debug the cases where it didn't work; although dealing with compiling either a kernel or module is a moderate level of difficulty as well.
 
Old 07-16-2014, 07:25 AM   #3
JayminD
LQ Newbie
 
Registered: Jun 2014
Location: INDIA
Distribution: UBUNTU, LINUX MINT, LXLE, KUBUNTU, ELEMENT OS, DEBIAN, FEDORA, MAJARO OS, LUBUNTU and many more
Posts: 11

Original Poster
Rep: Reputation: Disabled
Question how to determine the code ???

Quote:
Originally Posted by rtmistler View Post

You'll have to determine if the particular code in question is compiled as a module or inline with the kernel.
Thanks a lot for it....Its very helpful for me..

But can just tell me that how can I determine that code whether it is compiled as a module or inline ???

and where can I find that code in my system's kernel tree ???

Please tell me detail..
your ans is very helpful for me..

thanks a lot...

regards

Jaymin d
 
Old 07-16-2014, 07:46 AM   #4
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
Quote:
Originally Posted by JayminD View Post
I want to edit some source in exciting USB driver of my kernel of UBUNTU.
"Some source" means absolutely zero to me or anyone else, because there's tons of source in the kernel and its associated drivers. This is also why I suggested that you familarize yourself with the structure of the kernel and driver source by looking at kernel.org. There's nothing stopping you from downloading a kernel and building it; the cautionary notes were if you were to choose to use the newly built kernel. Understand that if download and build the kernel and drivers, all that does is compiles and links the code. Placing the kernel binary in the location where your system looks for it, is vastly different. Much easier also, but potentially more dangerous. I think it's safe though for you to download the source and try to build the entire kernel and its drivers.

Quote:
Originally Posted by JayminD View Post
So where can I found it ??
In the kernel source tree at the top level, there is a directory named "drivers" and under there are sub-directories for things like "usb". There are source files under that hierarchy. And there's a lot of USB source code, merely saying you want to modify it and using the adjective "exciting" doesn't really zero in on what exactly you wish to do, except possibly exploration for the sake of learning. Therefore I assume you're merely looking to learn and become familiar. Do what I recommend in the last paragraph.

Quote:
Originally Posted by JayminD View Post
and at where(mean at where particular lines) can I do changes that make effect ??
Just about any line of code you change, excepting comments, will have an effect; not all effects will be good.

In summary:
  1. Either try to do some of this and then write back detailing your attempts and where you got stuck
  2. Describe better the exact changes you wish to make, but understand that if you say "I just want to change some USB driver behaviors" and what you're really saying is that you want someone else to tell you exactly what to do and how to do it, that this is nothing I can help you with.
 
Old 07-16-2014, 05:12 PM   #5
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625
It is usually not easy to decompile a driver. The more common way is to get the driver source code and recompile it as you wish and then just add it to kernel. May need to remove prior one. Can sometime just rename the new and blacklist the old.
 
  


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
compile NIC driver on other kernel linux box? hocheetiong Linux - Newbie 2 10-26-2008 12:53 PM
Linux USB kernel driver issue rockballad Programming 0 01-27-2008 11:00 PM
How to compile device driver code for linux kernel 2.4.21 shrikantpwr245 Programming 1 06-04-2006 06:51 AM
how to compile the linux driver to support SMP kernel? beast Programming 1 08-01-2005 10:28 PM
how to compile the linux driver to support SMP kernel beast Programming 1 08-01-2005 10:19 AM

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

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