Skip to content

Architecture overview

Chikuma is the iPod classic's retail firmware, taken apart and built again from the outside in. These pages show how its pieces fit, at the level the device itself arranges them.

Where the original decides something, Chikuma reproduces the decision and proves it against the original running on the same emulated machine. That covers how a menu drills down, how a screen fades and how a track reaches the DAC. Where the original decides nothing, such as what a source file is called or where shared code lives, the choice is Chikuma's, and it says so at the place it is made.

The shape of the system

The stack, from the metal up, is the device's own stack, because structure follows the firmware.

Layer What it is More
Boot chain A reproduced mask boot ROM and NOR bootloader, both C, built from source and signed with Chikuma's own certificate chain. The recovery stage beside them is Zig. The same chain boots the original firmware, which is the control, and the bootloader is the one in a real iPod's flash. The boot chain, in C
Kernel The firmware's own RTXC design: tasks, priorities, preemption, mutexes with priority inheritance, timers, slots and events, a heap with boundary tags, and a service dispatch. The task table carries the real names, ids and priorities. Kernel
Storage An ATA driver, a partition layer, FAT16 and HFS+. The filesystem never calls the disk directly. It posts to a work queue and blocks, as the device's own disk tasks do. Storage
Music database The iTunesDB and ArtworkDB, streamed as the firmware streams them, with the orders, placeholders and covers the device derives from them. Genius walks a similarity graph iTunes wrote. The music database, Genius
Display and UI Granite, the compositor, drives the panel and a hardware scaler. The view classes on top render screens that build themselves from the resource archive. Display and UI, the resource archive
Media Video goes through a hardware H.264 decoder. Audio goes through sm1, a DSP running a codec program the CPU loads before each track. Chikuma reproduces how both are driven. Audio and video, How sm1 plays music
Devices Every piece of hardware the firmware touches, from the wheel and the PMU to the crypto blocks, has a model in the emulated machine. Chikuma's driver for it is the same one that runs on the real iPod. The device models
Accessories The dock, the Apple accessory protocol, the headphone remote, and USB. Accessories and iAP

The OS (kernel, drivers and interface) is written in Zig. The reproduced boot ROM and NOR bootloader are C, and the published libraries Apple shipped come from upstream, in their own languages.

The three tags

Three tags run through the code and these pages:

Tag Meaning
MEASURED read from the image, or observed on a live trace of the original
INFERRED reasoned on top of a measurement
OURS a stand-in, declared in the file where it stands in, naming the behaviour that would replace it

A page that describes reproduced behaviour has a test behind it that fails if the behaviour changes. Some subsystems are thin for the moment, and their pages say so. Status keeps the full, live account of what works and what does not.

Fidelity to behaviour

Chikuma reproduces Apple's behaviour, and does not try to match the shipped binary. It has to stay recompilable and changeable, since that is the reason to rebuild it rather than patch the original.

The behaviour is checked by subtraction against the original on the same machine.

Upstream libraries

The image embeds several well-known open-source libraries. Chikuma uses them from upstream, at versions of its own choosing (FreeType is 2.14.3):

Library Used for
FreeType text rasterisation
SQLite the Genius queries
zlib inflate
Vincent a software OpenGL ES 1.1, for Cover Flow and the tilted album art

Only the parts Apple grew onto these libraries are recovered. A line gets recovered when it could have been different had Apple chosen differently. An implementation of a public standard that someone already wrote is taken from them. The media page shows how this plays out with the OpenGL ES stack.