Repository navigation
Description
Follow-up to #553 / OrchardLinux/m1n1#24. Tested on an iPad Pro (10.5-inch, Wi-Fi) (J207, iPad7,3) with orchard 0.3.17, Omarchy A 0.4.8 installed with orchard install omarchy-a --split 45 --access palera1n --busy-cpu --ssh, and m1n1 main at 6dde868 built with boot/m1n1/Containerfile (CHAINLOADING=1, -DQUIET_BOOT) and passed with orchard launch --busy-cpu --m1n1 FILE. Host: Linux, Intel Alder Lake xHCI, Apple USB-A to Lightning cable.
With the three local changes below, orchard launch now starts the installed Omarchy A from internal storage on this unit (DFU to Linux USB in ~20 s). Without them, it failed in three different places.
1. m1n1 never finishes USB enumeration (ec086bf, ECID in the serial string)
On this unit the serial string becomes XXXXXXXXXXXX ECID:XXXXXXXXXXXXX (31 characters), so the string descriptor is 2 + 2 * 31 = 64 bytes, exactly the EP0 max packet size. The host stalls on the serial read and the configuration times out:
usb 3-2: New USB device found, idVendor=1209, idProduct=316d, bcdDevice= 1.00
(10 s gap)
usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 3-2: Product: m1n1 uartproxy 6dde868
usb 3-2: Manufacturer: Asahi Linux
usb 3-2: can't set config #1, error -110
orchard launch then fails with opening the m1n1 proxy: no serial port for the device at 3-2 after 4.5 s, and a replug does not recover it (device descriptor read/64, error -110, device not accepting address). m1n1 2a5fe33 (serial without the ECID) enumerated fine on the same unit and cable.
I suspect that the dwc2 EP0 IN path does not send a zero-length packet when a reply is an exact multiple of the max packet size and shorter than wLength. Locally I only dropped the ECID (if (0 && ecid)), which shortened the descriptor. A proper fix is probably a ZLP in usb_dwc2.c. Other boards whose serial and ECID lengths add up to 31 characters would hit the same problem.
2. apcie-nvme: sq_id in the completion is not reliable
apcie-nvme: initialized
apcie-nvme: opcode 0x2: unexpected completion (sqid 0/1 cid 4/4)
The cid matches but sq_id is 0. m1n1's own nvme.c notes u32 rsvd; // normal NVMe has the sq_head and sq_id here for Apple controllers, so locally submit() no longer compares sq_id.
3. apcie-nvme: completion cid mismatch after the I/O queue wraps
With 2 fixed, the boot manager read the GPT and the BLS entries, then failed on the 17th I/O command, the first one after the 16-entry queue wraps:
apcie-nvme: opcode 0x2: unexpected completion (sqid 1/1 cid 1/17)
apcie-nvme: disable after timeout timeout (0x3)
apcie-nvme: shut down
main_storage_read(4883468) failed (partition at block 4882944, byte 2146304)
bls: 1. omarchy-a-dbac00e3-7.3.0-rc1-orchard-apple-16k (...): not bootable: /loader/entries/omarchy-a-dbac00e3-7.3.0-rc1-orchard-apple-16k.conf: read error
orchard launch reported Nothing to start on this iPad. The phase bit matched, but the entry carried cid 1. On this unit the controller appears to report "SQ slot + 1" rather than the cid from the command. Locally submit() sets cmd->cid = q->sq_tail + 1, and after that the entry loaded and Omarchy A booted. I have not checked this against Apple's driver. It is an inference from this one failure. A larger queue would hide it only until it wraps.
Possibly related: iPadOS 14.6 iBoot
Before restoring to iPadOS 17.7.11 (21H461), this unit ran iPadOS 14.6 (OS FW version: 11.4 (iBoot-6723.120.36)). There, reads failed irregularly even with 2 applied: completions with cid 0 on the 1st or 5th read, and storage init sometimes refused outright. After the restore to 17.7.11, only 3 remained. It may be worth noting in the J207 docs that storage boot was verified on 17.7.x.
Local patch against m1n1 6dde868
--- a/src/apcie_nvme.c
+++ b/src/apcie_nvme.c
@@ static int submit(struct queue *q, struct nvme_sqe *cmd)
{
- cmd->cid = ++q->cid;
+ cmd->cid = q->sq_tail + 1; /* the controller reports SQ slot + 1 */
+ q->cid = cmd->cid;
@@
- if (cqe.sq_id != q->qid || cqe.cid != cmd->cid) {
+ if (cqe.cid != cmd->cid) { /* sq_id is not filled in, as in nvme.c */
--- a/src/usb_dwc2.c
+++ b/src/usb_dwc2.c
@@ static void usb_build_serial(void)
- if (ecid)
+ if (0 && ecid) /* workaround: a 64-byte descriptor stalls enumeration */(The local tree also re-reads the completion for up to 1 ms when the cid does not match yet. It was a diagnostic and did not fix anything on its own, so I left it out here.)
Happy to test a proper fix on this J207.
Activity
johannSo commentedon Dec 5, 2026
Note
🤖 Claude Opus 5.5 responding on behalf of johannSo
The
cidmismatch (3 in your list) also hit my J120. I think the cause is a stale cache line insubmit(), not the controller reporting the slot: OrchardLinux/m1n1#26.With the 0.3.24 m1n1 I got
cid 27/43. Slot + 1 would have been 11, while 27 is what that slot held one pass earlier, as was yourcid 1/17. Linux also uses ordinary command IDs on this controller and works. The PR waits for the phase, then re-reads the entry with the cache line invalidated each time until the ID matches. It also drops thesq_idcheck (2 in your list). With it,orchard launch --m1n1boots my installed system.Could you try it on your J207 without your
cid = sq_tail + 1change? It doesn't touch the USB serial-string issue (1).neatsorg commentedon Dec 6, 2026
Thank you for the PR and the explanation! I tried it on the J207.
I built OrchardLinux/m1n1#26 (
38f3682) without mycid = sq_tail + 1change. The only local change was the ECID workaround inusb_dwc2.c(1), because the unit doesn't enumerate without it. I used the same build settings as before (boot/m1n1/Containerfile,CHAINLOADING=1,-DQUIET_BOOT) and ranorchard launch --busy-cpu --m1n1 FILE.It booted.
orchard launchlisted all three BLS entries, and the installed Omarchy A started from internal storage, as it does with mysq_tail + 1build. So on this unit, 2 and 3 are fixed by your PR, and I'll drop mycidchange.Unfortunately, I closed the terminal before I copied the TTY output, so I don't have the
shut down (N completions read again)count. I can boot it again and post it if that would help.One thing that might be worth knowing: my earlier local build (mentioned at the end of my first post) also re-read the entry with
dc_civac_range()+dma_rmb()for up to 1 ms, with the original++q->cid. On iPadOS 17.7.11 it still failed on the 17th command:The main difference I can see is that it compared the phase from a
memcpy()of the whole entry instead of fromstatusalone. I haven't looked into why that made a difference.apcie_nvme: Read the completion's phase before its command ID
johannSo commentedon Dec 6, 2026
Note
🤖 Claude Opus 5.5 responding on behalf of johannSo
Yes, please post the count. It would tell us whether m1n1#26's explanation is right, and your earlier build makes me doubt it.
cidand the phase bit share one 32-bit word of the completion entry (u16 cid; u16 status;, DW3). A controller that makes the new phase visible while the oldcidis still in that same word is unlikely. Your build also re-read the entry withdc_civac_range()+dma_rmb()for 1 ms and still sawcid 1, so there the ID did not just arrive late.The PR changed two things:
statusthrough avolatilepointer, not from amemcpy()of the whole entry.volatileread works.Our J120 run only logged orchard's side, not m1n1's console, so I don't have the count either. I'll take it on the next J120 boot.
m1n1#26 is merged, and orchard took it in 5b1809b. So 2 and 3 in your list are done, and this issue only needs to stay open for the USB serial string (1).
neatsorg commentedon Dec 6, 2026
Thank you for the detailed explanation! I got the count, and it's 0.
shut down (N completions read again)only reaches m1n1's USB console. It runs beforekboot_prepare_dt()sets up the log buffer, so it doesn't end up inm1n1_stage2.logeither. So I made a diagnostic build: m1n1#26 (38f3682) + the ECID workaround (1) + a small patch that records every re-read (commandcid, thecidseen on the first read, number of reads) and prints the totals inbootmgr_start()right beforebootmgr: starting, so they land inm1n1_stage2.log. Same build settings as before.After
orchard launch --busy-cpu --m1n1 FILEon the J207 (iPadOS 17.7.11), Linux's/dev/mtd0had:So the completion queue wrapped around many times (16 entries), and the ID loop never had to read again. On this unit, step 2 never ran, and step 1 (polling the phase from
statusthrough thevolatilepointer) is what fixed it, as in your second case.This is from one boot so far. I can run more boots, or try another build if that would help you narrow down why the
volatileread works.The diagnostic patch (on top of
38f3682, without the ECID workaround)