TCP/IP over PPP between a PalmOS PDA and Linux

Version 1.1, 09-Jun-2003

Update History

  • 10-May-2004 – Added PayPal Donate button, based on reader suggestions
  • 09-Jun-2003 – Modified script to parse /etc/resolv.conf for DNS
  • 09-Jun-2003 – Fixed the pppd kill line – -f1, not -f2!
  • 08-Jun-2003 – Fixed spellings, acknowledgements
  • 07-Jun-2003 – Initial release

Related Download

  • palm-ppp – script to automate the connection process

Here’s how you get your PalmOS based PDA to talk TCP/IP over PPP to a Linux box, that is in turn connected to the Internet. This kind of setup lets you run TCP/IP applications like Web browsers and sync your Avantgo even if the required support is not installed on your host Linux machine.

Requirements:

  • A PalmOS based PDA running PalmOS 3.x or newer
  • The appropriate serial or USB cable to connect to your Linux PC
  • A fairly stock Linux distribution (I used RedHat Linux 9 for this)
  • The appropriate ppp and iptables packages installed on the Linux box
  • Some TCP/IP program (such as a web browser, email program, etc.) installed on the PDA.
  • Root access to your Linux box, or a “sudo” configuration item that lets you run the script below as root, without needing a password.
  • (Optional) Some coffee or coke would help. Order pizza – you should be done by the time it arrives (if not, at least you’ll get the pizza free ;)

System check

First, make sure you can hotsync your PDA with your Linux box, using such excellent tools such as pilot-link and/or jpilot. If you can’t do that yet, you probably need to go back a step and figure out how to get this going. Check the sites mentioned, download the packages, and Read The Fine Manual. If you use USB, you definitely should read this.

OK, I assume you can hotsync your PDA using serial, USB, IRDA or Bluetooth. For this How-to, I will assume USB connectivity (that being the most common these days), but the principles remain the same no matter what you do.

Note:Many new Palm PDAs seem to use /dev/ttyUSB1 as their primary port instead of /dev/ttyUSB0. I don’t know why this happens, or whether it is the Palm or Linux, but the single most common gottcha is trying to sync via /dev/ttyUSB0 when your Palm sits on /dev/ttyUSB1. If you aren’t sure, watch /var/log/messages and see what you get when you plug in the cable and try to hotsync.

The second gottcha is the fact that most people assume that the USB port is always there, like a serial port. Well, it isn’t (at least logically). /dev/ttyUSB1 becomes a valid device only when the USB device (in this case the Palm) goes live (like with a hotsync). It will take a few seconds for stuff to settle. Until then, do not attempt to hotsync or establish a ppp link – it will fail. Always kick off your USB device communication process first, wait for a couple of seconds, then start the relevant process on the PC side.

Final check – we do a hotsync. Kick off your favourite sync program on the PC. Here is a test command line I use:

pilot-xfer -p usb:/dev/ttyUSB1 -b palm_backup/

You should hear the “tweedledee!” and the contents of the PDA should get backed up into the palm_backup/ directory.

Hah! I just tricked you into doing that long overdue backup of your PDA! ;-)

Anyway, we have proof of working connectivity here, so let’s move on.

Setting up the PDA

Now this is really simple.

Go to Prefs, and select “Network” from the drop-down menu (Palm OS 3.x, 4.x) or from the Preferences panel (PalmOS 5.x).

Create a new network profile by pulling down the menu and selecting “New” (PalmOS 3.x, 4.x) or tap the “New” button (PalmOS 5.x).

Edit the name, and call it “Linux PPP”. Make sure that “Connection” is set to “Cradle/Cable” (or whatever you are going to be using to connect). Click on “Details” and set “Idle Timeout” to “Never”., then click on “OK”

Don’t make any other changes. For your reference, here are the settings (which are mostly the defaults):

  • Service: Linux PPP
  • User Name: (should be blank)
  • Password: (should be “-Prompt-”, not “-Assigned-”)
  • Connection: Cradle/Cable (or whatever connection you wish to use)

Under Details, you have:

  • Connection type: PPP
  • Idle timeout: Never
  • Query DNS: (Checked)
  • IP Address: (Checked) Automatic

That’s it.

At this point, you may want to check your pizza timer – we are almost done.

Configuring the Linux side

I assume you have root access to the box – if not, you will need help from your sysadmin (sysadmins love pizza – you may want to buzz her *now* to let her know that there is some on the way.)

Specifically, she has to make an entry in the sudo configuration file, which will allow you to run this script as root. She can do this by running “visudo”, then appending the following two lines to the end of the file:

Cmnd_Alias PALMPPP=/usr/local/bin/palm-ppp
%palmusers ALL=NOPASSWD: PALMPPP

She then needs to add you to a user group called “palmusers” in /etc/group.

If this sounds complicated, don’t worry about it – that is why she is the sysadmin, and you are just a user. ;-)

OK, now that you are root (or God – what difference?), you need The Script.

Click here, then save the file as “palm-ppp”.

Edit it for taste (and proper parameters in the parameter block), refrain from commenting on my coding skills (I am a user, not a programmer!), make it executable

 chmod +x palm-ppp

and copy it to its final location (/usr/local/bin sounds like a good idea).

Beam me up, Scotty!

OK, now for the taste of the pudding.

On the Palm, hit Prefs>Network and click “Connect”. The Palm will try to connect.

NOTE:If you are using a USB port to connect, you have to start the connection on the Palm first, then wait a few seconds, and then run the script!

Now if you are root, run the script directly,

/usr/local/bin/palm-ppp

if you are a plain old user, and your sysadmin has set up a sudo setup for you (remember that pizza? this is where the payoff comes!), run

sudo /usr/local/bin/palm-ppp

Here is what I see:

[achitnis@wookie] ~$ sudo palm-ppp
Using interface ppp0
Connect: ppp0 <--> /dev/ttyUSB1
local  IP address 192.168.99.1
remote IP address 192.168.99.2

Link is up, your Palm is at 192.168.99.2

If you didn’t see that (or something similar) you DidSomethingWrong(tm), go back and review this document, and fix the problem.

Hurry, the pizza is getting cold!

If you did see this (or something similar), then try pinging your Palm:

[achitnis@wookie] ~$ ping 192.168.99.2
PING 192.168.99.2 (192.168.99.2) 56(84) bytes of data.
64 bytes from 192.168.99.2: icmp_seq=1 ttl=255 time=5.14 ms
64 bytes from 192.168.99.2: icmp_seq=2 ttl=255 time=4.77 ms ^C

--- 192.168.99.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1009ms
rtt min/avg/max/mdev = 4.770/4.959/5.149/0.202 ms

If you see that, you are effectively done.

OK, it works

Great! Now lets get play with the new toys!

Fire up your TCP/IP application on your Palm, and try it out. This could be a web browser, an email package, a telnet/ssh session, whatever.

It should Just Work(tm). ;-)

Avantgo

In my case, I needed this for a specific purpose – to get Avantgo’s PalmOS client to pick up content without the need for a supporting program on the Linux box.

This (at the time of writing) is needed because Avantgo has changed the MAL protocol for the PalmOS 5.x clients, and has not released any code that will let Linux/Unix/non-Windows users sync their Avantgo content. Such code is available for the protocol used with Avantgo clients prior to the PalmOS 5.x client, and a very nice plugin that uses this code to make Avantgo syncing possible using the excellent jpilot is available from Jason Day.

However, until Tom Whittaker (the author of Malsync, and who is also with Avantgo) makes available new code that we Linux users can use, I need to sync my PalmOS 5.x Avantgo client using its built-in “Modem Sync” feature.

I assume you have used Avantgo before, know what it is, and have a client properly configured, and your Avantgo account set up.

Now start the Avantgo client, and pull down the menu. Select “Modem Sync”, and the client should conenct to the Avantgo servers and pick up its content.

When that is done, you can also use the Avantgo client as a fairly capable web browser to go to pages you haven’t specifically added as a channel to your Avantgo profile.

Jpilot

Because your primary port that you use to connect your Palm to your PC is now the sole property of pppd (until you kill it), you will not be able to sync with Jpilot in the regular fashion.

Not an issue, you need to configure “Network Hotsync” on both sides, so that the hotsync happens over TCP/IP, not directly via the communication port.

On the Palm, go to your Hotsync application, and change the connection from “Local” to “Modem” above the arrowed Hotsync icon

Now pull down the menu, select Modem Sync Preferences, and change “Direct to Modem” to “Network”.

Pull down the menu again, and select “LANSync Preferences”, and change “Local Hotsync” to “LANSync”.

Finally, pull down the menu again and select “Primary PC Setup”, and make the following entries:

  • Primary PC Name: (Leave this blank, see note below)
  • Primary PC Address: 192.168.99.1 (default address in my script)
  • Subnet Mask: (You can leave this blank)

Note: If you specify a name in the Primary PC Name field, you have to ensure that it can be resolved using the DNS server you provide to the connection. If the Palm cannot find the name, it will not sync. The workaround (which I have used here) is to leave the name field blank, in which case Hotsync will use only the IP address.

OK, now fire up jpilot, go to File>Preferences>Settings and set your Serial Port to “net:” (no quote marks, just the word net followed by a colon).

OK, that’s it. One change from the usual procedure – since jpilot isn’t looking at the USB port anymore but at a network connection, start the sync process by clicking the jpilot sync button first.

Now click the Hotsync icon in the Hotsync application on the Palm. This icon will now have a picture of a phone on it. Do not press the Hotsync button on the cradle – that will always try and do a normal hotsync, not a network hotsync.

“Tweedledee!” – you should now see a network hotsync happen.

The Pizza

By now, your pizza should have arrived. I hope it is hot, and has lots of pepperoni on it, with tons of cheese. Jalapenos would be nice too.

Enjoy it, and remember to give your sysadmin her share.

Frequently Asked Questions (FAQ)

Here are a couple of gottchas you may face. This isn’t a comprehensive list – if you find more (and also a solution), please let me know.

  • Why doesn’t pppd die after a disconnect?This happens if you are using a USB connection. The current code used by pppd barfs when the device it is connected to suddenly disappears (which is how the USB host/slave design works), and in effect hangs. I have a work-around from a friend who patched pppd, but why slashdot my server when you can slashdot his? ;-) He will put up the code soon, and I will link to it.In the meanwhile, just kill pppd manually after you disconnect the Palm, using the command
    killall -HUP pppd

    This could be dicey if you have multiple ppp connections running, so a safer one would be this:

    kill -HUP `ps ax|grep pppd|grep ttyUSB|grep local|cut -d " " -f1`

    This will kill any pppd talking to a USB port and in local (i.e. non-modem) mode.

  • I can’t get it up a second timeUmmmm…..Seriously, not an issue. It is related to the problem described above – just kill off pppd before re-trying a connect.
  • Argh, now regular hotsync doesn’t work!Naturally, you have pppd hanging onto your USB port for dear life! Kill it!
  • Connects fine, but I can’t get out on the Internet from the PalmAre you able to get out on the Internet from your PC? If it is via a proxy server, then you will have to configure your PalmOS based application to use the same proxy server.Of course, I assume that you have provided a valid DNS server for the Palm to use, by editing the script and changing the value of “MyDNS”…. you did, didn’t you? Huh? The script now automagically parses /etc/resolv.conf to figure out what your DNS is.
  • Nope, nothing works for me, please help me!I am really sorry, but that’s what mailing lists and Linux User Groups are for. I really don’t have the time to give 1:1 support to people.I suggest that you join the fine mailing lists of the jpilot and pilot-link projects.

    Or check out your local Linux User Group’s mailing list. I am a member of the Bangalore Linux User Group – go to their site and join the technical discussions group.

    Mailing lists like these abound with knowledgable people, all very eager to help you.

    And yes, even I can be found there! ;-)

Acknowledgements

The following people directly or indirectly contributed to the information in this document, and I thank them all:

  • Kishore Bhargava
    Old comrade-in-arms in the Linux and OpenSource world, who re-acquainted me with the concept of Palm PPP and Avantgo modem sync.
  • Nicholas Piper
    Helped me get the network sync business going. Also has the pppd patch!
  • Daniel Robbins
    I “borrowed” some code from his excellent “Linux 2.4 stateful firewall design” tutorial for the iptables parts of the script.
  • Judd Montgomery
    Author of jpilot, the defacto Palm desktop for many Linux/Unix users around the world.
  • The Pilot-Link Team
    The authors of the software that provides the backbone to most PalmOS-to-Linux/Unix connectivity these days. Many important packages (such as jpilot, malsync and others) are built on the work of this team.
  • Jason Day
    Encouraged me to write this document, and has helped plug many holes in my Palm-Linux-jpilot toolkit.
  • The good folks on the various mailing lists that I frequent, who put up with constant questions and pleas for help, and have never let me down.

Comments are closed.