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

nRF52840 USB Cancel IN Transfer

I am working on the Mbed-OS HAL implementation for the nRF52840 USB device.

I have it almost passing all the automated tests. One where it fails is when the Mbed test suite attempts to halt an endpoint.

Essentially the test works like this:

  1. OUT xfer - write a random payload to device endpoint
  2. IN xfer - read back payload
  3. Make sure data written and data read are the same
  4. ...continue to loop...
  5. OUT xfer - write a random payload to device endpoint
  6. HALT IN endpoint
  7. IN xfer - endpoint should reply STALL
  8. CLEAR HALT on IN endpoint
  9. OUT xfer - write a new random payload to device endpoint
  10. IN xfer - read back payload
  11. Make sure the new random payload and the data read are the same

The failure occurs because the Mbed stack immediately loads the payload received during the OUT stage into EasyDMA and begins the transfer for the corresponding IN endpoint. Then the endpoint is halted, it replies STALL as expected. But when the HALT is cleared, the hardware is still prepared to ACK the next IN transfer that begins on that endpoint. It will then respond with the old payload -- causing the test to fail.

This happens more often than not, but sometimes the test does pass.

I have attached a screenshot of the captured USB traffic during this failure.

Is there a way to clear the USB hardware readiness state for an IN endpoint after an EasyDMA transfer has been completed on it? I have tried disabling and reenabling the endpoint and the issue still occurs. It seems as though the USB hardware should allow this kind of operation...

Parents
  • Hi,

    I recommend you ask about this in the mbed forums, as you will probably get much better feedback on it there. (The mbed USB stack is not used in the nRF5 SDK, so we do not have much experience with it).

  • Hi Einar,

    I am actually working on contributing the USB implementation to Mbed-OS for the nRF52840. This is not an issue with Mbed. The issue is that the Nordic USB hardware does not present a clear way to cancel an auto-ACK on an IN endpoint after a DMA transfer has been completed.

    The test only passes intermittently, presumably when the DMA transfer is fast enough to overwrite the old data before the new data is requested by the host.

    Is there some way I can get support from Nordic in implementing the USB HAL for Mbed-OS? The implementation is very close to done, there are just a few more bugs to iron out.

    Please let me know if there is a way I can converse with Nordic engineers via email.

    Thank you

Reply
  • Hi Einar,

    I am actually working on contributing the USB implementation to Mbed-OS for the nRF52840. This is not an issue with Mbed. The issue is that the Nordic USB hardware does not present a clear way to cancel an auto-ACK on an IN endpoint after a DMA transfer has been completed.

    The test only passes intermittently, presumably when the DMA transfer is fast enough to overwrite the old data before the new data is requested by the host.

    Is there some way I can get support from Nordic in implementing the USB HAL for Mbed-OS? The implementation is very close to done, there are just a few more bugs to iron out.

    Please let me know if there is a way I can converse with Nordic engineers via email.

    Thank you

Children
Related