Skip to content

gs_usb: fix compat with AMD xHCI USB#42

Merged
CamilleTTT merged 1 commit intoToyotaInfoTech:mainfrom
BenGardiner:fix-stm32-amd-xhci-compat
Mar 9, 2026
Merged

gs_usb: fix compat with AMD xHCI USB#42
CamilleTTT merged 1 commit intoToyotaInfoTech:mainfrom
BenGardiner:fix-stm32-amd-xhci-compat

Conversation

@BenGardiner
Copy link
Contributor

The AMD xHCI USB host is very very picky . About timings, and descriptors and ... well everything.

This commit gets RAMN gs_usb up to the strict requirements enforced by AMD xHCI. Still works on other Intel USB as well.

  • Fix STM32 HAL USB PCD concurrency bug by adding IRQ-safe critical sections
  • Handle lock failure edge case: re-enable IRQ before returning HAL_BUSY
  • Move USB concurrency fix to usbd_conf.c with USER CODE block protection
  • Fix USB PCD concurrency: add __HAL_LOCK with IRQ critical sections in HAL driver
  • Fix EP2 OUT descriptor: wMaxPacketSize 128->64 for Full-Speed USB compliance
  • Add IAD for GS_USB+DFU interfaces for AMD xHCI compatibility
  • STALL unhandled USB control requests in composite Setup handler
  • Add WARNING comments for AMD xHCI USB compatibility

The AMD xHCI USB host is very very picky . About timings, and
descriptors and ... well everything.

This commit gets RAMN gs_usb up to the strict requirements enforeced by
AMD xHCI. Still works on other Intel USB as well.

* Fix STM32 HAL USB PCD concurrency bug by adding IRQ-safe critical sections
* Handle lock failure edge case: re-enable IRQ before returning HAL_BUSY
* Move USB concurrency fix to usbd_conf.c with USER CODE block protection
* Fix USB PCD concurrency: add __HAL_LOCK with IRQ critical sections in HAL driver
* Fix EP2 OUT descriptor: wMaxPacketSize 128->64 for Full-Speed USB compliance
* Add IAD for GS_USB+DFU interfaces for AMD xHCI compatibility
* STALL unhandled USB control requests in composite Setup handler
* Add WARNING comments for AMD xHCI USB compatibility
@github-actions
Copy link

github-actions bot commented Mar 6, 2026

🔨 Build & Macro Coverage Report

Default Builds — Hex File Sizes

ECU Debug (tag 15.0) Debug (gsusb) (tag 15.0) Release (tag 15.0) Release (gsusb) (tag 15.0)
ECUA 482 KiB (494200 bytes) 496 KiB (508592 bytes) 314 KiB (322484 bytes) 323 KiB (331410 bytes)
ECUB 332 KiB (340532 bytes) 332 KiB (340532 bytes) 194 KiB (199306 bytes) 194 KiB (199306 bytes)
ECUC 312 KiB (320200 bytes) 312 KiB (320200 bytes) 173 KiB (178057 bytes) 173 KiB (178057 bytes)
ECUD 322 KiB (330640 bytes) 322 KiB (330640 bytes) 181 KiB (185549 bytes) 181 KiB (185549 bytes)

Macro Coverage Build Results

ECU Variant Macros Changed Result Hex Size Warnings
ECUA gsusb +ENABLE_GSUSBENABLE_CDC ✅ Pass 266 KiB 0
ECUA no_debug ENABLE_USB_DEBUGENABLE_JOYSTICK_CONTROLSENABLE_SCREENENABLE_CHIP8GENERATE_RUNTIME_STATS ✅ Pass 223 KiB 1
ECUA no_extras ENABLE_J1979ENABLE_MINICTFENABLE_CHIP8ENABLE_SCREENENABLE_SPI ✅ Pass 233 KiB 1
ECUA no_uds ENABLE_UDSENABLE_UDS_REPROGRAMMING ✅ Pass 271 KiB 1
ECUB kwp +ENABLE_KWP ✅ Pass 197 KiB 0
ECUB no_dynamic_bitrate ENABLE_DYNAMIC_BITRATE ✅ Pass 194 KiB 0
ECUB watchdog +WATCHDOG_ENABLE ✅ Pass 195 KiB 0
ECUC uart +ENABLE_UART ✅ Pass 190 KiB 0

Source Code Compile Coverage

  • Total .c source lines: 18024
  • Lines compiled in ≥1 configuration: 16811 (~93%)
  • ENABLE_ macro coverage: 19/21 (90.5%) macros tested in both ON and OFF states
Full ENABLE_ Macro Coverage Table
# Macro Tested ON Tested OFF Covered
1 ENABLE_ADC default (ECUB, ECUC, ECUD) default (ECUA)
2 ENABLE_CDC default (ECUA) default (ECUB, ECUC, ECUD), variant: gsusb (ECUA)
3 ENABLE_CHIP8 default (ECUA) default (ECUB, ECUC, ECUD), variant: no_debug (ECUA), variant: no_extras (ECUA)
4 ENABLE_DYNAMIC_BITRATE default (ECUA, ECUB, ECUC, ECUD) variant: no_dynamic_bitrate (ECUB)
5 ENABLE_GSUSB variant: gsusb (ECUA) default (ECUA, ECUB, ECUC, ECUD)
6 ENABLE_I2C default (ECUA, ECUB, ECUC, ECUD)
7 ENABLE_J1979 default (ECUA, ECUB, ECUC, ECUD) variant: no_extras (ECUA)
8 ENABLE_JOYSTICK_CONTROLS default (ECUA) default (ECUB, ECUC, ECUD), variant: no_debug (ECUA)
9 ENABLE_KWP variant: kwp (ECUB) default (ECUA, ECUB, ECUC, ECUD)
10 ENABLE_MINICTF default (ECUA, ECUD) default (ECUB, ECUC), variant: no_extras (ECUA)
11 ENABLE_SCREEN default (ECUA) default (ECUB, ECUC, ECUD), variant: no_debug (ECUA), variant: no_extras (ECUA)
12 ENABLE_SPI default (ECUA, ECUD) default (ECUB, ECUC), variant: no_extras (ECUA)
13 ENABLE_UART variant: uart (ECUC) default (ECUA, ECUB, ECUC, ECUD)
14 ENABLE_UDS default (ECUA, ECUB, ECUC, ECUD) variant: no_uds (ECUA)
15 ENABLE_UDS_REPROGRAMMING default (ECUA, ECUB, ECUC, ECUD) variant: no_uds (ECUA)
16 ENABLE_USB default (ECUA) default (ECUB, ECUC, ECUD)
17 ENABLE_USB_AUTODETECT default (ECUA, ECUB, ECUC, ECUD)
18 ENABLE_USB_DEBUG default (ECUA) default (ECUB, ECUC, ECUD), variant: no_debug (ECUA)
19 ENABLE_XCP default (ECUB, ECUC, ECUD) default (ECUA)
20 GENERATE_RUNTIME_STATS default (ECUA, ECUB, ECUC, ECUD) variant: no_debug (ECUA)
21 WATCHDOG_ENABLE variant: watchdog (ECUB) default (ECUA, ECUB, ECUC, ECUD)

@CamilleTTT CamilleTTT merged commit 8830b08 into ToyotaInfoTech:main Mar 9, 2026
13 checks passed
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