Accessories and iAP¶
The dock connector is how the iPod talks to chargers, car head units, speakers, remotes and the FM accessory. Two things travel over it: a serial protocol Apple calls the Accessory Protocol (iAP), and USB. Chikuma reproduces the parts of both that the firmware carries, and some of it already runs on a real iPod.
iAP and its transports¶
iAP is a framed command protocol. On the iPod classic it runs over two transports: the dock connector's serial line, through an on-chip UART, and a transport inside the USB HID interface. Commands are grouped into lingoes, such as a general lingo, a display-remote lingo, an extended-interface lingo for browsing the library, and digital audio. This device speaks most of them.
iAP 1 and iAP 2 on one wire¶
iAP 1 is what the device carries, so Chikuma reproduces it first, with the firmware as oracle. iAP 2 came after this firmware and has nothing in the image to recover, so everything Chikuma builds for it is OURS.
The two share a wire and differ in their lead bytes:
A link can therefore offer both and route by the header. Sent an iAP 2 frame, the original firmware refuses it, which confirms by measurement that it does not speak iAP 2.
iAP 2 and car head units¶
A current head unit that plays from an Apple device over USB speaks iAP 2 and has dropped iAP 1. For those cars a stock iPod classic is mass storage at best.
Chikuma's iAP 2 sits on its own vendor interface beside the HID one, laid out the way Apple's own USB transport for it is. HID stays iAP 1's, and the bulk pair is iAP 2's.
| Layer | Contents |
|---|---|
| Link | detect, negotiation, sequence and acknowledgement, retransmission, sessions |
| Control | identification, Now Playing with artwork, the media library, keys, digital audio |
Both layers were checked end to end against Apple's own accessory code on the host, including a full library sync and an artwork transfer. Ported to Zig, they run inside Chikuma on the emulated machine and on a real iPod, which a Mac app drives over them in a development build. None of it has run in a car yet.
Talking to the original over the dock¶
The emulated machine exposes the dock serial line as a socket, which turns the original into a live iAP oracle. Send it a frame, read its answer.
The general-lingo conversation is reproduced and gated against the original's measured replies:
| Question | Answer |
|---|---|
| device name | iPod |
| software version | the version the image reports |
| a lingo's protocol version | that lingo's version |
qemu-ipod/tools/iap.py drives the conversation and qemu-ipod/gates/iap_dock_gate.py holds the
answers.
What a car or a dock uses¶
Beyond the general lingo, chikuma/drivers/iap/ answers the parts a car stereo or a dock actually
uses.
The Simple Remote buttons drive Chikuma's menus and player the way they drive the original's. The emulator's scripted input goes through them too, because one press is one row.
The extended interface browses the library by category, plays a selection, and reports the track, its position and its changes.
The push-image command sends a picture to the device's screen. Chikuma reassembles it, decodes it in the pixel formats the original accepts, and draws it on the connected-accessory screen built from the archive.
Detecting what is plugged in¶
Before any serial conversation, the iPod identifies an accessory by a resistor. The accessory ties the dock's identify pin to ground through a known resistance. The device reads it through the PMU's analog input and maps it to one of a handful of bands, and an open circuit means nothing is attached.
The scheme is recovered from the firmware, and it also matches Apple's published iPod Interface Specification. Its identity table names the bands: a simple dock, a diagnostic dock, a battery pack, a UART dock, a car charger, and so on.
Two accessory tasks split the work. One owns the resistor detection that gates features, the other owns the serial conversation. None of it is exercised yet, because the emulated machine has no accessory attached, so every observation is of the absent case.
The headphone remote¶
Apple's headsets with a remote, such as the EarPods and the in-ear headphones, do not use iAP at all. A small chip on the iPod's own board reads their buttons: MIKEY, on the I2C bus.
Plugging a headset in powers the chip, and the chip identifies the accessory. Each button press then raises an interrupt, and the firmware answers it by reading two registers, one for the centre button and one for the volume pair.
Chikuma's driver is a port of the firmware's (chikuma/drivers/hw/mikey.zig). It works on a real
iPod classic 6.5G, with centre single, double and triple click, and volume.
The bootloader holds the chip in reset¶
The bootloader leaves the headphone-jack detect pin as an output driven low. The chip then sees an empty jack forever and answers nothing, which looks exactly like a board without one. The firmware's own pin table makes that pin an input, and Chikuma does the same at boot.
When a headset is identified¶
The firmware identifies a headset when it resumes from sleep, not at power-up, because it is always already running when a headset arrives. Chikuma's boot stands where that resume would. It also watches the jack-detect pin, so a pull and a re-plug identify again instead of silencing the chip for good.
Volume on these EarPods is OURS¶
On the test unit the EarPods identify as a kind of headset the original reads no volume buttons from. The chip still reports the presses, one report per press and nothing on release. Chikuma reads them and takes each report as a single click. With nothing to ramp on, there is no hold-to-ramp.
What a press does¶
That part is the firmware's. The centre button's gestures come from the archive's remote bindings. A volume step on Now Playing brings up the same volume bar as the click wheel, for the same 4 s.
The accessory board, on paper¶
A physical accessory board exists as a design. It has a 30-pin dock plug, an analog multiplexer that picks an identity resistance in hardware the way the emulator picks it in software, a small microcontroller speaking iAP over the serial line, and USB to a host.
Nobody has built or tested it. One hardware question is open: Apple's specification and community pinouts disagree on the identify-pin numbering, so it has to be metered on a real connector first.
Warning
The FireWire power pins must be left unconnected on this board.
USB¶
The dock connector's other half is USB: the device stack and its two configurations, the hand-over of the disk to a Mac, and the separate disk-mode image. All of it is on USB and disk mode.
Status¶
| State | Pieces |
|---|---|
| Reproduced | the headphone remote (MIKEY) driver and its gestures, iAP 1 message decoding and routing, the dock-serial and USB-HID transports, the general-lingo conversation, Simple Remote, the extended interface's browse and playback, the push-image command, the USB device stack with its two configurations, mass storage with the disk hand-over |
| OURS | volume buttons on a headset the original reads none from, iAP 2 in its entirety (its authentication is permissive and says so), the I2C bus lock the serial path shares |
| Open | iAP 1 accessory authentication on Chikuma's side |
| Best-effort | the FM radio accessory and Nike+ / Sports, only if the hardware can be modelled from what the firmware actually uses |
Accessory authentication¶
How the original checks an accessory is read now, including that the lingoes an accessory may use travel in its own certificate. The exchange has run against the original in the emulator. Chikuma's iPod side does not verify yet, and it answers the commands that need authentication with the same refusal the original gives an unauthenticated accessory.
The FM radio accessory stays best-effort. Nike+ / Sports is not something this device runs.