HP 39gs hpgcc aplet development

Hello, there. It has been two months since not updated this blog. Well, this is because I’m busy with school exams and studying. Luckily, now I’m free. So, a few days ago, I was trying something new on my graphing calculator. It is a second-hand hp 39gs calculator which was released in 2006. It has a powerful ARM CPU. However, the program is running on a Saturn CPU emulator.

This is a limitation when I want to program something fun. To bypass this, I found a fantastic project, HPGCC. It allows me to program on PC with c and run it on the calculator with some SysRPL exploit. Unfortunately, this project is so old that a modern compiler cannot compile it. Meanwhile, its newest version is not supporting hp 39gs. To solve this, I fix the old code manually. Then, I get some references from some other hp 39gs Github projects.

Toolchain Preparation

First, we need to find the ancient HPGCC SDK. I found it after I browsed 69 pages of Google search results. Unfortunately, I lose the link to download the SDK. But you can refer to the Arnie97 GitHub repository. I only found some rare HP 39gs applet examples using HPGCC there throughout the whole Internet.

Luckily, I have arranged the fixed hpgcc toolchain and uploaded it into my GitHub repository. You can just download it and build it natively using MakeFile.

Connection between PC and HP 39gs

This part is tricky because the only reliable way to connect to HP 39gs is by using the HP connectivity kit. It also can be connected using xkermit or xmodem according to the HPGCC SDK document. Sadly, the connectivity kit only runs on Windows.

To let connectivity kit run on Linux, I use Wine to run it. Then, I add a new rule into the udev under directory /etc/udev/rules.d as 50-hpcalc.rules.

SUBSYSTEM==”tty”, ATTRS{idVendor}==”03f0”, ATTRS{idProduct}==”0121”, SYMLINK+=”hpcalc”

So that, once the calculator is connected to PC, it will automatically registered as /dev/hpcalc.

Then, I need to port the Linux device into the Wine device port. To do that, I just edit the registry of Wine and change the value of COM1 under HKEY_LOCAL_MACHINE\Software\Wine\Ports to /dev/hpcalc. Now, just restart the computer and the the /dev/hpcalc can be seen in terminal and connectivity kit can detected the calculator normally.

Compile the code

For this, you can refer to the github repository. There has the steps required for compiling.