Files
makronix/mobile/docs/BOOT.md
T
lotherkandClaude Opus 5.5 d29094e24f mobile: our initramfs replaces pmOS's in the boot image
- base/initramfs/init builds the gadget with NCM and ACM at once: the root's
  stage 1 no longer rebinds it, so the host keeps its link and address and
  netconsole runs from 1.5 s.
- The root grows itself online to its partition
  (base/void/rootfs/.../03-grow-root.sh), which the pmOS initramfs did;
  tools/mkrootimg.sh copies base/<base>/rootfs/ before the SoC's files.
- tools/build-busybox.sh: SOURCE_DATE_EPOCH of the pinned source, so the
  initramfs is reproducible; pinned in device.conf (4950e286679ca4fa).
- Makefile: INITRAMFS defaults to ours; bootimg checks the pins after the
  inputs are built.

Measured on hotdogb: switch_root at 1.27 s (pmOS: about 3.5 s), a fresh
root grown from 281468 to 25493504 blocks, 10 of 10 warm reboots, no
WARNING, make flash end to end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:45:42 +00:00

5.8 KiB

Boot chain (hotdogb)

  • Bootloader: OnePlus ABL. Takes boot_a/boot_b (A/B), Android boot image header v2, kernel as Image (uncompressed), separate DTB at 0x01f00000.

  • The image is padded to 100663296 bytes (96 MiB), the size of the baseline.

  • head.S of the kernel carries the non-EFI image header the stock chain accepts (branch, zero word, offset 0x80000).

  • Display: the ABL leaves a lit panel and a framebuffer at 0x9c000000. The panel driver must hand off (not reset the panel) and use the 7T SOFEF03F sequence; the 7T Pro driver garbles this phone. A good boot logs:

    handoff: reset_gpio=0 power_mode=0x9c ... compression_mode=0x00
    handoff: compression enable sent, err 0
    
  • Access on a running system (Void root, since 2026-11-08):

    • USB network: the phone is 172.16.42.1, root/makronix over ssh. The host gets 172.16.42.2 by DHCP -- from the initramfs, then from usb0-dhcp (dnsmasq, DHCP only: no route, no DNS) in the root system, so a replugged cable no longer leaves the host without an address. Before that service a host that missed the initramfs's DHCP had no IPv4, and ssh and netconsole failed although the phone ran (a "hang" that was none, 2026-11-08). The fallback still works: ping -6 ff02::1%<if> names the phone's fe80:: address, ssh root@fe80::...%<if> (phone_addr in tools/lib.sh does both).
    • Serial: the initramfs's gadget has an ACM function next to the network since 2026-11-08 (base/initramfs/init; with the pmOS initramfs stage 1 adds it, 01-acm-console.sh), so the host has /dev/ttyACM0 (group dialout) with the kernel console (console=ttyGS0) and a login (agetty-ttyGS0). login hangs the line up after the password: the host must open the port again (a terminal program does; a script reopens it).
    • Fastboot from Linux: reboot-mode bootloader (or recovery) shuts down cleanly and restarts with the reboot reason in the PMIC (/etc/runit/shutdown.d/95-reboot-mode.sh, base/reboot2.c; needs mode-bootloader on the PON node of the DT). Measured: fastboot 7 s after the command, no button pressed. tools/flash.sh and tools/flash-root.sh do it themselves when no phone is in fastboot (fastboot_ready). After a large flash (userdata) ABL stays busy for more than 15 s and does not answer: wait (fastboot_answers, up to 120 s), never cut the command off and never reset the device. Two usbresets 30 s apart in that state crashed the phone into Qualcomm's crash-dump mode (05c6:900e, screen dark; out with Power 15 s), 2026-11-08.
    • By hand, when Linux does not run: Power 15 s, then Power + Vol Up + Vol Down.
    • Clock: the PMIC RTC cannot be set from Linux and reads 1970; rtc-offset keeps the difference on the root file system (loaded at boot, saved at shutdown), tools/phone-time.sh sets the time from the host and saves it. Needed once per root image.

Verification

tools/mkbootimg.sh was compared with cmp against the image that booted on the phone on 2026-11-07 (kernel 7.0.0-sm8150-g2509837001fc-dirty, baseline DTB, pmOS initramfs): identical, 100663296 bytes.

Since 2026-11-07 the command line no longer carries pmOS's pmos_boot_uuid/pmos_root_uuid: devices/<d>/cmdline holds the device's arguments, and tools/mkbootimg.sh appends pmos_root_uuid=$ROOT_UUID, the UUID tools/mkrootimg.sh gives our root file system. The image is therefore no longer byte-identical with the baseline above; the baseline's command line was the current one plus the two pmOS UUIDs.

Root file system

On userdata (ROOT_PARTITION), as a bare ext4 file system, no partition table inside: the initramfs finds it by UUID, and the root grows it online to the partition on the first boot (base/void/rootfs/.../03-grow-root.sh). The pmOS installation that was on userdata is gone once make flash-root ran, and with it the root of the fallback slot's image; ~/.local/var/pmbootstrap/chroot_native/home/pmos/rootfs/oneplus-hotdogb.img restores it (fastboot flash userdata that file).

Slots and the retry count

The bootloader counts down slot-retry-count on every boot of a slot that is not marked successful, and nothing in our images marks it yet. At 0 the slot is unbootable -- and the bootloader does not fall back to the other slot: it stops on "The current image have been destroyed and can not boot", although slot b was bootable (measured 2026-11-07, build/logs/fastboot-slots-2026-11-07.log: slot-retry-count:a:0, slot-unbootable:a:yes, slot-retry-count:b:5, slot-unbootable:b:no). The images are intact. Fastboot (buttons) and fastboot set_active a set the count back to 7 (tools/flash.sh does that after every flash).

Since 2026-11-07 Linux marks the slot successful. The state is byte 6 of the GPT attributes of boot_<slot> (../docs/reference/qbootctl.txt): bits 0-1 priority, 2 active, 3-5 retry count, 6 successful, 7 unbootable -- read on the phone and matched against fastboot getvar (0x37 = priority 3, active, retry 6). qcom-ab-slot (soc/sm8150/rootfs/usr/bin/, POSIX sh) sets bit 6 in the primary and the backup GPT, with both CRCs, and checks both tables before and after; the runit service slot-successful (soc/sm8150/rootfs-void/) runs it once sshd runs. tools/mkrootimg.sh copies both directories into the root image. Measured: after a flash (set_active: retry 7, not successful) the first boot marks the slot at 6.4 s, and the bootloader then reports slot-successful:a:yes with the retry count unchanged across reboots (build/logs/fastboot-slots-after-mark-2026-11-07.log).

What it does not cover: a boot image that hangs before sshd is never marked, and after 7 such boots the slot is unbootable, with no fallback (above). set_active from fastboot is then the way back.