Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7ae5480
devices/n42: describe the iPhone 5 and its firmware recipes
brkosebay Dec 1, 2026
9d3a0b5
boot: build the N42 watchdog and framebuffer diagnostic loaders
brkosebay Dec 1, 2026
0a2f4b4
kernel: build the fenced N42 installer writer on apple-armv7
brkosebay Dec 1, 2026
01edc5e
boot: pin the N42 read-only flash and boot entry reader
brkosebay Dec 1, 2026
5e3827f
n42: derive and install the Mesa SGX event template from 12H321
brkosebay Dec 1, 2026
3a09571
schemas: describe hash-pinned byte ranges in peripheral recipes
brkosebay Dec 1, 2026
20de872
release: index the board-specific ARMv7 m1n1 Mach-O and its method data
brkosebay Dec 1, 2026
3707813
ci: name board-specific m1n1 files in the producer contract
brkosebay Dec 1, 2026
b374397
Merge main into the N42 board
henrikklee Dec 2, 2026
e17ce53
Merge the 32-bit m1n1 route: the N42 boots by ibss-m1n1
henrikklee Dec 2, 2026
3adbbb1
Ship methods.toml in the board data the CLI reads, too
henrikklee Dec 2, 2026
2d95ca5
boot: one 32-bit m1n1 for every board, no N42-only builds
henrikklee Dec 2, 2026
703f8c3
Merge the 32-bit route branch: keys and the platform page
henrikklee Dec 2, 2026
aac4aae
n42: public IMG3 keys for the 12H321 iBSS, iBEC and DeviceTree
henrikklee Dec 2, 2026
0f823dc
Merge the 32-bit route branch: m1n1 main with the N42 support
henrikklee Dec 2, 2026
f515a69
Merge remote-tracking branch 'origin/main' into boot-32bit-m1n1-route
henrikklee Dec 2, 2026
141db64
Docs: the P105's state as main records it
henrikklee Dec 2, 2026
88d4557
Merge branch 'boot-32bit-m1n1-route' into n42-board-adopt
henrikklee Dec 2, 2026
2b63bf1
Merge remote-tracking branch 'origin/main' into n42-board-adopt
henrikklee Dec 2, 2026
2f9cb4b
kernel: leave the armv7 lock and config to the kernel lock PR
henrikklee Dec 2, 2026
1013565
n42: features follow the kernel orchard builds
henrikklee Dec 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions boot/initramfs/install/install_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,11 +681,7 @@ def install_kernel(path, root, *, size, sha256, expanded_limit, package=None):


def install_firmware(bundle, root, *, size, sha256):
"""The private firmware bundle (lib/firmware/... plus mixin.json) into /usr/lib/firmware.

Arch's /lib is a link to usr/lib, which the extractor never follows, so
firmware paths are mapped explicitly; nothing outside it is written.
"""
"""Install verified peripheral firmware and Mesa's N42 userspace event template."""
data = bundle.read(size + 1)
if len(data) != size or hashlib.sha256(data).hexdigest() != sha256:
raise InstallError('firmware-mismatch', 'Firmware bundle size or hash differs from the plan')
Expand All @@ -699,16 +695,24 @@ def install_firmware(bundle, root, *, size, sha256):
continue
if not (member.isfile() and name.startswith('lib/firmware/')):
raise InstallError('unsafe-archive', 'Firmware bundle may contain only firmware files')
parent, leaf = parent_fd(root_fd, 'usr/' + name)
try:
fd = os.open(leaf, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644, dir_fd=parent)
with os.fdopen(fd, 'wb') as output:
output.write(archive.extractfile(member).read())
os.fchown(output.fileno(), 0, 0)
os.fchmod(output.fileno(), 0o644)
count += 1
finally:
os.close(parent)
blob = archive.extractfile(member).read()
if name == 'lib/firmware/apple/sgx543-n42/gl-event.pds':
# Mesa's UAPI 3 frame builder reads the event program through this manifest.
paths = [('usr/local/lib/sgx2d/gl-event.pds', blob),
('usr/local/lib/sgx2d/pack.txt', b'pds 0x98956000\nimg 0x98956000 gl-event.pds\n')]
else:
paths = [('usr/' + name, blob)]
for path, content in paths:
parent, leaf = parent_fd(root_fd, path)
try:
fd = os.open(leaf, os.O_WRONLY | os.O_CREAT | os.O_TRUNC | os.O_NOFOLLOW, 0o644, dir_fd=parent)
with os.fdopen(fd, 'wb') as output:
output.write(content)
os.fchown(output.fileno(), 0, 0)
os.fchmod(output.fileno(), 0o644)
count += 1
finally:
os.close(parent)
finally:
os.close(root_fd)
return count
Expand Down
4 changes: 2 additions & 2 deletions boot/m1n1/build
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ in_builder() {
if [[ -d "$source/build/arm32" ]]; then in_builder make clean; fi
in_builder make -j2 USE_CLANG=1 ARCH=aarch64-linux-gnu \
TOOLCHAIN=/usr/lib/llvm-19/bin/ LLDDIR=/usr/lib/llvm-19/bin/ CHAINLOADING=1 \
EXTRA_CFLAGS="$extra_cflags"
EXTRA_CFLAGS="$extra_cflags -g0"
mkdir -p "$(dirname "$output")"
cp "$source/build/m1n1.bin" "$output"
# The same build as Mach-O, for a chain that starts m1n1 from iBoot as the
Expand All @@ -94,7 +94,7 @@ cp "$source/build/m1n1-idevice.macho" "$source/build/monitor-stub.macho" "$(dirn
in_builder make clean
in_builder make -j2 M1N1_ARCH=arm USE_CLANG=1 \
TOOLCHAIN=/usr/lib/llvm-19/bin/ LLDDIR=/usr/lib/llvm-19/bin/ CHAINLOADING=1 \
EXTRA_CFLAGS="$extra_cflags"
EXTRA_CFLAGS="$extra_cflags -g0"
cp "$source/build/m1n1-armv7.macho" "$(dirname "$output")/"
sha256sum "$output" 2>/dev/null || shasum -a 256 "$output"
echo "Loader: $output"
6 changes: 4 additions & 2 deletions chips/s5l8950x.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ soc = "s5l8950x"
architecture = "arm"
image_format = "img3"
platform = "apple-armv7"
reference_version = "8.4.1"
stages = ["iBSS", "iBEC"]

[evidence]
platform = "32-bit kernelcache in the IPSW; not run"
stages = "iBSS far smaller than iBEC in the IPSW; not run"
platform = "N42 (iPhone5,2) from RAM with the S5L8950X kernel series: both Swift cores, AIC timer per CPU, USB gadget, Wi-Fi, NAND read-only (devices/n42/README.md)"
stages = "N42: kDFU, then a patched iBSS and iBEC from 8.4.1 / 12H321 start the 32-bit m1n1 with bootx"
reference_version = "8.4.1 / 12H321 has public IMG3 keys for the N42 iBSS, iBEC and DeviceTree, and a jailbreak that reaches kDFU"
69 changes: 69 additions & 0 deletions devices/n42/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# iPhone 5 (Global), N42

The first A6 (S5L8950X, two Apple Swift ARMv7s cores, 1 GiB) board of the
apple-armv7 platform. The kernel side is the S5L8950X series for
OrchardLinux/linux `armv7`: SoC core, PMGR gates and USB PHY, the iPhone 5
peripherals and NAND. The device tree is `s5l8950x-n42.dts`, which
includes `s5l8950x-5.dtsi` (what the N41 and N42 share) and `s5l8950x.dtsi`.

## Boot method

The board boots like every 32-bit board: the `ibss` route and its
`ibss-m1n1` method (`docs/platforms-and-builds.md`, "32-bit boot"), a
patched iBSS and iBEC, Apple's DeviceTree, then the 32-bit m1n1 with `bootx`.
The tested starting point was an iPhone5,2 already jailbroken on iOS 8.4.1
(12H321), entering kDFU with kloader (OrchardLinux/m1n1#17). m1n1 supplies the RAM layout, scanout,
initrd, and per-device wireless addresses and touch calibration to Linux.

## What ran

One iPhone5,2 (iOS 8.4.1, 12H321), from RAM, with OrchardLinux/linux `armv7`
plus the S5L8950X series, built with clang 19 in the platform's toolchain
image.

| Feature | Seen | Notes |
|---|---|---|
| CPUs | both cores online, the USB shell reached | The A6 has no ARM PMU. The clocksource is the 24 MHz watchdog counter; each core has its own AIC timer. |
| USB serial and network | `ttyGS0` shell, CDC networking | No `clk_ignore_unused`: the PHY holds its PMGR gates. |
| Display | simplefb and fbcon on iBoot's 640x1136 scanout | |
| Backlight | LM3534 on, brightness 300 written and read back | |
| NAND | The iOS System partition mounts read-only; the installer kernel permits writes inside the Linux partition fence | SanDisk PPN, 2 buses x 2 CAUs x 1056 blocks. The Data partition is read but encrypted. |
| Wi-Fi | WPA2 on 5 GHz, DHCP, DNS and HTTP | BCM4334 on HSIC port 4. |
| Bluetooth | the patchram loads, `hci0` answers | Not brought up or scanned yet. |
| Battery | percentage, voltage, current, temperature, capacity and cycles | bq27540 over HDQ on UART5. |
| Charger | VBUS online and the input limit read | The driver runs disarmed and writes nothing. |
| Touch | the kernel boots the digitizer; one-finger frames with moving coordinates | `/dev/input/event0` and multi-touch not checked yet. |
| Buttons | gpio-keys probes | Presses not checked. |

## Firmware

`firmware.json` builds the Wi-Fi firmware (`centennial.trx` with the
`heineken-m-ms.txt` NVRAM), the Bluetooth patchram (`BCM4334B1 37.4 MHz
Centennial Murata` from BlueTool) and `N42.mtprops` from the 12H321 IPSW.

It also takes the GPU's microkernel out of the kernelcache:
`apple/sgx543-s5l8950x.fw`, from the `sgx543-from-kernelcache@1` step. The
A6's GPU kext is another build than the A5's (class `SGXDriver543RC2`,
`__data` 0x14eb4 and `__const` 0x300 bytes), so the A6 has its own file
and the kernel driver its own offsets into it. It needs a tools release
whose step takes that class.

For Mesa on kernel UAPI 3 the same peripheral recipe takes 168 bytes of the
GL event program from the 12H321 system volume. The installer writes the
verified program and its two-line manifest to `/usr/local/lib/sgx2d`.
Set `ORCHARD_FIRMWARE_ROOT` to the root of a locally readable copy of the
8.4.1 system volume and `ORCHARD_FIRMWARE_KERNELCACHE` to its decoded
kernelcache before running `orchard fw build n42 --type peripheral --out ./firmware` or
`orchard install`. Each local input must match the recipe hash. The restore
version used for the bootloader is independent of the peripheral firmware.

The touchscreen takes one complete HBPP DATA packet from the `C1F57,1`
profile in N42.mtprops. The recipe checks the output hash and installs the
64,340-byte packet as `apple/z2-n42.bin`. The kernel receives touch and
proximity calibration separately through the device tree.

## N41

The iPhone5,1 (N41) is the same phone without the CDMA bands, which Linux
does not drive. `s5l8950x-n41.dts` uses the same include, but no N41 has run
it.
46 changes: 33 additions & 13 deletions devices/n42/boot.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,57 @@
"firmware": [
{
"ipsw": {
"version": "10.3.4",
"build": "14G61",
"url": "https://updates.cdn-apple.com/2019/ios/091-25277-20190722-0C1B94DE-992C-11E9-A2EE-E2C9A77C2E40/iPhone_4.0_32bit_10.3.4_14G61_Restore.ipsw",
"bytes": 2000796302,
"sha256": "31b4e67cdeae511bd27ff8a2a285753f7ac9608b8d848e1dec68efc980108695"
"version": "8.4.1",
"build": "12H321",
"url": "https://secure-appldnld.apple.com/ios8.4.1/031-31065-20150812-7518F132-3C8F-11E5-A96A-A11A3A53DB92/iPhone5,2_8.4.1_12H321_Restore.ipsw",
"bytes": 1656563298,
"sha256": "9757457a242e9e3ce613a10a671e464631777b7d347c7b47c281c8ec1f1d0668"
},
"selected_by": "chip-reference",
"keys": {
"Firmware/dfu/iBSS.n42.RELEASE.dfu": {
"kind": "img3",
"iv": "fdad2b7a35384fa2ffc7221213ca1082",
"key": "74cd68729b800a20b1f8e8a3cb5517024a09f074eaa05b099db530fb5783275e",
"source": "api.ipsw.me v4 keys (12H321, public firmware keys); checked 2026-12-02 by decrypting this member (iBoot-2261.30.37)"
},
"Firmware/dfu/iBEC.n42.RELEASE.dfu": {
"kind": "img3",
"iv": "ba178c287f6ce38acbec569f6adbf170",
"key": "888f24c26a13fdb2c8182b156d793b1350428e2b6c31a634d16a61752b236dc9",
"source": "api.ipsw.me v4 keys (12H321, public firmware keys); checked 2026-12-02 by decrypting this member (iBoot-2261.30.37)"
},
"Firmware/all_flash/all_flash.n42ap.production/DeviceTree.n42ap.img3": {
"kind": "img3",
"iv": "40dc28c4fc1b28df6f44bff7f833b44d",
"key": "dccfcf97891d4fa62fef944ff646ce9a81e821883f2b6bc3cc5ca3a22ee90ce9",
"source": "api.ipsw.me v4 keys (12H321, public firmware keys); checked 2026-12-02 by decrypting this member (model iPhone5,2)"
}
},
"selected_by": "newest",
"inputs": {
"BuildManifest.plist": {
"ipsw": {
"zip": "BuildManifest.plist"
},
"sha256": "579ec834734372c9ef66071d12e0cf9e349be0e6ef15912b4ae9e04b0009daf2"
"sha256": "b89d57d025e380799e609b6e3345617a817bcc7ad2c3a7892ec822dc84a4d652"
},
"iBSS": {
"ipsw": {
"zip": "Firmware/dfu/iBSS.iphone5.RELEASE.dfu"
"zip": "Firmware/dfu/iBSS.n42.RELEASE.dfu"
},
"sha256": "5bbe5e485e00735040da0dbfa705640574f4650af28e959a8ba5be5b6e6fd4b2"
"sha256": "22a1a86d8b2af3a33cbdef4f8a6e925bf0a57d69e9a001578d9ebb3378c5d6f1"
},
"iBEC": {
"ipsw": {
"zip": "Firmware/dfu/iBEC.iphone5.RELEASE.dfu"
"zip": "Firmware/dfu/iBEC.n42.RELEASE.dfu"
},
"sha256": "68062186f6603179102949253dde530cc0bc347b637d227c42ddf236c98dc38d"
"sha256": "23303f289949f9e098f799304ae1a74daad92a96b2d1189fc2929d7a0a3acf75"
},
"DeviceTree": {
"ipsw": {
"zip": "Firmware/all_flash/DeviceTree.n42ap.img3"
"zip": "Firmware/all_flash/all_flash.n42ap.production/DeviceTree.n42ap.img3"
},
"sha256": "26a3f0db29d78627698dee1cfc7ef3621b4fab5c748f0529c9e41f3d3871ea07"
"sha256": "41feb6c5372def063433b417b3d089ed773c1bb9330dc3d6c8b6eccf93301d3c"
}
}
}
Expand Down
58 changes: 56 additions & 2 deletions devices/n42/device.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# iPhone 5 (Global) (N42): identity from public sources
# (tools/catalog/generate). No Orchard bring-up yet; see docs/device-bring-up.md.
# iPhone 5 (Global) (N42): identity, kernel and manual boot prerequisites.
schema = 1
kind = "hardware.device"

[device]
profile = "n42"
name = "iPhone 5 (Global)"
apple_products = ["iPhone5,2"]
dt_compatible = ["apple,n42ap"]

[match.dfu]
chip = 0x8950
Expand All @@ -15,3 +15,57 @@ board = 0x02
[boot]
methods = ["ibss-m1n1"]
entries = ["pico-checkm8", "kdfu"]
# The 32-bit boards' ibss route (routes.toml): booted from a jailbroken iOS 8.4.1
# (12H321), where kloader enters kDFU; a patched iBSS and iBEC follow, and iBEC
# starts the 32-bit m1n1 with bootx (README.md, OrchardLinux/m1n1#17).

[kernel]
platform = "apple-armv7" # kernel/series/apple-armv7, kernel/configs/apple-armv7
dtb = "s5l8950x-n42" # arch/arm/boot/dts/apple/<dtb>.dtb

[firmware]
recipe = "firmware.json"

# iOS prepares the LwVM split separately. The install kernel restricts writes
# to Linux partitions in the released space.
[storage]
reclaims = false

[support]
status = "supported"

# States: working, untested, missing, none (features.toml).
# States follow the kernel orchard builds (OrchardLinux/linux `armv7`): it has
# the A6, the iPhone 5's device tree with both cores, the framebuffer, the USB
# gadget and the watchdog (OrchardLinux/linux#88). "working" was seen on one
# iPhone5,2 from RAM. What Berkay's open kernel PRs bring is "missing" here,
# with the PR that brings it, until that PR is in armv7.
[features]
display = "working" # simplefb on iBoot's 640x1136 scanout, fbcon.
screen_off = "missing"
backlight = "missing" # LM3534 backlight: OrchardLinux/linux#59 (not in armv7 yet); worked on its kernel.
gpu_desktop = "missing" # SGX543MP3: OrchardLinux/linux#61 (not in armv7 yet).
touch = "missing" # Z2 digitizer: OrchardLinux/linux#59 and #65 (not in armv7 yet).
buttons = "missing" # gpio-keys for Home, Hold, Volume and Ringer: OrchardLinux/linux#59 (not in armv7 yet).
accelerometer = "missing"
gyroscope = "missing" # AP3GDL gyroscope: OrchardLinux/linux#63 (not in armv7 yet).
light_sensor = "missing"
touch_id = "none"
storage_read = "missing" # N42 NAND reader: OrchardLinux/linux#60 (not in armv7 yet); read on its kernel.
storage_write = "missing" # Fenced N42 NAND writer: OrchardLinux/linux#69 (not in armv7 yet).
wifi = "missing" # BCM4334 on HSIC: OrchardLinux/linux#59 (not in armv7 yet); WPA2, DHCP and HTTP on its kernel.
bluetooth_input = "missing" # BCM4334 Bluetooth: OrchardLinux/linux#59 (not in armv7 yet).
bluetooth_audio = "missing"
cellular = "missing"
battery = "missing" # bq27540 over HDQ: OrchardLinux/linux#59 (not in armv7 yet); read on its kernel.
charging = "missing" # D1972 charger: OrchardLinux/linux#59 and #62 (not in armv7 yet).
charging_control = "missing" # The charger driver runs disarmed: it logs and writes nothing.
suspend = "missing"
resume = "missing"
usb_serial = "working" # ttyGS0 shell, no clk_ignore_unused.
usb_network = "working"
usb_host = "missing"
audio_output = "missing"
audio_input = "missing"
camera = "missing" # Front and rear cameras: OrchardLinux/linux#66 (not in armv7 yet).
video_decode_hevc = "missing"
Loading
Loading