Skip to content

Apple's open-source XNU kernel on Android phones: its own loader and drivers, Metal on the Adreno. Runs from RAM; a reboot gives the phone back to Android.

C

The kernel is hakios-kernel: make kernel copies XNU's output there, and xl, make phone, make qemu-open and the prebuilt take it

shimoku210d55f45f74
diff --git a/Makefile b/Makefile
index 5427714..af21276 100644
--- a/Makefile
+++ b/Makefile
@@ -97,7 +97,7 @@ hello:
qemu-open: kernel loader-open hello
mkdir -p logs
xnuloader/mkpayload.py -o qemu/payload.bin \
- kernel=xnu-src/xnu-8796.121.2/BUILD/obj/DEVELOPMENT_ARM64_BCM2837/mach.development.bcm2837 \
+ kernel=hakios-kernel \
ramdisk=userland/hello --cmdline "$(ARGS_OPEN)"
qemu/run.sh $(SECS) | tee logs/qemu-open.log
diff --git a/docs/getting-started/building.md b/docs/getting-started/building.md
index 15aebe7..8dbfcb0 100644
--- a/docs/getting-started/building.md
+++ b/docs/getting-started/building.md
@@ -14,8 +14,9 @@ make kernel # xnu/apply.sh (once), xnu-deps/setup.sh (once), then t
`make kernel` is `tools/make-kernel.sh`: it copies the drivers you edited into the tree (`xnu/sync-drivers.sh`), puts the
configuration's choice of drivers where XNU's build reads it (`tools/hakios-config.py kernel`), builds, and judges the result by
what failed rather than by the exit status (the last steps of XNU's own build always fail on this machine configuration, for kext
-symbol sets this kernel does not have; any other failure is a failure). The kernel is
-`xnu-src/xnu-8796.121.2/BUILD/obj/DEVELOPMENT_ARM64_BCM2837/mach.development.bcm2837`.
+symbol sets this kernel does not have; any other failure is a failure). The kernel is **`hakios-kernel`** at the top of the
+repository (XNU's build calls it `mach.development.bcm2837` in `xnu-src/.../BUILD/obj/DEVELOPMENT_ARM64_BCM2837/`; every tool
+takes the copy named `hakios-kernel`, and `prebuilt/hakios-kernel` when there is none).
| Host | Toolchain |
|---|---|
diff --git a/docs/port-pkg110.md b/docs/port-pkg110.md
index 25c5696..b47951d 100644
--- a/docs/port-pkg110.md
+++ b/docs/port-pkg110.md
@@ -70,7 +70,7 @@ the boot test itself: `./xl enter` does a `fastboot boot`, which a truly locked
## Running from Windows (Git Bash) — what had to be solved
-- **No theos needed for a first boot.** `xl` falls back to `prebuilt/mach.development.bcm2837` and
+- **No theos needed for a first boot.** `xl` falls back to `prebuilt/hakios-kernel` and
`prebuilt/loader.efi` when nothing is built (`xl:50-53,120`): those are the `redwood` kernel and
loader, i.e. for this SoC. The toolchain is only needed to build a *changed* kernel (which the
cellular fix eventually is).
diff --git a/prebuilt/SHA256SUMS b/prebuilt/SHA256SUMS
index 25b00cb..1738842 100644
--- a/prebuilt/SHA256SUMS
+++ b/prebuilt/SHA256SUMS
@@ -1,6 +1,6 @@
Built 2026-10-25 22:53 from this tree.
-03e794e8e1d389a6abb9bcd2431eaccf9747271ff8c1234922225718c70441e9 prebuilt/mach.development.bcm2837
+03e794e8e1d389a6abb9bcd2431eaccf9747271ff8c1234922225718c70441e9 prebuilt/hakios-kernel
adb2f30c01ad7e6842ce6cec43b8d75bc0f76d68543ffb41c0d02c1d285e4b73 prebuilt/loader.efi
932c856c04e87611b16c872da37c461d572c6258da0202ecd875d91c29886e03 prebuilt/userland/HakiosAudio
45bffe2da6b2484836bd29074b39bd5cc67b4cdaa253c2aa39561ce5188d6ddc prebuilt/userland/child
diff --git a/prebuilt/mach.development.bcm2837 b/prebuilt/hakios-kernel
similarity index 100%
rename from prebuilt/mach.development.bcm2837
rename to prebuilt/hakios-kernel
diff --git a/qemu/run-ios.sh b/qemu/run-ios.sh
index e826710..d7f041a 100755
--- a/qemu/run-ios.sh
+++ b/qemu/run-ios.sh
@@ -34,8 +34,8 @@
# file that holds the image at the right offset (reflinked, so it costs neither disk space nor
# host RAM).
cd "$(dirname "$(readlink -f "$0")")/.." || exit 1
-K=xnu-src/xnu-8796.121.2/BUILD/obj/DEVELOPMENT_ARM64_BCM2837/mach.development.bcm2837
-[ -f $K ] || { K=prebuilt/mach.development.bcm2837; echo "run-ios.sh: no kernel built here, using $K" >&2; }
+K=hakios-kernel
+[ -f $K ] || { K=prebuilt/hakios-kernel; echo "run-ios.sh: no kernel built here, using $K" >&2; }
# iOS has to be told which iPhone it runs on, and that comes from the user's own IPSW, into the loader at build time
# (xnuloader/mkidentity.sh). The loader in prebuilt/ has no Apple data, so with it iOS does not start, and the window stays black.
if [ ! -f xnuloader/loader.efi ] && [ -z "$QEMU_PREBUILT_LOADER" ]; then
diff --git a/tools/apfs/bench-phone.sh b/tools/apfs/bench-phone.sh
index b9c04bf..e05021a 100755
--- a/tools/apfs/bench-phone.sh
+++ b/tools/apfs/bench-phone.sh
@@ -18,7 +18,7 @@ EXTRA=${2:-}
CPUS=${BENCH_CPUS:-8}
FREQ=${BENCH_FREQ:-1}
cd "$ROOT" || exit 1
-K=xnu-src/xnu-8796.121.2/BUILD/obj/DEVELOPMENT_ARM64_BCM2837/mach.development.bcm2837
+K=hakios-kernel
[ -n "${BENCH_KERNEL:-}" ] && cp -p "$BENCH_KERNEL" "$K"
printf "%-7s %9s %8s %12s %12s %10s %8s %4s %s\n" readers wall_ms MB/s lock_wait_ms lock_held_ms inflate_ms hash_ms bad sums
diff --git a/tools/make-kernel.sh b/tools/make-kernel.sh
index 21828d3..3ef5870 100755
--- a/tools/make-kernel.sh
+++ b/tools/make-kernel.sh
@@ -48,12 +48,15 @@ fi
log=${KERNEL_LOG:-xnu-build.log}
./xnu-build.sh -k "$@" 2>&1 | tee "$log"
status=${PIPESTATUS[0]}
+# The kernel's name is HakiOS's: XNU's build calls its output mach.<config>.<machine>, and the copy every tool takes
+# (xl, make phone, make qemu-open, tools/update-prebuilt.sh) is ./hakios-kernel
+named() { cp -p "$KERNEL" hakios-kernel && echo "make-kernel: built: hakios-kernel ($KERNEL)"; }
if [ "$status" -eq 0 ]; then
- echo "make-kernel: built: $KERNEL"
+ named
exit 0
fi
if judge "$log"; then
- echo "make-kernel: built: $KERNEL"
+ named
echo "make-kernel: (exit status $status is the kext symbol-set checks failing, as they do on this configuration; see $0)"
exit 0
fi
diff --git a/tools/provenance.allow b/tools/provenance.allow
index 85d930c..6e883fe 100644
--- a/tools/provenance.allow
+++ b/tools/provenance.allow
@@ -7,7 +7,7 @@
# The first line that matches a path decides. A file that no line explains fails the check.
# --- built from this repository -----------------------------------------------------------------------
-open prebuilt/mach.development.bcm2837 the kernel, built from Apple's open xnu-8796.121.2 plus xnu/hakios.patch and xnu/files: APSL-2.0, corresponding source here and at Apple
+open prebuilt/hakios-kernel the kernel, built from Apple's open xnu-8796.121.2 plus xnu/hakios.patch and xnu/files: APSL-2.0, corresponding source here and at Apple
open prebuilt/loader.efi the boot loader, built from xnuloader/loader.c: MIT
open prebuilt/userland/* our programs and libraries, built from userland/src: MIT
open devices/redwood/prebuilt/BootShim.bin built from the shim of Mu-Silicium with our change (uefi/hakios.patch): BSD-2-Clause-Patent
diff --git a/tools/update-prebuilt.sh b/tools/update-prebuilt.sh
index ae2dca1..d90ebe6 100755
--- a/tools/update-prebuilt.sh
+++ b/tools/update-prebuilt.sh
@@ -5,10 +5,10 @@
set -e
cd "$(dirname "$(readlink -f "$0")")/.."
# KERNEL=... to take the kernel from a tree built elsewhere (xnu/apply.sh makes one anywhere)
-K=${KERNEL:-xnu-src/xnu-8796.121.2/BUILD/obj/DEVELOPMENT_ARM64_BCM2837/mach.development.bcm2837}
+K=${KERNEL:-hakios-kernel}
MU=Mu-Silicium
mkdir -p prebuilt/userland devices/redwood/prebuilt
-cp $K prebuilt/mach.development.bcm2837
+cp $K prebuilt/hakios-kernel
# The loader in prebuilt/ is built with the PLACEHOLDER identity (xnuloader/mkidentity.sh --placeholder: no Apple data), in a
# temporary copy so that the real xnuloader/identity.h of this tree, made from your own IPSW, is left alone and never copied
# here. It boots the open kernel (make qemu-open); to start iOS, build the loader yourself (make loader).
@@ -34,6 +34,6 @@ fi
{
echo "Built $(date '+%Y-%m-%d %H:%M') from this tree."
echo
- sha256sum prebuilt/mach.development.bcm2837 prebuilt/loader.efi prebuilt/userland/* devices/redwood/prebuilt/* 2>/dev/null
+ sha256sum prebuilt/hakios-kernel prebuilt/loader.efi prebuilt/userland/* devices/redwood/prebuilt/* 2>/dev/null
} > prebuilt/SHA256SUMS
ls -la prebuilt prebuilt/userland devices/redwood/prebuilt
diff --git a/xl b/xl
index 20e9c6a..2114f40 100755
--- a/xl
+++ b/xl
@@ -52,8 +52,8 @@ cd "$(dirname "$(readlink -f "$0")")" || exit 1
# On a Mac: flock, GNU timeout and stat, and Android's platform-tools, from tools/macos-bin (see its README)
[ "$(uname)" = Darwin ] && PATH=$PWD/tools/macos-bin:$PWD/tools/macos-bin/platform-tools:$PATH
# the kernel and the loader built here, or else the ones that come with the repository
-K=xnu-src/xnu-8796.121.2/BUILD/obj/DEVELOPMENT_ARM64_BCM2837/mach.development.bcm2837
-[ -f $K ] || K=prebuilt/mach.development.bcm2837
+K=hakios-kernel # make kernel makes it
+[ -f $K ] || K=prebuilt/hakios-kernel
L=xnuloader/loader.efi
if [ ! -f $L ]; then
L=prebuilt/loader.efi
diff --git a/xnu/README.md b/xnu/README.md
index 500a874..09e2998 100644
--- a/xnu/README.md
+++ b/xnu/README.md
@@ -23,7 +23,7 @@ xnu-deps/setup.sh # dependencies, mig/unifdef/tcsh, the SDK overlay, two
./xnu-build.sh -j8 -k # about a minute on 12 threads
```
-The kernel: `xnu-src/xnu-8796.121.2/BUILD/obj/DEVELOPMENT_ARM64_BCM2837/mach.development.bcm2837`.
+The kernel: `hakios-kernel` at the top of the repository (`make kernel` copies it there from XNU's `xnu-src/xnu-8796.121.2/BUILD/obj/DEVELOPMENT_ARM64_BCM2837/mach.development.bcm2837`).
`./xl run` and `qemu/run-ios.sh` take it from there (`prebuilt/` only when it is missing).
Things to know: