This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

USBD Driver - Bug when removing ISO endpoint

Hello,

I am working on implementing the USB HAL for the nRF52840 for Mbed-OS's upcoming USBDevice feature release. I am trying to get my implementation to pass all of Mbed's automated tests.

I have encountered an issue with the Nordic USBD driver in SDK14.2, but have determined the bug is still present in SDK15.2

The issue is this:

During a `set_interface` call from the upper layers of the Mbed stack, endpoints that are part of the current interface are removed. My implementation calls `nrf_drv_usbd_ep_disable` during this call, which works fine for all non-ISO endpoints.

At some point in the call flow, the endpoint being removed is aborted, resulting in a call to `nrf_usbd_epout_clear`. In this function, there is an `ASSERT` that will always fail for the `ISOOUT` endpoint. When you pass in the `ISOOUT` endpoint number (8), the ASSERT fails because the endpoint's index is outside the bounds of the `NRF_USBD->SIZE.EPOUT[]` array. I think what should happen when the `ISOOUT` endpoint index is passed is the driver should access `NRF_USBD->SIZE.ISOOUT` instead.

See the culprit line here:

https://github.com/ARMmbed/mbed-os/blob/8f48104842a8932382fd18f952e994facb1513e2/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_14_2/drivers_nrf/hal/nrf_usbd.h#L1202-L1208

Check out the Github conversation here:

https://github.com/ARMmbed/mbed-os/issues/7674

Here's a screenshot during debugging that shows the call stack in Eclipse: