Playing with Android - Kernel and Modules

Kernel

I already wrote several notes about cross-compiling programs for Android. Well, the same thing applies for the kernel. Actually, the Scratchbox toolchain can compile the Linux kernel without any problem.

First, you need to get the kernel sources there. Then, do the usual make xconfig. Remember to do this outside Scratchbox, since the toolchain does not have the libraries necessary to build the GUI used for xconfig. The rest is regular kernel compiling configuration.

When configuration is done, log into the Scratchbox toolchain /scratchbox/login, and type make. You can use the -kernel option of the emulator to use the zImage you just built.

Modules

I initially chose to rebuild the Android kernel because module support was turned off in the emulator. After adding loadable kernel module (LKM) support and compiling the kernel, building a module is easy with the toolchain. Writing the module is the hard part (see this book for an in-depth coverage of Linux device drivers). Once it's done, use a Makefile like the one below, and just type make while in the toolchain environment.

obj-m    := android_driver.o 
 
KDIR    := /path_to/kernel_src_dir 
PWD    := $(shell pwd) 
 
default: 
        $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

Discussion

Enter your comment (wiki syntax is allowed):
WRETY
 
wiki/android6.txt · Last modified: 2008/11/22 13:42 by fred
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki