USBX CDC ACM on STM32F407ZGT6: COM Port Recognized but Can't Connect
Hi everyone,
I am trying to get a USBX CDC ACM device running on an STM32F407ZGT6, using a project generated by STM32CubeMX. I'm basing my work on the example provided for the STM32F469 (DEVICE_CDC_ACM).
Problem Description
The device is partially working. When I plug it in, Windows Device Manager recognizes it and assigns a COM port. However, when I try to connect using any terminal software (Tera Term, PuTTY, etc.), the connection fails. The software cannot open the port.
Debugging Findings
Through debugging, I've identified a key issue in the initialization sequence:
Instance Activator Not Called: The callback function I set for cdc_acm_parameter.ux_slave_class_cdc_acm_instance_activate(which is CDC_Init_FS) is never triggered. This prevents the proper initialization of my CDC ACM instance.
Null Pointer in Thread: The usbx_cdc_acm_read_thread_entryfails because it encounters a null pointer. Specifically, the comparison ux_utility_memory_compare(data_interface->ux_slave_interface_class->ux_slave_class_name, ...)fails because data_interface->ux_slave_interface_classis a null pointer.
Root Cause Hypothesis: This strongly suggests that the data interface for the CDC ACM class was not correctly associated with a class instance during the enumeration process. The ux_slave_interface_classpointer for the data interface is not being set, which is likely why the instance activator is never called.
My Setup and Configuration
MCU: STM32F407ZGT6
Software Packages: STM32CubeMX-generated code with USBX and ThreadX.
Reference Example: ST's DEVICE_CDC_ACMexample for STM32F469, which I have adapted for the F407.
What I've Already Checked/Tried
Clock Configuration: The USB clock is confirmed to be exactly 48 MHz .
Pin Configuration: The USB DP (PA12) and DM (PA11) pins are correctly configured for their alternate function.
Interrupts: The USB global interrupt is enabled in the NVIC.
Device Manager Recognition: The fact that a COM port appears indicates that the basic device descriptor is correct and the host identifies it as a CDC device at a high level .
Specific Questions
Based on the symptoms and the null pointer, I suspect the issue lies in the USB configuration descriptors or how the CDC ACM class is registered. Could you please help me with the following?
What are the common reasons for the ux_slave_interface_classpointer of a data interface remaining null in a USBX CDC ACM setup?
When migrating the CDC ACM example from an F469 to an F407, are there any critical changes needed in the device or configuration descriptors that are often overlooked? Specifically, should I pay special attention to the Union Functional Descriptor that links the control and data interfaces?
In the ux_device_class_cdc_acm_activatefunction within USBX, what are the precise conditions that must be met for the instance_activatecallback to be called? My function is not being called, so one of these conditions is likely not met.
Any guidance or suggestions on where to look in the descriptor or initialization code would be greatly appreciated. Thank you for your time and expertise.
