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. Loading random image when activity is brought up...Not working any ideas?

I would also like to point out that I've tried all three of these

private Integer [] mImageIds = {
            R.drawable.icon,
            R.drawable.shoticon,
            R.drawable.mixicon,
            };

private static final Integer [] mImageIds = {
            R.drawable.icon,
            R.drawable.shoticon,
            R.drawable.mixicon,
            };
private static Integer [] mImageIds = {
            R.drawable.icon,
            R.drawable.shoticon,
            R.drawable.mixicon,
            };




NONE OF THOSE HAVE MADE A DIFFERENCE.







-- 

2. download android 2.2 failed because of "File too large6"

Hi Edward,

You shouldn't by any chance be really low on diskspace?

- Henrik

-----Original Message-----
From: android-porting@googlegroups.com 
[mailto:android-port...@googlegroups.com] On Behalf Of edwardlee lee
Sent: 25. juni 2010 02:52
To: android-porting
Subject: [android-porting] download android 2.2 failed because of "File too 
large6"

Hi All,

I fetch android 2.2 source code (froyo) but failed.

Here is error log:
Fetching projects:   4% (7/159)  remote: Counting objects: 23726, done.
remote: Compressing objects: 100% (6188/6188), done.
fatal: write error: File too large6), 8.00 MiB | 14 KiB/s
fatal: index-pack failed
error: Cannot fetch platform/cts

Has anyone meet this issue?

How to fix it?

Any help will be thankful.

Edward

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

3. Froyo make file

4. Aha... Ternyata AHA Gagal Connect

5. How to Store values from Date Picker into the database

6. Inbuilt Test runner

7. Will the HTC EVO become a Developer Phone. Welcoming speculation