[SOLVED] How do I enable Nexus 7 USB tether on Jelly Bean?

Search This thread

cbdonohue

Member
Jun 18, 2012
25
8
Is there a way compile the JB source so USB tether is enabled?

I made the following modification to frameworks/base/core/res/res/values/config.xml but the Nexus 7 with JB doesn't bring up any USB network interface or show the tethering option in the menu

Code:
 <!-- List of regexpressions describing the interface (if any) that represent tetherable
         USB interfaces.  If the device doesn't want to support tething over USB this should
         be empty.  An example would be "usb.*" -->
    <string-array translatable="false" name="config_tether_usb_regexs">
        <item>"usb0"</item>
    </string-array>
 
Last edited:

cbdonohue

Member
Jun 18, 2012
25
8
I asked a similar question http://xdaforums.com/showthread.php?t=1822788

a 3rd-party app may be able to help, but the kernel apparently has to be compiled with CONFIG_NETFILTER/CONFIG_IP_NF_IPTABLES and/or RNDIS

I tried using android-wired-tether with a custom kernel that includes netfilter, iptables, and rndis. This still did not work since the application tries to access usb0 directly and the Nexus 7 never creates that interface even with a customized config.xml
 
Last edited:

cbdonohue

Member
Jun 18, 2012
25
8
I was able to get the USB tethering, Wi-Fi hotspot, and Bluetooth tethering options to come up in the menu on the Nexus 7 using the attached overlay placed in device/asus/grouper/overlay/frameworks/base/core/res/res/values/config.xml
The Wi-Fi hotspot and Bluetooth tethering options appear to work.

However, the USB tethering option unchecks itself after a second when I try to activate it.
I get the following error in logcat:
Code:
09-13 13:10:41.820: E/UsbDeviceManager(331): Failed to switch USB config to rndis,adb
 

Attachments

  • config.zip
    3 KB · Views: 984
  • device-2012-09-13-085841.jpg
    device-2012-09-13-085841.jpg
    16.6 KB · Views: 4,292
Last edited:
  • Like
Reactions: naeco

cbdonohue

Member
Jun 18, 2012
25
8
I am happy to announce I got native USB tethering working on the Nexus 7

I had to make the changes to the config.xml as shown in the previous post and also had to modify out/target/product/grouper/root/init.usb.rc by adding the following

Code:
on property:sys.usb.config=rndis
    write /sys/class/android_usb/android0/enable 0
    write /sys/class/android_usb/android0/idVendor 18d1
    write /sys/class/android_usb/android0/idProduct 4e23
    write /sys/class/android_usb/android0/functions ${sys.usb.config}
    write /sys/class/android_usb/android0/bDeviceClass 224
    write /sys/class/android_usb/android0/enable 1
    setprop sys.usb.state ${sys.usb.config}

on property:sys.usb.config=rndis,adb
    write /sys/class/android_usb/android0/enable 0
    write /sys/class/android_usb/android0/idVendor 18d1
    write /sys/class/android_usb/android0/idProduct 4e24
    write /sys/class/android_usb/android0/functions ${sys.usb.config}
    write /sys/class/android_usb/android0/bDeviceClass 224
    write /sys/class/android_usb/android0/enable 1
    start adbd
    setprop sys.usb.state ${sys.usb.config}

I'm also using a modified tegra kernel with RNDIS options activated...not sure if this is required (I'm assuming it is). I will try the stock kernel later.
 
Last edited:

trevd

Inactive Recognized Developer
Jul 19, 2011
895
1,271
Hull
Samsung Galaxy Tab 4
Props to You!

I was able to get the USB tethering, Wi-Fi hotspot, and Bluetooth tethering options to come up in the menu on the Nexus 7 using the attached overlay placed in device/asus/grouper/overlay/frameworks/base/core/res/res/values/config.xml
The Wi-Fi hotspot and Bluetooth tethering options appear to work.

However, the USB tethering option unchecks itself after a second when I try to activate it.
I get the following error in logcat:
Code:
09-13 13:10:41.820: E/UsbDeviceManager(331): Failed to switch USB config to rndis,adb

Nice work and quick as well, I do like those overlays, there is plenty of nice tweaks to be had out of them if folks are willing to put the effort in. ;)

I built my own overlay earlier on after you planted the seed and was quite surprised to get Wifi-Hotspot for free. It does work, well my HTC Sensation connects to it, which is quite amusing as Cm10 on the sensation doesn't have a working WifiHotspot :laugh: I think a bit of cross device hacking is in order there

I'm also using a modified tegra kernel with RNDIS options activated...not sure if this is required (I'm assuming it is). I will try the stock kernel later.

I think this is my missing link, I was going to have a proper look at some point and you've saved me a job there, I'll build myself a fresh kernel now and see if it is the case.

:good:
 

cbdonohue

Member
Jun 18, 2012
25
8
So does this require both a modified (before compile) Kernel and ROM?

After talking with trevd, I am pretty confident you need to modify the .config created by "make tegra3_android_defconfig" so the RNDIS driver is in the kernel. I won't be able to compare the stock kernel to my modified one until the weekend (I only have one Nexus 7 and have to do other testing with it). The .config file I used for my modified tegra kernel is attached.

So yes, modify the kernel and Jelly Bean source. I can certainly help anyone if they run into trouble.

I plan on putting up flashable images when I can and submitting a patch to cyanogen.
 

Attachments

  • tegra_config.zip
    20 KB · Views: 567
Last edited:

retfeg

Senior Member
Nov 15, 2011
82
0
I was able to get the USB tethering, Wi-Fi hotspot, and Bluetooth tethering options to come up in the menu on the Nexus 7 using the attached overlay placed in device/asus/grouper/overlay/frameworks/base/core/res/res/values/config.xml
The Wi-Fi hotspot and Bluetooth tethering options appear to work.

However, the USB tethering option unchecks itself after a second when I try to activate it.
I get the following error in logcat:
Code:
09-13 13:10:41.820: E/UsbDeviceManager(331): Failed to switch USB config to rndis,adb

Would love to use your overlay.
Where exactly do I find the above mentioned path?
When I connect Nexus 7 to my Mac and see the file structure, it is missing the device/asus/grouper/overlay/frameworks/base/core/res/res/values/config.xml
 

cbdonohue

Member
Jun 18, 2012
25
8
Would love to use your overlay.
Where exactly do I find the above mentioned path?
When I connect Nexus 7 to my Mac and see the file structure, it is missing the device/asus/grouper/overlay/frameworks/base/core/res/res/values/config.xml

You need to modify the files in the Jelly Bean source code and recompile the operating system.
 

nextelbuddy

Senior Member
Aug 13, 2009
702
139
I'm very curious and I have asked this so many times and no one has answered me.

Why would you want to tether your device? your device cant and does note generate its own Mobile internet service like a 3G/4G device. its wifi only so why would you want to share your devices wireless connectivity?

the only thing I can think of is if you have a desktop or laptop that does NOT have a wireless card and you want to use your Nexus 7 as a wireless card essentially and then plugging it in via USB to your desktop/laptop?

what other reason could you have for wanting to share your devices wireless connectivity?
 

ObsidianX

Senior Member
Apr 1, 2009
89
259
San Jose
I'm very curious and I have asked this so many times and no one has answered me.

Why would you want to tether your device? your device cant and does note generate its own Mobile internet service like a 3G/4G device. its wifi only so why would you want to share your devices wireless connectivity?

the only thing I can think of is if you have a desktop or laptop that does NOT have a wireless card and you want to use your Nexus 7 as a wireless card essentially and then plugging it in via USB to your desktop/laptop?

what other reason could you have for wanting to share your devices wireless connectivity?

You can reverse-tether a device in order to get connectivity from your PC. This is what I'm looking to accomplish with my device while I'm at work so I can access the company intranet.
 

cbdonohue

Member
Jun 18, 2012
25
8
@cbdonohue:

Hey! Do you think you could upload your kernel/framework files to use in the mean time?


1. Download the tegra kernel branch android-tegra3-grouper-3.1-jb-fr2 and compile using the attached defconfig. (This enables the RNDIS driver)

2. Download grouper branch android-4.1.1_r1.1 and copy the compiled tegra kernel into it.

3. Modify the following grouper file with the attached config.xml (This allows the 'Tether to USB' option to come up in the settings')
device/asus/grouper/overlay/frameworks/base/core/res/res/values/config.xml

4. Compile grouper

5. Modify the following file with the attached init.usb.rc (This allows the OS to enable RNDIS USB tethering)
out/target/product/grouper/root/init.usb.rc

6. Flash to device.

At some point in the future I can make a flashable image or patch that will make this easier. In the mean time these steps should do it. Let me know if you have any issues.
 

Attachments

  • modifications.zip
    23.7 KB · Views: 497

cbdonohue

Member
Jun 18, 2012
25
8
I'm very curious and I have asked this so many times and no one has answered me.

Why would you want to tether your device? your device cant and does note generate its own Mobile internet service like a 3G/4G device. its wifi only so why would you want to share your devices wireless connectivity?

the only thing I can think of is if you have a desktop or laptop that does NOT have a wireless card and you want to use your Nexus 7 as a wireless card essentially and then plugging it in via USB to your desktop/laptop?

what other reason could you have for wanting to share your devices wireless connectivity?

One reason would be If you wanted to communicate between a PC and an Android device without being wireless. This could be to hide the connection or reduce the impact of RF interference. Not all applications need internet access...it might be just to send data between two end points.
 
Last edited:

cbdonohue

Member
Jun 18, 2012
25
8
USB interface and addressing specifics

For those of you who are interested...

If the Nexus 7 is acting as a USB device you can turn USB tethering on from the settings menu. The Android device automatically assigns its USB interface a hard coded IP address and starts DHCP server to hand out an address to the USB host at the other end.
If you want to change the IP address that the Android assigns itself you can modifiy the USB_NEAR_IFACE_ADDR constant in following file:
frameworks/base/services/java/com/android/server/connectivity/Tethering.java
If you want to disable the DHCP server, you can simply remove the address space you are using from the mDhcpRange array in the same file.

If the Nexus 7 is acting as a USB host (using USB OTG) then you must manually bring up the USB interface (ifconfig rndis0 x.x.x.x) since the USB menu settings will not do anything.

As an aside, am I the only one surprised to find hard coded IP addresses deep in the Android code?! haha
I've found some other gems like "shoud not get here" lines and c/c++ goto statements.
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 5
    I am happy to announce I got native USB tethering working on the Nexus 7

    I had to make the changes to the config.xml as shown in the previous post and also had to modify out/target/product/grouper/root/init.usb.rc by adding the following

    Code:
    on property:sys.usb.config=rndis
        write /sys/class/android_usb/android0/enable 0
        write /sys/class/android_usb/android0/idVendor 18d1
        write /sys/class/android_usb/android0/idProduct 4e23
        write /sys/class/android_usb/android0/functions ${sys.usb.config}
        write /sys/class/android_usb/android0/bDeviceClass 224
        write /sys/class/android_usb/android0/enable 1
        setprop sys.usb.state ${sys.usb.config}
    
    on property:sys.usb.config=rndis,adb
        write /sys/class/android_usb/android0/enable 0
        write /sys/class/android_usb/android0/idVendor 18d1
        write /sys/class/android_usb/android0/idProduct 4e24
        write /sys/class/android_usb/android0/functions ${sys.usb.config}
        write /sys/class/android_usb/android0/bDeviceClass 224
        write /sys/class/android_usb/android0/enable 1
        start adbd
        setprop sys.usb.state ${sys.usb.config}

    I'm also using a modified tegra kernel with RNDIS options activated...not sure if this is required (I'm assuming it is). I will try the stock kernel later.
    3
    Hey folks,

    I took cbdonohue's modifications and built them into CM10 and it works like a charm! I took the liberty of uploading the ZIP to dev-host:

    http://d-h.st/KIr


    All credit goes to cbdonohue for finding and creating the modification. I just built it :)
    2
    Not to be 'that guy', but could you please add a question mark to the title of your thread? I came in here hoping for a solution, not a question ;)
    2
    @cbdonohue:

    Hey! Do you think you could upload your kernel/framework files to use in the mean time?


    1. Download the tegra kernel branch android-tegra3-grouper-3.1-jb-fr2 and compile using the attached defconfig. (This enables the RNDIS driver)

    2. Download grouper branch android-4.1.1_r1.1 and copy the compiled tegra kernel into it.

    3. Modify the following grouper file with the attached config.xml (This allows the 'Tether to USB' option to come up in the settings')
    device/asus/grouper/overlay/frameworks/base/core/res/res/values/config.xml

    4. Compile grouper

    5. Modify the following file with the attached init.usb.rc (This allows the OS to enable RNDIS USB tethering)
    out/target/product/grouper/root/init.usb.rc

    6. Flash to device.

    At some point in the future I can make a flashable image or patch that will make this easier. In the mean time these steps should do it. Let me know if you have any issues.
    2

    http://source.android.com/source/building-kernels.html

    There you go, get invloved! Also the search function works a treat on here as well, anything you're gonna ask has probably already been answered, saves typing aswell :D