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 126.96.36.199-59465-g42bad32.
How to compile step by step:
- Prebuilt cross compilation tool chain from the AOSP source.
- Kernel source for Nexus One
- 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 https://android.googlesource.com/kernel/msm.git
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 188.8.131.52-59465-g42bad32.
Next fetch the config from your Nexus One and enable tun support
adb pull /proc/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 184.108.40.206-59465-g42bad32. 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=220.127.116.11-59465-g42bad32 preempt mod_unload ARMv7