Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
r_o_e_e
Old
#1  
Junior Member - OP
Thanks Meter 0
Posts: 4
Join Date: Dec 2009
Default building a kernel with device driver

Hi,
I am new to the android development and a bit confused from all this (root, no root etc).

Say I want to write a new kernel driver to handle keyboard input, and want it to run only on my phone. And my phone is not the developer phone, nor exploitable for root privilege escalation.

Can I download the source files and compile a new kernel with my driver? I guess I cannot use the Android sources, but need my phone specific branch. e.g if I own an HTC Hero I need to get the specific sources from HTC, and they don't publish kernel sources for all their models...

But if I found the source, add my sources and compiled it, It should be easy (and legit ) to load the new image to the consumer phone right ?

Thanks
Roee
 
MasterCLC
Old
#2  
Junior Member
Thanks Meter 0
Posts: 7
Join Date: May 2009
More or less that is correct. The source code will contain the license terms, if it says GPL then you are golden. If you get the source from a questionable route and it's not necessarily "public" then it goes into a gray area. Generically speaking, if you get the Android source, and the source code for your keyboard, build an image with it, flash it to your phone, then you are perfectly fine. If you choose to redistribute that code that you mashed together, it's arguable you'd then also have to publish your mashed up code or at the very least the 2 sources you used to mash it together. Mash is the best word I can think of right now

-Chad
 
r_o_e_e
Old
#3  
Junior Member - OP
Thanks Meter 0
Posts: 4
Join Date: Dec 2009
Thanks for the reply Chad.

If the software is GPL, and I don't intend to publish the code, I just want to play and check couple of things.
I wonder if i can only compile a new keyboard driver (for example), and just load the ko file somehow without flushing the whole kernel.

I don't have much experience in the linux world, but I would guess it will be something like :
get the branch from the android git
compile a new kernel object for the keyboard
use adb to load the ko file to the device
insmod the new device
somehow remove the current keyboard device and map a new device with the new kernel driver

is this the correct flow ? is there example of how to do it somewhere ?

Cheers
Roee
 
r_o_e_e
Old
#4  
Junior Member - OP
Thanks Meter 0
Posts: 4
Join Date: Dec 2009
Ok, I think I have a little better understanding after I played with my G1 today...

So now I understand how to enumerate all the devices in the system, and find the proper devices (e.g using cat /proc/bus/input/devices , or in /devices/virtual/input/ ), but I fail to understand how to replace the proper lkm module. When I run lsmod, the only module loaded is the Wlan module.
How can I find which file is responsible for the keyboard and replace it with my driver? Or must I recompile the whole kernel in order to replace the driver with my modified driver?

I guess it became an easy linux questions.... (just not easy for me )
 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Go to top of page...