recipe introduction (skip this)

Compared to today’s beautifully packaged and highly sanitized offerings, the pre-iPhone handheld market was the wild west. Huge varieties of form factors were being explored, and the devices which could potentially be replaced by a PDA ranged from MP3 or MiniDisc players, a pad of paper, a GameBoy, an IR TV remote, a cell phone, a gps unit, or even a projector controller. Sadly, the coherent packaging of all of these features in a stylus-free and easy to use device with a centralized app store proved to be the magic bullet Palm was searching for. Apple beat them to the punch, and the rest is history. Working with the palmOS dinosaurs is still enjoyable though; they’re a fascinating window into a past that had a very different idea of the future.

All the palm devices were heavily based around interaction with a home computer. There was limited support for intra-device communication over IR starting with the Palm III and an add-on which was released in 1998 for the original (1996) Pilot and (1997) PalmPilot, eventually expanding to include Bluetooth and Wi-Fi on the last devices in the mid-to-late aughts. In general, it wasn’t expected that you would be live-tweeting via graffiti. Palm envisioned the handheld as a way to replace your rolodex and communicate asynchronously, largely via email. You would HotSync™ your Palm prior to leaving home, then respond to your emails throughout the day as you had time, before finally sending all your responses at the end of the day when you had access to your home computer (obviously the loop was shorter if you used your work computer). While this relaxed pace of response was quickly outcompeted by Treo/Blackberry-enabled always-on communication, the inherent asynchrony of the early palmOS devices has a certain appeal.

With that in mind, I started trying to find ways to use my PalmPilot instead of my phone where I could. The pen-and-paper replacement functionality still works just fine, obviously; to-do lists tend to not be aided that much by an internet connection. The .mobi standard for ebooks, originally based on the palm database format, is declining in use now as epubs become more common, but it’s still pretty easy to find or convert ebooks into that format. The calendar functionality works just fine for a few more years also (until Palm Day). The largest challenge nowadays is finding ways to actually communicate (using that desirable async workflow) to anybody who’s not still living in 2001.

state of the palm

It’s pretty hard nowadays to find good connected apps to use on Palm devices. Unless you’re still running a Windows XP-era version of Outlook and tracking your calendar events in Lotus Notes, your favorite applications probably won’t have support for offline browsing, and modern javascript is an ambitious ask for the venerable Motorola 68K. The ubiquity of HTTPS-by-default is another challenge for a device from a time where hiding your files consisted of setting a bit on its header (and asking all other applications to kindly respect that). With that in mind, I decided to try and come up with something myself, both to practice my C and because I wanted to make stuff like this when I was a kid.

PalmOS application development for interaction with modern web APIs is difficult, but the alternative (writing conduits) has also become unexpectedly challenging, largely because the Conduit Development Kit (CDK) had seemingly bit-rotted off the internet. Luckily for our anxious readers, Dmitry (the patron saint of palmOS) had a copy laying around, and it’s now publicly available again courtesy of PalmDB.

make install heffalump logo

Since I mostly use a PalmPilot Professional, I decided to go the route of using a HotSync conduit for pushing updates to the device, both because Windows tends to have decent backwards compatibility and because I haven’t actually had phone service usable with an on-device modem for about a decade. I’ve been using mastodon instead of twitter as much as possible lately, so I figured an offline client (beginning with just a reader) would be a good place to start. I mostly just read things anyway, so a timeline-download conduit and a timeline-display handheld application seemed like an edible elephant. Also this project I had just read about was pretty cool, so I had the concept on the brain already. With a specific goal in mind finally, I started looking for a toolchain to use.

As a rust programmer by day, I had also largely hallucinated away the difficulties of working with old C toolchains. The choices I identified for developing the handheld application were:

  1. The CodeWarrior IDE and its associated toolchain (2004 - must use 2004 IDE) (It was at this point, dear reader, that I discovered there is a character limit on the palmOS memo app and had to switch)
  2. A very old version of PilRC (2000s - the gnu toolchain from the time)
  3. An updated toolchain assembled by Dmitry and the owner of the palm2000 website (gcc 9 - no support for statics or jumps > 32k)

Option 3 was the obvious choice, but I was still struggling to get everything working. With my toolchain-related limitations in mind, I threw everything in a docker container so I could never have to think about it again™. It’s available here if you want to follow along at home. Writing an app for palmOS is very different to writing an app for a modern handheld. There is no real attempt to limit your access to anything on the device, and your ability to crash the handheld is limited only by your willingness to write to a NULL pointer or some other application’s data. At this point I pretty much just typed in the hello_world example from the PalmOS Programming Bible, and acquired some bits and bobs from Tavisco’s excellent Palmkdex to get things started. The latest build of the client (which I’ve named heffalump, in keeping with mastodon’s pachyderm theme) is available here. It was unreasonably satisfying to build a palmOS app in a containerized GitHub action for some reason. I’m exploring it with my therapist.

Now that an app to display data is made, it’s time to actually load some data. So far as I’m aware, HotSync Manager never had a 64 bit build, and each conduit registered for a application is expected to have an associated 32-bit dll which hotsync will call into. Registering a conduit consists of 1: Writing the appropriate data to a registry key (which requires sequential numbering among the keys for all conduits) and 2: not messing up the registry. Luckily, the CDK has functionality that will do this step for you. Unluckily, I prefer to write rust, so I started with writing a conduit-agnostic wrapper for the Conduit Manager DLL. At this point, I could register a conduit, but had no way to actually make the conduit. Again, I didn’t feel like writing C++97, so I also wrapped the sync logic and made a schmancy builder-pattern installer creator thing for conduits that will definitely be used a whole lot by both people who still use palms. My time management sucks.

heffalump conduit installed

At this point I was getting annoyed that I had spent so long on these things, so I just imported megalodon-rs to download my mastodon timeline instead of writing the code myself. The conduit itself is exported as a 32-bit dll with a single entry point called OpenConduit, which HotSync calls after loading your dll. I think there are supposed to be more functions exported, but it works fine so far ¯\_(ツ)_/¯. Internally, the conduit just takes an empty PalmDOC database (PDB) file, downloads the timeline data, then stuffs everything into the PDB and sends the entire thing to the handheld. I doubt any custom HotSync conduit has had an entire tokio runtime stuffed in it before, but it only took me an afternoon to write and it takes ~5s to run, so chalking this one up as a win. You can clone the repo here, and install the conduit yourself using the provided binary if you too would like to use the world’s most exclusive mastodon client.

heffalump reader

I learned a ton through this process, and I couldn’t have done it without lots of help from Dmitry, Tavisco, and the other holdouts who still write code and host content for palmOS, so thanks again to them. You can follow me on mastodon @knickish@hachyderm.io, or join the PalmDB discord server if you found this content interesting.