HowTo - Building Android Kernel Modules (bcm4329.ko)

This post describes the process of building an individual kernel module for Android without compiling the whole kernel.

In order to do this, you need to make sure you already have your Android kernel source compiled, and the version of your module should be the same with the version of your kernel.

Here are some good links for compiling a whole Android kernel: Kernel source (CyanogenMod version) Building kernel from source Integrate kernel into image

After you compile a whole kernel and installed it into your device, if you just want to modify some driver and recompile the specific module, you don’t need to recompile the kernel again. Here is how to compile and install a single module for Android kernel.

In this example, we are interested in buiding the wireless driver module for Google Nexus One – bcm4329.ko. Suppose you are now under the kernel source directory. Here we go:

1. Include the arm-eabi- tool directory into the path.

1
$ export PATH=$PATH:~/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/

2. Generate the configuration file.

(1) Use herring_defconfig as the default configuration file.

1
$ make ARCH=arm herring_defconfig

(2) Modify the configuration file .config with the following changes.

1
2
3
CONFIG_CROSS_COMPILE = "arm-eabi-"
CONFIG_LOCAL_VERSION = "-cyanogenmod"
#CONFIG_LOCALVERSION_AUTO

And set all CONFIG_BCM* to m .

(3) Change another file (and I don’t know why)

1
$ vi scripts/setlocalversion

Locate the following line:

1
2
if $short; then
echo "+"

and change echo "+" to echo "".

3. Set building architecture to be arm.

1
$ export ARCH=arm

4. Make

1
$ make modules

5. Push the new module into the phone.

(1) Remount to be writable.

1
$ adb remount

(2) Push into the device.

1
$ adb push drivers/net/wireless/bcm4329/bcm4320.ko /system/modules

Reference: Compiling kernel modules (tun.ko) for Android