Connecting your Windows Mobile 2003 device via USB


From SynCE-Wiki

Windows Mobile 2003 Support: Installing SynCE, Connecting Your Device, Using SynCE, SynCE Utilities, Troubleshooting

Contents

Configuring Kernel Driver

These actions described in this section have to be performed every time you upgrade your Linux kernel!

SynCE uses a Linux kernel driver called ipaq in order to handle the USB connection. You may need to patch this driver before you can make a successful USB connection.

First you must read the following instructions depending on whether you have a Stock or Custom kernel. Most users will have a stock kernel. After all, if you've compiled your own kernel, you'll know about it!

Stock Kernel

Execute the command:

uname -r

This will output your kernel version. If this version is older than 2.6.9, then you will have to follow the instructions in the Windows Mobile 2003 ipaq Driver page before you can continue. All other users can skip to the next step.

Custom Kernel

Make sure that your kernel configuration has the following enabled as loadable modules:

Device Drivers ---> USB Support ---> USB Serial Converter support --->
    <M> USB PocketPC PDA Driver

Device Drivers ---> Network device support ---> PPP (point-to-point protocol) support
    <M> PPP support for async serial ports

Find out USB information about your device

Make sure your device is not connected to your computer before following these steps:

  1. Save a list of the devices currently on USB by running the command:
    cat /proc/bus/usb/devices > /tmp/before
  2. Connect your device to your computer.
  3. Save the updated list to a new file:
    cat /proc/bus/usb/devices > /tmp/after
  4. Disconnect your device.
  5. Compare the two lists by running the command:
    diff /tmp/before /tmp/after

You should get an output like the following:

23a24,31
> T:  Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 10 Spd=12  MxCh= 0
> D:  Ver= 1.00 Cls=ff(vend.) Sub=ff Prot=ff MxPS= 8 #Cfgs=  1
> P:  Vendor=049f ProdID=0003 Rev= 0.00
> C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=  2mA
> I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=ipaq
> E:  Ad=01(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
> E:  Ad=82(I) Atr=02(Bulk) MxPS=  16 Ivl=0ms
>

Important parts of the text have been highlighted in red.

Class, Subclass and Protocol

Does your output look like this? Compare the parts marked red:

T:  Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  9 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=ef(unk. ) Sub=01 Prot=01 MxPS=16 #Cfgs=  1
P:  Vendor=0bb4 ProdID=0b01 Rev= 0.00
S:  Manufacturer=MSFT
S:  Product=PocketPC USB Sync
C:* #Ifs= 2 Cfg#= 1 Atr=c0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=ef(unk. ) Sub=01 Prot=01 Driver=(none)
E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=1ms
I:  If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=(none)
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=03(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms

If your device matches the above then you should stop now. It is very likely to crash your kernel if you continue. This is because the device is running Windows Mobile 2005. For SynCE support for your device, please visit the Windows Mobile 2005 Support page.

The Number of USB Configurations

Look at the value of #Cfgs=. If it's 1, skip to The Driver Entry section below! If it's 2 or more, continue setting up your device with SynCE but after you have finished it please send us mail to synce-devel@lists.sourceforge.net and tell us:

  1. brand and model of your device
  2. the output from diff /tmp/before /tmp/after
  3. if it worked properly with these instructions.

The Driver Entry

Look at the Driver=. Read the corresponding section below:

Driver=ipaq 
Your kernel recognised the device, good!
Driver=usbserial 
Your kernel recognised the device, good!
Driver=(none) 
Your kernel driver did not recognize your device. You need to perform some special configuration:
  1. If your kernel version is 2.6.10 or later, please send us mail to synce-devel@lists.sourceforge.net and tell us:
    1. your kernel version
    2. brand and model of your device
    3. vendor/product USB IDs for your device (see Vendor= and ProdID=)
  2. Edit your module options:
    1. Find which of these files or directories exist:
      • The directory /etc/modprobe.d
      • The directory /etc/modutils
      • The file /etc/modprobe.conf.local
      • The file /etc/modprobe.conf
      • The file /etc/modules.conf
    2. If one of the directories exists on your distribution, use a text editor to create the file synce in that directory. If one of the files exists, open it in a text editor.
    3. Add a line like this, but replace the vendor=0x049f and product=0x0003 values with the correct values from the command you ran previously.
      options ipaq vendor=0x049f product=0x0003
    4. If you created or edited the /etc/modutils/synce file, run the update-modules command.
  3. If you have the file /etc/rc.local, open it with a text editor and add this line in order to have things working directly next time you restart your computer:
    /sbin/modprobe ipaq
  4. Now run this command as root to remove the ipaq module:
    rmmod ipaq
    and ignore any ERROR: Module ipaq does not exist in /proc/modules message.
  5. Run this command as root to reload the ipaq module:
    modprobe ipaq
  6. If you got no output from the modprobe command (meaning it succeeded), restart this guide from the Find out USB Information about your Device section. If you get the message FATAL: Module ipaq not found, follow the instructions on the Windows Mobile 2003 ipaq Driver page. If you got another error message, ask for Help.
Another Driver= Entry 
Ask for Help!.

The Number of USB Endpoints

Next you look at the #EPs= entry or count the number of lines beginning with E:, meaning the number of USB endpoints:

Two or Three USB Endpoints 
Good, nothing to do here.
Four USB Endpoints 
Special attention is needed. Either follow the instructions written by Stefan Langeland or these:
  1. Follow the instructions on the Windows Mobile 2003 ipaq Driver page if you haven't already done so.
  2. Find which of these files or directories exist:
    • The directory /etc/modprobe.d
    • The directory /etc/modutils
    • The file /etc/modprobe.conf.local
    • The file /etc/modprobe.conf
    • The file /etc/modules.conf
  3. If one of the directories exists on your distribution, use a text editor to create the file synce in that directory. If one of the files exists, open it in a text editor.
  4. Add a line like this:
    options ipaq ttyUSB=1
  5. If you created or edited the /etc/modutils/synce file, run the update-modules command.
  6. If you have the file /etc/rc.local, open it with a text editor and add this line in order to have things working directly next time you restart your computer:
    /sbin/modprobe ipaq
  7. Now run this command as root to remove the ipaq module:
    rmmod ipaq
    and ignore any ERROR: Module ipaq does not exist in /proc/modules message.
  8. Run this command as root to reload the ipaq module:
    modprobe ipaq
  9. If you got no output from the modprobe command it was meaning it succeeded.
Another Number of Endpoints 
Ask for Help.

Configuration of the Connection

  1. Connect your device.
  2. As user root, try the following synce-serial-config commands until one of them succeed:
    • synce-serial-config ttyUSB0
    • synce-serial-config tts/USB0
    • synce-serial-config usb/tts/0
    • synce-serial-config usb/ttyUSB0
    • synce-serial-config ttyu0
    Important: If you had four USB endpoints in the USB information for your device instead of the usual two, you should use 1 instead of 0 in the commands above.
    If you get the message synce-serial-config was unable to find a character device named..., ask for Help.

This does not have to be done again on your system unless your device appears on a different tty for some reason.

Configuring the Firewall

SynCE requires the following TCP ports to be open in the firewall between your PC and the device:

From device to PC
  • 5678
  • 5679
From PC to device
  • 990

Refer to the documenation of your Linux distribution for details on how to allow traffic on these ports between your PC and device. Some details that might be of interest when configuring the firewall:

When the synce-serial scripts are used, the device is connected via PPP. The default local IP address of the PPP connection is 192.168.131.102 and the default remote IP address is 192.168.131.201. These IP addresses can be changed by passing different parameters to the synce-serial-config tool. Run synce-serial-config without parameters, read its man page or read its wiki page to know more.

If the synce-serial-start script (see the next section, Starting the Connection) detects any firewall rules whatsoever you will see this message:

Warning!
You have firewall rules that may prevent SynCE from working properly!

This is just a warning and can be ignored if you know that your firewall will not block the ports needed by SynCE.

Starting the Connection

For the time being, this part is very brief!

  1. Ensure your device is set to allow external connection.
  2. As your own user (not root), start dccm:
    vdccm
    or like this if your device is password-protected:
    vdccm -p password
    This must be done after each time you have rebooted your computer.
  3. Connect your device.
  4. As root, run this command:
    synce-serial-start
  5. If synce-serial-start just hangs with the message synce-serial-start is now waiting for your device to connect and you have a Smartphone, did you really follow the instructions on the Windows Mobile 2003 Smartphone Patch page?

If you want synce-serial-start to be automatically executed when your device is plugged in and if you have udev installed, you can create the following file: /etc/udev/rules.d/z30_synce.rules

BUS!="usb", ACTION!="add", KERNEL!="ttyUSB*", GOTO="synce_rules_end"
SYSFS{idVendor}=="VENDOR NUMBER", SYSFS{idProduct}=="PRODUCT NUMBER", RUN+="/usr/local/sbin/synce-serial-start"
LABEL="synce_rules_end"

VENDOR-NUMBER and PRODUCT-NUMBER have to be replaced by the values for your specific device. You can find them in /proc/bus/usb/devices. Alternatively, if you created /tmp/before and /tmp/after, you can do:

diff /tmp/before /tmp/after |grep "P:"

For example my XDA2 has the VENDOR-NUMBER 0bb4 and PRODUCT NUMBER 0a02.

If this does not work, check where synce-serial-start has in fact been installed on your system - on Debian/Ubuntu it may be in

/usr/bin/synce-serial-start

To check, you can do

which synce-serial-start

Testing the Connection

Applications and tools (except for synce-serial-*) that use SynCE must be executed by the same user as is running dccm (not root).

As your own user, try this command:

pstatus

Note: If you are using the packages for Debian/GNU Linux, you must use this command:

synce-pstatus

If you successfully got information about your device, congratulations for enduring all the quirks involved in setting up SynCE!

Now is a good time to play with the other command line tools included with SynCE. However, don't forget the next step below.

If you get the message below, the connection failed, and you should make sure that you followed all the steps in this guide properly.

pstatus: Unable to initialize RAPI: An unspecified failure has occurred

If you truly did follow the guide, you may want to get Help.

Disconnection

In order to properly disconnect your device, you should first close the network connection between your device and SynCE. There are a couple of ways to do this.

Just unplugging the USB cable is not proper disconnection when using SynCE. (This will hopefully be fixed in the kernel driver some day)

Before you unplug the cable you should do one of these actions, in order of preference:

  1. Disconnect with the GNOME Tray Icon or with SynCE-KDE
  2. Disconnect with the appropriate action on your PDA
  3. Run killall -HUP dccm from the command line
  4. Run synce-serial-abort. Please note that this command is only to be used when everything else fails. It also seems like it only works for USB connections while the USB cable is connected.


Autoconnect

If you want to automatically execute synce-serial-start when plugging-in your device and you use "udev", you can create the rule /etc/udev/rules.d/z30_synce.rules

BUS!="usb", ACTION!="add", KERNEL!="ttyUSB*", GOTO="synce_rules_end"
SYSFS{idVendor}=="0bb4", SYSFS{idProduct}=="0a02", RUN+="/usr/local/sbin/synce-serial-start"
LABEL="synce_rules_end"

You need to change idVendor (e.g. 0bb4) and idProduct (e.g. 0a02), to the ones of your device. You can find them out via the "lsusb" command:

Bus 003 Device 006: ID 0bb4:0a02 High Tech Computer Corp. Himalaya GSM/GPRS Pocket PC

Success

Congratulations, you have successfully connected your device to your computer and is communicating with SynCE. Next step:

Using SynCE