how edit usb driver and compile it again in linux kernel?
Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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
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
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:
Either try to do some of this and then write back detailing your attempts and where you got stuck
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.