Tag Archives: nokia n900

connecting a Raspberry Pi to a Nokia N900 using USB networking

I’ve got a Nokia N900 going spare since I upgraded to a phone for which people actually write apps. Lots of possibilities with the N900. It’s got a shedload of radios, a decent CPU, an IR blaster, and not one but two cameras. The one thing it doesn’t have is any way to plug in more things.

Enter the Raspberry Pi I got at PyCon last week. It comes with lots of GPIO pins, and a USB port where one might plausibly plug in an N900. Clearly, these two devices were meant to be friends. Let’s get them talking.

Prepping the N900

The N900 runs Maemo, a heavily customized Debian fork, which was a fine OS for a hackable device. However, I used mine as an actual phone for several years, and it’s gotten kinda janky, so I’m going to blast it back to factory-fresh and then bring it up to the latest community-developed version of Maemo.

Reset N900 to factory state

Maemo wiki: updating the firmware

Using flasher 3.5 on Win7 x64, installed to C:\Program Files (x86)\maemo\flasher-3.5.
Install libusb 1.2.2.0 from SourceForge. Copy amd64 version of libusb0.dll to flasher install dir.

Shut down N900. While holding down U key on N900 keyboard, plug USB cable into PC.

Run libusb bin\inf-wizard.exe. Select “Nokia N900 (Update mode)” from device list. Create a .inf, save it, and install the .inf using the “Install Now” button. Click past the unsigned driver warnings.

Open a console as an administrator. cd to flasher install dir. Run flasher-3.5.exe --read-device-id to see if the flasher app works.
result:

flasher v2.5.2 (Sep 24 2009)

USB device found found at bus bus-0, device address \\.\libusb0-0001--0x0421-0x0105.
Found device RX-51, hardware revision 2101
NOLO version 1.4.14
Version of 'sw-release': RX-51_2009SE_21.2011.38-1.002_PR_002

Flash eMMC image

This is the user filesystem. I got the latest version from http://skeiron.org/tablets-dev/nokia_N900/.

C:\Program Files (x86)\maemo\flasher-3.5>flasher-3.5.exe -F C:\Users\jeremye\Downloads\RX-51_2009SE_10.2010.13-2.VANILLA_PR_EMMC_MR0_ARM.bin -f
flasher v2.5.2 (Sep 24 2009)

Image 'mmc', size 255947 kB
        Version RX-51_2009SE_10.2010.13-2.VANILLA
USB device found found at bus bus-0, device address \\.\libusb0-0001--0x0421-0x0105.
Found device RX-51, hardware revision 2101
NOLO version 1.4.14
Version of 'sw-release': RX-51_2009SE_21.2011.38-1.002_PR_002
Booting device into flash mode.
Suitable USB device not found, waiting.
USB device found found at bus bus-0, device address \\.\libusb0-0001--0x0421-0x01c8.
Raw data transfer EP found at EP2.
[init        20 %   32768 /  255947 kB     0 kB/s]

Unplug N900’s USB cable. Remove battery. Wait until N900 shuts down. Replace battery. While holding down U, reconnect USB cable.

Flash rootfs image

This is where Linux lives. I used Maemo 5 PR 1.3.1, which is the very last official version, postdates the skeiron.org mirror, and can be found on Nokia’s files site by Googling parts of the filename: RX-51_2009SE_21.2011.38-1_PR_COMBINED_MR0_ARM.bin

C:\Program Files (x86)\maemo\flasher-3.5>flasher-3.5.exe -F "C:\Users\jeremye\Downloads\RX-51_2009SE_21.2011.38-1_PR_COMBINED_MR0_ARM.bin" -f -R
flasher v2.5.2 (Sep 24 2009)

SW version in image: RX-51_2009SE_21.2011.38-1_PR_MR0
Image 'kernel', size 1705 kB
        Version 2.6.28-20103103+0m5
Image 'rootfs', size 185728 kB
        Version RX-51_2009SE_21.2011.38-1_PR_MR0
Image 'cmt-2nd', size 81408 bytes
        Version BB5_09.36
Image 'cmt-algo', size 519808 bytes
        Version BB5_09.36
Image 'cmt-mcusw', size 5826 kB
        Version rx51_ICPR82_10w08
Image '2nd', size 14720 bytes
        Valid for RX-51: 2217, 2218, 2219, 2220, 2120
        Version 1.4.14.9+0m5
Image 'xloader', size 14848 bytes
        Valid for RX-51: 2217, 2218, 2219, 2220, 2120
        Version 1.4.14.9+0m5
Image 'secondary', size 109440 bytes
        Valid for RX-51: 2217, 2218, 2219, 2220, 2120
        Version 1.4.14.9+0m5
Image '2nd', size 14720 bytes
        Valid for RX-51: 2101, 2102, 2103
        Version 1.4.14.9+0m5
Image 'xloader', size 14848 bytes
        Valid for RX-51: 2101, 2102, 2103
        Version 1.4.14.9+0m5
Image 'secondary', size 109440 bytes
        Valid for RX-51: 2101, 2102, 2103
        Version 1.4.14.9+0m5
Image '2nd', size 14848 bytes
        Valid for RX-51: 2307, 2308, 2309, 2310
        Version 1.4.14.9+0m5
Image 'xloader', size 14848 bytes
        Valid for RX-51: 2307, 2308, 2309, 2310
        Version 1.4.14.9+0m5
Image 'secondary', size 109440 bytes
        Valid for RX-51: 2307, 2308, 2309, 2310
        Version 1.4.14.9+0m5
Image '2nd', size 14848 bytes
        Valid for RX-51: 2407, 2408, 2409, 2410
        Version 1.4.14.9+0m5
Image 'xloader', size 14848 bytes
        Valid for RX-51: 2407, 2408, 2409, 2410
        Version 1.4.14.9+0m5
Image 'secondary', size 109440 bytes
        Valid for RX-51: 2407, 2408, 2409, 2410
        Version 1.4.14.9+0m5
Image '2nd', size 14848 bytes
        Valid for RX-51: 2301, 2302, 2303, 2304, 2305, 2306
        Version 1.4.14.9+0m5
Image 'xloader', size 14848 bytes
        Valid for RX-51: 2301, 2302, 2303, 2304, 2305, 2306
        Version 1.4.14.9+0m5
Image 'secondary', size 109440 bytes
        Valid for RX-51: 2301, 2302, 2303, 2304, 2305, 2306
        Version 1.4.14.9+0m5
Image '2nd', size 14848 bytes
        Valid for RX-51: 2401, 2402, 2403, 2404, 2405, 2406
        Version 1.4.14.9+0m5
Image 'xloader', size 14848 bytes
        Valid for RX-51: 2401, 2402, 2403, 2404, 2405, 2406
        Version 1.4.14.9+0m5
Image 'secondary', size 109440 bytes
        Valid for RX-51: 2401, 2402, 2403, 2404, 2405, 2406
        Version 1.4.14.9+0m5
Image '2nd', size 14720 bytes
        Valid for RX-51: 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2111, 2112, 2113, 2114, 2115, 2116, 2117, 2118, 2119
        Version 1.4.14.9+0m5
Image 'xloader', size 14848 bytes
        Valid for RX-51: 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2111, 2112, 2113, 2114, 2115, 2116, 2117, 2118, 2119
        Version 1.4.14.9+0m5
Image 'secondary', size 109440 bytes
        Valid for RX-51: 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2111, 2112, 2113, 2114, 2115, 2116, 2117, 2118, 2119
        Version 1.4.14.9+0m5
Image '2nd', size 14848 bytes
        Valid for RX-51: 2501, 2502, 2503, 2504, 2505, 2506
        Version 1.4.14.9+0m5
Image 'xloader', size 14848 bytes
        Valid for RX-51: 2501, 2502, 2503, 2504, 2505, 2506
        Version 1.4.14.9+0m5
Image 'secondary', size 109440 bytes
        Valid for RX-51: 2501, 2502, 2503, 2504, 2505, 2506
        Version 1.4.14.9+0m5
Image '2nd', size 14848 bytes
        Valid for RX-51: 2607, 2608, 2609, 2610
        Version 1.4.14.9+0m5
Image 'xloader', size 14848 bytes
        Valid for RX-51: 2607, 2608, 2609, 2610
        Version 1.4.14.9+0m5
Image 'secondary', size 109440 bytes
        Valid for RX-51: 2607, 2608, 2609, 2610
        Version 1.4.14.9+0m5
Image '2nd', size 14848 bytes
        Valid for RX-51: 2507, 2508, 2509, 2510
        Version 1.4.14.9+0m5
Image 'xloader', size 14848 bytes
        Valid for RX-51: 2507, 2508, 2509, 2510
        Version 1.4.14.9+0m5
Image 'secondary', size 109440 bytes
        Valid for RX-51: 2507, 2508, 2509, 2510
        Version 1.4.14.9+0m5
Image '2nd', size 14720 bytes
        Valid for RX-51: 2201, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2216
        Version 1.4.14.9+0m5
Image 'xloader', size 14848 bytes
        Valid for RX-51: 2201, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2216
        Version 1.4.14.9+0m5
Image 'secondary', size 109440 bytes
        Valid for RX-51: 2201, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2216
        Version 1.4.14.9+0m5
Image '2nd', size 14848 bytes
        Valid for RX-51: 2601, 2602, 2603, 2604, 2605, 2606
        Version 1.4.14.9+0m5
Image 'xloader', size 14848 bytes
        Valid for RX-51: 2601, 2602, 2603, 2604, 2605, 2606
        Version 1.4.14.9+0m5
Image 'secondary', size 109440 bytes
        Valid for RX-51: 2601, 2602, 2603, 2604, 2605, 2606
        Version 1.4.14.9+0m5
USB device found found at bus bus-0, device address \\.\libusb0-0001--0x0421-0x0105.
Found device RX-51, hardware revision 2101
NOLO version 1.4.14
Version of 'sw-release': RX-51_2009SE_21.2011.38-1.002_PR_002
Sending xloader image (14 kB)...
100% (14 of 14 kB, avg. 2900 kB/s)
Sending secondary image (106 kB)...
100% (106 of 106 kB, avg. 13359 kB/s)
Flashing bootloader... done.
Sending cmt-2nd image (79 kB)...
100% (79 of 79 kB, avg. 13250 kB/s)
Sending cmt-algo image (507 kB)...
100% (507 of 507 kB, avg. 25381 kB/s)
Sending cmt-mcusw image (5826 kB)...
100% (5826 of 5826 kB, avg. 31839 kB/s)
Flashing cmt-mcusw... done.
Sending kernel image (1705 kB)...
100% (1705 of 1705 kB, avg. 30459 kB/s)
Flashing kernel... done.
Sending and flashing rootfs image (185728 kB)...
100% (185728 of 185728 kB, avg. 13689 kB/s)
Finishing flashing... done
CMT flashed successfully

-R flag reboots N900 after flash. N900 goes through “5 white dots” boot seq, then asks for date and time input. Looks like all settings were wiped out, as planned.

Install community-maintained Maemo (CSSU)

Maemo wiki: Community SSU

Go to http://repository.maemo.org/community/community-fremantle.install in Nokia Web to install Stable variant of CSSU. Add the catalog. Let it install the CSSU Enabler. Click through all the messages. Close the app manager and open the Community SSU app that it just installed. If it complains about HAM (the app manager) still being open, just run it again. Once it’s done, it’ll return you to HAM. Click Update All to install the CSSU Maemo update, which is a 34 MB download and may take a while over WiFi.

Fill the temporal void with fruit salad.

The phone will eventually reboot, and you’ll get an “Operating system updated” banner.

Useful apps

Install “OpenSSH Client and Server” from the Network section in HAM. Set a root password when it asks for one.

Install “rootsh” from the System section in HAM, which gives you the gainroot script (equivalent to su?).

Open an xterm. Become root (sudo gainroot). Edit /etc/passwd using vi or whatever to change the password field of the user account from ! to *, or you won’t be able to log in over SSH using pubkey auth because sshd will think the user account is locked out. (BTW, I learned this from running the OpenSSH server in debug mode with sshd -d, in which it’ll stay attached to the terminal and show useful status messages).

Raspberry Pi network interface config

My Pi is running Raspbian.

Before any N900-specific config, you can plug in the N900 and it’ll be detected as a USB Ethernet adapter, normally network interface usb0.

dmesg output:

[ 1108.249401] usb 1-1.3: new high speed USB device number 55 using dwc_otg
[ 1108.351182] usb 1-1.3: New USB device found, idVendor=0421, idProduct=01c8
[ 1108.351219] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 1108.351241] usb 1-1.3: Product: N900 (PC-Suite Mode)
[ 1108.351258] usb 1-1.3: Manufacturer: Nokia
[ 1108.365353] cdc_acm 1-1.3:1.6: This device cannot do calls on its own. It is not a modem.
[ 1108.365930] cdc_acm 1-1.3:1.6: ttyACM0: USB ACM device
[ 1108.378603] cdc_ether 1-1.3:1.8: usb0: register 'cdc_ether' at usb-bcm2708_usb-1.3, CDC Ethernet Device, 56:7d:26:7a:1a:63

ifconfig output:

usb0      Link encap:Ethernet  HWaddr 56:7d:26:7a:1a:63
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Maemo wiki: N900 USB networking

I’m using the instructions for Debian Lenny. Add a new udev rule matching the N900’s identifiers:

/etc/udev/rules.d/99-nokia-n900.rules:

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

Reload the udev rules:

udevadm control --reload-rules

Unplug and replug the N900. The N900 now comes up as the n900 interface in dmesg:

[ 2275.378869] usb 1-1.3: USB disconnect, device number 55
[ 2275.397706] cdc_ether 1-1.3:1.8: usb0: unregister 'cdc_ether' usb-bcm2708_usb-1.3, CDC Ethernet Device
[ 2277.147123] usb 1-1.3: new high speed USB device number 56 using dwc_otg
[ 2277.248904] usb 1-1.3: New USB device found, idVendor=0421, idProduct=01c8
[ 2277.248940] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 2277.248961] usb 1-1.3: Product: N900 (PC-Suite Mode)
[ 2277.248979] usb 1-1.3: Manufacturer: Nokia
[ 2277.265004] cdc_acm 1-1.3:1.6: This device cannot do calls on its own. It is not a modem.
[ 2277.265592] cdc_acm 1-1.3:1.6: ttyACM0: USB ACM device
[ 2277.277117] cdc_ether 1-1.3:1.8: usb0: register 'cdc_ether' at usb-bcm2708_usb-1.3, CDC Ethernet Device, 56:7d:26:7a:1a:63
[ 2277.572415] udevd[5046]: renamed network interface usb0 to n900

and ifconfig:

n900      Link encap:Ethernet  HWaddr 56:7d:26:7a:1a:63
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

The N900 expects that the USB host will be using IP address 192.168.2.14, so let’s make that happen on system boot and when the N900 is plugged in (auto and allow-hotplug respectively). Edit /etc/network/interfaces to add these lines:

allow-hotplug n900
auto n900
iface n900 inet static
    address 192.168.2.14
    netmask 255.255.255.0

Bring it online now:

ifup n900

Confirm that the IP got assigned with ifconfig n900:

n900      Link encap:Ethernet  HWaddr 56:7d:26:7a:1a:63
          inet addr:192.168.2.14  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Note, as I just found out, that this only works if you connect the N900 in “PC Suite” or “Charging Only” mode. If you connect the N900 in “Mass Storage” mode, it emulates a hard drive instead to give you access to its microSD reader and internal storage, and you’ll see this in dmesg:

[ 3440.675342] usb 1-1.3: new high speed USB device number 64 using dwc_otg
[ 3440.777489] usb 1-1.3: New USB device found, idVendor=0421, idProduct=01c7
[ 3440.777525] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 3440.777547] usb 1-1.3: Product: N900 (Storage Mode)
[ 3440.777564] usb 1-1.3: Manufacturer: Nokia
[ 3440.777580] usb 1-1.3: SerialNumber: 372041756775
[ 3440.788540] scsi2 : usb-storage 1-1.3:1.0
[ 3441.796667] scsi 2:0:0:0: Direct-Access     Nokia    N900              031 PQ: 0 ANSI: 2
[ 3441.802419] sd 2:0:0:0: [sda] Attached SCSI removable disk
[ 3441.807315] scsi 2:0:0:1: Direct-Access     Nokia    N900              031 PQ: 0 ANSI: 2
[ 3441.813912] sd 2:0:0:1: [sdb] Attached SCSI removable disk
[ 3441.969928] sda: detected capacity change from 7948206080 to 0
[ 3444.909499] sd 2:0:0:0: [sda] 56631296 512-byte logical blocks: (28.9 GB/27.0 GiB)
[ 3444.911077] sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 3445.128870]  sda:
[ 3448.903605] sd 2:0:0:1: [sdb] 15523840 512-byte logical blocks: (7.94 GB/7.40 GiB)
[ 3448.904939] sd 2:0:0:1: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 3448.913276]  sdb: sdb1

The mode setting seems to be sticky: you can get the N900 to go back to being a fake Ethernet adapter by connecting it at least once in PC Suite mode, after which it can be unplugged and replugged as much as you like, even if you leave it in Charging Only by not selecting a mode. However, the mode setting doesn’t persist across reboots. When I power-cycled my N900 while it was connected to the Pi, it didn’t come up as a network device until I manually selected PC Suite mode again.

Advertisements
Tagged ,