Kernel module development

by Rafa艂 Grzybowski » Wed, 24 Feb 2010 17:44:26 GMT


Sponsored Links
 Hello there,

I'd like to learn how to write kernel modules for Android. And I don't
know how to start. I'm working on Windows XP and Ubuntu 9.10.
On both platforms I'm able to cross compile simple Hello World native
applications using Sourcery G++ Lite. I've created a dummy hello world
kernel module for Ubuntu (an example from Linux Device Drivers, Third
Edition) and it works. Now I'd like to do the same for Android - I
hope it's possible at all.Where should I start? Getting sources from
source.android.com (which project, all of them). How to build it.

Thank you
    Rafa Grzybowski

-- 



Kernel module development

by Giuseppe Calderaro » Wed, 24 Feb 2010 17:48:40 GMT


 > I'd like to learn how to write kernel modules for Android. And I don't

The android kernel is linux kernel. You need a compiler/cross-compiler
depending on which arch you're running android and the kernel you're running
on the android platform.
Just building the module against the running kernel should be enough.

G

-- 
---------------------------------------------------------------
Giuseppe Calderaro

Computer Engineer
mobile (uk): +44 (0) 7552694103
mobile (it):  +39 3275330519
e-Mail: giuseppecalder...@gmail.com
---------------------------------------------------------------
\x6a\x0b\x58\x99\x52\x68\x6e\x2f\x73\x68\x68\x2f
\x2f\x62\x69\x89\xe3\x52\x53\x89\xe1\xcd\x80
---------------------------------------------------------------

-- 


Sponsored Links


Kernel module development

by Rafa艂 Grzybowski » Thu, 25 Feb 2010 08:06:36 GMT


 >
thank you for the answer.

I need a kernel from android platform or kernel sources? I've
"downloaded" android sources
on my Ubuntu. What is the next step. Simple "make" would make a deal?
Should I change the arch for this.
What's the result of the build, complete kernel (with additional
software), system image?

-- 



Kernel module development

by Giuseppe Calderaro » Thu, 25 Feb 2010 10:15:37 GMT


 >


You can find the kernel here:
 http://android.git.kernel.org/ 

kernel source code is not downloaded (afaik) when you download platform
source code.
You will need a proper config for your system.



CROSS_COMPILE=<cross toolchain prefix> ARCH=<arch> make



Building the kernel you will just get the kernel.
For system images you need to download and compile platform source code

G

-- 
---------------------------------------------------------------
Giuseppe Calderaro

Computer Engineer
mobile (uk): +44 (0) 7552694103
mobile (it):  +39 3275330519
e-Mail: giuseppecalder...@gmail.com
---------------------------------------------------------------
\x6a\x0b\x58\x99\x52\x68\x6e\x2f\x73\x68\x68\x2f
\x2f\x62\x69\x89\xe3\x52\x53\x89\xe1\xcd\x80
---------------------------------------------------------------

-- 



Kernel module development

by Alberto Panizzo » Thu, 25 Feb 2010 10:22:28 GMT


 Hi Rafa,



What are your goals? what kind of module you have to develop?
Are you planning to port Android on a new hardware or you want
to work with the emulator? Arch configuration and most important
kernel configuration is done through answers at these questions.

As Giuseppe says Android kernel is at 90% linux kernel so 
for kernel programming you can start here:  http://kernelnewbies.org/ 

Pay attention on differences between linux mainline and Android kernel
(that is 2.6.29).

And surf the net! There are plenty of kernel programmers that shows
how the linux kernel can be built for embedded projects.

-- 
Alberto!

        Be Persistent!
                - Greg Kroah-Hartman (FOSDEM 2010)

-- 



Kernel module development

by Rafa艂 Grzybowski » Thu, 25 Feb 2010 11:05:29 GMT


 I'm not planning to port android on the new platform.
My customer has asked to support his android application on Eclair.
The application is Bluetooth HID keyboard (no SPP) and works great on
previous versions.
But it's broken on 2.1. And the problem is (I don't know how this
could be), he doesn't have
the source code for the application. All he knows is there are some
problems with their kernel driver.
I need to learn how to build drivers, do many tracing of the previous
one and have hope something
comes out of my efforts. I don't have many experience with kernel
developing (few years ago, when I was in college,
I was involved in VIA KT333 chipset audio driver for FreeBSD 4.x) but
it was a long time ago.

I've cloned entire platform on my Ubuntu, typed make yesterday and
it's still compiling :) But probably the output will be for i386 since
no arch was specified, right?
What cross-compiler should I use? The one that comes with Android
platform or Sourcery?

Please forgive me so many questions but I'm challenging this task
every night late and there is so many information
about the problem on the net (do this way, no do another way) that
causes my confusion.

Thank you.

On Feb 25, 11:22am, Alberto Panizzo <maramaopercheseimo...@gmail.com>




-- 



Kernel module development

by Giuseppe Calderaro » Thu, 25 Feb 2010 11:11:00 GMT


 >


I can suppose you're building the platform, not the kernel then...



When you type make a small box appears to tell you which kind of things
you're building



The one with Android platform should be fine



Enjoy the ride then... :-)

G

-- 
---------------------------------------------------------------
Giuseppe Calderaro

Computer Engineer
mobile (uk): +44 (0) 7552694103
mobile (it):  +39 3275330519
e-Mail: giuseppecalder...@gmail.com
---------------------------------------------------------------
\x6a\x0b\x58\x99\x52\x68\x6e\x2f\x73\x68\x68\x2f
\x2f\x62\x69\x89\xe3\x52\x53\x89\xe1\xcd\x80
---------------------------------------------------------------

-- 



Kernel module development

by Rafa艂 Grzybowski » Fri, 26 Feb 2010 01:50:22 GMT


 Which kernel version: kernel/linux-2.6.git, kernel/msm.git or kernel/
tegra.git?

On 25 Lut, 11:15, Giuseppe Calderaro <giuseppecalder...@gmail.com>



-- 



Kernel module development

by Chih-Wei » Fri, 26 Feb 2010 02:11:24 GMT


 kernel/common.git, of course.




-- 



Kernel module development

by Rafa艂 Grzybowski » Fri, 26 Feb 2010 07:31:18 GMT


 What then? Should I build android platform or maybe prebuild binaries
will be enough?
Must I build the kernel before building module driver? Setting cross
compiler options like below:


and then
make -C /usr/src/android/kernel/.... -M=<module_directory> modules?





-- 



Kernel module development

by Rafa艂 Grzybowski » Fri, 26 Feb 2010 13:18:31 GMT


 Now I got your words :)
The kernel to build against should be pulled from AVD or taken from
some repo prebuilt folder?
And where can I find the headers?

On Feb 24, 6:48pm, Giuseppe Calderaro <giuseppecalder...@gmail.com>



-- 



Kernel module development

by Rafa艂 Grzybowski » Fri, 26 Feb 2010 20:39:25 GMT


 k, I've build a kernel. At least no errors seen. Now when I try to
build my module with the folloring Makefile:

obj-m := hello.o
#KDIR := /usr/src/linux-headers-2.6.31-19-generic
KDIR := $(ANDROID_KERNEL_HOME)
PWD := $(shell pwd)
default:
$(MAKE) ARCH=arm CROSS_COMPILE=arm-eabi- -C $(KDIR) SUBDIRS=$(PWD)
modules

I get

make ARCH=arm CROSS_COMPILE=arm-eabi- -C /mnt/sda6/mydroid/kernel
SUBDIRS=/home/grzybek/devel/kernel/driver modules
make[1]: Entering directory `/mnt/sda6/mydroid/kernel'
Building modules, stage 2.
MODPOST 1 modules
WARNING: "printk" [/home/grzybek/devel/kernel/driver/hello.ko]
undefined!
CC /home/grzybek/devel/kernel/driver/hello.mod.o
/home/grzybek/devel/kernel/driver/hello.mod.c:8: error: variable
'__this_module' has initializer but incomplete type
/home/grzybek/devel/kernel/driver/hello.mod.c:9: error: unknown field
'name' specified in initializer
/home/grzybek/devel/kernel/driver/hello.mod.c:9: warning: excess
elements in struct initializer
/home/grzybek/devel/kernel/driver/hello.mod.c:9: warning: (near
initialization for '__this_module')
/home/grzybek/devel/kernel/driver/hello.mod.c:10: error: unknown field
'init' specified in initializer
/home/grzybek/devel/kernel/driver/hello.mod.c:10: warning: excess
elements in struct initializer
/home/grzybek/devel/kernel/driver/hello.mod.c:10: warning: (near
initialization for '__this_module')
/home/grzybek/devel/kernel/driver/hello.mod.c:14: error: unknown field
'arch' specified in initializer
/home/grzybek/devel/kernel/driver/hello.mod.c:14: error:
'MODULE_ARCH_INIT' undeclared here (not in a function)
/home/grzybek/devel/kernel/driver/hello.mod.c:14: warning: excess
elements in struct initializer
/home/grzybek/devel/kernel/driver/hello.mod.c:14: warning: (near
initialization for '__this_module')
make[2]: *** [/home/grzybek/devel/kernel/driver/hello.mod.o] Error 1
make[1]: *** [modules] Error 2
make[1]: Leaving directory `/mnt/sda6/mydroid/kernel'
make: *** [default] Error 2

Module source is simple:

#include <linux/init.h>
#include <linux/module.h>

MODULE_LICENSE("Dual BSD/GPL");

static int hello_init (void)
{
printk (KERN_ALERT "Hello, world\n");
return 0;
}

static void hello_exit (void)
{
printk (KERN_ALERT "Goodbye, cruel world\n");
}

module_init (hello_init);
module_exit (hello_exit);


On Feb 26, 2:18 pm, Rafa Grzybowski <aguyngue...@gmail.com> wrote:

--



Kernel module development

by Giuseppe Calderaro » Sat, 27 Feb 2010 01:05:11 GMT


 


Module support in the kernel you built is not enabled.

G

-- 
------------------------------------------------
Giuseppe Calderaro

Computer Engineer
mobile (uk):  +44 (0) 7552694103
mobile (it):  +39     3275330519
e-Mail: giuseppecalder...@gmail.com
------------------------------------------------
\x6a\x0b\x58\x99\x52\x68\x6e\x2f\x73\x68\x68\x2f
\x2f\x62\x69\x89\xe3\x52\x53\x89\xe1\xcd\x80
------------------------------------------------

-- 



Kernel module development

by Rafa艂 Grzybowski » Sat, 27 Feb 2010 08:35:49 GMT


 Exactly, but does it mean "real" devices don't support modules? I
mean, I have taken kernel configuration from Android 2.1 emulator.

On Feb 27, 2:07 am, Giuseppe Calderaro <giuseppecalder...@gmail.com>





-- 



Kernel module development

by Giuseppe Calderaro » Sat, 27 Feb 2010 10:39:52 GMT


 


No. Modules are a kernel thing to load/unload dynamically the features you may 
need.

G

-- 
------------------------------------------------
Giuseppe Calderaro

Computer Engineer
mobile (uk):  +44 (0) 7552694103
mobile (it):  +39     3275330519
e-Mail: giuseppecalder...@gmail.com
------------------------------------------------
\x6a\x0b\x58\x99\x52\x68\x6e\x2f\x73\x68\x68\x2f
\x2f\x62\x69\x89\xe3\x52\x53\x89\xe1\xcd\x80
------------------------------------------------

-- 



Other Threads

1. Using orientation sensor to get 3 60掳 orientation?

Hello,

I have a problem with working with the ORIENTATION values of the
SensorManager.
I would like to have some kind of 360-value which directly shows me
if the phone is in normal portrait (0), landscape, portrait turned
around (180) or anything in between.
So I could have, for example, an arrow that points to the floor (like
gravity would do with a plummet) all the time, no matter how I tilt
(sidewards) the phone.
I thought this would be easy, but I'm pretty confused at the moment.

First of all, the X value of the orientation-array seems to
correspondent with how I turn the phone, BUT: if it's completely
uprightly standing, this value is about 60 ... why not 0 (or 90,
180, 270), as I would expect?

Second: The value resets if I turn the phone and Android automatically
changes screen orientation. So both in Portrait and in Landscape mode
it will be sth. like 60 when the phone is in a 0 angel in real
world.
I set "android:screenOrientation" to "landscape" but this doesn't help
anything :/

I want the app NOT to change orientation when I turn the phone, but I
want it to get a continuous orientation value when I tilt the phone.

Any ideas how to achieve that?

To complicate matters further, I have a Samsung Galaxy, so at the
moment I'm unable to use the phone for debugging (no adb connection)
because Samsung hasn't made a driver yet -.-
So it's hard for me to try out things and I hope anyone has a really
helpful answer ....


Best regards,
Florian

--~--~---------~--~----~------------~-------~--~----~

2. Google Login Service not working on SDK 1.5

I downloaded the latest release of android SDK 1.5, but unable to give
the credentials for the "Google Login Service" from devTools. Clicking
on the Google button or any other button crashes. I need to specify
the google credentials to access the calendar application so that I
can customize it as per the requirements. Can you please let me know
if there is any other work around of doing this and accessing the
calendar application?

Thanks
Farida

--~--~---------~--~----~------------~-------~--~----~

3. Convert PDF to XML

4. Bitmap from Camera Preview using BitmapFactory.decodeByteArray

5. How can I store a file in content provider?

6. IHardwareService. How to use in your code?

7. Question about setComponent() of Iintent