Jump to content

Mk4 Android Tethering How-to


wiregr

Recommended Posts

I managed to get my MK4 pineapple to successfully connect to the internet through my Android phone and thought I would share the steps for anyone who's interested. I've tested this on a fresh MK4 Pineapple (firmware 2.0) using a Google Nexus running CyanogenMod9. I'm not sure if this will work with other tethering software like PDAnet.

After looking around on google, it seems that in order to get an openwrt router to connect via android tether, the only real packages we need that aren't already installed on the Pineapple are:

  • kmod-usb-net
  • kmod-usb-net-cdc-ether (depends on kmod-usb-net)
  • kmod-usb-net-rndis (depends on kmod-usb-net, kmod-usb-net-cdc-ether)

The official openwrt package repo has these, but they're all built against kernel 3.3.7 which is too new (pineapple firmware 2.0 went out with 3.2.14), so I checked out an older revision of the openwrt source tree and packages (revision 31222 which used the correct kernel version) and built what was missing. After copying them over to the pineapple and installing using opkg, the pineapple detected my phone just fine and was able to pull down an ip and connect to the internet.

So here's a step-by-step:

  1. Download the missing packages and copy them over to your pineapple (/tmp in this example)
  2. Run the following commands in this order:
    opkg --nodeps install /tmp/kmod-usb-net_3.2.14-1_ar71xx.ipk
    opkg --nodeps install /tmp/kmod-usb-net-cdc-ether_3.2.14-1_ar71xx.ipk
    opkg --nodeps install /tmp/kmod-usb-net-rndis_3.2.14-1_ar71xx.ipk


  3. Reboot the pineapple (not sure if this is necessary)
  4. Connect your android phone to the pineapple via USB
  5. Turn on USB tethering
  6. On the pineapple, run dmesg and verify that usb0 shows up
  7. Add the following to /etc/config/network (This ensures that usb0 will obtain an ip via dhcp):
    config interface usb
        option ifname usb0
        option proto dhcp


  8. Restart pineapple again, enable tethering in android again.

At this point, ifconfig usb0 should show that usb0 has automatically obtained a valid ip address and you should be able to ping out to the internet.

Now that it's working, you'll still need to setup ip forwarding to properly forward traffic from clients to/from the usb:

iptables -t nat -A POSTROUTING -s 172.16.42.0/24 -o usb0 -j MASQUERADE
iptables -A FORWARD -s 172.16.42.0/24 -o usb0 -j ACCEPT
iptables -A FORWARD -d 172.16.42.0/24 -m state --state ESTABLISHED,RELATED -i usb0 -j ACCEPT

At this point, you should be able to connect to the pineapple and browse the internet as usual. Tested with urlsnarf and everything seemed to be working properly :) If anyone's interested, I can post a step-by-step so you can build everything yourself.

Here are the package files I used:

kmod-usb-net_3.2.14-1_ar71xx.ipk

kmod-usb-net-cdc-ether_3.2.14-1_ar71xx.ipk

kmod-usb-net-rndis_3.2.14-1_ar71xx.ipk

Anyways, let me know if you have any questions. I've been a lurker for a while and I wanted to try and contribute for once :D

Link to comment
Share on other sites

Excellently done! Can't wait to try it out!

:::Picks up phone to call friendly Nexus owner down the street:::...

Edit: Did you make any attempts at mounting the microSD storage for use on the pineapple? That would surely be total win!

telot

Edited by telot
Link to comment
Share on other sites

Excellently done! Can't wait to try it out!

:::Picks up phone to call friendly Nexus owner down the street:::...

Edit: Did you make any attempts at mounting the microSD storage for use on the pineapple? That would surely be total win!

telot

I haven't tried on the nexus, since there's only internal storage and it's setup as MTP instead of USB mass storage so I think it's a little more involved to get it mounted. I'll do some more research and see if I can figure anything out.

With a regular phone with a microsd card it might be a little easier. If I have time today I'll try it out with my wife's phone and report back.

Edit: I accidentally a word

Edited by wiregr
Link to comment
Share on other sites

if I could use my galaxy s II and the micro sd card in the phone I am so doing this. only thing scarring me at the moment is actually putting on the CyanogenMod, I also recently put ics on my phone as well. Will keep this on my watch list

Link to comment
Share on other sites

So the wife's phone also uses Media Transfer Protocol to share files with PC too which makes things a bit more complicated. I want to say that if you have an android phone that uses the normal USB Mass Storage mode (i.e. connecting your phone to a PC makes the SD card contents unavailable on the phone) that it wouldn't be too hard, but I can't say for sure.

As far as MTP support goes, I'll see if I can find a workaround. I found a filesystem implementation that sounds promising, but I'm concerned about some of the functionality, namely that "libmtp (and I assume the MTP protocol itself) doesn’t support seeking within a file or partial file reads or writes. You have to fetch or send the entire file" - from this site.

Maybe using some program that allows for file sharing on the android (something like android fileshare) would work?

Link to comment
Share on other sites

Can you post your .config file you used to build these modules. I've tried to build them before but get a kernel panic whenever I bring the usb0 interface up. I'd like to see what you are doing different.

Thanks!

Link to comment
Share on other sites

Mad props to wiregr!!

I can confirm this is working great on my unlocked Galaxy Note :)

Between this and the new ALFA AWUS036NHA support in 2.2.0 we're nearly to 4 methods for Internet connection! Will have to roll this into the next major firmware revision when we redesign the ICS menus.

Congrats and cheers :D

Link to comment
Share on other sites

Mad props to wiregr!!

I can confirm this is working great on my unlocked Galaxy Note :)

Between this and the new ALFA AWUS036NHA support in 2.2.0 we're nearly to 4 methods for Internet connection! Will have to roll this into the next major firmware revision when we redesign the ICS menus.

Congrats and cheers :D

+1

This is awesome!!

the pineapple just keeps getting better and better.

the new UI is much smoother on my android phone as well:-)

Link to comment
Share on other sites

Okay, so this is the second time that my post has been deleted (this time alongside a post from someone saying they saw the first). Can somebody explain if I'm doing something wrong or violating a rule here? Should I not be posting the .config file, or is there a problem because I put it up on pastebin? I'd really like to know what I was doing wrong so I can avoid it in the future.

Link to comment
Share on other sites

  • 2 weeks later...

This sounds great! My contract is running out, and now I know what to do with my old, rooted Desire! :lol:

Since this is included in the firmware now, are the steps in the original post still necessary? Or is it just a case of connecting one's phone and ensuring development mode is enabled?

Also, is there any news on the SD card access? Otherwise, where do I store logs and so on?

Many thanks - awesome work as ever.

Link to comment
Share on other sites

It is enabled by default BUT you still need to run these IP table command:

iptables -t nat -A POSTROUTING -s 172.16.42.0/24 -o usb0 -j MASQUERADE

iptables -A FORWARD -s 172.16.42.0/24 -o usb0 -j ACCEPT

iptables -A FORWARD -d 172.16.42.0/24 -m state --state ESTABLISHED,RELATED -i usb0 -j ACCEPT

That will be built in next version though too.

Link to comment
Share on other sites

This sounds great! My contract is running out, and now I know what to do with my old, rooted Desire! :lol:

Since this is included in the firmware now, are the steps in the original post still necessary? Or is it just a case of connecting one's phone and ensuring development mode is enabled?

Also, is there any news on the SD card access? Otherwise, where do I store logs and so on?

Many thanks - awesome work as ever.

Actually, yeah, I was able to get SD card access working although I haven't done much testing other than verifying that I could see files, read, and write to the phone. Basically, I built the necessary kernel modules needed to get cifs working on the pineapple, and then hijacked a bit of the functionality of the "Samba Filesharing" program on my phone to get it to share over the USB tether interface (rndis0) instead of over wifi. I'll write up some step-by-step instructions when I get home this afternoon

Also as it turns out, the small, powered USB hub that came with the original Rock Band works wonderfully with the pineapple. It's just the right size (pretty small) and the USB->DC plug that came with my external battery fits it. This is probably a better solution as you can leave the USB hub connected and automatically mount a dedicated USB stick when the pineapple boots instead of having to manually set everything up each time.

Edited by wiregr
Link to comment
Share on other sites

anyone get the tethering to work on the Samsung galaxy S2 LTE yet? tried to activate usb tethering and the checkbox just remains grey when I try to. Anyone know of a way around this issue?

Thanks

Just wanted to add my lsusb and dmseg to my post if anyone needs reference:

lsusb:

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

dmesg:

[ 34.760000] usbcore: registered new interface driver rtl8187

[ 36.630000] usbcore: registered new interface driver ath9k_htc

[ 36.890000] usbcore: registered new interface driver usbserial

[ 36.900000] usbcore: registered new interface driver usbserial_generic

[ 36.900000] usbserial: USB Serial Driver core

[ 36.940000] usbcore: registered new interface driver cdc_ether

[ 37.170000] usbcore: registered new interface driver rndis_host

[ 1315.270000] usb 1-1: new high-speed USB device number 2 using ath79-ehci

[ 1315.870000] usb 1-1: device not accepting address 2, error -71

[ 1328.680000] usb 1-1: new high-speed USB device number 5 using ath79-ehci

[ 1329.280000] usb 1-1: device not accepting address 5, error -71

[ 1385.830000] usb 1-1: new high-speed USB device number 9 using ath79-ehci

[ 1386.430000] usb 1-1: device not accepting address 9, error -71

[ 1400.600000] usb 1-1: new high-speed USB device number 11 using ath79-ehci

[ 1415.780000] usb 1-1: new high-speed USB device number 13 using ath79-ehci

[ 1416.000000] usb 1-1: USB disconnect, device number 13

[ 1440.000000] usb 1-1: new high-speed USB device number 16 using ath79-ehci

[ 1440.170000] usb 1-1: USB disconnect, device number 16

[ 1443.920000] usb 1-1: new high-speed USB device number 18 using ath79-ehci

[ 1446.200000] usb 1-1: new high-speed USB device number 19 using ath79-ehci

[ 1447.600000] usb 1-1: new high-speed USB device number 20 using ath79-ehci

[ 1451.250000] usb 1-1: new high-speed USB device number 21 using ath79-ehci

[ 1457.900000] usb 1-1: new high-speed USB device number 23 using ath79-ehci

[ 1458.800000] usb 1-1: new high-speed USB device number 24 using ath79-ehci

[ 1459.400000] usb 1-1: device not accepting address 24, error -71

[ 1478.620000] usb 1-1: new high-speed USB device number 27 using ath79-ehci

[ 1481.880000] usb 1-1: new high-speed USB device number 28 using ath79-ehci

[ 1526.920000] usb 1-1: new high-speed USB device number 32 using ath79-ehci

[ 1527.520000] usb 1-1: device not accepting address 32, error -71

[ 1571.270000] usb 1-1: new high-speed USB device number 38 using ath79-ehci

[ 1574.330000] usb 1-1: new high-speed USB device number 39 using ath79-ehci

[ 1581.960000] usb 1-1: new high-speed USB device number 40 using ath79-ehci

[ 1582.200000] usb 1-1: device descriptor read/all, error -71

[ 1591.230000] usb 1-1: new high-speed USB device number 43 using ath79-ehci

[ 1592.080000] usb 1-1: new high-speed USB device number 44 using ath79-ehci

[ 1592.280000] usb 1-1: USB disconnect, device number 44

[ 1594.030000] usb 1-1: new high-speed USB device number 45 using ath79-ehci

[ 1614.750000] usb 1-1: new high-speed USB device number 49 using ath79-ehci

[ 1614.950000] usb 1-1: USB disconnect, device number 49

[ 1630.760000] usb 1-1: new high-speed USB device number 51 using ath79-ehci

[ 1642.410000] usb 1-1: new high-speed USB device number 52 using ath79-ehci

[ 1643.560000] usb 1-1: new high-speed USB device number 53 using ath79-ehci

[ 1646.440000] usb 1-1: new high-speed USB device number 54 using ath79-ehci

[ 1647.040000] usb 1-1: device not accepting address 54, error -71

[ 1647.640000] usb 1-1: new high-speed USB device number 56 using ath79-ehci

[ 1650.450000] usb 1-1: new high-speed USB device number 57 using ath79-ehci

[ 1651.050000] usb 1-1: device not accepting address 57, error -71

[ 1657.000000] usb 1-1: new high-speed USB device number 59 using ath79-ehci

[ 1657.240000] usb 1-1: device descriptor read/all, error -71

[ 1672.450000] usb 1-1: new high-speed USB device number 61 using ath79-ehci

[ 1673.570000] usb 1-1: new high-speed USB device number 62 using ath79-ehci

[ 1674.170000] usb 1-1: device not accepting address 62, error -71

[ 1681.420000] usb 1-1: new high-speed USB device number 64 using ath79-ehci

[ 1689.030000] usb 1-1: new high-speed USB device number 66 using ath79-ehci

[ 1692.320000] usb 1-1: new high-speed USB device number 67 using ath79-ehci

[ 1698.030000] usb 1-1: new high-speed USB device number 68 using ath79-ehci

[ 1698.630000] usb 1-1: device not accepting address 68, error -71

[ 1699.310000] usb 1-1: new high-speed USB device number 70 using ath79-ehci

[ 1713.080000] usb 1-1: new high-speed USB device number 72 using ath79-ehci

[ 1721.820000] usb 1-1: new high-speed USB device number 74 using ath79-ehci

[ 1731.340000] usb 1-1: new high-speed USB device number 76 using ath79-ehci

[ 1731.560000] usb 1-1: USB disconnect, device number 76

[ 1736.610000] usb 1-1: new high-speed USB device number 77 using ath79-ehci

[ 1747.320000] usb 1-1: new high-speed USB device number 79 using ath79-ehci

[ 1747.920000] usb 1-1: device not accepting address 79, error -71

[ 1753.330000] usb 1-1: new high-speed USB device number 82 using ath79-ehci

[ 1753.930000] usb 1-1: device not accepting address 82, error -71

[ 1754.520000] usb 1-1: new high-speed USB device number 84 using ath79-ehci

[ 1755.120000] usb 1-1: device not accepting address 84, error -71

[ 1761.580000] usb 1-1: new high-speed USB device number 86 using ath79-ehci

[ 1761.890000] usb 1-1: USB disconnect, device number 86

[ 1773.260000] usb 1-1: new high-speed USB device number 88 using ath79-ehci

[ 1774.550000] usb 1-1: new high-speed USB device number 89 using ath79-ehci

[ 1775.150000] usb 1-1: device not accepting address 89, error -71

[ 1783.580000] usb 1-1: new high-speed USB device number 92 using ath79-ehci

[ 1783.830000] usb 1-1: USB disconnect, device number 92

[ 1785.570000] usb 1-1: new high-speed USB device number 93 using ath79-ehci

[ 1786.750000] usb 1-1: new high-speed USB device number 94 using ath79-ehci

[ 1791.710000] usb 1-1: new high-speed USB device number 96 using ath79-ehci

[ 1792.020000] usb 1-1: USB disconnect, device number 96

[ 1793.250000] usb 1-1: new high-speed USB device number 97 using ath79-ehci

[ 1793.850000] usb 1-1: device not accepting address 97, error -71

[ 1799.780000] usb 1-1: new high-speed USB device number 99 using ath79-ehci

[ 1800.380000] usb 1-1: device not accepting address 99, error -71

[ 1808.650000] usb 1-1: new high-speed USB device number 101 using ath79-ehci

[ 1809.250000] usb 1-1: device not accepting address 101, error -71

[ 1809.880000] usb 1-1: new high-speed USB device number 103 using ath79-ehci

[ 1817.640000] usb 1-1: new high-speed USB device number 105 using ath79-ehci

[ 1817.890000] usb 1-1: USB disconnect, device number 105

Edited by g4hsean
Link to comment
Share on other sites

  • 1 month later...

anyone get the tethering to work on the Samsung galaxy S2 LTE yet? tried to activate usb tethering and the checkbox just remains grey when I try to. Anyone know of a way around this issue?

Thanks

Just wanted to add my lsusb and dmseg to my post if anyone needs reference:

lsusb:

dmesg:

I have a rooted Samgsung galaxy s2 (Model: SGH-i777) and followed the directions, and it worked perfectly. However when I rebooted the pineapple, at the last step it would stop recognizing the phone as usb0.

I have verified that this is reproducible. I flashed the entire pineapple with the latest update again, and got the exact same results. I'm haven't tried writing a script that'll uninstalling and reinstalling those packages to see if I can get it working with some sort of automaticity, but I will post the results when I do this.

See if this is the issue for you as well.

Link to comment
Share on other sites

I have a rooted Samgsung galaxy s2 (Model: SGH-i777) and followed the directions, and it worked perfectly. However when I rebooted the pineapple, at the last step it would stop recognizing the phone as usb0.

I have verified that this is reproducible. I flashed the entire pineapple with the latest update again, and got the exact same results. I'm haven't tried writing a script that'll uninstalling and reinstalling those packages to see if I can get it working with some sort of automaticity, but I will post the results when I do this.

See if this is the issue for you as well.

did u issue the command reboot through ssh or the ui? how about tying to unplug the power instead?

Link to comment
Share on other sites

I have a rooted Samgsung galaxy s2 (Model: SGH-i777) and followed the directions, and it worked perfectly. However when I rebooted the pineapple, at the last step it would stop recognizing the phone as usb0.

I have verified that this is reproducible. I flashed the entire pineapple with the latest update again, and got the exact same results. I'm haven't tried writing a script that'll uninstalling and reinstalling those packages to see if I can get it working with some sort of automaticity, but I will post the results when I do this.

See if this is the issue for you as well.

I might actually end up going the rooting route I was just hoping that there was an easier way to do it without rooting. Then again its worth it so ill root it anyways.

Link to comment
Share on other sites

  • 4 weeks later...

did u issue the command reboot through ssh or the ui? how about tying to unplug the power instead?

Hey sorry I haven't responded. I don't get enough "me time" to tinker with this thing.

Since my last post, I see that these modules are now integrated, which is cool. I went ahead and upgraded, and as before, tethering worked like a charm out of the box, but as before, after a reboot, it won't recognize it anymore.

I had said reboot with ssh. I tried power cycling(now with the 2.6.1 release) am getting the same result. Works directly after flash, but nothing more. I don't understand it.

Edited by Jonathan Frias
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...