Skip to content

Settings and the Preferences file

The iPod keeps its settings in one object in memory and one file on the disk, iPod_Control/Device/Preferences. The Settings screens are built from the resource archive like every other screen, and their rows read and write that object through properties. Chikuma reproduces the object, the file and the rules that bind them, in chikuma/ui/silver/prefs.zig and its neighbours.

The file is the object

The Preferences file is 0xB8C bytes, and it is a straight image of the settings object, starting four bytes into it. Every getter in the firmware addresses the object, so a field's offset in the file is its offset in the object minus four. Two writers in the firmware touch the same byte from the two sides, the defaults writer through the image and a migration step through the object, and they agree on this rule.

Chikuma keeps the file byte for byte. New settings of Chikuma's own never go into it, because they would collide with fields of the object nobody has read yet. They live in a separate 20-byte file on the volume instead.

Loading: defaults first

At boot the firmware loads in three steps:

  1. it clears the object and writes the defaults
  2. it reads the file over them
  3. it checks the file's version word and the word after it, and if the file looks wrong it writes the defaults again

So a file can be on the disk and be ignored whole. The defaults are a short list of stores over a zeroed object. A few take their value from the hardware: the volume ceiling, for example, and two fields chosen by the model's family code. The Home menu's default row set is one word, and it gives exactly Music, Videos, Photos, Podcasts, Extras, Shuffle Songs, and Radio, which a separate gate then hides.

Saving

The firmware writes the file only when the object is dirty, and always the whole image. It writes at shutdown and periodically, from a task that flushes the databases. Chikuma writes the same image the same way. The moment it writes, from a hook installed once the filesystem is mounted, is Chikuma's own, because that flushing task is not reproduced. One stamp field near the start of the file is also kept as it was loaded, since what the firmware puts there has not been read.

The write path was tested against a writable copy of a real volume. A clean object writes nothing, a change marks the object dirty, the file that lands has the right length, and a fresh load reads the new value back. On the real iPod, Preferences have been rewritten in place, and fsck_hfs passed the volume before and after.

Words that hold more than one setting

Most settings have a field of their own, but not all of them:

Word Holds
the clock word bit 0 is the 24-hour clock, bit 1 is Time in Title
the clicker word two bits for the clicker's four-way choice, the low one also read as a plain on/off

The two clock bits disagree on polarity. Bit 0 set means the 24-hour clock is on. Bit 1 set means Time in Title is off. A shared helper between them would have inverted one silently, so Chikuma's tests pin each bit, each polarity, and that changing one never touches the other.

Daylight saving is not a setting at all. The toggle reads the home time zone, flips its offset by sixty minutes and writes it back.

The Volume Limit and the board's ceiling

The volume lives in a domain of 256 levels. A unit sold where the volume is capped by regulation tops out at 216 instead, whatever the user's limit is. That ceiling is a bit in the board's SysInfo, read once and cached. Nothing in the interface can raise it.

The Volume Limit screen moves the limit with the wheel through a clamped add, as Brightness does. SELECT commits, MENU restores the value the screen opened with, and Play toggles between limited and unlimited. The limit is stored as one word of the Preferences image. Audio and video follows the volume from there down to the codec register.

Coverage

The Settings screens hold twenty editable rows: eighteen value rows and two customisation templates. In Chikuma all twenty show their current value, change when chosen, and keep the change across a reboot. A census tool reads the rows and their bindings from the archive on one side, and what Chikuma answers on the other, and it runs in make check. So a row cannot quietly stop working.

Date and Time are not value rows. They push the date picker, which has its own editing.

A row that was taken out

The archive carries everything for a setting called "Classic Mode": the label, the info pane, a complete preview layout for the Settings screen, an action name, and a toggle function that still works. The Settings row list does not include it. The flag it would toggle has no reader anywhere in the image, the loader never restores it, and no binding navigates to its layout. It is a feature removed before release, and Chikuma leaves it out as the device does.

About: the version and the serial

The version the About screen shows is built into the image as a classic four-part version number: major, minor and bug release packed in two bytes, then a stage and a pre-release number. The image is 2.0.1, final. A final release with no pre-release number prints as plain 2.0.1, and anything else gets a stage suffix. That is the last version the 6.5G board accepts. Later versions all belong to the next generation.

The serial is not in the image. The OS never parses the NOR's configuration records. The second boot stage reads them and leaves a SysInfo block for the OS, with the FireWire id, the board's hardware version and the memory size. The firmware branches on the hardware version in places, such as which timers the clicker uses. The WTF shows how that block gets built and handed over.