Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB PMA Buffers are not initialised correctly, causing USB enumeration to fail #2

Open
hepr-skylotec opened this issue Oct 27, 2022 · 1 comment

Comments

@hepr-skylotec
Copy link

Using:

  • STM32L452RE on custom board.
  • STM32CubeIDE 1.10.1
  • STM32L4 HAL 1.17.2
  • X-CUBE-AZRTOS-L4 6.1.7

While trying to get UsbX working all different setups would fail. Hardware is known good as the built in ST Bootloader enumerates correctly and works perfectly to flash over USB from Windows.

I finally tracked it down to the Buffer Descriptor table in PMA Memory not being correcly initialised by the UsbX STM adaptation layer in x-cube-azrtos-l4/tree/main/Middlewares/ST/usbx/common/usbx_stm32_device_controllers/

A "dumb" workaround by calling HAL_PCDEx_PMAConfig() before starting the stack makes enumeration work.

E.g. for a CDC class use the following works.

  HAL_PCDEx_PMAConfig(&hpcd_USB_FS, 0x00 , PCD_SNG_BUF, 0x18);
  HAL_PCDEx_PMAConfig(&hpcd_USB_FS, 0x80 , PCD_SNG_BUF, 0x58);
  HAL_PCDEx_PMAConfig(&hpcd_USB_FS, 0x81 , PCD_SNG_BUF, 0xC0);
  HAL_PCDEx_PMAConfig(&hpcd_USB_FS, 0x01 , PCD_SNG_BUF, 0x110);
  HAL_PCDEx_PMAConfig(&hpcd_USB_FS, 0x82 , PCD_SNG_BUF, 0x100);

But this should really be fixed in ux_dcd_stm32_initialize() or ux_dcd_stm32_initialize_complete()

Without any reasonable PMA configuration USB will always fail and be completely unusable.

@hepr-skylotec hepr-skylotec changed the title USB PMA Buffers are not initialised correctly causing USB failed enumeration USB PMA Buffers are not initialised correctly causing USB enumeration to fail Oct 27, 2022
@hepr-skylotec hepr-skylotec changed the title USB PMA Buffers are not initialised correctly causing USB enumeration to fail USB PMA Buffers are not initialised correctly, causing USB enumeration to fail Oct 27, 2022
@AYEDMSTM
Copy link

AYEDMSTM commented Nov 4, 2022

Hi @h-actsafe

Can you please take a look at this example of PMA config with Ux_Device_CDC_ACM developed on G0 [STM32G0C1E-EV]
https://github.com/STMicroelectronics/x-cube-azrtos-g0/blob/2b77e6fa7dd42cd60a959cff12abc8c3055dc543/Projects/STM32G0C1E-EV/Applications/USBX/Ux_Device_CDC_ACM/USBX/App/app_usbx_device.c#L273

Best Regards.
Mohamed

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

No branches or pull requests

2 participants