How to compile tun.ko for android 4.1.1 on rk3018 (rock chip rk3066) 3.0.8+ SMP preempt mod_unload ARMv7.


Kernel version: 3.0.8+ #146 SMP PREEMPT Thu Mar 21 14:11:53 CST 2013 armv7l unknown
Build number: Rk3018_ANDROID4.1.1-SDK-v1.00.02 rk3018sdk-CH4.1.1 JRO03H 20130312.3018 release-keys

If your using feat VPN or openvpn android apps, you will get the code M10 error or unable to load tun.ko respectively.
It's because that kernel driver module wasn't provided with your droid (Jelly bean) so you can't run SSL based VPN's.

This particular flavour of working tun.ko kernel module was not available on the tun.ko repository database at the time of writing.
mondinfo on some of the other modules on this droid shows Kernel module ver magic: 3.0.8+ SMP preempt mod_unload ARMv7

You will need:

Linux x86 operating environment (PC running Linux hosting the compilation environment).
Android ndk - see tutorial on http://ohheyitslou.blogspot.co.uk/2011/09/ohheyitslou-custom-android-kernel-guide.html with youtube video
Android source - https://github.com/omegamoon/rockchip-rk30xx-mk808
About 3Gb+ free space on $home (or chosen storage).

For droid:

Install app tun.ko (after the build) with google play.

Get installed.

Make sure you have a compiler (developer) environment as per the ndk tutorial (so you have make etc).
Install the ndk, preferably off a users home directory. Set the CROSS_COMPILE environment variable as per the ndk tutorial.
Unpack the rockchip-rk30xx-mk808 kernel source into a directory.

Get ready.

To make sure everything is clean in the source before starting, issue the following command from the source folder:
make clean && make mrproper
get the config needed by cp arch/arm/configs/mk808b_defconfig  .config
edit the Makefile and edit: EXTRAVERSION = +           (add the plus sign)

Get building.

Issue make -j3 ARCH=arm  As the ndk guide says, the j3 depends on what CPU you have to
devote threads to the compilation job (see cat /proc/cpuinfo|grep processor|wc -l)
When done, the file you need will be in drivers/net/tun.ko which will need copying to
the droid somewhere writeable with an ext4 (not FAT) file system.

With a rooted droid, you can copy tun.ko to the correct location to persist over reboots.

To load the module, use google play to install tun.ko app.

Even though an old ndk was used with build .config that didn't match running kernel,
from a source that was not exact, modload ./tun.ko worked and the VPN came up.

Persistent load on boot

No advise as yet to achieve this but placing tun.ko on /mnt/sdcard or /system/lib/modules allows
the tun.ko android app to load the module when you run this app before running your VPN app.

Warnings!

Beware of flaky modules on tun.ko repository (will cause your droid to reboot)!
Toolchains other than arm-eabi-4.4.0 seem to produce unexecutable object code.