How to compile tun.ko For Android (Commtiva Z71)

I’ve been too busy these days to compile a kernel module for android.

For those who want to compile a tun.ko kernel for Android (a commtiva z71 variant), here are the general steps. You need a linux environment to compile this module.

1. Download the kernel and supporting files for commtiva z71 devices here: and extract it to a directory of your choice.
2. Download the SDK and NDK for android: and
3. Copy config.gz from your phone and place it into your kernel source folder. To get it from your phone, type:
adb pull /proc/config.gz .
gunzip config.gz
mv config .config
4. Edit .config so as TUN module will be included into the kernel:
5. Run uname to get running kernel version of your phone:
uname -a
Linux localhost #7 PREEMPT Tue Jan 4 16:51:45 CST 2011 arv61 GNU/Linux
6. If there was some extra characters in your kernel version, like, you’d have to edit the Makefile to use the corresponding version:
EXTRAVERSION = -063c4d24
7. Set your environment variables:
export ARCH=arm
export CROSS_COMPILE=arm-eabi-
export PATH=$PATH:~[path of your arm-eabi compile toolkit binary in android ndk]
8. cd to your kernel folder and make modules
cd ~[path of your kernel source]
make modules

Resulting tun.ko should be in the drivers/net folder of your kernel source.

Just beware, it is not for the fainthearted.

Further information:


3 comments for “How to compile tun.ko For Android (Commtiva Z71)

  1. nai
    March 22, 2011 at 1:56 pm

    just what I was looking for. Thank you. :)

  2. Pingback: what is android
  3. Pingback: learn ubuntu

Leave a Reply

Your email address will not be published. Required fields are marked *