Page 1 of 1

Custom xHCI driver: Address Device reports Success but slot stays Default, no EP0 events

Posted: Thu Dec 03, 2026 7:07 am
by Magpie0817
Custom xHCI driver: Address Device reports Success but slot stays Default, no EP0 events

Three questions first, details below:
  1. Is there a documented reason for [c]Address Device[/c] to complete with Success while the slot stays in Default state and no device address is assigned?
  2. Doorbell is written, EP context is Running, ring and dequeue pointer match, yet a No-Op TRB never produces a Transfer Event. What else gates endpoint scheduling?
  3. CRCR reads back as 0x00000008 (only CRR set, pointer 0). Is pointer readback just unimplemented, or did my write not take effect?
Background

Windows KMDF driver, direct MMIO access to the xHCI controller, system usbxhci unloaded. On the very same machine, port and cable, Ubuntu's xhci_hcd enumerates the device fine (sends GET_DESCRIPTOR 1.4 ms after the port reset, gets the 18-byte device descriptor back in 80 us). So hardware and cable are fine.
  • Controller: Intel Sunrise Point-LP, PCI 8086:a0ed
  • HCSPARAMS1 = 0x08001040 (MaxSlots 64, MaxPorts 16)
  • HCSPARAMS2 = 0x14200054 (34 scratchpad buffers, ERST max 5)
  • HCCPARAMS1 = 0x20007FC1 (CSZ=0, 32-byte contexts)
  • Device: Apple iPhone (A6, CPID 8950) in DFU mode, 05ac:1227, high speed, zero endpoints
What works
  • Init: RS=0, wait HCH=1, HCRST, 1 ms delay (Intel), wait CNR=0
  • DCBAAP and CONFIG written, both read back correctly
  • ERST one segment, ERSTSZ=1, ERDP with EHB handling; events arrive
  • 34 scratchpad buffers allocated as one contiguous block, array at DCBAA[0]
  • Port reset: PORTSC written as PP|PRC to clear stale PRC, then PP|PR. Result PED=1, SPD=3, PLS=0
  • Enable Slot -> cc=1 (slot 1); Disable Slot -> cc=1; Address Device -> cc=1
  • Reset Endpoint (DCI 1) works; Set TR Dequeue Pointer works
What fails

1) Address Device reports Success but the slot is not addressed

Input context (32-byte contexts):

Code: Select all

ICC   dword1 = 0x00000003      A0=slot, A1=EP0
SLOT  dword0 = 0x08300000      route 0, speed 3 (HS), ctx entries 1
      dword1 = 0x00010000      root hub port 1, num ports 0
      dword2 = 0
      dword3 = 0
EP0   dword0 = 0x00000000      EP state 0, interval 0
      dword1 = 0x00400026      CErr 3, type 4 (control), MPS 64
      dword2 = 0x72300001      TR dequeue lo, DCS=1
      dword3 = 0
      dword4 = 0x00000008      average TRB length
After the command completes with cc=1, the output device context shows:

Code: Select all

slot dword3 = 0x09000000   ->  Slot State = 1 (Default), Device Address = 0
So the controller did write dwords 0-1 (they match the input), but the slot never reached Addressed (state 2) and no address was assigned. DCBAA[1] does point at this device context (verified). I do not touch the output context after the command, it is hardware owned.

2) No Transfer Event for EP0, ever

A No-Op TRB with IOC at ring index 0, doorbell[slot]=1: no event within 300 ms. After Reset Endpoint + Set TR Dequeue the output EP0 context reads EP state=1 (Running), dequeue = ring base | DCS=1, and a following No-Op still produces nothing.

3) Control transfer never completes normally

Code: Select all

Setup TRB:  TRT=IN, IDT=1, CH=1, setup bytes 80 06 0100 0000 0040
Data TRB:   DIR_IN, CH=1, len 64
Status TRB: IOC, DIR=0
  • BSR=0 (slot addressed to address 1): completion code 4 (USB Transaction Error)
  • BSR=1 (no SET_ADDRESS, device stays at address 0): no event at all
After the failed transfer the output EP0 context shows EP state=2 (Halted) and dequeue = ring + 0x10, so the controller did consume the first TRB once, but the device never answers.

Ruled out
  • Scratchpads: 34 allocated as one contiguous block (was 2, fixed)
  • EP context layout: MPS in ep_info2 (dword1 bits 31:16), interval = 0 (it was accidentally 64 because I had put MPS into dword0)
  • PORTSC write mask: only PLS/PP/LWS written, never PED as 1
  • HCRST without halting first: now RS=0 + wait HCH=1 before HCRST
  • Event parsing: all events queued, never discarded; command completions validated against the command TRB physical address
  • Control data buffer: dedicated non-cached contiguous buffer, not a stack buffer
What I am looking for
  • A minimal working xHCI implementation that does not rely on usbxhci or xhci_hcd
  • Any erratum for Sunrise Point-LP that affects endpoint scheduling
  • Or just: which register/field am I still missing during init?
Thanks.(i used a translator,please ignore ant awkward phrasing)

Re: Custom xHCI driver: Address Device reports Success but slot stays Default, no EP0 events

Posted: Thu Dec 03, 2026 2:41 pm
by BenLunt
Hi,
Magpie0817 wrote: ↑Thu Dec 03, 2026 7:07 am Windows KMDF driver
...
[*]Device: Apple iPhone (A6, CPID 8950) in DFU mode, 05ac:1227, high speed, zero endpoints
I take it that you are on an Apple iPhone under a Windows environment, yes?
If so, I may not have any help for you at all, though I will try.
I don't have any background on an Apple device, and am only "bare metal" knowledge for the environment.
Magpie0817 wrote: ↑Thu Dec 03, 2026 7:07 am 1) Address Device reports Success but the slot is not addressed
Did you set/clear the "block" bit?
You should (sometimes a must) send the Address Device command twice, once with it set, once with it clear.

Hope that helps,
Ben
- https://www.fysnet.net/the_universal_serial_bus.htm