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

modem-cycle: leave the phone in the loader after a run, not in Android -- the kernel already hands control back at loader_return_after with the modem, the DSPs and the GPU stopped, and the next run starts from there with no reboot; a phone the watchdog reset into Android is sent back to fastboot, so it always sits where it can be recovered; XL_END=android keeps the old way

shimoku7473cfb293ac67
diff --git a/tools/modem-cycle.sh b/tools/modem-cycle.sh
index 4cf2f9d..a69d7ec 100755
--- a/tools/modem-cycle.sh
+++ b/tools/modem-cycle.sh
@@ -1,6 +1,7 @@
#!/bin/bash
# tools/modem-cycle.sh "KERNEL ARGS" [SECS] [LOG]: wait for the phone (up to 6 h), enter the loader, upload the
-# system image, run the kernel with those args, summarize the modem's log, and put the phone back into Android.
+# system image, run the kernel with those args, summarize the modem's log, and leave the phone in the loader
+# (or fastboot) for the next run (XL_END=android: back to Android).
# The phone is never flashed: the kernel is booted with "fastboot boot"-like upload through xl.
cd "$(dirname "$0")/.." || exit 1
PATH=$PWD/tools/macos-bin/platform-tools:$PWD/tools/macos-bin:$PATH
@@ -13,7 +14,23 @@ XL_SB_DELAY=${XL_SB_DELAY:-600} XL_CMDLINE="debug=0x8 rd=md0 hv_wdt_pet=1 bootcp
echo "$(date +%T) state after run: $(./xl state)"
L=$(ls -t logs/*-run.log.live | head -1); F=${L%.live}; echo "LOG=$F"
cat $L $F 2>/dev/null | grep -a "mpss: \(7: \(THE\|the watch\)\|11\|rmtfs\|tftp\|servreg\|dms\|nas\|ipa: \(THE\|from node\|the modem\|a probe\)\|link: \(THE\|tftp\)\|LAST WORDS\|step 1[01]\)\|serving system\|panic(\|ipa: \|cell: \|net: en1\|wda: \|wds: \(THE\|the client\|about\)" | grep -v "about to ask\|about to tell" | sed 's/^\[ *[0-9.]*\]: //' | awk '!seen[$0]++' | cut -c1-230 | head -80
-echo "== back to Android"
-case "$(./xl state)" in loader|fastboot) XL_FORCE=1 ./xl reboot >/dev/null 2>&1 ;; esac
-for i in $(seq 1 40); do s=$(./xl state); [ "$s" = android ] && break; sleep 5; done
+# Where the phone is left (XL_END): "loader" (default) -- the kernel hands control back to our loader
+# at the end of the run (loader_return_after: the modem, the DSPs and the GPU stopped first), and the
+# phone stays there, in the loader's fastboot-protocol channel, ready for the next run with no reboot
+# at all; if the return failed and the watchdog reset the phone into Android, it is sent back to
+# fastboot, so a phone left alone always sits where it can be recovered. "android": the old way,
+# back to Android after every run.
+case "${XL_END:-loader}" in
+android)
+ echo "== back to Android"
+ case "$(./xl state)" in loader|fastboot) XL_FORCE=1 ./xl reboot >/dev/null 2>&1 ;; esac
+ for i in $(seq 1 40); do s=$(./xl state); [ "$s" = android ] && break; sleep 5; done ;;
+*)
+ echo "== staying in the loader / fastboot"
+ for i in $(seq 1 60); do s=$(./xl state); [ "$s" != absent ] && break; sleep 5; done
+ if [ "$s" = android ]; then
+ PATH=$PWD/tools/macos-bin/platform-tools:$PATH adb reboot bootloader >/dev/null 2>&1
+ for i in $(seq 1 30); do s=$(./xl state); [ "$s" = fastboot ] && break; sleep 5; done
+ fi ;;
+esac
echo "$(date +%T) phone: $s"; echo DONE