cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U5G9J DK2 + 4G Module (USB CDC ECM) not detecting USB device

devin-hu
Associate II

Hi everyone,

I'm working on a project where I want to connect the STM32U5G9J microcontroller to the internet using a 4G module. For this, I purchased the STM32U5G9J-DK2 development kit and a 4G network module that supports USB CDC ECM device mode.

To get started, I referred to the example STM32Cube_FW_U5_V1.7.0\Projects\STM32U5G9J-DK2\Applications\USBX\Ux_Host_HID and configured USB and the USBX stack in STM32CubeMX accordingly. However, the STM32 DK2 does not detect the USB device when it's plugged in — no insertion event is triggered.

I'm a beginner when it comes to both USB and STM32 development. Could anyone suggest what documentation, examples, or guides I should refer to in order to complete this project?

Any help would be greatly appreciated.
Thanks in advance!

7 REPLIES 7
Andrew Neil
Super User

Welcome to the forum.

 


@devin-hu wrote:

a 4G network module that supports USB CDC ECM device mode


We've had long discussions about this before.

These types of modules tend to be targetted at systems with a full OS - like Windows or Linux - to provide the USB Host support.

They tend to have complex composite USB devices which enumerate to multiple interfaces - it's not just a simple UART-over-USB.

This is not well-supported by small microcontrollers.

You'd probably be better looking for a 4G module specifically designed for use with microcontrollers - with UART or similar interface.

EDIT: Or using an embedded Linux host instead.

 


@devin-hu wrote:

I'm a beginner when it comes to both USB and STM32 development. 


Do you have any experience with any other microcontroller(s) ?

This would seem a bit ambitious as a beginner's first project ...

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
devin-hu
Associate II

Hi, Andrew Neil

Previously, I built a demo using a UART interface. However, due to the 4G module’s UART limitation (maximum baud rate of 1 Mbps), the data throughput was not ideal. In our typical use case, the data volume can reach up to 2MB, and the low throughput introduces significant latency.

To address this, we redesigned the system using the STM32U5G9, which supports USB CDC ECM Host, as the main controller. The 4G module’s only other high-speed interface is USB, so the two devices will communicate via USB CDC ECM.

On the software side, the STM32U5 will use the NetX Duo network stack. Once ECM communication is established, network operations should be possible (though some additional drivers for the 4G module may need to be implemented).

Sounds like a Linux host would be more appropriate...

 


@devin-hu wrote:

The 4G module’s only other high-speed interface is USB, so the two devices will communicate via USB CDC ECM..


Again, it's probably more than just a CDC ECM - there might be half a dozen or so!

What do you see when you plug it into a Windows or Linux machine?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

@devin-hu wrote:

due to the 4G module’s UART limitation (maximum baud rate of 1 Mbps), the data throughput was not ideal.


Just a thought: are you sure that was actually limited by the UART speed - not the 4G service?

 

PS:

Note that the STM32U5G9J-DK2 only has 3 Mbytes total RAM - so that's less that 3 seconds of data even at 1Mbps!

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

In fact, a UART baud rate of 1 Mbps translates to a data transfer speed of only about 100 KiB/s under the 8N1 format.

Even typical Flash memory can achieve write speeds more than 200 KiB/s.

I think you missed the point?

Thinking of the volume of data which these speeds imply - do you have the storage capacity for that?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
FBL
ST Employee

Hi @devin-hu 


As host, we don't have ready to use example, but you can refer to this as reference.

UINT status;

/* The USB controller should be the last component initialized so that
everything is ready when data starts being received. */

/* Initialize USBX. */

ux_system_initialize(memory_pointer, UX_USBX_MEMORY_SIZE, UX_NULL, 0);

/* The code below is required for installing the host portion of USBX */
status = ux_host_stack_initialize(UX_NULL);

/* Register cdc_ecm class. */

status = ux_host_stack_class_register(_ux_system_host_class_cdc_ecm_name,
    ux_host_class_cdc_ecm_entry);

/* Perform the initialization of the network driver. */

_ux_network_driver_init();

/* Initialize NetX Duo. Refer to NetX Duo user guide for details to add initialization code. */

/* Register the platform-specific USB controller. */

status = ux_host_stack_hcd_register("controller_name", controller_entry, param1, param2);

/* Find the CDC-ECM class. */
class_cdc_ecm_get();

/* Now wait for the link to be up. */

while (cdc_ecm -> ux_host_class_cdc_ecm_link_state != UX_HOST_CLASS_CDC_ECM_LINK_STATE_UP)
    tx_thread_sleep(10);

/* At this point, everything has been initialized, and we've found a CDC-ECM device.
    Now NetX Duo can be used to communicate with the device. */

As a device, I suggest you looking at this example as it runs web http server over USB interface. It’s designed to load files and web pages stored in SD card using a web HTTP server through USB CDC_ECM on STM32U5 using USBX, NetXDuo, FIleX, and threadX.

Now, about this example Ux_Host_HID, which board revision are you using? The application has been tested with STM32U5G9J-DK2 revision MB1918-U5G9ZJQ-B01. Also check your setup as mentioned in the readme.
Check your option bytes. Provide more details about the issue so we may help you.

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.