Sync Your Pocket PC




Sync Your Pocket PC

Just because your Pocket PC is powered by Windows doesn't mean you can't sync it with Ubuntu.

Inside the box of your Pocket PC, you'll find a USB cable that's compatible with nearly every computer on the planet. What you won't find is software that's compatible with anything other than Windows. To sync your Pocket PC with Ubuntu, you'll need some additional software. Fortunately, most of this software is available in Ubuntu's universe repository.

ActiveSync, the software that comes with your Pocket PC, takes care of synchronizing calendars and contacts, and also installing applications in the Pocket PC. With the ipaq USB-serial module, the SynCE suite of tools, and Multisync, you can do all of this on your Linux system.

Connecting the Pocket PC

The first order of business is to figure out which interface your Pocket PC uses. If you're using a recent Pocket PC, it will probably look like an iPAQ as far as Linux is concerned. Before you plug in your Pocket PC, run sudo modprobe ipaq to load the iPAQ USB-to-serial driver. Plug in your Pocket PC and examine the output of dmesg to see whether it was detected and which device represents it. In the following example, a Pocket PC was detected on /dev/ttyUSB0:

bjepson@ubuntu:~$ sudo modprobe ipaq
Password:
bjepson@ubuntu:~$ dmesg | tail
[ 1720.274390] usbcore: registered new driver usbserial
[ 1720.285461] drivers/usb/serial/usb-serial.c: USB Serial support registered for generic
[ 1720.317318] usbcore: registered new driver usbserial_generic
[ 1720.319073] drivers/usb/serial/usb-serial.c: USB Serial Driver core
[ 1720.415421] drivers/usb/serial/usb-serial.c: USB Serial support registered for PocketPC PDA
[ 1720.448394] drivers/usb/serial/ipaq.c: USB PocketPC PDA driver v0.5
[ 1720.457095] usbcore: registered new driver ipaq
[ 1738.233238] usb 1-1: new full speed USB device using ohci_hcd and address 2
[ 1738.796279] ipaq 1-1:1.0: PocketPC PDA converter detected
[ 1738.803167] usb 1-1: PocketPC PDA converter now attached to ttyUSB0

Unfortunately, this probably won't work with a Pocket PC that's too new. At the time of this writing, SynCE did not yet support the most recent Pocket PC operating system, Windows Mobile 5.0.


The next thing you'll need to do is install some packages, but before you do so, make sure you've enabled the universe repository in /etc/apt/sources.list. Then, run sudo apt-get update to get the latest packages and install synce, dccm, and some supporting tools:

bjepson@ubuntu:~$ sudo apt-get install synce-dccm synce-serial librra0-tools
            

When dpkg hits the synce-serial package, it will ask you for a few things: the serial interface used by your Pocket PC, the IP addresses for the PPP connection used with your Pocket PC, and the IP address of your DNS server. You need to provide the DNS server address, but you can accept the defaults for the rest (although you should check the serial interface against what you found earlier in the output of dmesg). Although you specified the serial port during the setup, I've found that you need to do it once more after installation, so run this command:

bjepson@ubuntu:~$ sudo synce-serial-config /dev/ttyUSB0

You can now run synce-serial-start to start a serial connection.

Testing the Connection

Now it's time to give it a try. Make sure your Pocket PC is connected to your computer, and start the dccm daemon. Without arguments, it will run in the background. Since this is its first time out, I suggest starting it in the foreground (-f) with debugging enabled (-d 4):

bjepson@ubuntu:~$ dccm -d 4 -f
dccm[4599]: Running in foreground
dccm[4599]: Listening for connections on port 5679

Open another terminal and start up SynCE:

bjepson@ubuntoo2:~$ sudo synce-serial-start

synce-serial-start is now waiting for your device to connect

If you see the error "synce-serial-abort was unable find a running SynCE connection. Will do nothing," then the Pocket PC has probably gone to sleep while you were setting things up. If it did, it will disconnect from the machine, and /dev/ttyUSB0 will disappear. If you see "PocketPC PDA converter now disconnected from ttyUSB0" in the output of dmesg, unplug it and plug it back in, and try synce-serial-start again.

Once you have the connection up and running, the Pocket PC should stay awake.


Watch the shell where you started dccm and wait a while; it can take anywhere from 30 seconds to a minute for the Pocket PC and dccm to start chatting. Once they begin talking to one another, you'll see something like this:

dccm[4941]: Connection from 192.168.131.201 accepted
info package (104 bytes):
  0000: 28 00 00 00 04 14 00 00  (.......
  0008: 11 0a 00 00 00 00 00 00  ........
  0010: 2a 1e c3 37 00 00 00 00  *..7....
  0018: 28 00 00 00 3c 00 00 00  (.......
  0020: 5a 00 00 00 00 00 00 00  Z.......
  0028: 50 00 6f 00 63 00 6b 00  P.o.c.k.
  0030: 65 00 74 00 5f 00 50 00  e.t._.P.
  0038: 43 00 00 00 50 00 6f 00  C...P.o.
  0040: 63 00 6b 00 65 00 74 00  c.k.e.t.
  0048: 50 00 43 00 00 00 53 00  P.C...S.
  0050: 53 00 44 00 4b 00 00 00  S.D.K...
  0058: 00 00 50 00 57 00 31 00  ..P.W.1.
  0060: 30 00 42 00 31 00 00 00  0.B.1...
  0068:
dccm[4941]: Talking to 'Pocket_PC', a PocketPC device of type PW10B1

To disconnect the Pocket PC, first run the command killall -HUP dccm. If all went well, you should see "Connection interrupted" and "Connection from 192.168.131.201 closed" in the dccm session. You can leave dccm running. To reconnect, run sudo synce-serial-start again.


Establish a Partnership

Before you can sync to the Pocket PC, you'll need to set up a partnership. Pocket PCs can be partnered with at most two computers, so if you've already configured your Pocket PC with a Windows computer running ActiveSync, you'll have one slot left. The synce-matchmaker program will pick an empty slot and use it:

bjepson@ubuntoo2:~$ synce-matchmaker create
[rra_matchmaker_create_partnership:356] Partnership slot 1 is empty on device
[rra_matchmaker_create_partnership:356] Partnership slot 2 is empty on device
Partnership creation succeeded. Using partnership index 1.

If you don't have a free slot, you'll need to pick one to remove. See the synce-matchmaker manpage for details.

You need to run synce-matchmaker only once to pair it with your computer.


Synchronize with Evolution

To synchronize your Pocket PC with Evolution, you'll need to install Multisync (http://multisync.sourceforge.net), a modular synchronization package that lets you create pairs of repositories that are kept in sync. To install Multisync and the SynCE plug-in, issue the command sudo apt-get install libmultisync-plugin-all synce-multisync-plugin, which will also install a collection of plug-ins, including the Evolution plug-in and the backup plug-in. You'll use the backup plug-in to verify that Multisync is running correctly before you try to synchronize it with SynCE.

At the time of this writing, most of the pieces required to sync a Pocket PC with KDE were present in Ubuntu, but they did not work well together. In particular, the Raki panel applet would segfault when it tried to set up a partnership, and the syncekonnector, required for syncing PIM information with KDE, did not build against the versions of various libraries included with Dapper. However, for those inclined to compile a handful of libraries from scratch, there is a HOWTO for Debian users at http://sourceforge.net/mailarchive/forum.php?thread_id=9562091&forum_id=15200.


Don't look for Multisync in Evolution: you won't find it under EditPlugins. You'll need to launch the multisync application under X11 to work with it (you can either launch it from a shell or load it from ApplicationsMultisync). When you launch Multisync, its main window appears, as shown in Figure.

Launching Multisync for the first time


Testing Multisync

To make sure that Multisync is working properly, you should configure the backup plug-in and do a test sync with it. Click the New button, and the Synchronization Pair dialog will appear, as shown in Figure.

Testing Multisync with the backup plug-in


Specify Ximian Evolution 2 as the first plug-in and Backup as the second (see Figure). Give this pair a name, and then click and set the Options for each plug-in. For Evolution, you need to specify which calendar, address book, and task categories to sync. For Backup, you need to specify a backup directory (this appears on the Options tab of the Backup plug-in options dialog). You can then dismiss the Synchronization Pair dialog by clicking OK, which returns you to the main Multisync window. Click once to select the pair you just created, and then click the Sync button. The sync should go quickly, depending on how many contacts, tasks, and appointments you have. Once it's finished, open a shell or Nautilus window and navigate to whichever backup directory you specified in the Backup options. You should see some new files there:

bjepson@ubuntoo2:~$ cd backup/
bjepson@ubuntoo2:~/backup$ ls -l
total 8
-rw-r--r-- 1 bjepson bjepson  26 2006-02-07 16:14 backup_entries
-rw-r--r-- 1 bjepson bjepson 422 2006-02-07 16:14 multisync1139346850-0

Syncing to the Pocket PC

Return to the Multisync main window and click Add again. This time, set up a Synchronization Pair between Evolution and the SynCE plug-in. Just as you did with the earlier pair, click Options (next to Evolution) to configure which categories to synchronize (the SynCE plug-in has no options). Click OK to dismiss the dialog and return to the Multisync main window. Click to select the Evolution/SynCE pair and click the Sync button.

If all went well, your Pocket PC and Evolution will be in sync. Click the Log button to see what happened. In Figure, you can see that two entries were copied successfully from the Pocket PC to Evolution.

The Multisync log after synchronizing with a Pocket PC


Each time you want to sync, you'll need to start dccm (or keep it running in the background), plug in the Pocket PC, and run sudo synce-serial-start. Then you can launch Multisync and synchronize. To disconnect, run killall -HUP dccm and unplug the Pocket PC.

Install Pocket PC Software

Pocket PC software usually comes in one of two forms: a self-installing .exe file designed to be run under Windows, or a .cab (cabinet) file that contains ready-to-run binaries for your Pocket PC. If you're stuck with an .exe file, no need to worry. The orange package is available in the universe repository [Hack #60] and will extract the .cab files for you:

$ orange PocketVCSSetup.exe
squeezing out: /home/bjepson/pocketvcs.arm.cab
squeezing out: /home/bjepson/pocketvcs.mips.cab
squeezing out: /home/bjepson/pocketvcs.sh3.cab
-------
3 files

Once you have the .cab file (either downloaded from a web site or extracted using orange), you can install it onto your Pocket PC. Most modern Pocket PCs are of the ARM variety, but you can use synce-pstatus to find out for sure:

$ synce-pstatus | grep ^Processor
Processor architecture: 5 (ARM)
Processor type:         2577 (StrongARM)

Then you can use synce-install-cab to install the .cab file for the appropriate architecture:

$ synce-install-cab pocketvcs.arm.cab
Copying file 'pocketvcs.arm.cab' to device...
File copy of 1660980 bytes took 0 minutes and 6 seconds, that's 276830 bytes/s.
Installing 'pocketvcs.arm.cab'...

After the file is copied over, you will see an installer run on your Pocket PC. You may be prompted for additional information. You can use the synce-list-programs and synce-remove-program utilities to list and remove programs you've installed on the Pocket PC.

Accessing the Pocket PC's Filesystem

You can work with files on the Pocket PC using the utilities listed in Figure.

Table Utilities for working with the Pocket PC filesystem
Utility Description
synce-pcp Copy a file
synce-pls List files
synce-pmkdir Create a directory
synce-pmv Move/rename a file
synce-prmdir Remove a directory


For example, the PocketVCS application (http://pocketvcs.emuunlim.com) isn't much good without some games. As you can see, it doesn't come with any:

$ synce-pls "/My Documents/PocketVCS/" 
AC--------      444646  Tue 11 Mar 2003 04:19:22 PM EST  PocketVCS.pro

To actually manipulate a file (copy, remove, etc.), you need to prefix it on the remote filesystem with a colon (:). Here's how to copy the free Oystron (http://www.io.com/~nickb/atari/oystron.html) over to the Pocket PC:

$ synce-pcp OYSTR29.BIN ":/My Documents/PocketVCS/OYSTR29.BIN" 
File copy took less than one second!

As you can see, the file is over there and ready to play:

$ synce-pls "/My Documents/PocketVCS/" 
AC--------        4096  Thu 01 Jul 2004 04:56:26 AM EDT  OYSTR29.BIN
AC--------      444646  Tue 11 Mar 2003 04:19:22 PM EST  PocketVCS.pro

Troubleshooting

If you have trouble with your Pocket PC, make sure that the ipaq module was loaded correctly and examine the output of dmesg to ensure that the Pocket PC was detected and the serial link was established.

If your Pocket PC and Evolution don't seem to be talking, go back to the terminal that's running dccm and make sure that it has recognized your Pocket PC and established a connection to it. If they aren't talking, try stopping the connection and reconnecting. If killall -HUP dccm doesn't reset the connection, try sudo synce-serial-abort. Pocket PCs are notorious for getting confused about things, so if you find that it's impossible to connect after that point, you might want to reset your Pocket PC. Heck, you might even need to reboot your computer if things get really confused.

If you still have problems, visit the SynCE web site (http://synce.sourceforge.net) for documentation and other troubleshooting information.

Brian Jepson