The author of the project rePalm rewrote Palm OS from scratch and plans to turn it into a platform for smart watches.

The author of the project rePalm rewrote Palm OS from scratch and plans to turn it into a platform for smart watches.


And, apparently, the watch on Palm OS will find its buyer:


image


Palm OS is an operating system for handheld computers, which was at the peak of popularity from 1998 to the first half of the 2000s. It is very simple and not demanding of resources, it carefully consumes battery power and is wonderfully designed for use in handheld computers. But in 2004–2005, Palm OS devices gave way to Windows Mobile devices:


image
(source)


This happened for various reasons, partly because of management errors, and partly because of the characteristics of the operating system itself: in 2004, Palm OS dragged along a long tail of backward compatibility, which prevented it from developing and moving forward. What cost, for example, the lack of memory protection: an error in the application could lead to the whole system hang or crash, as in the days of Windows 9x or Mac OS 9. Or the implementation of the file system: the files were stored as records in the database, and the size of one record could not exceed 64 kilobytes. It was probably a good decision in 1996, but such a data storage system was not adapted for large multimedia files and memory cards that appeared later.


Well, you can not ignore the change of architecture in Palm OS 5.0 with Motorola 68k to ARM. Then, for compatibility with old applications, a binary translator was added to the operating system, which on the fly recoded the instructions from M68k to ARM. In principle, even with such a layer, old applications worked on new processors no worse than on native 68K, because Palm OS system calls were natively executed on ARM, and the performance loss from translation leveled off the increased frequency of new processors several times compared to Motorola Dragonball. The real problem was that the developers did not get the tools to create native ARM applications. The code for Palm OS 5 was still compiled for 68k, and even standard applications worked through the compiler layer.


However, despite the many architectural features of the Palm OS, its strengths have not ceased to be strong. This is still a simple, low-level, resource-undemanding system. In 2015, I used the Palm Pilot with a 16 MHz processor as a diary, and I was completely comfortable! Moreover, many people loved this system for its simplicity, and many had enough basic applications. Readers, players, diaries and planners, games - all this exists under the Palm OS in abundance. Find the use of this operating system today.


Therefore, after so many years, the community of fans of this system has survived, which supports websites with applications, runs its own subreddit and continues use palm trees.


image


But one of the community members went further, deciding to move Palm OS to a more modern hardware and find useful use for this project.


Dmitry Greenberg, programmer from Google, since 2003 created tweaks and hacks for Palm OS devices, among which WarpSpeed ​​is a program for “overclocking "PDA, and PowerSDHC - driver for SDHC memory cards.


In Google, Dmitry was engaged mainly in embedded systems. In particular, he participated in the development of the operating system for Android Wear smart watches, Nexus Q media player and Android TV platform.


Dismissed from Google, Dmitry decided to create a platform for smart watches based on Palm OS 5.x, an operating system that was last updated 15 years ago:


image


At first glance, the plan is excellent: it is unlikely that modern platforms for smart watches will compare with Palm OS in terms of resource consumption and battery life.


The problem is that the source code for Palm OS has never been published. Yes, some pieces of source code appeared in open access to application development textbooks, but this is not enough. The source code was from the company PalmSource and the licensees, mainly companies that produced their devices on the Palm OS - under the terms of the NDA, of course. Therefore, to find the source code of this operating system after so many years is not possible, and the legality of its use will be questionable.


There remains a difficult and thorny path for the most hardcore enthusiasts with reinforced concrete willpower: reverse engineering. It was this path that Dmitry chose, gradually, in several stages implementing his plans.


For starters, you should have written a tool for unpacking ROM images of Palm OS devices. Then it was necessary to disassemble the main components of the operating system, obtained from the unpacked image. Then - the longest and monotonous work - it was necessary to understand the logic of the functions of the system API and write your own implementation of these functions. And the most difficult thing is to write the kernel of the operating system, since the existing ones (for example, linux) do not support some of the functions of the Palm OS kernel (suspending threads, turning on/off preemptive multitasking).


Read the full Palm OS rewrite history from scratch in the Dmitry blog , I’m just briefly retell the implementation of the main stages. Dmitry spent several months implementing system APIs, which would be enough to load the OS. A few more weeks - on the reverse-engineering of the graphics subsystem, and two months - on writing code to support drawing. At this point, the implemented functionality was enough to run the operating system on top of the linux kernel in QEMU, and load the image of some Palm OS device in this environment.


rePalm’s * FIRST * boot (c) Dmitry Grinberg
rePalm’s FIRST boot (c) Dmitry Grinberg


To move from an emulator to a real hardware, many more tasks needed to be done: choose a well-documented and stably working hardware platform, write the OS kernel for the selected architecture, write the ARM translator in Thumb (the processor chosen by Dmitry Cortex-M4 only supports double-byte Thumb instructions while many Palm OS components use full 4-byte ARM instructions), and write the JIT compiler (!!!) to make a double translation of M68k - & gt; ARM - & gt; Thumb worked with adequate speed.


After a year of active development, rePalm runs on the STM32F429 debug board, the graphics, touchscreen and SD card work, the synchronization via HotSync works, and most applications and games written for Palm OS 5.x work just fine. The plans include Wi-Fi and Bluetooth support, sound support and USB device connection in mass storage mode, and SSL library update. Dmitry complements his blog post as it develops, and also regularly updates the project in Subreddit r/Palm .


image
(c) Dmitry Grinberg




It is pleasant to follow the work of an enthusiastic person and observe how an interesting and ambitious project develops. But it is worth remembering that Dmitry is primarily an engineer and a programmer. For him, the solution of the engineering problem (bringing the Palm OS into line with the modern world) is higher than creating a commercial product, be it a smart watch or something else. I am sure that there will be a lot of interesting applications for the project, but what will happen next, and we’ll see a modern version of Fossil WristPDA — hard to say. It remains only to wish Dmitry good luck and follow the development of rePalm.


image
(c) Dmitry Grinberg


P.S. Thank you Newbilius for the thought of posting this article here from the blog. About such cool projects should know more people!

Source text: The author of the project rePalm rewrote Palm OS from scratch and plans to turn it into a platform for smart watches.