Home > MOD and HACK > How to get LG headset sources compile in to kernel module(.ko).

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

This article is about compiling specific sources into Kernel Module in Android, read this first before you proceed further

I have taken Headset Driver as a use case.

1. Create a folder headset_lg at location: ~/gt540_2.1/kernel/arch/arm/mach-msm/headset_LG

2. Copy board-swift-headset.c from ~/gt540_2.1/kernel/arch/arm/mach-msm/swift to headset_LG folder and make changes to it below

change //static int __init lge_hsd_init(void) to static int lge_hsd_init(void)
change // actuall call is static void __exit lge_hsd_exit(void) to static void lge_hsd_exit(void)
also comment this line

write make file to compile the .c file

# Makefile for the swift specific files

#obj-y += board-swift-bl-rt9393.o
obj-m = board-swift-headset.o // replace obj-y to obj-m // were m stand for Module

3. also change need to be made inside /home/br/gt540_2.1/kernel/arch/arm/mach-msm/rpc_server_misc.c

comment the global variable “headset_inserted” which is used to udpate the status of actual hardware

4. change to root folder of the kernel and run make. you shall see the .ko file at location given below

 Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/zImage is ready
Building modules, stage 2.
MODPOST 16 modules
LD [M] arch/arm/mach-msm/headset_LG/board-swift-headset.ko

Installing Kernel Module

~/arch/arm/mach-msm/headset_LG/$adb push /sdcard/board-swift-headset.ko
~/arch/arm/mach-msm/headset_LG/$adb shell
# insmod /sdcard/board-swift-headset.ko //dont panic, filesystem should restart after executing insmod stmt
# lsmod // to verify the driver
# rmmod board-swift-headset.ko // to remove kernel module

Categories: MOD and HACK
  1. December 28, 2010 at 3:14 pm

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

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: