Pages

Get it free, Try now

Free Cell Phones

Tuesday, December 28, 2010

How to compile Android Device Driver as a Module(.ko)

Here are the quick steps to be followed.

Prerequisite:
1. kernel sources from vendor say HTC wildfire(2.1 update-1)
2. Android source code for Éclair
3. Create a new folder called Kernel and copy the contents from the sources download via vendor

Step1: Copy config.gz from running hardware

adb pull /proc/config.gz
gunzip config.gz
mv config .config


Step 2: Copy/Overwrite the .config file to the kenel root directory

open .config file and search for
CONFIG_MODULE_NAME1=y
CONFIG_MODULE_NAME2=y


and replace 'y' with 'm', we use CONFIG_MODULE_NAME1 as module

CONFIG_MODULE_NAME1=m
CONFIG_MODULE_NAME2=y

Step 3: Check the active kernel version on the hardware using 'OR' if you are using own Boot.img then skip this and move on to step 4:

adb shell
# uname -a

or you may get the details of the kernel from the Settings->Aboutphone->SoftwareInformation: Kernel version

2.6.29-6fb59e13 HTC-kernel@xxxxxxxx

open Makefile in the kernel folder, search and replace "EXTRAVERSION =" with "EXTRAVERSION =-6fb59e13"

Step 4: Set the Env variables

export ARCH=arm
exprot CROSS_COMPILE=arm-eabi-
export PATH=$PATH:~/eclair/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/


now perform make modules for make from the kernel sources

kernel:$ make modules or make

after successful compilation, check out the .ko files next to the sources in the same directory

Complete example: How to get LG headset sources compile in to kernel module(.ko)

1 comment:

  1. [...] me of follow-up comments via email. Notify me of new posts via email. How to compile Android Device Driver as a Module(.ko) Android – Accessing Input device “msm_pcm_in” from User space [...]

    ReplyDelete