Nexus One: tun.ko

Posted in General on December 25th, 2011 by Friedrich Schäuffelhut – 2 Comments

Since I could not find the tun.ko module for my Nexus One I built it myself. Here is the download link: tun.ko for Nexus One, Kernel Version

sha1: f62236f4e1c2ee411c2c155379c86277618a7b6a
md5: f7cb1ea9f8b12afa3b94333d174fb55c

How to compile step by step:


  1. Prebuilt cross compilation tool chain from the AOSP source.
  2. Kernel source for Nexus One
  3. The Nexus One kernel config

Requirements 1 and 2 are available through the AOSP site. The AOSP source is about 9.4GB large, the kernel source needs about 800MB. The kernel config is on the phone located at /proc/config.gz.

First download the AOSP source following the instructions on the AOSP site, but when initializing the repository use this command instead:
repo init -b android-2.3.6_r1

Store the path to the AOSP source in a shell variable

Now create a new directory some where, clone the kernel repository and switch to the correct branch

git clone
cd msm
git checkout -t origin/android-msm-2.6.35

Finally select the commit matching your kernel via the command git checkout 42bad32.
Note: the git hash is part of the kernel version

Next fetch the config from your Nexus One and enable tun support

adb pull /proc/config.gz
gunzip config.gz
sed -i 's/# CONFIG_TUN is not set/CONFIG_TUN=m/' config

Now prepare the build

make ARCH=arm CROSS_COMPILE=$AOSP_SOURCE/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- distclean
cp config .config

One thing I don’t fully understand is the middle number of the kernel version I could not figure out how to produce that exact kernel version in an official way. I would appreciate if somebody could shine some light on this. So I used the following hack

echo '#!/bin/bash' > scripts/setlocalversion
echo 'echo -59465-g42bad32' >> scripts/setlocalversion

and finally execute the build

make ARCH=arm CROSS_COMPILE=$AOSP_SOURCE/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- modules

You’ll find the tun.ko here: drivers/net/tun.ko

To verify the version issue the command
strings ./drivers/net/tun.ko | grep vermagic
Which should display
vermagic= preempt mod_unload ARMv7

2 Comments on “ Nexus One: tun.ko ”

  • Apurva Jaiswal
    March 3rd, 2012 23:25

    Thanks a ton man! Your blog finally helped after hours of frustration. Your small hack was just impressive. HATS OFF!

  • nodje
    March 21st, 2012 08:02

    you just saved my life, and made my day: I was just looking for a tun.ko for stock version of android.

    now I can surf the web freely from behind the GFW of CN ;)

    many thanks!

Leave a Reply

- seven = 1