cancel
Showing results for 
Search instead for 
Did you mean: 

USBx CDC ACM Dual Composite not working on STM32H723

NRedd.2
Associate III

Hello all,

 

Following up on https://community.st.com/t5/stm32cubeide-mcus/usbx-dual-composite-cdc-acm-not-working/td-p/708277, I tried to implement the same Dual CDC-ACM on STM32H723 Nucleo. I have run into the same issues.

With just one CDC_ACM class registration, the example works well. But when two classes are registered, it is gibberish on the COM port (UART). 

uint8_t UserClassInstance[USBD_MAX_CLASS_INTERFACES] = {
    CLASS_TYPE_CDC_ACM,
    CLASS_TYPE_CDC_ACM
};

 

Similar to the previous post, I have modified ux_device_descriptors.c to correctly add the endpoints to the device framework string. With this change, I am able to see two ACM devices on Linux. 

[  +5.485446] usb 1-4.3.2: new full-speed USB device number 48 using xhci_hcd
[  +0.191080] usb 1-4.3.2: New USB device found, idVendor=0483, idProduct=5740, bcdDevice= 2.00
[  +0.000006] usb 1-4.3.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  +0.000002] usb 1-4.3.2: Product: STM32 Virtual ComPort
[  +0.000002] usb 1-4.3.2: Manufacturer: STMicroelectronics
[  +0.000001] usb 1-4.3.2: SerialNumber: CDC_ACM001
[  +0.015570] cdc_acm 1-4.3.2:1.0: ttyACM1: USB ACM device
[  +0.000352] cdc_acm 1-4.3.2:1.2: ttyACM2: USB ACM device

NRedd2_0-1723621915432.png

 

I have also increased FIFO sizes.

VOID USBX_APP_Device_Init(VOID)
{
  /* USER CODE BEGIN USB_Device_Init_PreTreatment_0 */

  /* USER CODE END USB_Device_Init_PreTreatment_0 */

  /* USB_OTG_HS init function */
  MX_USB_OTG_HS_PCD_Init();

  /* USER CODE BEGIN USB_Device_Init_PreTreatment_1 */

  /* Set Rx FIFO */
  HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_HS, 0x200);

  /* Set Tx FIFO 0 */
  HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, 0x40);

  /* Set Tx FIFO 2 */
  HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 1, 0x40);

  /* Set Tx FIFO 3 */
  HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 2, 0x40);
  /* USER CODE END USB_Device_Init_PreTreatment_1 */

  /* Initialize and link controller HAL driver */
  ux_dcd_stm32_initialize((ULONG)USB_OTG_HS, (ULONG)&hpcd_USB_OTG_HS);

  /* Start the USB device */
  HAL_PCD_Start(&hpcd_USB_OTG_HS);

  /* USER CODE BEGIN USB_Device_Init_PostTreatment */

  /* USER CODE END USB_Device_Init_PostTreatment */
}

 

Please find the GitHub repo here

Can someone from STM assist me please?

 

Best regards,

Navin

1 ACCEPTED SOLUTION

Accepted Solutions
FBL
ST Employee

Hi @NRedd.2 

Sorry for my late response. Your configuration is missing the initialization of the interfaces. You need to adjust CDC endpoint address for each CDC interface etc.. I suggest you follow this article to learn more about composite classes in USBX How to implement the USB device composite class in... - STMicroelectronics Community

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

7 REPLIES 7
FBL
ST Employee

Hi @NRedd.2 

Have you tried the example provided? x-cube-azrtos-h7/Projects/NUCLEO-H723ZG/Applications/USBX/Ux_Device_CDC_ACM at main · STMicroelectronics/x-cube-azrtos-h7 (github.com)

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

NRedd.2
Associate III

Hi @FBL,

 

Thank you for the response!

Yes, I have initially generated the code from STM32CubeMX based on the link you have suggested. Please find the repository here

And then, I tried to add another slave class, but I couldn't get it working.

With the initial example, I could communicate with ACM0 and ACM1 using terminal applications. 

After I added the ACM2 class, I can't even get the singe ACM to work (ACM1). Although, on Linux I see ACM devices listed.

 

Best regards,

Navin

 

Hi @FBL ,

 

Have you looked into the issue yet?

FBL
ST Employee

Hi @NRedd.2 

I have an issue to flash your code on my end. To isolate the issue, I suggest you temporarily simplify the configuration by only adding the second CDC-ACM class and verifying if it works independently. This can help identify if the issue is with the second class or with the overall configuration

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

NRedd.2
Associate III

Hi @FBL,

Thank you for the response!

As per your suggestion, I have isolated the ACM2 and pushed the code on GitHub. I think then the issue points to the overall configuration.

To isolate the second ACM:

  • I commented out the enumerator so that I have only one CDC class.
    •  uint8_t UserClassInstance[USBD_MAX_CLASS_INTERFACES] = {
      CLASS_TYPE_CDC_ACM,
      - CLASS_TYPE_CDC_ACM
      + // CLASS_TYPE_CDC_ACM
      };
  • Commented out the ACM1 device class registration and passed the ACM1's parameter to ACM2 for activation, deactivation and parameter change.
    • if (ux_device_stack_class_register("ACM2",
      ux_device_class_cdc_acm_entry,
      cdc_acm_configuration_number,
      cdc_acm_interface_number,
      &cdc_acm_parameter_1) != UX_SUCCESS)
      {
      /* USER CODE BEGIN USBX_DEVICE_CDC_ACM_REGISTER_ERORR */
      return UX_ERROR;
      /* USER CODE END USBX_DEVICE_CDC_ACM_REGISTER_ERORR */
      }

NRedd2_0-1723882570404.png

 

PS:

> I have an issue to flash your code on my end.

The project is configured for CMake. The only change I have made to compile is to append the compiler path 

set(TOOLCHAIN_PREFIX                /opt/gcc-arm-none-v12/bin/arm-none-eabi-)

to cmake/gcc-arm-none-eabi.cmake.

 

Best regards,

Navin

 

FBL
ST Employee

Hi @NRedd.2 

Sorry for my late response. Your configuration is missing the initialization of the interfaces. You need to adjust CDC endpoint address for each CDC interface etc.. I suggest you follow this article to learn more about composite classes in USBX How to implement the USB device composite class in... - STMicroelectronics Community

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

NRedd.2
Associate III

Hi @FBL 

 

I followed one of the blog posts and got it working. 

Seems like when UART is echoing, it doesn't work as expected.