USB networking

(Questions about these procedures)
(removed incorrect "bad link" comment; the link is fine.)
 
(45 intermediate revisions not shown)
Line 1: Line 1:
-
{{Midgard article}}
+
This page describes how the maemo platform can be turned into a [[USB]] network device. The first part describes how to configure the Nokia tablet as a USB pluggable network device. The second part describes how to configure various platforms to use the Nokia tablet as a network device. This article is based loosely on the Maemo 3.x [http://maemo.org/development/documentation/manuals/3-x/howto_usb_networking_bora/ configuring USB networking HOWTO].
 +
You might want to use the tablet as a USB network device to log into your tablet remotely, or to transfer data from your tablet to another computer, in a situation where wifi or bluetooth are not an option. If you wish to connect your tablet to a Linux machine over TCP/IP, the [http://maemo.org/development/documentation/pc_connectivity/ PC connectivity] section in the Maemo SDK documentation also contains useful information.
-
This page describes how the maemo platform can be turned into a USB network device. There are two parts to this document. The first part of this document describes how to configure the Nokia 770/n800 to be a USB plugable network device. The second part of this document describes how to configure various platforms to use the Nokia 770/n800 as a network device. These are the reasons that you may want to use Usb Networking with the Nokia 770/n800
+
'''WARNING'''
 +
Currently there is a bug in the g_ether.ko driver of OS2008 (both 4.0.1 and 4.1) which prevents USB networking from working correctly with Windows machines (but not with Linux machines). See [https://bugs.maemo.org/show_bug.cgi?id=3243 bug #3243] for details. The bug was introduced somewhere between kernels 2.6.18 and 2.6.21, so Maemo versions based on 2.6.18 kernels (e.g. OS2007 and earlier) will work.
-
* Transfer data back and forth between the Nokia 770/n800 and a host computer.
+
== USB networking for N900 ==
-
* Perform remote logins to the Nokia 770/n800 from a host computer.
+
-
* Add a third connectivity tool to the existing WAN and BlueTooth support that the Nokia comes with out of the box.
+
-
* ...
+
-
As with all usb hardware, driver software must installed on the host computer before the usb device is attached. Please make sure that your Nokia 770 is not connected to the computer while performing these steps.
+
Please visit [[N900 USB networking]].
 +
== Tablet USB network configuration ==
-
= Nokia 770/n800 USB Network Environment Configuration =
+
=== USB statusbar plugin ===
-
http://m770cias.garage.maemo.org/images/usbnet/usbnet_concept_800.png
+
The [http://garage.maemo.org/projects/usb-otg-plugin/ usb-otg-plugin] applet lets you set up USB networking tablet-side, and switch between host and client mode. This is the easy way to do things and no other tablet-side configuration is required.
-
An usbnet concept image helps to see what the configuration will do. In normal circumstances, the USB Mass storage driver had control of the usb hardware. USBNet will displace the mass storage driver's control of the usb hardware with the g_ether network driver. Until the replacement occurs, the host computer will see the 770/n800 as just another mass storage device or an empty cable.
+
Alternatively you could try the usb networking applet found here:
 +
  http://repository.maemo.org/extras-devel/pool/diablo/free/m/maemo-control/
-
NOTE: After installing USB networking you should setup a dummy access pointby running the following:
+
=== Behind the scenes ===
-
gconftool -s -t string /system/osso/connectivity/IAP/DEFAULT/type DUMMY
+
-
After running this, you will see a "DEFAULT" connection appear in the connection manager.
+
In normal circumstances, the USB Mass storage driver had control of the USB hardware. USBNet allows the g_ether network driver to take control of the USB interface.
-
== Start and Stop Script ==
+
After installing USB networking, set up a dummy access point by running the following:
-
For convenience, I placed the following script /etc/init.d/usbnet on my Nokia: In order to add this script to your device, you will need root access. Please see [[root access]] for information.
+
gconftool-2 -s -t string /system/osso/connectivity/IAP/DUMMY/type DUMMY
 +
gconftool-2 -s -t string /system/osso/connectivity/IAP/DUMMY/name 'Dummy network'
 +
gconftool-2 -s -t boolean /system/osso/connectivity/IAP/DUMMY/autoconnect true
 +
 
 +
You should see a "DEFAULT" connection appear in the connection manager.
 +
 
 +
'''WARNING'''
 +
Currently there is a bug in Diablo that causes DUMMY connections not to show up in connection manager, a semi-official fix is outlined in [https://bugs.maemo.org/show_bug.cgi?id=3306#c23 bug #3306].
 +
 
 +
=== Starting and stopping USB network mode ===
 +
 
 +
To easily start & stop USB network mode, place the following script in /etc/init.d/usbnet on your tablet. To do this, you will need [[root access]] to the device.
 +
 
 +
While switching between modes by running the script, it is important to disconnect the USB cable.
<pre>
<pre>
Line 34: Line 47:
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=usbnet
NAME=usbnet
-
DESC="USB Networking for Nokia 770"
+
DESC="USB Networking for Nokia Internet Tablets"
INITFILE=/etc/init.d/$NAME
INITFILE=/etc/init.d/$NAME
Line 46: Line 59:
         if [ "$USBNET" = "" ]
         if [ "$USBNET" = "" ]
         then
         then
-
           echo "entering Ethernet via USB mode (g_ether)..."
+
           echo "Entering Ethernet via USB mode (g_ether)..."
           insmod /mnt/initfs/lib/modules/$KERNEL_VERSION/g_ether.ko
           insmod /mnt/initfs/lib/modules/$KERNEL_VERSION/g_ether.ko
-
           echo "waiting, then starting up the usb0.."
+
           echo "Waiting, then bringing up the usb0 interface.."
           sleep 1
           sleep 1
           /sbin/ifup usb0
           /sbin/ifup usb0
         else
         else
-
           echo "already in Ethernet-via-USB mode..."
+
           echo "Already in Ethernet-via-USB mode..."
-
           echo "try ping 192.168.2.15"
+
           echo "Try ping 192.168.2.15"
         fi
         fi
         ;;
         ;;
Line 71: Line 84:
exit 0
exit 0
</pre>
</pre>
 +
The script needs to have executable permissions, which you can give with
 +
sudo chmod a+x /etc/init.d/usbnet
-
Definitely, there is some room for improvement, but it can be used as a startup script or - as I currently do - manually:
+
The script is quite basic, but can be run automatically at start-up, or manually using the command:
 +
sudo /etc/init.d/usbnet [start|stop]
 +
to activate or deactivate USB networking.
-
sudo /etc/init.d/usbnet start
+
There is a default USB network interface configuration on Nokia N800 and 770 tablets. In the file /etc/network/interfaces, you should see a section which looks like this:
-
activates the USB-networking while
+
-
 
+
-
sudo /etc/init.d/usbnet stop
+
-
deactivates, i.e. switches back to USB mass storage device mode.
+
-
 
+
-
While switching, it is important to have USB disconnected! Otherwise the kernel modules will be blocked.
+
-
 
+
-
I found that the usb0 configuration was already there in the SE2005 image on my Nokia. Check /etc/network/interfaces. Otherwise, you need to configure the network on the device by adding the following lines to /etc/network/interfaces on the 770 and comment out or delete the existing usb0-entry:
+
<pre>
<pre>
 +
auto usb0
iface usb0 inet static
iface usb0 inet static
       address 192.168.2.15
       address 192.168.2.15
       netmask 255.255.255.0
       netmask 255.255.255.0
-
       broadcast 192.168.2.255
+
       gateway 192.168.2.14
-
      up route add default gw 192.168.2.14
+
</pre>
</pre>
-
I.e. on the windows side, the USB cable will be 192.168.2.14, the Nokia's side will be 192.168.2.15. Feel free to change that as you like.
 
-
= Host Platform USB Network Configuration =
+
With this default configuration, the tablet interface will have the IP address 192.168.2.15, and the remote end will have the IP address 192.168.2.14.
-
The Nokia 770/n800 configuration was the focus of part I of the USB Networking document. In part II our attention is turned to the configuration of various host computers.
+
-
==Linux==
+
== Host USB Network Configuration ==
-
===Common Kernel Issues===
+
-
The focus of you Linux distribution will determine if you need to support this step or not. If the distro you use has a general purpose Linux kernel configured, then you may not need to worry about usbnet configuration support in the kernel.
+
-
<pre>
+
=== Windows ===
-
#
+
-
# USB Network Adapters
+
-
#
+
-
...
+
-
CONFIG_USB_USBNET=m
+
-
</pre>
+
-
The Linux usbnet configuration is show above.
+
====Requirements====
-
*Fedora You can locate this information by looking at the config* files in your grub /boot partition.  
+
* For Windows 2000, you will need to download [ RNDIS drivers] from Microsoft.
-
*Debian
+
* Download the file "Nokia770 USB Ethernet RNDIS.inf" from [http://homepage.hispeed.ch/mlivoncic/Nokia770%20USB%20Ethernet%20RNDIS.inf here] or [http://homepage.sunrise.ch/mysunrise/mlivoncic/Nokia770%20USB%20Ethernet%20RNDIS.inf here]. This allows to recognise that the RNDIS driver can be used with the Nokia device, and other Linux USB devices.
-
*Ubuntu
+
* [http://appcheck.net.temp.realssl.com/storage/Nokia900%20USB%20Ethernet%20RNDIS.inf Here] is an updated inf that should work on newer (32 or 64) bit Windows. It's not really tested much so please report results on the talk page!
-
*Suse
+
* If you are using an N800, skip all the steps below which apply to the N770; the bora distribution supplies a control panel applet called "maemo-statusbar-usbnet". Once installed, the control panel "Maemo-DM" will allow you to change the function of the USB port from "MMC emulation" to a RNDIS emulation of a USB ethernet interface. You will also need to set the WinXP side's IP address to be fixed at 192.168.2.14.
-
===Fedora Core===
+
-
===Debian===
+
==== Preparing the Windows host ====
-
There is another howto located here: [[USB Networking with Debian]] Note that this HOWTO recommends a different IP address configuration. If you don't want to change the config on the device you already setup, substitute 192.168.2.14 for 192.168.2.1 in the guide.
+
-
The Platform Document on USB Networking also describes a Debian PC setup.
+
On Windows 2000, dowload & unpack RNDIS-USB-Kit_05.exe [http://www.microsoft.com/whdc/device/network/NDIS/rndis.mspx on the Microsoft web site]. You need to copy rndismpy.sys (30 KB) and usb8023y.sys (14 KB) from
 +
RNDIS USB kit 2005\Drivers\x86fre\sys files
 +
to a folder of your choice, e.g. c:\Drivers\Nokia770_RNDIS. Add "Nokia770 USB Ethernet RNDIS.inf" to the same folder; this will complete your driver set.
-
==Windows==
+
When you connect the Nokia to the PC, it will look for a suitable driver. As opposed to the USB mass device mode, Windows will not find a suitable driver by default. Windows supports so-called RNDIS devices, but it does not know that the N770 will act as such. Therefore, we need to instruct it to do so: In the driver dialog, provide the driver's location. Point it to the directory where you previously downloaded the "Nokia770 USB Ethernet RNDIS.inf" (or linux.inf) file. It will show you a driver called ''Linux USB Ethernet/RNDIS Gadget''. Install it.
-
===Requirements===
+
A new network card with this name will become visible afterwards, which you can configure normally. Set the IP address to 192.168.2.14. Optionally activate ICS (Internet Connection Sharing) on your network adapter to share the outside world with your little Nokia.
-
*Windows XP SP2 contains the required .sys files.
+
-
*Windows 2000, you will need to download the RNDIS drivers from http://www.microsoft.com/whdc/device/network/NDIS/rndis.mspx.
+
=== Linux ===
-
*Download the file Nokia770 USB Ethernet RNDIS.inf from here or here It will instruct Windows XP that its built-in RNDIS driver is appropriate for Linux USB networking devices, and the Nokia 770 as such.
+
==== Kernel Configuration ====
 +
You should have the usbnet module available for your Linux kernel. On most distributions, this is the case by default. If this is not the case for your distribution, you will need to enable USB networking support in the kernel.
 +
If you build your own kernel then you want 'CDC Ethernet support' in USB Network adaptors.
-
*If you are using an N800, skip all the steps below which apply to the N770; the bora distribution supplies a control panel applet called "maemo-statusbar-usbnet". Once installed, the control panel "Maemo-DM" will allow you to change the function of the USB port from "MMC emulation" to a RNDIS emulation of a USB ethernet interface. You will also need to set the WinXP side's IP address to be fixed at 192.168.2.14.
+
<pre>
 +
#
 +
# USB Network Adapters
 +
#
 +
...
 +
CONFIG_USB_USBNET=m
 +
...
 +
CONFIG_USB_NET_CDCETHER=m
 +
...
 +
</pre>
-
This file is my updated/improved version of linux.inf from gumstix. The original version did not work with the current download for Windows 2000 from above.
+
==== NetworkManager based ====
-
I tried these 3 .inf files on a Windows2000 (5.00.2195 SP3) plateform, but none of them reconized the N770 (the list of drivers stays blank after selecting the directory where the .inf and .sys files are)... any ideas ?
+
A recent NetworkManager (at in least Fedora 12 and Ubuntu Karmic Koala) supports Ethernet USB gadgets out-of-the-box. However the 'auto usb0' entry that it creates amongst your connection list is configured for DHCP and the tablet will not provide that, so it will time out.
-
*...and of course, as usual, i.e. need to be root / have xterm on the Nokia 770.  
+
The easiest/cleanest way to get it to work is probably to create a new connection using the same MAC address as 'auto usb0' has, and then providing a fixed IP address: 192.168.2.14/255.255.255.0 for example, or change settings on the connection created by network-manager.
-
===Setting up your environment on Nokia 770===
+
==== Fedora ====
-
For convenience, I placed the following script /etc/init.d/usbnet on my Nokia:
+
Older Fedora versions also supports Ethernet USB gadgets out-of-the-box. To configure the USB networking:
-
<pre>
+
-
#! /bin/sh
+
-
#
+
-
# Startup script for USBnet (networking, instead of USB Mass Storage behaviour)
+
-
# Author: Michael Mlivoncic
+
-
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+
* Connect the tablet with g_ether.ko loaded to your Linux PC
-
NAME=usbnet
+
* Open System -> Administrate -> Network (or run system-config-network from command line).
-
DESC="USB Networking for Nokia 770"
+
* Press the "New" button to create a new network interface. Select "Ethernet" network card type.
-
INITFILE=/etc/init.d/$NAME
+
* On the next screen, select the "Netchip Technology, Inc. Linux-USB Ethernet/RNDIS Gadget (usb0)" or "Nokia Mobile Phones N900 (PC-Suite Mode)".
 +
* Choose "Static IP address" and enter the IP address 192.168.2.15 for your PC, if you are using the default usb0 configuration on your tablet. Don't fill the gateway field on the Fedora side.
 +
* Fill other settings (DNS etc) if you want to, then press "Finish".
-
case "$1" in
+
Now reconnect the tablet to PC and the interface should automatically configure.
-
start)
+
-
        USBNET="`lsmod | grep g_ether`"
+
-
        if [ "$USBNET" = "" ]
+
-
        then
+
-
          echo "entering Ethernet via USB mode (g_ether)..."
+
-
          insmod /mnt/initfs/lib/modules/current/g_ether.ko
+
-
          echo "waiting, then starting up the usb0.."
+
-
          sleep 1
+
-
          /sbin/ifup usb0
+
-
        else
+
-
          echo "already in Ethernet-via-USB mode..."
+
-
          echo "try ping 192.168.2.15"
+
-
        fi
+
-
        ;;
+
-
stop)
+
-
        echo "switching back to USB Mass Storage mode..."
+
-
        echo "removing module g_ether"
+
-
        /sbin/ifdown usb0
+
-
        sleep 2
+
-
        rmmod g_ether
+
-
        ;;
+
-
*)
+
-
        printf "Usage: $INITFILE {start|stop}\n" >&2
+
-
        exit 1
+
-
        ;;
+
-
esac
+
-
exit 0
+
==== Debian ====
-
</pre>
+
-
Definitely, there is some room for improvement, but it can be used as a startup script or - as I currently do - manually:
+
Ensure that the usbnet module is available to your kernel (try ''modprobe usbnet'', then ''lsmod'' to check).
-
sudo /etc/init.d/usbnet start
+
Add the following to /etc/network/interfaces:
-
activates the USB-networking while
+
<pre>
 +
allow-hotplug usb0
-
sudo /etc/init.d/usbnet stop
+
mapping hotplug
-
deactivates, i.e. switches back to USB mass storage device mode.
+
        script grep
 +
        map usb0
-
While switching, it is important to have USB disconnected! Otherwise the kernel modules will be blocked.
 
-
 
-
I found that the usb0 configuration was already there in the SE2005 image on my Nokia. Check /etc/network/interfaces. Otherwise, you need to configure the network on the device by adding the following lines to /etc/network/interfaces on the 770 and comment out or delete the existing usb0-entry:
 
-
<pre>
 
iface usb0 inet static
iface usb0 inet static
-
       address 192.168.2.15
+
       address 192.168.2.14
       netmask 255.255.255.0
       netmask 255.255.255.0
       broadcast 192.168.2.255
       broadcast 192.168.2.255
-
       up route add default gw 192.168.2.14
+
       up iptables -I INPUT 1 -s 192.168.2.15 -j ACCEPT
</pre>
</pre>
-
I.e. on the windows side, the USB cable will be 192.168.2.14, the Nokia's side will be 192.168.2.15. Feel free to change that as you like.
+
After plugging in the tablet, you can bring up the network interface with the command ''ifup usb0''.
-
===Preparing the Windows host===
+
==== Configuring the host as a gateway ====
-
When you connect the Nokia to the PC, it will look for a suitable driver. As opposed to the USB mass device mode, Windows will not find a suitable driver by default. Actually, Windows XP comes with built-in support for so called RNDIS devices, but it does not know that the N770 will act as such. Therefore, we need to instruct it to do so: In the driver dialog, choose that you will provide the driver's location. Point it to the directory where you previously downloaded the Nokia770 USB Ethernet RNDIS.inf (or linux.inf) file. It will show you a driver called ''Linux USB Ethernet/RNDIS Gadget''. Install it.
+
If your host has no firewalling rules, you can set the gateway rules by modifying /etc/interfaces file.
-
===Additional step for Windows 2000===
+
<pre>
-
As mentioned before, Windows 2000 lacks of the basic driver files. So, first unpack RNDIS-USB-Kit_05.exe you have downloaded above (266kB from July 2005). You only need to copy rndismpy.sys (30 KB) and usb8023y.sys (14 KB) from
+
iface usb0 inet static
 +
        address 192.168.2.14
 +
        netmask 255.255.255.0
 +
        up echo 1 > /proc/sys/net/ipv4/ip_forward
 +
        up iptables -P FORWARD ACCEPT
 +
        up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.2.0/24
 +
        down echo 0 > /proc/sys/net/ipv4/ip_forward
 +
        down iptables -t nat -F POSTROUTING
 +
</pre>
 +
Else add the necessary MASQUERADE rules to normal firewall rules.
-
RNDIS USB kit 2005\Drivers\x86fre\sys files
+
If you get the following error:
-
to a folder of your choice, e.g. c:\Drivers\Nokia770_RNDIS. Add Nokia770 USB Ethernet RNDIS.inf to the same folder; this will complete your driver set. As with Windows XP, now just install it from the Device Manager dialog.
+
<pre>
 +
iptables v1.2.11: can't initialize iptables table `NAT': Table does not exist (do you need to insmod?)
 +
Perhaps iptables or your kernel needs to be upgraded.
 +
</pre>
 +
You need verify that your kernel has the relevant iptables modules included, and hotplug or udev is set up properly on your computer.
-
A new network card with this name will become visible afterwards. I assume, you know or can figure out how to set up this network adapter. Minimally, set its IP-address to static 192.168.2.14. Optionally activate ICS (Internet Connection Sharing) on your network adapter to share the outside world with your little Nokia.
+
==== Configuring the host as a bridge ====
 +
Normally eth0 is on dhcp. This configuration allows my tablet to be on the same LAN as the rest of my boxes. You need the '''bridge''' module for 802.1d Ethernet Bridging installed.
-
===Testing the connection===
+
iface br0 inet dhcp
-
To test the connection, you can either type '''ping 192.168.2.15''' on your PC or vice versa, '''ping 192.168.2.14''' in the xterm.
+
          hostname ash
 +
          pre-up  echo    "Adding ethernet bridge between LAN and PAN"
 +
          pre-up  ifconfig eth0 0.0.0.0
 +
          pre-up  brctl    addbr br3
 +
          pre-up  brctl    setfd br3 0
 +
          pre-up  brctl    stp br3 off
 +
          pre-up  brctl    addif br3 eth0       
 +
          pre-down echo    "Removing ethernet bridge between LAN and PAN"
 +
          post-down brctl    delif br3 eth0
 +
          post-down brctl    delbr br3
 +
          post-down ifdown eth0
 +
          post-down ifup eth0
-
For troubleshooting, use '''ifconfig -a''' and route to verify on the Nokia, '''ipconfig /all''' and '''route print'''.
+
I do
 +
  ifup br0
-
===Known issues===
+
And the tablet is then on the LAN.
-
As opposed to connecting with a Debian host, I realize some problems when unplugging and replugging the USB cable between the two devices - Windows will indicate a code 10-error indicating that the device could not start properly. The problem seems to be actually on the Nokia side - as rebooting the device helps. So, make sure to first initialize g_ether, then connect the cable and enjoy networking.
+
-
Probably some background service on the N770 interferes with unloading/loading sequence of g_ether and g_mass_storage. i.e. some task mounts/unmounts MMC card when plugging in USB.
+
==== Configuring the host firewall ====
-
I would highly appreciate any comments on this - Does re-connecting USB work for you? Seems to work fine with XP together with IT2006.
+
If you have your Linux host configured with a strict firewall, you may need to modify your iptables to allow the tablet to access the internet over USB networking.
-
Does anyone know a fix for this?
+
-
===Final remarks===
+
To allow access both to & from the tablet, the following iptables rules are required:
-
I have my Nokia 770 now for almost a week. A impressive little Linux box. I like the BT networking as it consumes less battery than WLAN. Now, It is even a USB network card (or even a USB to BT and WLAN dongle). Many of the Howtos here were very useful (especially Swap device, BT networking, BT OBEX,...) So, hope you enjoy my contribution and do not hesitate to add some stuff.
+
-
A few ideas about how to use this feature: I already have OpenSSH on the Nokia. So, if the PC has WinSCP installed, you can browse the Filesystem or copy files to the MMC card (other than the first partition, as it is automatically deactivated when USB is plugged in; however you can re-mount it with
+
  iptables -A OUTPUT -o usb0 -j ACCEPT
 +
  iptables -A INPUT -i usb0 -j ACCEPT
-
mount /media/mmc1
+
=== Testing the connection ===
 +
To test the connection, you can either type ''ping 192.168.2.15'' on your PC or ''ping 192.168.2.14'' in an xterm on your tablet.
 +
For troubleshooting, use ''ifconfig -a'' and ''route'' to verify on the Nokia and on a Linux or Unix PC, and ''ipconfig /all'' and ''route print'' on Windows.
-
As I mentioned at the beginning, my PC has the faster USB interface. Now, when I'm connected, I can backup the whole root-fs to my Linux box with maximum performance.
+
=== Known issues ===
 +
When unplugging and replugging the USB cable between the two devices, Windows will indicate a code 10-error indicating that the device could not start properly. The problem appears to be with the Nokia tablet, since after rebooting the device, networking works again. Remember to first initialize g_ether before plugging your tablet into the USB host.
-
<PRE>rsync -avzxlrP <del>delete </del>inplace --numeric-ids  / 192.168.8.4:/Nokia770_Backup</PRE>
+
This seems to be the case with Ubuntu too. Replugging causes following messages appear in the kernel log:
-
Why am I backuping everything? If I ever screw it up again (before SE2006), I hope to be able to use the trick from http://maemo.org/maemowiki/ModifyingRootImage and flash my backup back onto the device.
+
<pre>
 +
[182104.412082] usb 3-1: new full speed USB device using uhci_hcd and address 29
 +
[182104.824071] usb 3-1: device not accepting address 29, error -71
 +
[182104.824100] hub 3-0:1.0: unable to enumerate USB device on port 1
 +
</pre>
-
I will let you guys know ;-)
+
Rebooting the tablet seems to work.
-
===Windows 98 and ME===
+
=== Frequently asked questions ===
-
Any chance that these OSes might support USB networking?
+
-
 
+
-
Since the first thing I would do with a computer of mine that ran these OSes was to get rid of them I'm talking about other people's computers, and I need to be sure I won't break anything. So I'm not gonna try out stuff myself.
+
-
 
+
-
===Questions about these procedures===
+
# So if we have already plugged in our 770 into XP, and it recognized it as a drive, do we need to remove the driver software that makes it appear as a USB drive, and replace it with the USBNet drivers?  
# So if we have already plugged in our 770 into XP, and it recognized it as a drive, do we need to remove the driver software that makes it appear as a USB drive, and replace it with the USBNet drivers?  
-
#* No, windows will assume it is a different device, so no conflict with the update/storage/network drivers for the Nokia770.  
+
#* No, windows registers the tablet in network mode as a different device.  
-
#* However, as stated above: you have to insmod the kernel module on the N770 before you connect the cable!
+
#* However, as stated above: you have to insmod the kernel module on your tablet before you connect the cable!
-
# When I try to do the above, I get an error stating that the driver I am trying to choose doesn't have anything to do with my hardware.  
+
# When I try to do the above, I get an error stating that the driver I am trying to choose doesn't have anything to do with my hardware.
-
#* Make sure you have activated USB networking on the Nokia side correctly. I'm also using 2006OS Beta if that makes a difference
+
#* Make sure you have activated USB networking on the Nokia side correctly.
-
#* Haven't tried with the Beta, but with the official release from 06/30/2006.
+
# My tablet can now talk to my XP machine, but how do I get out to the rest of the network?
# My tablet can now talk to my XP machine, but how do I get out to the rest of the network?
-
Firstly, set up a dummy access point, as described above, so that you can configure the network settings in connection manager for your usbnet connection. This will allow you to configure proxy server access. Secondly, install a proxy on your local machine. Examples include [http://www.proxomitron.info/ proxomitron] or [http://www.handcraftedsoftware.org/ freeproxy].
+
#:First, set up a dummy access point, as described above, so that you can configure the network settings in connection manager for your usbnet connection. This will allow you to configure proxy server access. Secondly, install a proxy on your local machine. Examples include [http://www.proxomitron.info/ proxomitron] or [http://www.handcraftedsoftware.org/ freeproxy].
-
 
+
# How do I set up DNS once I have connected the tablet and the host?
-
=Other Notes=
+
#* Install and configure pdnsd on your host computer, and add nameserver 192.168.2.14 to the file /etc/resolv.conf on your tablet.
-
It is possible to have the MMC cards available for local use on the device (but not available for the computer) while using USB Networking. See here: How_to_use_both_USB_networking_and_the_memory_card_at_the_same_time
+
#* or configure the host as a gateway, and use the same DNS servers as your host (without messing up /etc/resolv.conf and the dnsmasq server):
 +
#::echo "nameserver xxx.xxx.xxx.xxx" >> /tmp/resolv.conf.ppp0
 +
#::where xxx.xxx.xxx.xxx is the dns server of the host (  as found in /etc/resolv.conf on the host linux box )
 +
#::echo again the second address if required.
 +
#::Don't forget to choose "dummy" from the wireless connection manager on the tablet and do 'ifup usb0' on the Linux box.
 +
#How do I keep my SD memory cards from being unmounted?
 +
#* Before you plug in the usb cable; open two xterminals and cd one to /media/mmc1 and the other to /media/mmc2 and leave them there. By keeping a foot in the door the cards are kept available ... the usbnet will still succeed.
[[Category:Users]]
[[Category:Users]]
-
[[Category:Midgard wiki]]
+
[[Category:Wiki page of the day]]
 +
[[Category:Connectivity]]
 +
[[Category:USB]]
 +
 
 +
[[Category:Power users]]

Latest revision as of 20:29, 21 August 2010

This page describes how the maemo platform can be turned into a USB network device. The first part describes how to configure the Nokia tablet as a USB pluggable network device. The second part describes how to configure various platforms to use the Nokia tablet as a network device. This article is based loosely on the Maemo 3.x configuring USB networking HOWTO.

You might want to use the tablet as a USB network device to log into your tablet remotely, or to transfer data from your tablet to another computer, in a situation where wifi or bluetooth are not an option. If you wish to connect your tablet to a Linux machine over TCP/IP, the PC connectivity section in the Maemo SDK documentation also contains useful information.

WARNING Currently there is a bug in the g_ether.ko driver of OS2008 (both 4.0.1 and 4.1) which prevents USB networking from working correctly with Windows machines (but not with Linux machines). See bug #3243 for details. The bug was introduced somewhere between kernels 2.6.18 and 2.6.21, so Maemo versions based on 2.6.18 kernels (e.g. OS2007 and earlier) will work.

Contents

[edit] USB networking for N900

Please visit N900 USB networking.

[edit] Tablet USB network configuration

[edit] USB statusbar plugin

The usb-otg-plugin applet lets you set up USB networking tablet-side, and switch between host and client mode. This is the easy way to do things and no other tablet-side configuration is required.

Alternatively you could try the usb networking applet found here:

 http://repository.maemo.org/extras-devel/pool/diablo/free/m/maemo-control/

[edit] Behind the scenes

In normal circumstances, the USB Mass storage driver had control of the USB hardware. USBNet allows the g_ether network driver to take control of the USB interface.

After installing USB networking, set up a dummy access point by running the following:

gconftool-2 -s -t string /system/osso/connectivity/IAP/DUMMY/type DUMMY
gconftool-2 -s -t string /system/osso/connectivity/IAP/DUMMY/name 'Dummy network'
gconftool-2 -s -t boolean /system/osso/connectivity/IAP/DUMMY/autoconnect true

You should see a "DEFAULT" connection appear in the connection manager.

WARNING Currently there is a bug in Diablo that causes DUMMY connections not to show up in connection manager, a semi-official fix is outlined in bug #3306.

[edit] Starting and stopping USB network mode

To easily start & stop USB network mode, place the following script in /etc/init.d/usbnet on your tablet. To do this, you will need root access to the device.

While switching between modes by running the script, it is important to disconnect the USB cable.

#! /bin/sh
#
# Startup script for USBnet (networking, instead of USB Mass Storage behaviour)
# Author: Michael Mlivoncic

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=usbnet
DESC="USB Networking for Nokia Internet Tablets"
INITFILE=/etc/init.d/$NAME

case "$1" in
start)
        umount /media/mmc1
        umount /media/mmc2
        sleep 2
        USBNET="`lsmod | grep g_ether`"
        KERNEL_VERSION="`uname -r`"
        if [ "$USBNET" = "" ]
        then
           echo "Entering Ethernet via USB mode (g_ether)..."
           insmod /mnt/initfs/lib/modules/$KERNEL_VERSION/g_ether.ko
           echo "Waiting, then bringing up the usb0 interface.."
           sleep 1
           /sbin/ifup usb0
        else
          echo "Already in Ethernet-via-USB mode..."
          echo "Try ping 192.168.2.15"
        fi
        ;;
stop)
         echo "switching back to USB Mass Storage mode..."
         echo "removing module g_ether"
         /sbin/ifdown usb0
         sleep 2
         rmmod g_ether
        ;;
*)
        printf "Usage: $INITFILE {start|stop}\n" >&2
        exit 1
        ;;
esac

exit 0

The script needs to have executable permissions, which you can give with

sudo chmod a+x /etc/init.d/usbnet

The script is quite basic, but can be run automatically at start-up, or manually using the command:

sudo /etc/init.d/usbnet [start|stop]

to activate or deactivate USB networking.

There is a default USB network interface configuration on Nokia N800 and 770 tablets. In the file /etc/network/interfaces, you should see a section which looks like this:

auto usb0
iface usb0 inet static
       address 192.168.2.15
       netmask 255.255.255.0
       gateway 192.168.2.14

With this default configuration, the tablet interface will have the IP address 192.168.2.15, and the remote end will have the IP address 192.168.2.14.

[edit] Host USB Network Configuration

[edit] Windows

[edit] Requirements

  • For Windows 2000, you will need to download [ RNDIS drivers] from Microsoft.
  • Download the file "Nokia770 USB Ethernet RNDIS.inf" from here or here. This allows to recognise that the RNDIS driver can be used with the Nokia device, and other Linux USB devices.
  • Here is an updated inf that should work on newer (32 or 64) bit Windows. It's not really tested much so please report results on the talk page!
  • If you are using an N800, skip all the steps below which apply to the N770; the bora distribution supplies a control panel applet called "maemo-statusbar-usbnet". Once installed, the control panel "Maemo-DM" will allow you to change the function of the USB port from "MMC emulation" to a RNDIS emulation of a USB ethernet interface. You will also need to set the WinXP side's IP address to be fixed at 192.168.2.14.

[edit] Preparing the Windows host

On Windows 2000, dowload & unpack RNDIS-USB-Kit_05.exe on the Microsoft web site. You need to copy rndismpy.sys (30 KB) and usb8023y.sys (14 KB) from

RNDIS USB kit 2005\Drivers\x86fre\sys files

to a folder of your choice, e.g. c:\Drivers\Nokia770_RNDIS. Add "Nokia770 USB Ethernet RNDIS.inf" to the same folder; this will complete your driver set.

When you connect the Nokia to the PC, it will look for a suitable driver. As opposed to the USB mass device mode, Windows will not find a suitable driver by default. Windows supports so-called RNDIS devices, but it does not know that the N770 will act as such. Therefore, we need to instruct it to do so: In the driver dialog, provide the driver's location. Point it to the directory where you previously downloaded the "Nokia770 USB Ethernet RNDIS.inf" (or linux.inf) file. It will show you a driver called Linux USB Ethernet/RNDIS Gadget. Install it.

A new network card with this name will become visible afterwards, which you can configure normally. Set the IP address to 192.168.2.14. Optionally activate ICS (Internet Connection Sharing) on your network adapter to share the outside world with your little Nokia.

[edit] Linux

[edit] Kernel Configuration

You should have the usbnet module available for your Linux kernel. On most distributions, this is the case by default. If this is not the case for your distribution, you will need to enable USB networking support in the kernel. If you build your own kernel then you want 'CDC Ethernet support' in USB Network adaptors.

#
# USB Network Adapters
#
...
CONFIG_USB_USBNET=m
...
CONFIG_USB_NET_CDCETHER=m
...

[edit] NetworkManager based

A recent NetworkManager (at in least Fedora 12 and Ubuntu Karmic Koala) supports Ethernet USB gadgets out-of-the-box. However the 'auto usb0' entry that it creates amongst your connection list is configured for DHCP and the tablet will not provide that, so it will time out.

The easiest/cleanest way to get it to work is probably to create a new connection using the same MAC address as 'auto usb0' has, and then providing a fixed IP address: 192.168.2.14/255.255.255.0 for example, or change settings on the connection created by network-manager.

[edit] Fedora

Older Fedora versions also supports Ethernet USB gadgets out-of-the-box. To configure the USB networking:

  • Connect the tablet with g_ether.ko loaded to your Linux PC
  • Open System -> Administrate -> Network (or run system-config-network from command line).
  • Press the "New" button to create a new network interface. Select "Ethernet" network card type.
  • On the next screen, select the "Netchip Technology, Inc. Linux-USB Ethernet/RNDIS Gadget (usb0)" or "Nokia Mobile Phones N900 (PC-Suite Mode)".
  • Choose "Static IP address" and enter the IP address 192.168.2.15 for your PC, if you are using the default usb0 configuration on your tablet. Don't fill the gateway field on the Fedora side.
  • Fill other settings (DNS etc) if you want to, then press "Finish".

Now reconnect the tablet to PC and the interface should automatically configure.

[edit] Debian

Ensure that the usbnet module is available to your kernel (try modprobe usbnet, then lsmod to check).

Add the following to /etc/network/interfaces:

allow-hotplug usb0

mapping hotplug
        script grep
        map usb0

iface usb0 inet static
       address 192.168.2.14
       netmask 255.255.255.0
       broadcast 192.168.2.255
       up iptables -I INPUT 1 -s 192.168.2.15 -j ACCEPT

After plugging in the tablet, you can bring up the network interface with the command ifup usb0.

[edit] Configuring the host as a gateway

If your host has no firewalling rules, you can set the gateway rules by modifying /etc/interfaces file.

iface usb0 inet static
        address 192.168.2.14
        netmask 255.255.255.0
        up echo 1 > /proc/sys/net/ipv4/ip_forward
        up iptables -P FORWARD ACCEPT
        up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.2.0/24
        down echo 0 > /proc/sys/net/ipv4/ip_forward
        down iptables -t nat -F POSTROUTING

Else add the necessary MASQUERADE rules to normal firewall rules.

If you get the following error:

iptables v1.2.11: can't initialize iptables table `NAT': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.

You need verify that your kernel has the relevant iptables modules included, and hotplug or udev is set up properly on your computer.

[edit] Configuring the host as a bridge

Normally eth0 is on dhcp. This configuration allows my tablet to be on the same LAN as the rest of my boxes. You need the bridge module for 802.1d Ethernet Bridging installed.

iface br0 inet dhcp
         hostname ash
         pre-up   echo     "Adding ethernet bridge between LAN and PAN"
         pre-up   ifconfig eth0 0.0.0.0
         pre-up   brctl    addbr br3
         pre-up   brctl    setfd br3 0
         pre-up   brctl    stp br3 off
         pre-up   brctl    addif br3 eth0         
         pre-down echo     "Removing ethernet bridge between LAN and PAN"
         post-down brctl    delif br3 eth0
         post-down brctl    delbr br3
         post-down ifdown eth0
         post-down ifup eth0

I do

 ifup br0

And the tablet is then on the LAN.

[edit] Configuring the host firewall

If you have your Linux host configured with a strict firewall, you may need to modify your iptables to allow the tablet to access the internet over USB networking.

To allow access both to & from the tablet, the following iptables rules are required:

 iptables -A OUTPUT -o usb0 -j ACCEPT
 iptables -A INPUT -i usb0 -j ACCEPT

[edit] Testing the connection

To test the connection, you can either type ping 192.168.2.15 on your PC or ping 192.168.2.14 in an xterm on your tablet.

For troubleshooting, use ifconfig -a and route to verify on the Nokia and on a Linux or Unix PC, and ipconfig /all and route print on Windows.

[edit] Known issues

When unplugging and replugging the USB cable between the two devices, Windows will indicate a code 10-error indicating that the device could not start properly. The problem appears to be with the Nokia tablet, since after rebooting the device, networking works again. Remember to first initialize g_ether before plugging your tablet into the USB host.

This seems to be the case with Ubuntu too. Replugging causes following messages appear in the kernel log:

[182104.412082] usb 3-1: new full speed USB device using uhci_hcd and address 29
[182104.824071] usb 3-1: device not accepting address 29, error -71
[182104.824100] hub 3-0:1.0: unable to enumerate USB device on port 1

Rebooting the tablet seems to work.

[edit] Frequently asked questions

  1. So if we have already plugged in our 770 into XP, and it recognized it as a drive, do we need to remove the driver software that makes it appear as a USB drive, and replace it with the USBNet drivers?
    • No, windows registers the tablet in network mode as a different device.
    • However, as stated above: you have to insmod the kernel module on your tablet before you connect the cable!
  2. When I try to do the above, I get an error stating that the driver I am trying to choose doesn't have anything to do with my hardware.
    • Make sure you have activated USB networking on the Nokia side correctly.
  3. My tablet can now talk to my XP machine, but how do I get out to the rest of the network?
    First, set up a dummy access point, as described above, so that you can configure the network settings in connection manager for your usbnet connection. This will allow you to configure proxy server access. Secondly, install a proxy on your local machine. Examples include proxomitron or freeproxy.
  4. How do I set up DNS once I have connected the tablet and the host?
    • Install and configure pdnsd on your host computer, and add nameserver 192.168.2.14 to the file /etc/resolv.conf on your tablet.
    • or configure the host as a gateway, and use the same DNS servers as your host (without messing up /etc/resolv.conf and the dnsmasq server):
    echo "nameserver xxx.xxx.xxx.xxx" >> /tmp/resolv.conf.ppp0
    where xxx.xxx.xxx.xxx is the dns server of the host ( as found in /etc/resolv.conf on the host linux box )
    echo again the second address if required.
    Don't forget to choose "dummy" from the wireless connection manager on the tablet and do 'ifup usb0' on the Linux box.
  5. How do I keep my SD memory cards from being unmounted?
    • Before you plug in the usb cable; open two xterminals and cd one to /media/mmc1 and the other to /media/mmc2 and leave them there. By keeping a foot in the door the cards are kept available ... the usbnet will still succeed.