Bring-up on a real iPod¶
Not instructions
This page tells how Chikuma got from the emulator onto one real iPod classic, and where the hardware differed from the emulator. It is not an install guide, and there is no release to install. Writing a device's flash or its firmware partition can leave it unbootable, and recovering one can mean opening the case. On the device says what the install path is and why to think twice before following it.
Chikuma runs on one real iPod classic, every day, through the dock line-out. Each difference below passed in the emulator and failed on the silicon.
The development unit is a late iPod classic 6G, the one often called the 6.5G, with a 160 GB PATA drive. Chikuma's bootloader lives in its flash. Chikuma's OS sits in its firmware partition, beside Apple's.
Power-on to the OS¶
The device runs the same sequence that the boot chain reproduces.
- The boot ROM looks for a first stage in the SPI NOR flash and starts it. When there is none it accepts, it falls back to USB DFU, where a small recovery image can be loaded into RAM. Its exception vectors and its interrupt handler stay at physical address 0 long after it is gone, which matters below.
- The bootloader's early phases set up stacks, then the platform: PLL and clocks, timers, GPIO defaults, the PMU and main memory. They hand what later phases need on in a list of records, the way EFI does it.
- The driver phase dispatches the bootloader's modules in a fixed order: interrupt controller, timer, CPU, display, the AES and SHA-1 engines, clocks, SPI, GPIO, the flash, the panel, the PMU and the charger, and finally the boot logo.
- The boot policy reads the reboot reason the previous OS left in SRAM, plus the buttons and the accessory state. It picks the OS, a pending updater, disk mode or diagnostics. Then it turns the MMU and caches off, reads and checks the image, and jumps to it.
- The OS starts with the MMU off and splits its SRAM and DRAM halves. It finds the hardware description the bootloader left through a tag at a fixed SRAM address.
On the development unit the policy has a choice Apple's does not have. It looks for Chikuma's OS and Chikuma's disk mode first, checks each against Chikuma's own key, and keeps Apple's as the fallback. The boot chain describes that part.
The piezo as a debug channel¶
A device with a dark screen says nothing, so the first tool was the piezo speaker.
| Sound | Meaning |
|---|---|
| a group of N short tones | the bootloader reached milestone N |
| slow toggles from an exception vector | one per exception number, so an abort names itself |
| one chirp at power-on | kept in development builds on purpose, as a POST beep |
The emulator decodes the same pin and logs every chirp and every group. A count heard on the device compares directly with a count in the emulator's log.
Boot differences between the emulator and the device¶
Each of these boots cleanly in an emulator that lacks the detail and fails on the device. The reproduction handles all of them. Where the emulator was wrong, it models the detail now, so the failure reproduces without the hardware.
Two timer interrupt lines¶
The hardware raises the bootloader's tick on a timer line of its own. An emulator that raises every timer interrupt on one line never runs the bootloader's interrupt path at all.
On the device the first tick vectors to a slot where Apple's bootloader has a small trampoline. An ordinary C function in that slot returns with the CPU still in interrupt mode, before the display modules are dispatched. The device beeps eight times and the screen stays dark.
Chikuma's trampoline is ported byte for byte from Apple's. The emulator splits the timer lines the way the hardware does.
A tick through the ROM's vector table¶
When the boot policy turns the MMU off to load the OS, a timer interrupt in that window vectors through physical address 0. That is the boot ROM's table and the ROM's own interrupt handler.
The device's memory map shows this region is the ROM mirrored over and over, not RAM, and the emulator now models it that way. Chikuma's bootloader masks that one timer for the length of the load and the hand-off. This is a declared divergence. Apple's bootloader survives the same window by a path that is not traced for the moment.
Waiting for the AES engine¶
The bootloader checks the OS image, waits for the AES engine to finish its job on the body, and jumps. A wait that tests the wrong status bit moves on while the engine is still working. Gating the engine's clock then freezes the job where it stands, and the OS hangs with most of its body still unreadable. A probe at the jump and a direct read of the engine's status register show both effects.
An emulator that does the whole job instantly can show neither.
Cleaning all four cache ways¶
Apple's data-cache clean sweeps every set of every way. A clean that covers only the first way leaves dirty lines in the other three, and their later eviction writes over memory the next stage has already set up. The emulator has no data cache to leave dirty, so only the device shows it. Chikuma's sweep covers all four ways.
The OS on silicon¶
The OS hit its own set of differences on the device. The emulator against the hardware keeps that list. A few of them:
| Difference | Effect |
|---|---|
| unaligned accesses | the emulator forgave them, the CPU faults on them, and audio stopped on them |
| a USB endpoint | armed without being activated |
| the drive | refuses any command that does not cover a whole 4 KiB physical sector |
| the audio DSP | the emulator modelled it as always ready |
| blocks with a gated clock | they latch their state when the clock stops under them |
The rest of the bring-up happened on this unit too. The USB stack and disk mode, the headphone remote, the charger and the power-saving inventory all carry measurements taken on it.
The host tool¶
On the host, everything goes through shiro, the project's own tool. It is pinned to the one
development unit by USB serial number and refuses any other iPod.
A device that has never run Chikuma needs the boot-ROM DFU exploit the first time it takes Chikuma's recovery stage. freemyipod's wInd3x implements it upstream. After that, Chikuma's own recovery stage, bootloader and disk mode carry every step, and the running OS reboots into them when the host asks. On the device has the outline and the hazards.