2023-05-05
05:05 AM
- last edited on
2023-12-06
05:11 AM
by
Laurids_PETERSE
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.
A 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
It 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.
In addition:
Function call to MX_USB_OTG_HS_PCD_Init should be disabled
and USB interrupts must be enabled
**************************
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"
2023-05-08 05:19 AM
I found the answer for the driver error "cannot start driver code 10"
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?
2023-05-08 05:19 AM
2023-05-11 02:48 AM - edited 2023-11-20 06:21 AM
found the answer myself.
In cubeIDE / cubeMX you have to define the usb endpoint adresses yourself. CubeMX does not do an automatic enumeration .
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
Video uses 4