Skip to content

Extract the SGX543 microkernel from the A6 GPU kext - #95

Merged
henrikklee merged 2 commits into
OrchardLinux:mainfrom
brkosebay:submit/n42-sgx
Dec 5, 2026
Merged

henrikklee merged 2 commits into
OrchardLinux:mainfrom
brkosebay:submit/n42-sgx

Conversation

@brkosebay

Copy link
Copy Markdown
Contributor

Accept the A6 SGXDriver543RC2 class alongside the A5 class when extracting the firmware from a locally supplied kernelcache. This enables the iPhone 5 recipe. The PR contains Rust source only. The workspace passed cargo build and cargo test.

The iPhone 5's kernelcache (S5L8950X, 12H321) holds the SGX543MP3's
kext under another driver class, SGXDriver543RC2, and no string
"SGXDriver543" alone, so sgx543-from-kernelcache@1 found no kext in
it. Match either class. The A6's kext is another build: its __data is
0x14eb4 bytes and its __const 0x300, and the container carries them
the same way. The P105 container comes out byte for byte as before
(5f929f35...).

Assisted-by: LLM
Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
The iPhone 5's peripheral recipe in orchard takes Mesa's graphics event
template, 168 bytes, out of the A6's dyld shared cache with a new key on
the input: "range": [offset, bytes]. The tools ignored the key and handed
over the whole cache, whose hash then did not match, so the firmware
build for the N42 stopped there.

Read the key: a range needs a rootfs path and a pinned sha256, is not
empty and does not run past the end of a 64-bit offset. The file is read
from the system volume (at most 512 MiB) and the range cut out of it.

Assisted-by: LLM
Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
[Orchard: rebased onto main next to MemberOf; dropped the
 ORCHARD_FIRMWARE_ROOT and ORCHARD_FIRMWARE_KERNELCACHE inputs from a
 local folder or kernelcache, which this recipe does not need; added a
 test for the range key, the changelog line and the commit message.]
@henrikklee
henrikklee marked this pull request as ready for review December 5, 2026 01:14
@henrikklee
henrikklee merged commit 9fc7f8c into OrchardLinux:main Dec 5, 2026
11 checks passed
@henrikklee

Copy link
Copy Markdown
Contributor

Thank you, Berkay! This is merged: the iPhone 5's GPU firmware and the graphics event template for Mesa now build from Apple's files, which orchard's N42 recipe has been waiting for.

What we changed on your branch before merging:

  • Rebased it onto main (it sat next to the newer "member of another restore image" input in catalog.rs and firmware.rs).
  • Kept your A6 kext match (SGXDriver543RC2) and the "range" reader as they were.
  • Left out the ORCHARD_FIRMWARE_ROOT / ORCHARD_FIRMWARE_KERNELCACHE path (inputs from a local folder or kernelcache). The recipe doesn't need it, and it wasn't documented; if you want it for development, it's welcome as its own small pull request with a note in the docs on what it's for.
  • Gave the second commit a message, added a test for the range key (pinned, not empty, no overflow, only on system files) and a changelog line. Both commits still carry you as the author, with an [Orchard: …] note of what we changed.

One thing we left as it was: the range read still loads the system file (up to 512 MiB) into memory to cut out its 168 bytes. Reading just the range would mean a range reader through the APFS extents, which isn't worth it while the same recipe reads the whole dyld cache anyway.

It reaches people with the next tools release.

@henrikklee henrikklee mentioned this pull request Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants