USB cell phone tethering to Raspberry PI


13 posts
by gbassett » Fri May 25, 2012 3:52 pm
The Raspberry Pi seems to suffer from a bug (expressed at http://thread.gmane.org/gmane.linux.usb.general/56830). In essence, my Samsung Galaxy S (Epic 4g variant) running CM7 doesn't tether due to bad CDC descriptors. It appears from the link the patch may be accepted into the debian kernel. What is the likelihood I"d be able to get the kernel with this patch without having to build it myself?

Thanks. (My Raspberry pi is going to be my redundant cellular wan portable router if I can get this issue worked out.)

Gabe
Posts: 2
Joined: Fri May 25, 2012 3:47 pm
by jon wise » Thu May 31, 2012 9:16 pm
My attempt to tether using Debian Squeeze to an HTC Wildfire S under Android v2.3.5 produces the following from dmesg:

usb 1-1.3: new high speed USB device number 10 using dwc_otg
usb 1-1.3: New USB device found, idVendor=0bb4, idProduct=0ff8
usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.3: Product: Android Phone
usb 1-1.3: Manufacturer: HTC
usb 1-1.3: SerialNumber: SH1BSTR09315
cdc_ether 1-1.3:1.0: usb0: register 'cdc_ether' at usb-bcm2708_usb-1.3, CDC Ethernet Device, 0b:16:21:2c:37:42

This looks promising but there are no signs of of internet access by ping, ifconfig or route. Do I need to do more?

Any suggestions would be very welcome.
Posts: 24
Joined: Thu May 31, 2012 8:21 pm
by ryanteck » Tue Jun 12, 2012 6:27 pm
I'm also trying to do this,
It seems that debain is picking the phone up for me (Samsung Galaxy Europa Flashed to 2.2 Unofficial) and is able to see it as a USB networking device (usb0).

I just cant seem to connect to the internet via it, I can get connection via a windows computer. If it would help I can get information from ubuntu on my PC.
Ryan Walmsley
17 Year Old Student & Geek
User avatar
Posts: 67
Joined: Mon Apr 16, 2012 10:49 am
Location: Stevenage , United Kingdom
by Marf » Thu Jul 05, 2012 12:02 pm
Did anyone manage to get this going?

I have an HTC Desire Z with CM7 and cannot tether either.
Posts: 1
Joined: Thu Jul 05, 2012 12:00 pm
by G7SXB » Wed Jul 11, 2012 10:55 pm
The solution to this is relatively easy when you understand what is going on. The following outlines my solution your mileage may vary and you use the information at your own peril. I suggest you make a backup of resolv.conf before you start tinkering

I'm using a Pi tethered to a Samsung Galaxy Europa GT-I5500 on usb1.

Before I tried the following I effectively ran as root by issuing the command :

sudo bash

Better to be god from the outset rather than get access denied type error messages.

First I set up the name servers in /etc/resolv.conf by editing it and having it contain just the following two lines :

nameserver 208.67.220.220
nameserver 208.67.222.222


After editing resolv.conf I then issued the command echo "1"> /proc/sys/net/ipv4/ip_forward to turn ip forwarding on.

I've taken eth0 down by issuing the command ifconfig eth0 down just avoid any confusion though I'm sure you can have it running though some manipulation of the routing tables may be in order to make it all work together. I just took it out of the loop to keep my already messy set-up as simple as possible.

You now need to get an ip address from the phone for the usb port to which your phone is tethered. To make this work you need dhcpcd (apt-get install dhcpcd) . Once installed issue the command dhcpcd usb[which ever port your phone is on] this should return an ip address and using ifconfig should confirm the port is configured with the returned address.

I'm running a headless Pi. I connect through usb0 using a Ben Nanonote running ssh (soon to be replaced with an Amstrad NC100 or dumb terminal when I can find one) . I've installed lynx on my Pi so I can now use my tether to surf the 'net in glorious text!


Any questions just message me

Regards

Duane Phillips
User avatar
Posts: 2
Joined: Sat Jul 07, 2012 10:15 am
Location: Johnstown, Kilkenny
by burdt » Fri Jul 27, 2012 1:07 am
I tried G7SXB's solution but i kept getting a segfault error upon starting dhcpcd.

ifconfig showed my phone (an HTC Inspire 4g) as usb0 and lsusb confirmed it.

Eventually I added the following to /etc/network/interfaces

auto eth0
iface eth0 inet dhcp
iface usb0 inet dchp

and executed the following command:

ifup usb0

and it finally worked.
Posts: 1
Joined: Fri Jul 27, 2012 1:00 am
by Robpol86 » Sat Jul 28, 2012 10:01 pm
With my Galaxy Nexus I did the following:
    Plug USB cable.
    Verify usb0 is in ifconfig (without an IP address).
    sudo dhclient usb0
    Verify usb0 has an IP address in ifconfig and verify internet with ping.

I was able to tether LTE to my Raspberry Pi easily with this. Oh and make sure you have internet on your phone before running dhclient.
User avatar
Posts: 9
Joined: Wed Jul 18, 2012 7:29 pm
Location: Austin, TX
by Robpol86 » Sun Jul 29, 2012 2:16 am
User avatar
Posts: 9
Joined: Wed Jul 18, 2012 7:29 pm
Location: Austin, TX
by code_311 » Fri Aug 03, 2012 5:41 pm
My Pi locks up the second I plug in my phone :-(
Posts: 2
Joined: Thu Jul 19, 2012 5:36 pm
by WrathOfTheAngels » Thu Sep 20, 2012 7:57 pm
Hi, I tryed previous solutions, but no one is working for me.

My ifconfig output is
Code: Select all
usb0      Link encap:Ethernet  HWaddr 2a:3c:1d:d1:9f:ae 
          inet addr:192.168.42.149  Bcast:192.168.42.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:17 errors:0 dropped:3 overruns:0 frame:0
          TX packets:11 errors:58 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1901 (1.8 KiB)  TX bytes:1894 (1.8 KiB)

and if I try to
Code: Select all
sudo dhclient usb0

I have got no output (good thing). But if I try to ping, for example http://www.google.com, I get a "can't be resolved".
What should I try to do?
Thank you for your answer
Posts: 10
Joined: Thu Sep 20, 2012 7:31 pm
by martin_xs6 » Fri Nov 30, 2012 9:35 am
So I got this working and setup a script and udev rule to auto setup my tether when it gets plugged in. I wanted to use my phone as a VNC client through the tether, so I wouldn't have been able to setup the tether every time.

This website helped when trying to figure out how to run a script when something gets plugged in:

http://ubuntuforums.org/archive/index.php/t-502864.html

When they talk about the rule, SYSFS should be ATTRS and usb_device should just be usb.

Then in the script I just had:
Code: Select all
#!/bin/bash
dhcpcd -k usb0  #stops an old dhcpcd
dhcpcd usb0       #gets usb0 an IP address.


I'm not sure how this will work for you guys, but with my phone (Nexus S) a USB tether shows up as a different device than when its not tethered so this works.

I can post more details tomorrow if people need them. I'm not at my rPi now..
Posts: 1
Joined: Fri Nov 30, 2012 9:18 am
by keble » Sun Jan 20, 2013 9:46 pm
Thanks for posting martin_xs6.
I have been trying to set up udev rules on and off for quite a while, without any success!

I tried following your recipe. For my rule I have:

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", ATTRS{idProduct}=="712e", RUN+="/home/pi/start_usb_network"

where I got the idVendor and idProduct from "lsusb"

and my script is:#!/bin/bash
# start usb0
dhcpcd -k usb0 #stop any old dhcpcd
dhcpcd usb0
echo "dhcpcd found"

Unfortunately zilch happens on plugging in my android and USB tethering.

I don't see any udev problems at boot:

dmesg | grep udev
[ 4.203969] udevd[137]: starting version 175

Can anyone suggest a way to debug these udev rules?
Posts: 36
Joined: Tue Apr 03, 2012 4:46 pm
by keble » Sun Jan 20, 2013 9:56 pm
Oops! Brain fade or whatever - this is now working!
Posts: 36
Joined: Tue Apr 03, 2012 4:46 pm