Closed
Description
Describe the bug
When attempting to run the USB shell or CDC_ACM USB samples (either using the old or new USB device stacks) on the STM32N657-DK (stm32n6570_dk) or NUCLEO-N657X0-Q (nucleo_n657x0_q) boards, the USB initialization fails and prints PCD_Init failed, 1
to the console.
To Reproduce
Run west build -b stm32n6570_dk samples/subsys/usb/cdc_acm
or west build -b nucleo_n657x0_q samples/subsys/usb/cdc_acm
Expected behavior
The USB samples successfully run and the STM32N6 USB device properly initializes.
Attempted workarounds
- Tried putting the usb device into full speed mode.
- Used KConfig option
CONFIG_USB_DC_STM32_CLOCK_CHECK=y
to verify that the USB clock was set correctly. - Tried running on both the Discovery Kit and Nucleo boards.
- Some debugging suggests that the issue is caused by
HAL_TIMEOUT
being returned on line 1387 of stm32n6xx_ll_usb.c. - Tried to add delays as mentioned in this ST Community post
- Tried running the equivalent sample for ThreadX (provided by ST) which was able to successfully enumerate the device.
- Found a related issue on the STM32U5, however I was not able to get USB full speed working, so it may not be related.
Impact
High
Logs and console output
[00:00:00.001,000] <dbg> usb_descriptor: ascii7_to_utf16le: idx_max 31, ascii_idx_max 15, buf 0x3419b91d
[00:00:00.001,000] <dbg> usb_descriptor: ascii7_to_utf16le: char E : 45, idx 15 -> 31
[00:00:00.001,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 4 : 34, idx 14 -> 29
[00:00:00.001,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 2 : 32, idx 13 -> 27
[00:00:00.001,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 3 : 33, idx 12 -> 25
[00:00:00.001,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 6 : 36, idx 11 -> 23
[00:00:00.001,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 3 : 33, idx 10 -> 21
[00:00:00.001,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 0 : 30, idx 9 -> 19
[00:00:00.001,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 0 : 30, idx 8 -> 17
[00:00:00.001,000] <dbg> usb_descriptor: ascii7_to_utf16le: char E : 45, idx 7 -> 15
[00:00:00.001,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 0 : 30, idx 6 -> 13
[00:00:00.001,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 0 : 30, idx 5 -> 11
[00:00:00.001,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 5 : 35, idx 4 -> 9
[00:00:00.001,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 6 : 36, idx 3 -> 7
[00:00:00.001,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 3 : 33, idx 2 -> 5
[00:00:00.001,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 2 : 32, idx 1 -> 3
[00:00:00.001,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 4 : 34, idx 0 -> 1
[00:00:00.001,000] <dbg> usb_dc_stm32: usb_dc_set_status_callback:
[00:00:00.001,000] <dbg> usb_dc_stm32: usb_dc_attach:
[00:00:00.001,000] <dbg> usb_dc_stm32: usb_dc_stm32_phy_specific_clock_enable: CLOCK CHECK
[00:00:00.001,000] <dbg> usb_dc_stm32: usb_dc_stm32_init: HAL_PCD_Init
[00:00:46.571,000] <err> usb_dc_stm32: PCD_Init failed, 1
[00:00:46.571,000] <dbg> usb_device: usb_enable: unlock usb_enable_lock mutex
*** Booting Zephyr OS build v4.1.0-3816-g958ef2288e01 ***
Environment:
- OS: Linux (via WSL)
- Toolchain: Zephyr SDK
- Zephyr: v4.1.0