The whole chain, and Tomodachi¶
run.py --payload drops the OS straight into memory. This page covers a boot that
starts where the device starts, and a macOS app that draws the machine as an iPod.
Tomodachi, the companion app¶

tomodachi/ is a small macOS app, in SwiftUI, built with XcodeGen from project.yml. It launches
qemu-ipod/tools/run.py headless and takes the panel over RFB, so the framebuffer is live rather
than screenshotted. Input, savestates and shutdown go in through QMP and the monitor, as separate
clients.
| Part | What it does |
|---|---|
| wheel | a trackpad bridge turns two-finger motion into notches, and the drawn wheel takes clicks on MENU, the transport caps and the centre button |
| Hold switch | the machine's hold switch |
| Cable Plugged In switch | the power/data source the PMU reports, the input half of the low-battery and disk-mode paths |
| footer | what is connected (VNC, QMP) and which payload and disk image are running |
| settings | run.py's own flags one for one: disk, payload, icount shift, warp, writable, debug channels, USB socket, gdb port |
| debug view | the machine's own traffic logs |
The footer names exactly which payload and image are running, since a stale build artifact gives no sign of itself. The settings map one for one to the command line you would have typed.
The app finds the checkout through IPOD_RE_ROOT, or by walking up from its own bundle. It is a
developer tool for this repository only.
Booting the real chain¶
cd qemu-ipod
./run_secure_boot.sh # builds everything, fresh disk, boots
DISK=.../sb_disk_retailos.img ./run_secure_boot.sh # the control: Apple's own RetailOS
ONB_DEBUG_LOG=0 ./run_secure_boot.sh # without the ONB's log lines
The machine walks the whole chain, and everything but the disk is Chikuma's:
Use --shift 7 --warp. The ONB waits in Stall() busy-loops on a timer read, and at the default
shift those run at a fifth of real time.
The ONB logs every module entry through ARM semihosting, which the emulator intercepts. This script turns it on by default. A build for a real device has it off, because no debugger is there to answer. Apple's own ONB carries no such calls, so an empty log also tells which ONB ran.
Chikuma's own CA¶
Apple's chain cannot be joined. Its root of trust is a fixed SHA-1 digest in mask ROM, with no fuse or field that could make a real device accept another key. So the reproduced boot ROM swaps that digest for Chikuma's own, and the whole X.509 chain becomes Chikuma's.
firmware/chikuma_ca is its own git repository, kept out of the main tree. It holds:
| Piece | Detail |
|---|---|
| root | RSA-2048, mirroring Apple's |
| intermediate and leaf | RSA-1024 |
| signatures | SHA-1 throughout |
| serials | the 9-byte 01 FB 01 FB… serials the ROM hard-compares |
bootstrap.sh regenerates the chain from the committed keys and never replaces one. The leaf key
signs the image, so a new key would invalidate everything already signed.
The emulator's hardware keys¶
Besides its signature, the container is encrypted, and Apple's format encrypts under a key that lives in silicon. The real GID and UID keys are unknowable, and they stay that way.
So the machine's AES model carries Chikuma's own hardware-key material for key selectors 1 and
2. It comes from a gitignored file in firmware/chikuma_ca. The C header is generated from it, never
typed by hand.
Three rules hold it in place:
- It is off by default, behind the
CHIKUMA_SECURE_BOOTenvironment variable. The gate is a runtime one, because a compile-time gate can silently compile the whole path out. - It must never activate for a build emulating real Apple firmware. There, a non-zero key selector staying inert is the only correct behaviour.
IV = 0, matching every real hardware-key job measured so far. Chikuma's container format follows the same convention, so the reproduced ROM's header-MAC and body-decrypt sequence works against these keys with no change at all.
The ONB is encrypted under selector 2, the selector Apple's own ONB container uses already.
Recovery paths, and the limit¶
The chain makes the recovery paths workable. A container that fails its check drops to the boot ROM's DFU recovery. BDS's no-OS path draws the restore screen and powers the device off. Both are now reachable on demand, from a built image, and the ONB's log tells whether the loader never jumped or jumped into an image that died.
Chikuma's CA root stays an emulator capability, though. A real S5L8702's mask ROM refuses a bootloader signed with it, because its root of trust is the digest burned into the ROM.
A real device gets Chikuma's bootloader by a different route, and from there the CA comes back into play. The bootloader on the development unit checks Chikuma's OS against the same leaf key the emulator's chain uses, and refuses at boot an image signed with any other key. On the device tells how that unit was set up.