USB Remote Wakeup not waking up host

I have a USB HID device using the 'old' USB stack in Zephyr. I have configured the 'CONFIG_USB_DEVICE_REMOTE_WAKEUP'

1. I put the HOST to Suspend

2. The NRF52 USB goes into Suspend.

3. A 'usb_wakeup_request' is called, and I see it calls into the

nrf_usbd_common_wakeup_req , which results in a 'ev_usbevent_handler' call to the USBD_EVENTCAUSE_USBWUALLOWED_Msk section.

It does call the

'            NRF_USBD->DPDMVALUE = USBD_DPDMVALUE_STATE_Resume
                << USBD_DPDMVALUE_STATE_Pos;
            NRF_USBD->TASKS_DPDMDRIVE = 1;

and the USBD reports a 'Resume' and the resulting log:

usb_hid: Device resumed
usb_hid: from suspend

but then results back in a Suspended state: usb_hid: Device suspended, and the HOST does not wakeup. I have other USB hardware (non NRF52) which is capable of waking up this HOST.

Using ncs 2.7.0.

I've also tried putting in the errata_171_end section into the USBWUALLOWED section. ie.

if (event & USBD_EVENTCAUSE_USBWUALLOWED_Msk) {

unsigned int irq_lock_key = irq_lock();

if (*((volatile uint32_t *)(0x4006EC00)) == 0x00000000) {
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
*((volatile uint32_t *)(0x4006EC14)) = 0x00000000;
*((volatile uint32_t *)(0x4006EC00)) = 0x00009375;
} else {
*((volatile uint32_t *)(0x4006EC14)) = 0x00000000;
}

irq_unlock(irq_lock_key);

LOG_DBG("USBD event: WUREQ (%s)", m_bus_suspend ? "In Suspend" : "Active");
if (m_bus_suspend) {
__ASSERT_NO_MSG(!nrf_usbd_common_suspend_check());
m_bus_suspend = false;

NRF_USBD->DPDMVALUE = USBD_DPDMVALUE_STATE_Resume
<< USBD_DPDMVALUE_STATE_Pos;
NRF_USBD->TASKS_DPDMDRIVE = 1;

const nrf_usbd_common_evt_t evt = {.type = NRF_USBD_COMMON_EVT_WUREQ};

m_event_handler(&evt);
}
}

However I still cannot get the HOST to Remote Wake up.

Thanks for any help!

Parents
  • Hi,

     

    Is this a windows PC?

     

    If yes, it is very important to know the restrictions when developing with USB on Windows. One being that Windows will always cache your USB descriptor initially, and not refresh it unless you change VID/PID of your device or delete the cached entries.

     

    If you change the descriptor, the easiest option is to change/append PID for development purposes.

     

    The OS might not allow a device to wake up the PC. You will need to manually enable or check the state of this feature. https://learn.microsoft.com/en-us/windows-hardware/drivers/usbcon/remote-wakeup-of-usb-devices

     This function indicates that the device is allowed, but just to check all the corners, it would be great to see if there is anything in the device settings on the PC side that might block it.

    nrf_usbd_common_wakeup_req , which results in a 'ev_usbevent_handler' call to the USBD_EVENTCAUSE_USBWUALLOWED_Msk section.

     

    Kind regards,

    Håkon

  • Yes it is a Windows PC. I checked under the Device Manager, the "Allow this device to wake the computer" is selected.

    Also, just before setting the computer to "Sleep", the usb_device.c has the RemoteWakeup Feature set. As per the:

    learn.microsoft.com/.../remote-wakeup-of-usb-devices

    case USB_SREQ_SET_FEATURE:

    LOG_DBG("Set Feature request");

    if (IS_ENABLED(CONFIG_USB_DEVICE_REMOTE_WAKEUP)) {

    if (setup->wValue == USB_SFS_REMOTE_WAKEUP) {

    usb_dev.remote_wakeup = true;

    return true;

    }

    }

    break;

  • I do notice that the Remote Wakeup DOES work some of the time.

    It is when the logs show only:

    usb_hid: Device suspended

    There after, subsequent Host Sleeps will always work and not result in the Suspend/Disconnect/Connect flow below.

    When it does NOT work, it shows multiple

    usb_hid: Device suspended
    usb_hid: Device disconnected
    usb_hid: Device connected
    usb_hid: Device suspended
    usb_hid: Device disconnected
    usb_hid: Device connected
    usb_hid: Device suspended

    Any guidance on this?

    Regards

Reply
  • I do notice that the Remote Wakeup DOES work some of the time.

    It is when the logs show only:

    usb_hid: Device suspended

    There after, subsequent Host Sleeps will always work and not result in the Suspend/Disconnect/Connect flow below.

    When it does NOT work, it shows multiple

    usb_hid: Device suspended
    usb_hid: Device disconnected
    usb_hid: Device connected
    usb_hid: Device suspended
    usb_hid: Device disconnected
    usb_hid: Device connected
    usb_hid: Device suspended

    Any guidance on this?

    Regards

Children
Related