0

I'm trying to create a USB composite device with 2 registered classes DFU and CDC ACM, using USBX middleware on stm32u585 mcu.

I was going through those two examples on git:

  • STM32CubeU5/Projects/B-U585I-IOT02A/Applications/USBX/Ux_Device_DFU/
  • STM32CubeU5/Projects/B-U585I-IOT02A/Applications/USBX/Ux_Device_HID_CDC_ACM/

Both examples work as expected when running separately.

As a starting point I used Ux_Device_DFU example and started copying CDC ACM part into my project. DFU and CDC ACM device classes are successfully registered using ux_device_stack_class_register function.

However when HAL_PCD_Start is called only DFU class is visible in device manager on PC.

I have noticed that in function MX_USB_Device_Init there are functions HAL_PCDEx_SetRxFiFo and HAL_PCDEx_SetTxFiFo being called and I do not understand how and which endpoints should be configured. I'm thinking this could be the case that CDC ACM class is not visible in device manager.

I was hoping if someone could help me out on this.

Some additinal info: MCU: STM32U585QIIx

STM32CubeMX version: Version 6.5.0

FW package version: SWM32Cube FW_U5 V1.1.0

mejha
  • 1

3 Answers3

0

From your description it seems the device framework (USB descriptors reported to host) are not updated, if you want to add CDC things into DFU, you should modify configuration descriptors in the device framework, to report to host that CDC is included in device side.

  • Thank you for answering. There is already some code initilized regarding this. How and where I can found more detail how to implement that or perhaps if there is already an example? – mejha Jul 11 '22 at 19:58
0

Agree with CQ answer, looks device descriptors are not updated to be for composite DFU+CDC device. As a starting point I would suggest you to take DFU application IOC file and using CubeMX add the CDC_ACM interface from USBX Class configuration Panel. The generated code should update the current DFU application with required device descriptors to have a composite device.

Regarding the second point: HAL_PCDEx_SetRxFiFo is used to configure the shared RX fifo for all EPs you could keep it unchanged as DFU by default uses EP0

HAL_PCDEx_SetTxFiFo need to be called to configure CDC_ACM IN EPs this is an example:

  HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80); // 512bytes allocated for shared RX FiFo
  HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x10); // 64 bytes for EP0 IN 
  HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x10); // CDC CMD EP1 IN
  HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 2, 0x10); // CDC IN DATA EP2 IN
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 19 '22 at 03:22
0

Thanks @CQ Xiao and @ABOUSTM for pointing out about USB Descriptors.

By changing VID and PID of device, different USB devices shows up in Device Manager. I tried two different configurations:

a) VID: 1155 PID: 57105 // defined in Ux_Device_DFU example

result: DFU device shows up, no composite device and no CDC_ADC (USB serial device)

This was my setup and that's why USB composite device and USB Serial Device did not show up.

b) VID: 1155 PID: 22352 // defined in Ux_Device_HID_CDC_ACM

result: USB Composite Device shows, USB Serial Device shows, DFU class is unrecognized, it is shown as in "Other devices" in device manager with Device desctiption: "@Internal Flash /0x0800.."

mejha
  • 1