consmirror.c: the BSD notice is replaced (Makronix's own file). Files with changes of other sessions pending are left for their commit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
155 lines
8.4 KiB
Markdown
155 lines
8.4 KiB
Markdown
# 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
|
|
`usbreset`s 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).
|
|
|
|
### System and data apart (since 2026-11-09)
|
|
|
|
The file system holds two things beside each other (docs/NEXT.md §6,
|
|
`base/AGENTS.md`):
|
|
|
|
/system/current/ the system; / is a bind mount of it
|
|
/system/previous/ the system before the last update: the way back
|
|
/data/ home/ root/ var/lib/ etc/upper etc/work -- the state
|
|
that survives an update
|
|
|
|
`base/initramfs/init` sets this up:
|
|
|
|
/ bind of /system/current
|
|
/home bind of /data/home
|
|
/root bind of /data/root
|
|
/var/lib bind of /data/var/lib
|
|
/etc overlay: lower /system/current/etc, upper /data/etc/upper
|
|
/data bind of the partition's /data
|
|
/system bind of the partition's /system
|
|
|
|
The partition itself is mounted at `/sysroot.real` in the initramfs and has
|
|
no path after `switch_root`; it does not need one (the overlay holds its
|
|
upper directory, the binds hold the file system).
|
|
|
|
The first boot creates `/data` and copies the system's `/var/lib` and
|
|
`/root` into it once. Consequences to know:
|
|
|
|
- An update is `make update-root` (`tools/update-root.sh`, after
|
|
`make roottar`): the tree is unpacked into `/system/.staging`, the old
|
|
`/system/previous` is removed, `/system/current` becomes `previous` and
|
|
the new tree `current`; `/data` is not touched. Two trees, A/B like the
|
|
boot slots, no version in a directory name (since 2026-11-11): the tree
|
|
says which Makronix it is in `/etc/makronix-release`, e.g.
|
|
`Makronix 0.99.9 Camouflage (unstable)`, written from
|
|
`src/sys/conf/makronix-release` and `makronix-codename`
|
|
(`tools/assemble-rootfs.sh`, `tools/lib.sh` makronix_version).
|
|
- WLAN networks and ssh host keys live in `/etc` and survive through the
|
|
overlay; bluetooth pairings, the machine id and `rtc-offset` live in
|
|
`/var/lib` and survive through the bind; `/home` and `/root` likewise.
|
|
- A file changed in `/etc` keeps the changed version even when a new system
|
|
ships a different one; there is no 3-way merge yet (documented, not
|
|
solved: `docs/NEXT.md`).
|
|
- `make flash-root` still overwrites the whole partition, `/data`
|
|
included. Before such a flash, take the state along:
|
|
`ssh root@172.16.42.1 'tar -C / -cf - etc/NetworkManager etc/ssh root home
|
|
var/lib/bluetooth var/lib/makronix var/lib/dbus' > backup.tar`
|
|
(done on 2026-11-09, `build/phone-backup-2026-11-09/`).
|
|
- An image from before 2026-11-09 has no `/system/current`; the initramfs
|
|
then mounts the partition at `/` as before (`layout: whole partition` in
|
|
dmesg), so the old images still boot.
|
|
|
|
## 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.
|
|
|
|
<!-- License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree. -->
|