...making Linux just a little more fun!

A way to connect an iPod Touch to a MIPSnetbook

By Anton Borisov


A couple years ago, I had a chance to work with industrial MIPS-based VME boards. It was so unusual to see that the modern failure-proof world actually extends beyond x86-architecture. Those VME boards had a Linux distrubution running, so no special knowledge was required to log in, and perform a task. Being designed for industrial purposes, it would be irrational to buy it for home use - so when I heard about a Chinese hardware company named Lemote [1], which has MIPS-based products in its portfolio, my first thought was - "Those guys have what I need - MIPS netbooks. I want it here, by my side". That's how the story began.

If you're a reasonably literate user of GNU/Linux system, then your experience with any netbook should be quite smooth - just as it was for me. As a matter of fact, the Yeeloong netbook has Debian preinstalled, with repositories tuned to update the "lenny" release. My first step was to upgrade Debian to the latest packages available. It's generally nice to have the most recent applications, the important ones in my case being gcc and building tools.

Connecting to iPod via iTunnel transport

Apple fans should know that to synchronize/copy files to an iPod or iPhone, an average user needs to have iTunes installed on a PC. It's ludicrous, but iTunes is only available for Mac OS/X and Windows - and the most ludicrous thing about iTunes is that it's compiled for x86 architecture only. No more PowerPC, only x86/x86_64. Should I even bother mentioning Linux and MIPS here?

I have an iPod Touch, second generation. A very handy device, with multi-touch and mobile Safari to surf the net via Wi-Fi. However, I faced a tough problem - how do I copy audio and video files onto it without Microsoft Windows and iTunes, i.e., directly from Linux? There is a solution, actually - you might be interested in doing a jail-break for your iPod, in order to install an SSH server and make a direct connection by means of SSHFS[2]

While writing about performing a jail-break is beyond the scope of this article, I can gladly tell you - it was scary, but at the end, I had a wonderful feeling - it works! And to cheer you up even more, there is no chance of turning your iPod into a brick. It's an absolutely amazing device in terms of recovery and hardware design.

Okay, back to basics. I managed to flash an updated, i.e. 'JB' firmware with an activated SSH server. Now, it was time to log into iPod's operating system. You can do it via Wi-Fi network, or alternatively, via USB-cable by means of the iTunnel [3] package. Let's see how it works in practice.

I grabbed the source code, and did a compilation. No external dependencies or additional libraries were required. Kudos to iTunnel and libiphone authors!

loongson@debian:~$ cd src/itunnel-0.0.9/
loongson@debian:~/src/itunnel-0.0.9$ make clean && make

I'm an unprivileged user at Yeeloong netbook, so I decided to use port 12022.

loongson@debian:~/src/itunnel-0.0.9$ ./itunnel 12022
get_iPhone() success
- successfully got device
server waiting for ssh connection on port 12022

server accepted connection, clientfd:5
client thread fd(5) running, server port 12022 , peer port 45964
tunnel now running.
SSH to localhost port 12022 to get to iPhone.
 (use ssh -D  to create SOCKS tunnel.)
do Ctrl+C to quit the server (can take a few seconds).

Well, everything's ready to login to iPhoneOS. Let's get to it. Don't forget about default password though: every Apple device seems to have a built-in 'mobile' user with password set to 'alpine'.

loongson@debian:~/src/itunnel-0.0.9$ ssh -l mobile -p 12022 localhost
mobile@localhost's password:
localhost:~ mobile$ uname -a
Darwin localhost 9.4.1 Darwin Kernel Version 9.4.1: Mon Dec  8 21:02:57 PST 2008; root:xnu-1228.7.37~4/RELEASE_ARM_S5L8720X iPod2,1 arm N72AP Darwin

Quite the usual Linux environment, almost all user-space utilities have been ported from the bigger PCs:


localhost:~ mobile$ uptime
 23:14pm  up 17 days 22:28,  1 user,  load average: 0.10, 0.11, 0.08


localhost:~ mobile$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/disk0s1          750M  475M  268M  64% /
devfs                  17K   17K     0 100% /dev
/dev/disk0s2           15G   15G  250M  99% /private/var

top, and many others...

Processes:  23 total, 1 running, 22 sleeping... 81 threads
Load Avg:  0.05,  0.09,  0.08    CPU usage:  3.70% user,  5.56% sys, 90.74% idle
SharedLibs: num =    0, resident =     0 code,     0 data,     0 linkedit.
MemRegions: num =  3000, resident =   40M +     0 private,   32M shared.
PhysMem:   26M wired,   16M active, 8448K inactive,  114M used, 1704K free.
VM: 583M + 0   251397(0) pageins, 2080(0) pageouts

 1599 top          7.4%  0:00.62   1    17     50   580K   848K  1348K    12M
 1592 bash         0.0%  0:00.12   1    13     42   340K   480K  1120K    13M
 1591 sshd         0.0%  0:00.50   1    14     37   368K   260K  1324K    13M
 1583 ptpd         0.0%  0:00.30   2    48     75   544K  1472K  1372K    14M
 1540 MobileSafa   0.0%  1:31.78   5   170    428 15832K    17M    37M    97M
   43 locationd    0.0%  0:56.46   9   100    141  1272K  1908K  1908K    29M
   32 fairplayd    0.0%  0:00.28   1    31     64   512K  1372K   512K    15M
   31 iapd         0.0%  0:40.24   9   116    156  1248K  2760K  1568K    30M
   30 mediaserve   0.0% 31:38.90   9   153    245  1820K  1944K  2292K    39M
   29 lockdownd    0.0%  0:03.25   3    62     99   876K  1792K   960K    26M
   28 update       0.0%  0:15.56   1    13     41   216K   624K   228K    11M
   26 sbsettings   0.0%  0:00.19   1    27    107   868K  2592K   856K    25M
   25 Navizon      0.0%  0:11.34   1    38    162  1280K  2924K  1396K    26M
   24 msd          0.0%  0:38.88   1    32     95  1192K  1656K  1240K    15M
   23 mslocd       0.0%  0:26.59   1    32     97   632K  1880K   788K    23M
   19 CommCenter   0.0%  0:04.97   4    83     90   848K  1764K   940K    25M
   17 BTServer     0.0%  0:01.18   2    66     93   636K  1556K   668K    17M
   16 SpringBoar   1.8% 59:16.65  13   325    689  9060K    17M    20M    86M
   15 configd      0.0%  6:28.52   5   160    127  1020K  1580K  1488K    16M
   14 syslogd      0.0%  1:17.33   4    37     35   320K   248K   444K    13M
   13 notifyd      0.0%  0:35.43   2   247     27   232K   248K   260K    12M
   12 mDNSRespon   0.0%  2:00.59   2    46     65   616K  1360K   912K    14M
    1 launchd      0.0%  0:40.65   3    78     35   284K   248K   396K    12M

Of course, switching to a higher level via the 'su' command allows you to see even more information. For instance, all the logging information about the Wi-Fi network iPod has managed to connect to is available through 'dmesg' output:

AppleBCM4325::setASSOCIATE() [configd]:  lowerAuth = AUTHTYPE_OPEN, upperAuth = AUTHTYPE_NONE, key = CIPHER_NONE, flags = 0x2
AppleBCM4325 Joined BSS:     BSSID = 00:14:d1:4b:e6:f7, adjRssi =  44, rssi = -46, rate = 54 (100%), channel =  1, encryption = 0x1, ap = 1, hidden = 0, directed = 0, failures =   0, age = 1, ssid = "my_net"
AirPort: Link Up on en0

Having SSH server up and running on the iPod Touch gives us the ability to connect to it via SSHFS-connection. Let's mount iPod' storage now!

loongson@debian:~$ sudo sshfs -p 12022 -o allow_other mobile@localhost:/private/var /media/usb
mobile@localhost's password:
loongson@debian:~$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda1             57685532  46146588   8608692  85% /
tmpfs                   514464         0    514464   0% /lib/init/rw
udev                     10240      3552      6688  35% /dev
tmpfs                   514464         0    514464   0% /dev/shm
                     15324954624 15062839296 262115328  99% /media/usb

Now, let's do some simple benchmarking - copy a single file from iPod Touch to a netbook's local filesystem:

loongson@debian:~$ rsync -v /media/usb/mobile/Media/mp3/Madonna/greatest_hits/106\ Crazy\ For\ You.mp3 .
106 Crazy For You.mp3

sent 5859015 bytes  received 31 bytes  1065281.09 bytes/sec
total size is 5858218  speedup is 1.00

About 1MiB/s - that's pretty fast.

And let's perform the backward operation, i.e. copy a single file from netbook to iPod:

loongson@debian:~$ rsync -v --progress ./wine-1.1.23.tar.bz2 /media/usb/mobile/Media/
    11075584  71%  140.08kB/s    0:00:30

Frustrating, isn't it? What reasonable explanation could there be? Well, I guess the bottleneck is that the performance of iPod's CPU - ARM processor clocked at 533 MHz could be too slow to handle encrypted SSH packets. What should I do? Simply login to iPod, and secure copy a necessary file from a host (i.e., Yeeloong) machine. Like this:

localhost:~ mobile$ scp loongson@* .
loongson@'s password:
Kylie Minogue - Je Ne Sais Pas Pourquoi.mp3             100% 5655KB   1.1MB/s   00:05

Voila - it works! The same bandwidth in both directions!


The approach of performing a jail-break first, and then attaching iPod's storage to PC via SSHFS is a long way to go for something so simple. But - and this is essential - Linux users have no other means of transferring files to the iPod, due to a) iTunes being available for Mac- and Windows-platforms only; b) iTunes being compiled against x86 CPU only (PowerPC/SPARC/MIPS/ARM Linux users should wave "bye-bye"!), and c) there being no means to log onto an iPod without the SSH server being pre-installed. On the other hand, once you have done so, you have a full control over your lovely iPod Touch.


[1] http://www.lemote.com/en/products/
[2] http://fuse.sourceforge.net/sshfs.html
[3] http://www.cs.toronto.edu/~jingsu/itunnel/


Talkback: Discuss this article with The Answer Gang


Anton jumped into Linux world in 1997, when he first tried a tiny muLinux distribution, being run from a single floppy. Later on, Red Hat and Slackware became his favorite choice. Nowdays, Anton designs Linux-oriented applications and middleware, and prefers to work with hardware labeled as "Powered by Linux".

Copyright © 2010, Anton Borisov. Released under the Open Publication License unless otherwise noted in the body of the article. Linux Gazette is not produced, sponsored, or endorsed by its prior host, SSC, Inc.

Published in Issue 177 of Linux Gazette, August 2010