Skip to content

enchilada: slot-B install to boot_b on sde, and its CONTRIBUTING §3.1 entry - #616

Closed
matthewjaybarr-png wants to merge 5 commits into
derekross:mainfrom
matthewjaybarr-png:enchilada-slot-b-entry
Closed

matthewjaybarr-png wants to merge 5 commits into
derekross:mainfrom
matthewjaybarr-png:enchilada-slot-b-entry

Conversation

@matthewjaybarr-png

Copy link
Copy Markdown
Contributor

The slot-B install for the OnePlus 6 (enchilada), as one PR: boot_b on LUN sde gets a real writer, and the CONTRIBUTING §3.1 entry names the one GPT write that marks it successful. Carries UFS_RW_LUNS=sde, as asked in the review of #530.

install-phone ──► boot_b (sde) + userdata (sda) ──► set-active b ──► boot slot B
                                                                       │
            tools/mark-slot-b (dry run, then --write, by hand, once) ◄─┘
            sets bit 54 of boot_b in LBA 1, 3, 786428, 786431

day 2:  omamobile push ──► boot_b on sde (UFS_RW_LUNS)

What changes

  • push finds slot B's images on the descriptor's UFS_RW_LUNS as well as sda; enchilada sets UFS_RW_LUNS=sde.

  • install-phone installs an android-v0 boot image to slot B (boot_b and userdata, then set-active b).

  • omamobile push rewrites enchilada's boot_b for day-2 kernels.

  • tools/mark-slot-b (new) is the §3.1 write. It reads SLOT_B_MARK="sde boot_b 1 3 786428 786431" from the descriptor and refuses unless:

    • the phone booted slot B;
    • the sector size and last LBA match;
    • both GPT copies are valid, describe each other and hold equal arrays;
    • boot_b is found once, in the descriptor's LBAs;
    • boot_b is active and not unbootable.

    It is a dry run by default. --write needs a typed confirmation, re-reads the four sectors, and sets bit 54 only, rewriting the array CRC and both header CRCs. It writes the primary pair and reads it back before the backup pair, through a private node under /run: the init's guard stays as it is, and /dev/sde is never recreated.

  • tests/mark-slot-b builds a 4096-byte-sector GPT and checks:

    • that a dry run writes nothing;
    • that --write changes exactly the four sectors and sfdisk -V accepts the result;
    • that a second run is a no-op;
    • each refusal.
  • CONTRIBUTING §3.1 gets the enchilada entry. AGENTS.md gets the same wording. NOTES records the plan, the GPT as read, the slot flags before (after: recorded when it runs), the rollback, and the owner's acceptance on OnePlus 6 (enchilada, SDM845) port: RAM-only first light, contributors welcome #432 that slot A holds the rescue.

Before / after

Before After
Writer for boot_b on sde none (RAM-only) install-phone, omamobile push
Marking slot B successful not allowed (no §3.1 entry) tools/mark-slot-b, by hand, once per install
tests/all 513 ok, 0 not ok; tools/pr-check origin/main passes

mark-slot-b's parser was also checked read-only against a copy of this phone's sde GPT. It found boot_b at entry 38 with the CRCs that NOTES records. Because boot_b there is not active yet, it refused, as it should before set-active b.

Merge danger

Low for other devices: every descriptor but enchilada's leaves UFS_RW_LUNS and SLOT_B_MARK unset, and both tools refuse without them. Nothing in this PR has written to the phone. The install and the GPT write each run on the owner's go after merge, and their slot flags go into NOTES.

🤖 Generated with Claude Code

matthewjaybarr-png and others added 5 commits November 10, 2026 10:40
… sets sde

push looked for <image>_b only under /sys/block/sda. It now looks on sda
and each LUN in UFS_RW_LUNS, the same LUNs the init guards, and refuses a
name found on more than one partition or a path it doesn't expect.
enchilada opts in with UFS_RW_LUNS=sde, where its boot_b is (derekross#530's
review). push and flash still refuse android-v0 until the slot-B install
and its CONTRIBUTING §3.1 entry land in this pull request.

tests/images-layout: the fake phone places partitions on one LUN; push
finds them on a UFS_RW_LUNS LUN, not on a LUN the descriptor doesn't
name, and refuses a duplicate name before writing anything.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The slot-B install for enchilada goes through the installer, the same
guarded path as every other phone: serial pinned, codename typed,
allowlist, dry run, then boot_b, userdata, set-active b and reboot.

- BOOT_METHOD=android-v0 is accepted; SOC_IDS/SOC_COMPATIBLE stay
  required for android-v4 only (v0 appends its one DTB).
- The product check (phone and manifest.json) uses FASTBOOT_PRODUCT
  when the descriptor sets it: OnePlus ABL reports the SoC, sdm845,
  which is not unique, so the serial and typed codename identify it.
- OnePlus ABL reports an empty version-bootloader. That is now refused
  unless the owner passes --bootloader-slots-match unreported, having
  compared both slots' firmware partitions from a read-only backup.
- omamobile-boot-update refuses android-v0, so such an install writes
  AUTO_WRITE=no: kernel updates reach slot B by push.
- enchilada's CMDLINE drops omamobile.initramfs and ufs-probe, so the
  installed boot_b hands off to the Arch root, as the hand-flashed one
  did (NOTES).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ates

tools/install-phone is now enchilada's first install, and its
boot-update.conf says AUTO_WRITE=no because omamobile-boot-update takes
only android-v4. push is the day-2 path: an android-v0 descriptor has
one image, boot_b, which push already finds on a UFS_RW_LUNS LUN (sde),
checks against the partition size and the storage guard's ro flag,
writes and reads back by sha256. Lift its android-v0 refusal; fastboot
and flash keep theirs, since the first install goes through the
installer.

tests/boot-method: enchilada push now stops at the missing images, still
before any phone access. RELEASES: the BOOT_METHOD row says which tools
take android-v0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a Qualcomm A/B phone slot B is marked successful in its GPT, which
the storage guard can't police, so the write gets its own tool, run by
hand once per install of slot B's boot image and never from a service.

The descriptor names the write (SLOT_B_MARK: the LUN, the partition and
the four LBAs). Over phone-ssh the tool reads both GPT copies through a
private node under /run (the init removes the whole-disk node, and that
stays so), checks both headers, both entry arrays and their CRCs, finds
the partition by name once, and refuses unless its sectors are the
named four, the phone booted slot B, and B is active and not unbootable.
It sets bit 54 and nothing else, recomputes the entry-array CRC and
both header CRCs, and checks that only those four sectors change. The
default is a dry run; --write asks for 'mark boot_b', re-reads the four
sectors, writes the primary pair, reads it back, then the backup pair.

enchilada's entry: sde boot_b, LBA 1, 3, 786428 and 786431. Checked
read-only against a copy of the real sde GPT: entry 38, the captured
header and array CRCs match, and the plan changes only those fields.
tests/mark-slot-b runs it against a synthetic 4096-byte-sector GPT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Write the entry the rule asks for before the GPT write is used: LUN
sde, boot_b at entry 38, LBAs 1, 3, 786428 and 786431, bit 54, and the
entry-array and header CRCs it rewrites. The generic wording names the
four sectors by role, since the entry sector depends on the partition.

The enchilada NOTES record the plan: the install, the GPT as read on
2026-11-09, the slot flags before and after (after: recorded when it
runs), the rollback from the off-repo copy of both GPT copies, and the
owner's written acceptance on derekross#432 that slot A holds the rescue.

tests/mark-slot-b: use grep -c instead of piping into grep -q under
pipefail (tests/grep-q-pipes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derekross

Copy link
Copy Markdown
Owner

Thank you, @matthewjaybarr-png. This is careful work: the tool is a dry run by default, checks both table copies before it changes one, changes only the bytes it names, and its test has sfdisk accept the result. The read-only groundwork on #432 and the RAM-only boot of the second-LUN guard are exactly the right order. And thank you for the written acceptance on #432; that is what I asked for.

I'm not merging it in this shape, for one reason of process and a few of substance.

The entry has to come from me, in its own change. On #432 I asked for the §3.1 entry "as its own pull request rather than inside the device PR", and CONTRIBUTING says a device PR never writes its own exception. Here the entry is the last commit of the PR that adds the three writers, and it also rewords the general rule for every Qualcomm phone ("LBAs 1, 2, last-1 and last" becomes "both headers and the entry sector holding slot B's boot partition in each copy"). You're right that the old wording doesn't fit your phone: boot_b is entry 38, in the second entry sector, and the backup array starts four sectors before the end. But that sentence is a safety rule, and I'm changing the neighbouring text in #639 right now, so I'll write both together. Please take the AGENTS.md and CONTRIBUTING.md changes out; I'll use your numbers.

So please split it in three:

  1. The push change and tools/mark-slot-b with its test, with no UFS_RW_LUNS and no SLOT_B_MARK in the descriptor yet. Both are inert that way, and I can merge them once the points below are in.
  2. The rule and the entry: mine, after install-phone: a first install can measure the other bootloader slot itself, per device and off by default (G4, D4) #639.
  3. The descriptor lines, the installer's and push's android-v0 paths and the command-line change, with the runbook, after the entry. Then each step on the phone is reported on OnePlus 6 (enchilada, SDM845) port: RAM-only first light, contributors welcome #432 before the next.

What I need changed in the tool and the notes:

  • mark-slot-b must check which phone answers before it makes the node. It takes the device from the command line and checks only that the phone booted slot B, which every phone here does. Even a dry run then makes a whole-disk node for sde on whatever tools/phone-ssh reaches. Please compare the first string of /proc/device-tree/compatible with the descriptor's COMPATIBLE first, as the init does, and add that refusal to the test.
  • The private node is a whole-disk node for sde. That's unavoidable for this write, and it is why the write needs a named exception; "/dev/sde is never recreated" undersells it. The entry will say it plainly. Please list in NOTES which partitions sde holds (names only, from PARTNAME), so the entry can say what that node reaches. I expect abl, tz, modem and the rest of the firmware to be there, next to boot_*.
  • Don't pipe the sector over SSH straight into dd on the disk. A transfer cut short writes part of a sector to the primary table. Copy the sector to a file in the private directory, check its SHA-256 on the phone, then dd from the file.
  • The rollback for "both copies invalid" can't work as written. It starts with "boot the rescue on slot A by the buttons", but boot_a is on sde, and if abl is too, a phone with no valid table on sde has no rescue, no fastboot and no fastboot boot: only Qualcomm's emergency download mode. Your write order makes that unlikely, but the notes have to say what it would really mean, and your acceptance on OnePlus 6 (enchilada, SDM845) port: RAM-only first light, contributors welcome #432 ("my rescue on slot A plus fastboot boot") needs to cover it in so many words. Please confirm from the PARTNAME map where abl_a/abl_b and xbl live.
  • --bootloader-slots-match unreported must not be available on other phones. Today a phone that reports no bootloader version is refused; with this change any install goes on once someone types unreported. Please accept it only when the descriptor says the bootloader reports none, and refuse it everywhere else, with a test. That part of the installer is being rewritten in install-phone: a first install can measure the other bootloader slot itself, per device and off by default (G4, D4) #639, so it's best based on that.
  • The runbook needs its gates: for each step what you expect, when you stop, how you undo it. In particular: both slots' flags from getvar after --set-active=b and before the first boot; on the first boot of B, from the Arch root, ls -l /dev/sde, cat /sys/block/sde/ro and each sde partition's ro (there is no enchilada device package, so nothing in Arch keeps that node away as the Pixels' udev rule does for sda; if it comes back, that needs a rule before the install is called supported); what a boot of B does with no laptop attached, before and after the mark, which I asked on 11-05; the dry run's output posted for my go before --write; and after --write, fastboot getvar slot-successful:b reading yes. Bits 54 and 55 have never been seen set on this phone, so that last read is what proves bit 54 means "successful" to this bootloader. Please also cite the source for the bit layout.

Smaller things: sdm845 as the fastboot product matches every SDM845 phone, so for such a descriptor the installer should require --serial (new in #641); the changed wording of the erase warning ("its data is lost, and an Android on slot A…") should stay as it was for the Pixels, with its own lines for your phone; and a dry run of the installer against the shipped enchilada descriptor would test the real file, where the new test uses a made-up one.

For the record, what I checked: the gate and the touched test suites pass on today's main, the push change leaves the Pixels' lookup as it was, and the table arithmetic in the tool and the notes is consistent. Nothing here is a judgment on the port. It is the first partition-table write in the project, so it goes in small steps.

@matthewjaybarr-png

Copy link
Copy Markdown
Contributor Author

Thank you for the careful review, @derekross. And sorry: you asked for the §3.1 entry as its own pull request, and I put it inside the device PR anyway, rule rewording and all. That was my mistake. The AGENTS.md and CONTRIBUTING.md changes are out.

I've split it as you laid out:

  1. tools/mark-slot-b and push over UFS_RW_LUNS, inert until the §3.1 entry (part 1 of #616) #651: the push change and tools/mark-slot-b with its test, with no UFS_RW_LUNS and no SLOT_B_MARK in the descriptor. It has your fixes:
    • the COMPATIBLE check before any node is made, with a test that another phone is refused and no mknod runs;
    • each sector copied to a file in the private directory, checked by SHA-256 on the phone, and dd from that file, with a test for a transfer cut short;
    • in NOTES, sde's partitions by PARTNAME and the plain statement that the node is a whole-disk sde node;
    • the corrected "both copies invalid" case, and the source for the bit layout.
  2. The rule and the entry: yours, after install-phone: a first install can measure the other bootloader slot itself, per device and off by default (G4, D4) #639. The numbers are in tools/mark-slot-b and push over UFS_RW_LUNS, inert until the §3.1 entry (part 1 of #616) #651's NOTES.
  3. The descriptor lines, the android-v0 paths, --bootloader-slots-match unreported limited to a descriptor that says the bootloader reports none (with its test), --serial for sdm845, the Pixels' erase warning as it was, a dry run against the shipped descriptor, and the runbook with each gate you listed. That waits for the entry and is based on install-phone: a first install can measure the other bootloader slot itself, per device and off by default (G4, D4) #639.

From the PARTNAME map: abl_a and abl_b are on sde, so you were right. With no valid table there, the only way back is EDL. xbl is not on sde. I haven't read which LUN holds it yet, because the phone only enumerates on a USB-C to C cable here. I'll post it on #432 when I have it. I'll also restate my acceptance on #432 to cover the EDL case.

Shall I close this one in favour of #651?

@derekross

Copy link
Copy Markdown
Owner

Yes, please close this one in favour of #651, @matthewjaybarr-png, and thank you for taking the review so well. No apology needed.

I've reviewed #651 there. Part 3 (the descriptor lines, the android-v0 paths, unreported limited by the descriptor, --serial for sdm845, the dry run against the shipped descriptor and the runbook with its gates) is best opened as a new pull request on top of #639 once the entry is in, rather than pushed here. I've seen your addition to the acceptance on #432 covering the EDL case; thank you. xbl's LUN can follow there when the cable allows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants