AdbNetworking

When porting Ubuntu to a new platform, making adb work is one important step to achieve. Bringing up a full networking stack might be difficult, so if you want the convenience of networking on the phone before enabling the wifi chips, you can use the following steps to have your phone use your laptop's internet connection via adb.

This is similar to reverse tethering.

ensure ppp is enabled on host and target kernel

CONFIG_PPP=y
CONFIG_PPP_ASYNC=y
CONFIG_PPP_SYNC_TTY=y
CONFIG_SLHC=y

This might not be the minimal set, but it works.

install ppp on both host and target

You will need both the ppp and libpcap0.8 packages.

On host

sudo sysctl net.ipv4.ip_forward=1
sudo iptables -t nat -I POSTROUTING -s 192.168.0.2 -j MASQUERADE -o eth0 # replace eth0 to the device node used on your host
sudo iptables -I FORWARD 1 --in-interface ppp0 -j ACCEPT
sudo iptables -I INPUT 1 --in-interface ppp0 -j ACCEPT

sudo adb ppp "shell:pppd nodetach noauth noipdefault defaultroute /dev/tty" nodetach noauth noipdefault notty 192.168.0.1:192.168.0.2

This will create network devices ppp0 on both host and target.

In the commands above, you will create a new private network between the host and the target, where the host ppp0 device will be assigned address 192.168.0.1 and the target ppp0 device will have 192.168.0.2. You may select different addresses if your host already uses the 192.168.0.x range.

You can verify the ppp0 devices exist on both host and target by issuing ifconfig.

Set DNS on target

echo nameserver 8.8.8.8 >> /etc/resolv.conf

"8.8.8.8" is Google nameserver, replace by any nameserver you want to use.

After all those steps, your phone has full internet access.

Final steps

If you mount root filesystem as RW by mount -o rw,remount /, you will be able to do something like apt-get install gdb, which will make it much easier to do development.

Then you can do something like "apt-get update ; apt-get install gcc" to do compile or something.

Touch/AdbNetworking (last edited 2014-11-26 06:50:59 by ycheng-twn)