This week I’m finishing up running the emulator on the P4 microcontroller. I also worked on performance. Next week, I’m working on validation and performance. The emulator is on schedule, and the risks around it are well-known and unsurprising by now.
We’re now running the emulator as a FreeRTOS task. I achieve this by linking the emulator with our FreeRTOS code and using FFI to call into it. This is slightly unusual, but prevents us from requiring larger architectural changes to the emulator for now. We are having some difficulty with the hardware, so we write the framebuffer out to serial. It is unfortunately slow to write frames, but compressing with miniz gets this time to around 1 second at the cost of running compression.
Performance on the P4 is unsurprisingly worse than on my Mac. Now that we’re running in FreeRTOS, my measurements are more faithful than running on bare-metal (which will tend optimistic). Boot-up is the most intensive section, as it clears memory and spends a lot of time doing device writes. It takes about 75 seconds (with frame streaming on), which is about 3-4x larger than reasonable. The emulator takes 16 seconds on my laptop, so we’re looking at about a 5x disadvantage. Interactions appear within about 1.5 seconds: some amount is due to emulator speed, yet this is confounded by: time to send frames over serial, the (emulated) timer interval, the scheduler, and compute overhead of compressing and streaming frames. I’ll discuss more in the next paragraph: I’ve learned that I don’t have the right tooling to measure practical latency yet.
I demonstrated this week that boot time is not a good predictor of usability. I planned several changes for performance (reducing allocations, updating rustc, LTO, using a single compilation unit, switching to m68k as CPU backend, using JIT) and measured almost every change to increase boot time, ending up with what appears to be a 50% regression in boot. Yet, after every change I also used the emulator interactively, and I observed a notable speedup in touch and frame latency. This has added unanticipated work, as I want to understand why the discrepancy exists (JIT is obvious: time compiling up front, time saved later; why updating rustc caused a major regression is less clear) and I need to write benchmarks against interaction latency.
Much of the knowledge needed for the emulator is in interface specs: the DragonBall VZ, the SED1376 display driver, etc. Architectural details about the m515 are largely not documented; some I’ve figured out through reverse engineering, some through the writings of reverse engineers like Dmitry Grinberg. The interface between PalmOS applications and the kernel is well-documented in prose by Palm. Similarly, m68k toolchains (I used gcc) are well-documented in manuals by their authors (though I often find the gcc manuals confusing and spend a lot of time on them). My strategy here has largely been to read a wide swath of online literature to extract high-level details during design, and then close read the most relevant sources during implementation.
It is difficult to disentangle what systems knowledge I’ve learned specifically for this project; I am already focused on systems and will work full-time on OS performance. Therefore, I’ll focus on my learning strategy this semester. I’ve acquired a lot of general embedded, systems, and performance knowledge through book learning and coursework. I read Remzi and Andrea Arpaci-Dusseau’s Operating Systems: Three Easy Pieces and am reading Hennessy and Patterson’s Computer Architecture: A Quantitative Approach (3rd Edition). While less specifically applicable, Stevens and Rago’s Advanced Programming in the Unix Environment presented broad ideas that have been useful here. I’ve read some of Brendan Gregg’s work (and have plans to read his book Systems Performance). Finally, I drew upon things I learned in 18-349 Embedded Systems course, 18-213 Computer Systems, and 15-441 Compilers, as well as parts of 15-445 Databases and 15-410 OS; I also drew upon performance and RISC-V knowledge developed in a hobby OS and in my compilers project. Most of this material either has exercises included or has been used towards a project of mine at some point, so my strategy here has been to work through closely and gradually over months.
I’ve mostly learned about FreeRTOS through their website. I skimmed their docs early on because I care mostly about the high-level architecture; other details I’ve picked up from their website later on and from Maggie’s code. I’ve learned about the ESP32-P4 and ESP-IDF toolchain through their documentation. This has mostly been understanding interfaces, so the strategy has been to search when the need arises.
In the interest of preparing to work in an industry heavily using LLMs, I have experimented with using Google’s Gemini-3.X and OpenAI’s Sol-6.2 to dig up facts and further reading. I was hoping that given their large training sets, they would be effective at identifying likely high-quality sources. I am not satisfied. In these cases, I’ve independently researched and come to a conclusion to compare against. For facts that are not “common knowledge,” the Gemini models appear to regularly hallucinate details and bias towards suggestions by the user, regardless of sources given or found. The OpenAI models appear to report facts reliably, but since I’m looking for obscure details, it tends to use the most direct option available — pulling someone else’s github code and scanning it — and this is uncomfortable in terms of integrity and licensing. Therefore, I’ve avoided using either as a search engine or for source discovery. It is possible that the situation has changed in recent weeks, especially having seen the recent Riemann news. In general, though, I’ve found that the sources and strategies that stuck with me the most were human recommendations, and I would be interested in hearing about teams and people that are effectively using LLMs to find sources.