Friday, July 2, 2010

VPN on the GW620 1.5 cupcake

This will make pptp with mppe work on your cupcake GW620 (but it should easily extend to other android 1.5 phones). L2TP, pptp without mppe and other configurations should work, but I have not tested them. You will need root on you phone.

0. Step: get the files
I have uploaded the kernel patch, pppd, mtpd and even busybox and a complete boot.img here and here.
The boot.img may not work for your phone, so you should consider creating it yourself as under step 1.

1. Step: update your kernel and create a boot.img
Use the GW620-LG Kernel sources for 1.5 and apply the patch at the end of this post. This is the state of ppp in 2.6.29 kernel with very little modifications.

I used /proc/config.gz on the phone as my starting point for the config.
After applying the patch, you have to enable
CONFIG_PPP, CONFIG_PPP_ASYN, CONFIG_PPP_MPPE and CONFIG_PPPOPNS.

You will find various resources on how to compile the kernel for android.

Create a new boot.img by
../android-1.5/out/host/linux-x86/bin/mkbootimg --cmdline 'root=/dev/mtdblock1 rootfstype=yaffs2 lpj=1912832 console=/dev/null' --kernel my-kernel/arch/arm/boot/zImage --ramdisk debug-ramdisk.cpio.gz -o debug-boot.img

I got the parameter for cmdline by looking at cat /proc/cmdline on my phone. You may check if it gives the same output on your phone (and I would also be interested to hear it!)
The kernel parameter is (of course!) the path to your kernel image you just created.
The ramdisk can be one extracted from a previous but image.

ATTENTION: Dont flash this right away! First try by using
fastboot boot debug-boot.img
to boot this image without flashing and see if everything works.
If it goes fine, then use fastboot flash boot debug-boot.img to flash it.


If your phone crashes on boot after you have replaced your kernel, you should also replace wireless.ko in /system/lib/modules/. This fixed the crashes for me.

2. Copy pppd and mtpd binaries to /system/bin on your phone.
Those binaries are build when you compile the plain 1.6 android source.

3. create /system/etc/ppp/chap-secrets
See pppd's documentation how this should look like. I would recommend you to test the pptp on your computer first and then use the same chap-secrets file.

4. Using adb to run:

mtpd pptp $hostname 1723 '' name $username defaultroute require-mppe-128 debug mru 1280 mtu 1280

(Everything in one line)
Replace $hostname and $username by their respective values. For $username you should have the entry in chap-secrets.

Here 1723 is the (standard) port for pptp servers. After the port come _two_ _single_ ' and the rest of the commandline is directly passed to the pppd binary.

You will have to omit require-mppe-128 if you dont use it.

When you enable debug, you will see verbose output in logcat. (See my other post on how to enable locat)

At first I tried without mru 1280 mtu 1280, but after half a minute or so, the logcat output would fill with pppd: Unsupported Protocol ... with varying protocol numbers.
Using mru 1280 mtu 1280 fixed this problem.

Notes:
If it does not work, check that the output of 'route' is correct. You may want to install busybox for that, because the supplied route command is awful.

You could call this binary by using ASE - android scripting, for example.

UPDATE:
You will have to make an link /dev.pts to /dev/pts
or apply the following patch to and comile your own pppd:

+++ ../android-1.6/external/ppp/pppd/sys-linux.c 2010-05-12 18:57:24.511791149 +0200
@@ -2561,7 +2561,7 @@
if (mfd >= 0) {
int ptn;
if (ioctl(mfd, TIOCGPTN, &ptn) >= 0) {
- slprintf(pty_name, sizeof(pty_name), "/dev.pts/%d", ptn);
+ slprintf(pty_name, sizeof(pty_name), "/dev/pts/%d", ptn);
chmod(pty_name, S_IRUSR | S_IWUSR);
#ifdef TIOCSPTLCK
ptn = 0;

2 comments:

  1. Identical output for "cat /proc/cmdline" on a v10T korean rom. :)

    ReplyDelete
  2. you're a master of GW620!

    how is it going your compiling cupcake?

    ReplyDelete