N900 USB networking

This page describes how to enable Networking on the N900 via USB. The first part describes how to configure the Nokia N900 as a USB pluggable network device. The second part describes how to configure various platforms to use the Nokia N900 as a network device. This article is based on the Maemo 4.x wiki for configuring USB networking.

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

Contents

N900 USB network configuration

There is a default USB network interface configuration on Nokia N900. 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

You can also add the following lines to set the default route correctly

      up route del default
      up route add default gw  192.168.2.14

and

      up run-standalone.sh dbus-send --type=method_call --system --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:DUMMY uint32:0
      down run-standalone.sh dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true

to properly set/reset the connection manager on connection/disconnection especially if you have set up a DUMMY network as decribed later.


With this default configuration, the N900 USB interface will have the IP address 192.168.2.15, and the remote end will have the IP address 192.168.2.14. By default, the USB network interface on the N900 is configured. You need to install the package usb-network-modules.

Starting USB network mode

Plug one end of the USB cable on the host and the other end into the N900. The N900 will bring up the mode-selection dialog. Select 'PC Suite mode'.


USB Mode-Selection dialog


Open a root shell in 'X Terminal' on the N900 and activate the interface by executing the following:

sudo gainroot
ifup usb0

If all went well, no errors will be displayed. The command 'ifconfig usb0' will give the following output:

Nokia-N900-42-11:~# ifconfig usb0
usb0      Link encap:Ethernet  HWaddr F2:50:8F:04:1D:8B  
          inet addr:192.168.2.15  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1021 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2003 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:86091 (84.0 KiB)  TX bytes:2556598 (2.4 MiB)

You should also be able to ping 192.168.2.15

Nokia-N900-42-11:~# ping 192.168.2.15
PING 192.168.2.15 (192.168.2.15): 56 data bytes
64 bytes from 192.168.2.15: seq=0 ttl=64 time=0.367 ms
64 bytes from 192.168.2.15: seq=1 ttl=64 time=0.214 ms
^C
--- 192.168.2.15 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.214/0.290/0.367 ms

If you can not ping the outside world (for example: local network works but Google does not), check your routing tables.

/home/user # route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.2.0     *               255.255.255.0   U     0      0        0 usb0
default         192.168.2.14    0.0.0.0         UG    0      0        0 usb0
default         *               0.0.0.0         U     0      0        0 gprs0

If you have a situation like above where the cell network's packets are at a lower default priority, you might have to run the following to fix it:

/home/user # route del default
/home/user # route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.2.0     *               255.255.255.0   U     0      0        0 usb0
default         *               0.0.0.0         U     0      0        0 gprs0
/home/user # ping google.com
PING google.com (74.125.45.103): 56 data bytes
64 bytes from 74.125.45.103: seq=0 ttl=51 time=257.081 ms
64 bytes from 74.125.45.103: seq=1 ttl=51 time=236.481 ms
64 bytes from 74.125.45.103: seq=2 ttl=51 time=256.226 ms
^C
--- google.com ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 236.481/249.929/257.081 ms

If after having fixed the routing table you still are not able to ping the outside world try to add a nameserver to /etc/resolv.conf

nameserver 127.0.0.1
# added Google DNS
nameserver 8.8.8.8
nameserver 8.8.4.4

Stopping USB network mode

This is optional. It is not necessary to stop the interface after unplugging the USB cable.

However, to stop the USB interface, unplug the USB cable and execute the following in 'X Terminal'

sudo gainroot
ifdown usb0

Host USB Network Configuration

The Host configuration is detailed in the Maemo 4.x USB Networking wiki. Please refer to it for details.

FIXME, there is no usb host mode on n900

Host configuration on Debian Lenny

Create the file in /etc/udev/rules.d/99-nokia-n900.rules and put in the following lines:

SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="0421", ATTRS{idProduct}=="01c8", ATTRS{manufacturer}=="Nokia", ATTRS{product}=="N900 (PC-Suite Mode)", NAME="n900"
#SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="0421", ATTRS{idProduct}=="01c8", ATTRS{manufacturer}=="Nokia", ATTRS{product}=="N900 (PC-Suite Mode)", NAME="n900p"

You have to reload udev rules with:

udevadm control --reload-rules

Then edit /etc/network/interfaces and add:

allow-hotplug n900
auto n900
iface n900 inet static
	address 192.168.2.14
	netmask 255.255.255.0
	up iptables -A POSTROUTING -t nat -s 192.168.2.15/32 -j MASQUERADE
	up echo 1 > /proc/sys/net/ipv4/ip_forward
        down iptables -D POSTROUTING -t nat -s 192.168.2.15/32 -j MASQUERADE
	down echo 0 > /proc/sys/net/ipv4/ip_forward

Now put your usb cable in the pc and in the n900 and on the host. To check that everything is set up properly you can run:

ifconfig n900

Automatic configuration with ubuntu 9.10

Note: this instructions should be fixed/improved:

Create the file in /etc/udev/rules.d/99-nokia-n900.rules and put in the following lines:

SUBSYSTEM=="net", ACTION=="add", ENV{ID_USB_DRIVER}=="cdc_ether", ENV{ID_MODEL}="N900__PC-Suite_Mode", ENV{ID_VENDOR}=="Nokia", NAME="n900"
SUBSYSTEM=="net", ACTION=="add", ENV{ID_USB_DRIVER}=="cdc_phonet", ENV{ID_MODEL}="N900__PC-Suite_Mode", ENV{ID_VENDOR}=="Nokia", NAME="n900pn"

Then edit /etc/network/interfaces and add:

auto n900
iface n900 inet static
	address 192.168.2.14
	netmask 255.255.255.0
	up iptables -A POSTROUTING -t nat -s 192.168.2.15/32 -j MASQUERADE
	up echo 1 > /proc/sys/net/ipv4/ip_forward
        down iptables -D POSTROUTING -t nat -s 192.168.2.15/32 -j MASQUERADE
	down echo 0 > /proc/sys/net/ipv4/ip_forward

finally you have to fix /etc/init/network-interface.conf, change the line:

stop on net-device-removed INTERFACE=$INTERFACE

with:

stop on net-device-remove INTERFACE=$INTERFACE

(Note the difference: net-device-removed)


You have to reload udev rules with:

udevadm control --reload-rules

Now put your usb cable in the pc and in the n900.

If all went fine:

  • you should see with ifconfig -a two new network interfaces, n900 and n900pn, the first one configured with the proper ip address 192.168.2.15, and should be able to ping the n900.
  • the n900 should be able to use the pc internet connection immediately.

Windows XP

Windows XP USB networking does not work out of the box, but the old 770 workaround still works. So follow these steps:

  • install the Mad Developer application and start it.
  • click on "Manage Usb" and then on "Load g_ether"
  • plug the device into the USB port. Windows will ask you to name a device driver for the RNDIS gadget. Select a device driver by hand and choose the linux.inf from the USB_networking page.
  • open a terminal on the N900 and get root e.g. via "sudo gainroot". Type "ifconfig usb0 192.168.0.1"
  • Now windows should display the network as connected. Set the PC ip address in the windows connections dialog.
  • Now you should be able to ping the device but not the other way round as Windows still filters the traffic. However everything else should work, e.g. MADDE

Using the usb networking for maemo apps

By default standard network apps works well with usb networking, while maemo specific apps not.

Install libicd-network-dummy from Fremantle Nokia-binaries repository or better libicd-network-null from extras-devel, and when usb networking is up pickup "Dummy network" from the connection manager. If the dummy network does not show up in the network manager you could run the following commands in xterm:

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"

and maybe

gconftool-2 -s -t string /system/osso/connectivity/IAP/DUMMY/autoconnect false

Then restart icd2:

killall icd2

or reboot the device.