Linux on a Calculator: How the HP Prime G2 Was Taught to Run X11 and Doom
Translated by a model; the original is in Russian.
Remy van Elst, the author of Raymii.org, poses a question that has become something of a meme: but can your calculator run Linux? His favorite machine is the HP-16C, an RPN calculator for programmers with support for hexadecimal, binary and octal number systems. Running Linux on it, however, is of course impossible: the NUT chip clocks in at around 220 kHz and offers 203 bytes for programs. But a far more serious machine is up to the task.
A Calculator More Powerful Than a Coffee Machine
The author calls the HP Prime G2 graphing calculator “comically overpowered.” Inside sits an ARM Cortex-A7 (i.MX 6 UltraLite), 256 MB of RAM and 512 MB of storage. In his words, it's closer to a small embedded Linux computer with a calculator keypad than to a traditional calculator. For comparison: the industrial coffee machine he works with at his day job uses an i.MX6 module of a similar class.
The author holds to a principle: a device you've bought belongs to its owner, not the manufacturer, so root access is a must — otherwise the gadget turns into e-waste right at the factory. On the Prime, unlike Texas Instruments and Numworks (which stripped out features because of exam modes and the fight against cheating), there was never any assembler, only HP's own BASIC-like language PPL — which means there's nothing to take away. That said, an HP engineer warned that the new chip could, if desired, be “encrypted and locked down tight.”
What He Managed to Bring Back to Life
The existing port with the 4.14 kernel had long been abandoned: the repositories had moved, buildroot wouldn't compile, and the devicetree was broken. Having recovered the sources via Software Heritage, the author whipped the build into shape:
- patched the keyboard driver (
imx_keypad.c) so that the Alpha key could enter digits and special characters like the hyphen, underscore and vertical bar; - wrote a driver for the new Ilitek ILI211X touchscreen, which replaced the discontinued Goodix, and made a calibration utility;
- compiled USB-serial straight into the kernel, since loading it as a module hung the device dead;
- raised the in-RAM image limit from 15 to 130 MB by changing offsets in the kernel config, u-boot and the uuu scripts;
- configured getty so the system would make it all the way to a login prompt.
After the startx command, twm launches with xeyes, xclock and xcalc — yes, you can now run a calculator on a calculator (a long press counts as a right click). It also ships with prboom at a decent framerate and the tiny tcc compiler: there's a hello.c in /root that you can build right on the device.
The author ran everything in RAM only, not risking a reflash of the NAND so as not to lose the stock software. For those interested, there's a ready-made image. For the G1 model there's a separate port with a 6.x kernel, and the most absurd trophy in the collection is someone else's Windows 10 port via UEFI, running calc.exe on the calculator.
Source: Lobsters
Comments
Sign in, to comment.