2025-04-01 7:41 AM
I am trying to implement an application with USB CDC-ECM host capabilities.
As a bring up setup, I configured two STM32 boards:
1) STM32U5G9J-DK2 board, configured as a CDC-ECM device, using USBX.
2) STM32U575I-EV, configured as a CDC-ECM host, using USBX.
I am able to connect both boards, and get some basic networking functionality, including ping and
UDP traffic.
Now I am trying to implement host suspend/resume and remote wakeup by device.
When performing suspend and resume by host only (without remote wakeup), everything works fine, and
I can see both suspend and resume signaling on device.
However, when using remote wakeup by device, I see the following flow of events:
1) Host sending suspend to device.
2) Device is getting the suspend signaling and enters suspend mode.
3) Device is activating remote wakeup signaling
4) Remote wake signal is detected on host (OTG_GINTSTS_WKUPINT is fired).
5) Host waits ~10 msec and desserts the resume signal (OTG_HPRT_PRES)
6) I see no resume signaling on device side, and no more SOF interrupts on host side.
The code I'm using for host suspend Signalling:
HAL_StatusTypeDef HOST_Suspend(HCD_HandleTypeDef *hhcd)
{
USB_OTG_GlobalTypeDef *USBx = hhcd->Instance;
uint32_t USBx_BASE = (uint32_t)USBx;
uint32_t hprt = USBx_HPRT0;
hprt &= ~USB_OTG_HPRT_PENA;
hprt |= USB_OTG_HPRT_PSUSP;
/* Set Suspend Mode */
USBx_HPRT0 = hprt;
return HAL_OK;
}
The code I'm using for host resume Signalling, after receiving WKUPINT interrupt:
void HAL_HCD_ResumeCallback(HCD_HandleTypeDef *hhcd)
{
USB_OTG_GlobalTypeDef *USBx = hhcd->Instance;
uint32_t USBx_BASE = (uint32_t)USBx;
uint32_t hprt;
tx_thread_sleep(1);
hprt = USBx_HPRT0;
hprt &= ~USB_OTG_HPRT_PENA;
hprt &= ~USB_OTG_HPRT_PRES;
/* Clear Resume bit */
USBx_HPRT0 = hprt;
}
The code for device remote wakeup signaling:
__HAL_PCD_UNGATE_PHYCLOCK((&hpcd_USB_OTG_HS));
USB_ActivateRemoteWakeup( USB_OTG_HS );
tx_thread_sleep(1);
USB_DeActivateRemoteWakeup( USB_OTG_HS );
Any idea why my remote wakeup flow is broken?
Thanks in advance.