Skip to content

payload: take over a live post-M4 ANS before booting a non-Linux payload - #198

Closed
techmore wants to merge 2 commits into
aurora-silicon:mainfrom
techmore:m4/payload-post-m4-ans-takeover-20261111-r2
Closed

techmore wants to merge 2 commits into
aurora-silicon:mainfrom
techmore:m4/payload-post-m4-ans-takeover-20261111-r2

Conversation

@techmore

Copy link
Copy Markdown
Contributor

Draft: one comparison test is still pending. A Stage 1 from 1.0.0b10 or later already powers ANS off and passes nvme.sart=, so with it this change shouldn't be needed. That boot (current Stage 1, Stage 2 without this change, same U-Boot) hasn't been run on the J773g yet. Until it has, I can't say whether this is needed beyond Stage 1 1.0.0b8 installs.

On T8132 (M4), an ESP Stage 2 that boots its embedded U-Boot can hand ANS over still running, with no apple,sart-entries, when Stage 1 predates the post-M4 power-off. A U-Boot with aurora-silicon/u-boot#38 and #40 only starts a post-M4 ANS from off, so it gets no NVMe. This change makes Stage 2 take that session over and power it off first. On a J773g (Mac mini M4) it was the missing piece for a native boot with no proxy: Stage 1, ESP Stage 2, U-Boot, shim, GRUB, then Linux with its root on NVMe.

What happens today. Stage 1 1.0.0b8 (installer Alpha 19) hands ANS over still running (nvme.adopt), with no SART entries:

nvme: ANS AP power quiesced for the next stage
nvme: controller disabled; preserving live RTKit session

An ESP Stage 2 that boots its embedded U-Boot never initialises NVMe. payload_run() calls nvme_shutdown() before kboot's pcie_init(), but it returns at once because this stage never ran nvme_init(). nvme_sart_entries() then has no session of its own and no nvme.sart= entries, so it reads the live SART and reports ANS as running, and kboot_prepare_dt() writes no apple,sart-entries. U-Boot with #40 refuses a running session that an earlier stage set up. On the J773g, natively, that U-Boot left no breadcrumb on the ESP and nothing came up.

With ANS powered off first. Through the proxy, a b10 instance ran nvme_init() and nvme_shutdown() itself and then booted the same U-Boot:

nvme: entry RUN=1 BOOT_STATUS=0xde71ce55 saved SART entries=0
nvme: ANS powered off, 9 SART entries kept
nvme: ANS started from off
nvme: initialized at 0x4c5cc0000
nvme: ANS powered off, 10 SART entries kept
...
FDT: ANS will be off; 10 SART entries passed on

U-Boot then wrote its first breadcrumb to the ESP (M4 U-Boot alive: NVMe scan and ESP FAT write reached).

The change. In payload_run(), before a payload other than boot= Linux on T8132: if this stage hasn't used NVMe and no earlier stage passed SART entries (nvme_post_m4_untouched()), call nvme_init() first. nvme_init() already takes an older stage's live session over, as in the log above. nvme_shutdown() then powers ANS off with its entries kept, and kboot_prepare_dt() passes them on. If nvme_init() fails, payload_run() fails as it does for the other handoff errors. A Stage 1 that already powers ANS off and passes nvme.sart= doesn't trigger it, and boot= is unchanged. For this one case it departs from #107's rule that a stage which doesn't use NVMe leaves ANS as it got it.

It is limited to T8132 because that is the only post-M4 SoC we can test. On T6050, #159 now adopts such a running session instead, and its commit message says that powering such a session off late failed there. If you'd rather cover every post-M4 SoC, the check is easy to widen.

Compatibility. For T8132 with an older Stage 1 and a Stage 2 carrying this change, the rows of the table on u-boot#38 change as follows:

U-Boot Before With this change
adopts only (aurora-wip) adopts the live session (per #38's table; not run on an M4) ANS is off and this U-Boot can't start it: no NVMe
#38 adopts the live session starts ANS from off
#38 + #40 refuses: no NVMe starts ANS from off (J773g, below)

So this belongs in the same pin set as u-boot#38, and shouldn't ship in a Stage 2 that a distribution pairs with an adopt-only U-Boot.

Tested on one J773g (Mac16,10, OS firmware 26.6.2, system firmware 27.0), natively. First, three boots with an earlier form of this change:

iBoot → Stage 1 1.0.0b8 → ESP Stage 2 → U-Boot → shim → GRUB → Linux.

Then, stacked with the J773g commits: runs 52–57 and 59 (run 58 was a CPU bring-up test I'm not counting here) used a Stage 2 built from aura 7df619d9, which is #113 (an earlier rebase), the J773g HDMI DCP mappings commit (separate PR) and this commit with the same patch-id as here, with the same U-Boot. Each booted natively through U-Boot to Linux (a TEST ONLY kernel based on aurora-silicon/linux#1192) with its root on NVMe, the GPU ready and HDMI up.

Not tested:

  • This branch as it is, on current main. It builds as an ESP Stage 2 (CHAINLOADING=1 ESP_STAGE2=1, Clang) and passes make format-check with clang-format 20.1.8. The same commit ran in runs 52–57 and 59, on top of kboot: T8132 USB3 calibration, AOP handoff and absent-ISP rule by ADT property #113 and an older main (c583339d, which already had nvme: T6050: adopt a live session an earlier stage passed on #159); the eight non-merge commits merged to main since then didn't run with it. The first three boots used an earlier form whose helper made the same test as nvme_post_m4_untouched() under an earlier name, without the extra chip_id == T8132 check in payload_run(); on this SoC that makes no difference.
  • Other T8132 boards, including J713.
  • A Stage 1 that already powers ANS off, an adopt-only U-Boot (expected to have no NVMe, above), and this stage booted directly by iBoot with an embedded payload. In that last case nvme_init() would take over iBoot's session.

Related: u-boot#38 and #40 (this needs them), #107 and #144 (the post-M4 power-off this relies on, in main since #144), #113 (the J773g support the tested image carried).

Stage 1 1.0.0b8 (installer Alpha 19) passes a T8132 ANS on running
(nvme.adopt), with no SART entries. An ESP Stage 2 that boots an
embedded payload such as U-Boot never initialises NVMe, so its
nvme_shutdown() returns at once and the payload gets that live
session. kboot_prepare_dt() then writes no apple,sart-entries, and a
U-Boot that only starts a post-M4 ANS from off (aurora-silicon/u-boot
aurora-silicon#38 with aurora-silicon#40) refuses it: no NVMe, so no ESP and no boot.

On T8132, when this stage hasn't used NVMe and no earlier stage passed
SART entries, call nvme_init() before nvme_shutdown(). nvme_init()
already takes an older stage's session over (power off, start from
off), so nvme_shutdown() then powers ANS off and kboot_prepare_dt()
passes the entries on. If nvme_init() fails, payload_run() fails as it
does for the other handoff errors.

Linux payloads (boot=) still get a running ANS. Other SoCs are
unchanged: T6050 now adopts a session passed on running (aurora-silicon#159), and
powering one off late failed there.

Assisted-by: LLM
Signed-off-by: Sean Dolbec <sdolbec1@gmail.com>
test_m3_defaults_optout.py builds the real payload_run() on the host
with the hardware calls stubbed. payload_run() now calls
nvme_post_m4_untouched() and nvme_init() on T8132 before
nvme_shutdown(), and the harness had no stubs for them, so every test
in the file failed to compile with -Werror.

Stub both. nvme_post_m4_untouched() returns false, so the harness keeps
its old NVMe path and the tests check the boot-args handoff as before.

Assisted-by: LLM
@techmore

Copy link
Copy Markdown
Contributor Author

CI note for 88c3fd3, which stubs nvme_post_m4_untouched()/nvme_init() in the test_m3_defaults_optout.py harness and fixes the earlier Pytest failures:

  • These jobs pass: Pytest on macos-26, ubuntu-latest + gcc, ubuntu-latest + llvm and ubuntu-24.04-arm, plus build, format-check, policy and stage1-clang.
  • Pytest (macos-15 + llvm-brew) was cancelled without running. It never got a runner (no runner name, no steps), and it stopped 15 min after it was queued: https://github.com/aurora-silicon/aura/actions/runs/43244442593/job/131273213503
  • The same job passed on main (run 43241376597), so the cancellation isn't caused by this change. A maintainer re-run of that job should clear it; I can't re-run it without admin rights.

@techmore

Copy link
Copy Markdown
Contributor Author

Closing. main commit aaec599 ("payload: start a post-M4 ANS an earlier stage powered off before any payload") now starts a powered-off post-M4 ANS and hands it on running for every payload, which covers this case in the opposite direction from this PR.

@techmore techmore closed this Nov 13, 2026
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.

1 participant