N900 USB networking

(Host configuration on Debian Lenny)
(Added instructions to prevent "Dummy Network" from being used when "Any Connection" is selected + the USB cable is not connected.)
Line 1: Line 1:
-
This page describes how to enable Networking on the [[Nokia N900|N900]] via [[USB]]. The first part describes how to configure the 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 [[USB networking|Maemo 4.x USB networking article]].
 
-
 
-
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 [http://maemo.org/development/documentation/pc_connectivity/ PC connectivity] section in the Maemo SDK documentation also contains useful information.
 
-
 
-
== N900 USB network configuration ==
 
-
 
-
There is a default USB network interface configuration on Nokia N900. In the file <code>/etc/network/interfaces</code>, you should see a section which looks like this:
 
-
<pre>
 
-
auto usb0
 
-
iface usb0 inet static
 
-
      address 192.168.2.15
 
-
      netmask 255.255.255.0
 
-
      gateway 192.168.2.14
 
-
</pre>
 
-
 
-
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'.
 
-
 
-
 
-
[[Image:Mode-selection.png|center|alt=USB Mode-Selection dialog|USB Mode-Selection dialog]]
 
-
 
-
 
-
Open a [[root access|root shell]] in [[terminal|X Terminal]] on the N900 and activate the interface by executing the following:
 
-
<pre>
 
-
sudo gainroot
 
-
ifup usb0
 
-
</pre>
 
-
 
-
If all went well, no errors will be displayed. The command 'ifconfig usb0' will give the following output:
 
-
<pre>
 
-
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)
 
-
</pre>
 
-
 
-
You should also be able to ping 192.168.2.15
 
-
<pre>
 
-
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
 
-
</pre>
 
-
 
-
To automatically setup usb0 when entering PC suite mode change the last few lines of <code>/usr/sbin/pcsuite-enable.sh</code> by adding the "ifup usb0" line.
 
-
<pre>
 
-
logger "$0: sent SIGUSR1 to syncd"
 
-
ifup usb0
 
-
exit 0
 
-
</pre>
 
-
 
-
And, to automatically down your usb0 interface when leaving PC suite mode, add to <code>/usr/sbin/pcsuite-disable.sh</code>
 
-
<pre>
 
-
ifdown usb0
 
-
exit 0
 
-
</pre>
 
-
 
-
In fact if you want to use the `Mail to exchange' feature to synchronize mail, calendar or contacts with an exchange server (such as Google mail) the 'PC suite mode' might block the exchange. So do not use it when connected in that mode, instead choose the 'charging only' mode instead. This
 
-
mode can be achieved by choosing neither of the offers in the above menu. Simply tap above the menu to close it. This 'charging only' mode still gives you the usb0 interface provided that you initialized it
 
-
once through the 'PC suite mode'.
 
-
 
-
If you can not ping the outside world (for example: local network works but Google does not), check your routing tables.
 
-
<pre>
 
-
/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
 
-
</pre>
 
-
 
-
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:
 
-
<pre>
 
-
/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
 
-
</pre>
 
-
 
-
If after having fixed the routing table you still are not able to ping the outside world try to add a nameserver to <code>/etc/resolv.conf</code>
 
-
 
-
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'
 
-
<pre>
 
-
sudo gainroot
 
-
ifdown usb0
 
-
</pre>
 
-
 
-
=== Fixing the MAC address ===
 
-
 
-
By default, the N900 sets a random MAC address for the USB interface every time you reboot.
 
-
This makes some operating systems (Mac OS X) detect a new device whenever you connect the N900
 
-
and ask you to configure the network interface. The solutions is to set a fixed MAC address
 
-
<pre>
 
-
sudo gainroot
 
-
echo options g_nokia host_addr=00:11:22:33:44:55 > /etc/modprobe.d/g_nokia
 
-
</pre>
 
-
After the next reboot your N900 will always be detected as the same device.
 
-
 
-
== Host USB Network Configuration ==
 
-
 
-
The Host configuration is detailed in the [[USB networking#Host_USB_Network_Configuration|Maemo 4.x  USB Networking article]]. 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"
 
-
 
-
The second rule is commented out as it is not needed for usb networking.
 
-
A different approach uses a DEVPATH key:
 
-
 
-
SUBSYSTEM=="net", ACTION=="add", DEVPATH=="/devices/pci0000:00/0000:00:1a.7/usb1/1-2/1-2:1.8/net/usb0", ATTRS{idVendor}=="0421", ATTRS{idProduct}=="01c8", ATTRS{manufacturer}=="Nokia", ATTRS{product}=="N900 (PC-Suite Mode)", NAME="n900"
 
-
SUBSYSTEM=="net", ACTION=="add", DEVPATH=="/devices/pci0000:00/0000:00:1a.7/usb1/1-2/1-2:1.0/net/usbpn0", ATTRS{idVendor}=="0421", ATTRS{idProduct}=="01c8", ATTRS{manufacturer}=="Nokia", ATTRS{product}=="N900 (PC-Suite Mode)", NAME="n900p"
 
-
 
-
Your DEVPATH may be different though, depending on which USB port is used on the host computer etc, so to make this work reliably you have to use always
 
-
the same usb port.
 
-
 
-
You can use
 
-
 
-
udevadm monitor --kernel
 
-
 
-
while plugging in the N900 to see what is the correct path.
 
-
 
-
After adding the udev rules, you have to reload them with:
 
-
udevadm control --reload-rules
 
-
 
-
Then edit <code>/etc/network/interfaces</code> and add:
 
-
<pre>
 
-
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
 
-
</pre>
 
-
 
-
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/10.04 ===
 
-
 
-
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 <code>/etc/network/interfaces</code> and add:
 
-
<pre>
 
-
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
 
-
</pre>
 
-
 
-
For 9.10 (NOT 10.04) you have to fix <code>/etc/init/network-interface.conf</code>, change the line:
 
-
stop on net-device-removed INTERFACE=$INTERFACE
 
-
with:
 
-
stop on net-device-remove INTERFACE=$INTERFACE
 
-
(Note the difference: net-device-remove'''d''')
 
-
 
-
You have to reload udev rules with:
 
-
udevadm control --reload-rules
 
-
 
-
You have to restart NetworkManager so it re-reads the interfaces file (otherwise it'll clobber your network device):
 
-
sudo /etc/init.d/network-manager restart
 
-
or
 
-
sudo service network-manager restart
 
-
 
-
Now put your USB cable in the PC and in the N900.
 
-
 
-
If you are unable to autoconnect through the networking applet, you may need to manually bring up the interface:
 
-
ifup n900
 
-
 
-
If all went fine:
 
-
* you should see with <code>ifconfig -a</code> 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 ===
 
-
 
-
Windows USB networking does not work out of the box, but the old 770 workaround still works.
 
-
So follow these steps:
 
-
# install the [[MADDE|Mad Developer]] application and start it and press "Manage USB" -> "Load g_either" -> "close".
 
-
# enter the following IP: 192.168.1.30, then press "configure" (this address will be used for the SCP client as well).
 
-
# connect your N900 via USB and select the older "Nokia770 USB Ethernet RNDIS.inf" driver(32bit only) from the [[USB_networking]] section or [http://appcheck.net.temp.realssl.com/storage/Nokia900%20USB%20Ethernet%20RNDIS.inf the newer(32 and 64bit) driver.]
 
-
# then change the IP, Gateway and DNS of the newly created network connection to 192.168.1.31.
 
-
# when you have finished USB networking, re-enable mass storage mode by pressing: "Manage USB" -> "Load g_nokia" -> "close".
 
-
 
-
=== Mac OS X ===
 
-
 
-
OS X will detect a new network interface and ask you to configure it. Choose DHCP with manual address and set the IP address to 192.168.2.14
 
-
 
-
To use the Internet connection of your Mac via USB networking make sure to enable System Preferences -> Sharing -> Internet sharing for the N900 interface [http://docs.info.apple.com/article.html?path=Mac/10.5/en/8156.html Howto]
 
-
 
== Using USB networking for Maemo applications ==
== Using USB networking for Maemo applications ==
Line 258: Line 12:
  gconftool-2 -s -t string /system/osso/connectivity/IAP/DUMMY/autoconnect false
  gconftool-2 -s -t string /system/osso/connectivity/IAP/DUMMY/autoconnect false
 +
 +
If connect automatically is used with "Any Connection", the phone will also use Dummy Network, which is not good. To prevent this, you need to run the following command :
 +
gconftool -s /system/osso/connectivity/network_type/auto_connect -t list --list-type string "[WLAN_INFRA,GPRS]"
 +
Keep in mind the above command will get overwritten if you change the value via UI. (If you choose any / wifi / gprs, and you will want to go back to "wifi or gprs" you will have to do the CLI thing again.
Then restart icd2:
Then restart icd2:

Revision as of 15:14, 22 August 2010

Using USB networking for Maemo applications

By default, standard network applications works well with USB networking, while Maemo-specific applications do 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

If connect automatically is used with "Any Connection", the phone will also use Dummy Network, which is not good. To prevent this, you need to run the following command :

gconftool -s /system/osso/connectivity/network_type/auto_connect -t list --list-type string "[WLAN_INFRA,GPRS]"

Keep in mind the above command will get overwritten if you change the value via UI. (If you choose any / wifi / gprs, and you will want to go back to "wifi or gprs" you will have to do the CLI thing again.

Then restart icd2:

killall icd2

or reboot the device.