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
xl: a hung run leaves its log and the phone is brought back from the bootloader, or told what to press
shimoku47eb340bd53b
diff --git a/xl b/xlindex 691578a..e4eb9a8 100755--- a/xl+++ b/xl@@ -27,6 +27,9 @@# XL_CMDLINE extra kernel boot-args; default "-v": the boot is shown as text on the phone's screen# (XL_CMDLINE="" for a blank screen, XL_CMDLINE="-v systrace=1" to trace failing syscalls)# XL_SECS seconds after which the kernel returns to the loader on its own (default 8)+# XL_FOLLOW=N fetch the kernel's log every N seconds during a run (default 10; XL_FOLLOW= for never), so that a kernel+# that hangs leaves what it said in logs/<time>-run.log.live; after a hang `run` brings the phone back to+# Android itself, or says what to press if it is stuck on the logo# XL_REBOOT_AFTER=1 when the run is over, send the phone back to Android (it charges there; in the loader it does not,# and its screen stays on: a phone left in the loader overnight is a flat one by morning)# XL_SB_DELAY seconds SpringBoard waits before it starts (default 8; see userland/src/inject_sb.c)@@ -76,6 +79,27 @@ wait_for() { # wait_for <state> <seconds>return 1}+# After a hang the watchdog resets the phone, and what comes up is not always Android: it can stop in its bootloader (it+# charges badly there and a person has to notice), or on the logo, where it does not show on USB at all. Wait for Android;+# a phone that appears in the bootloader or in this loader is sent on to Android at once; if nothing has come back after+# two and a half minutes, say what a person has to do, because nothing here can reach a phone that is not on USB.+recover_phone() {+ local i s+ for ((i = 0; i < 150; i += 3)); do+ s=$(state)+ case "$s" in+ android) echo "xl: phone is back in Android"; return 0 ;;+ fastboot) echo "xl: the phone stopped in its bootloader: sending it on to Android"; timeout 10 fastboot reboot >/dev/null 2>&1 ;;+ loader) echo "xl: the phone is in this loader: sending it on to Android"; fb reboot >/dev/null ;;+ esac+ sleep 3+ done+ echo "xl: the phone has not come back (state: $(state)): it is on the logo, off, or not on this cable."+ echo "xl: hold the power button for about 15 seconds; it restarts into Android."+ echo "xl: for the bootloader (fastboot) hold power and volume-down while it restarts."+ return 1+}+enter() {case "$(state)" inloader) return 0 ;;@@ -153,6 +177,7 @@ run() { # run <oem command> <label># the loader goes on answering: ask every two seconds until the result is no longer "running".# XL_FOLLOW=N: fetch the log as it stands every N seconds as well, so that a phone that# resets without a word leaves all it said up to then ($log.live)+ local XL_FOLLOW=${XL_FOLLOW-10} # (a run that hangs leaves $log.live: what the kernel said up to a few seconds before)local deadline=$(( $(date +%s) + ${XL_SECS:-8} + 100 )) followed=$(date +%s)while :; doresult=$(FB_TIMEOUT=15 fb getvar result | grep '^result:')@@ -172,7 +197,8 @@ run() { # run <oem command> <label>fiif [ -z "$result" ]; thenecho "xl: no answer — the kernel hung; waiting for the watchdog to reset the phone"- wait_for android 120 && echo "xl: phone is back in Android" || echo "xl: phone did not come back (state: $(state))"+ [ -f "$log.live" ] && echo "xl: what the kernel said before it stopped answering: $log.live"+ recover_phonereturn 2fifetch_log "$log"