cancel
Showing results for 
Search instead for 
Did you mean: 

Nucleo STM32H7A3, AzureRTOS_H7, USBX CDC_ACM generation by CubeIDE 1.12 incomplete.

Johannes
Senior

Hello Everyone

I am trying to make AzureRTOS USBX CDC ACM work on my Nucelo H7A3ZI

I am thrilled that CubeIDE now allows to select Packages like AzureRTOS_H7.

 

I was quite successful. ThreadX is running fine. I was able to enable USBX Device CDC ACM as well.

 

Question: Is the CubeIDE 1.12 implementation incomplete at the moment?

the feature in CubeIDE is only preliminary for now?

 

I observe, that CubeIDE 1.12 does not generate all code necessary to make CDC-ACM work.


_legacyfs_online_stmicro_images_0693W00000bjTRJQA2.pngA complete folder is missing here

usbx_STM32_device_controllers

 

In addition

in the user application ux device thread there is no initialization of the Hardware driver


_legacyfs_online_stmicro_images_0693W00000bjTSHQA2.pngIt is missing this:

static VOID app_ux_device_thread_entry(ULONG thread_input)
{
  /* USER CODE BEGIN app_ux_device_thread_entry */
	USBX_APP_Device_Init();
 
  TX_PARAMETER_NOT_USED(thread_input);
  /* USER CODE END app_ux_device_thread_entry */
}

and this:

/* USER CODE BEGIN 1 */
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, 0x10);
 
  /* Set Tx FIFO 2 */
  HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 1, 0x10);
 
  /* Set Tx FIFO 3 */
  HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 2, 0x20);
  /* 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 */
}
 
/* USER CODE END 1 */

I was able to pull the code from st git repository

https://github.com/STMicroelectronics/x-cube-azrtos-h7

 

I also found out, that the memory settings in IOC file are too small:

the USBX System stack must be large enough, otherwise the USB Device initialization will fail with insuficient memory.


_legacyfs_online_stmicro_images_0693W00000bjTSvQAM.pngIn addition:

Function call to MX_USB_OTG_HS_PCD_Init should be disabled

0693W00000bjTTUQA2_image.png

and USB interrupts must be enabled


_legacyfs_online_stmicro_images_0693W00000bjTTjQAM.png**************************

at least, a USB virtual port is displayed on myPC at the moment. But it still has errors. There is still some implementation missing.

 

"Driver cannot be started"

 


_legacyfs_online_stmicro_images_0693W00000bjTQlQAM.png 

3 REPLIES 3
Johannes
Senior

I found the answer for the driver error "cannot start driver code 10"

https://community.st.com/s/question/0D53W00001F0YM3SAN/azure-rtos-usbx-device-descriptor-errors?t=1683547709123

I needed to change the end point addresses in ux_device_descriptors.h

#define USBD_CDCACM_EPIN_ADDR                         0x82U  //changed from 0x81
#define USBD_CDCACM_EPOUT_ADDR                        0x03U  //changed from 0x01

I don't understand why this helps.

Can anyone explain?

Johannes
Senior

 found the answer myself.

In cubeIDE / cubeMX you have to define the usb endpoint adresses yourself. CubeMX does not do an automatic enumeration .


_legacyfs_online_stmicro_images_0693W00000bjrW3QAI.png 

all endpoints must not overlap.

In-Endpoints are typically 0x80+n and output endpoints are 0x00+n

In and out of one element can have the same number.

In this example

MSC (mass storage) one in and one out (1, 0x81)

CDC-ACM (serial port) uses two endpoint groups

  • command (2)
  • Data (3, 0x83)

Video uses 4