Keil Logo

ARM: USBD_EndpointConfigure fails with ARM_DRIVER_ERROR_PARAMETER


Information in this knowledgebase article applies to:

  • USB device drivers

QUESTION

When in some situations an USB device class don't work as expected, like in this example the ADC, in the Event Recorder log are errors like:

USBD_Driver, EndpointConfigureFailed,  device=0  ep_addr=0x81
  ep_type=Isochronous  ep_max_packet_size=192  error=ARM_DRIVER_ERROR_PARAMETER

But what exactly does ARM_DRIVER_ERROR_PARAMETER mean? Is there a way to find that out, so the problem can be resolved?

ANSWER

Unfortunately, USBD driver functions can return ARM_DRIVER_ERROR_PARAMETER for multiple reasons. To find out the actual reason for the failure, the code execution needs to be inspected during runtine using the µVision Debugger. Only so the path that lead to ARM_DRIVER_ERROR_PARAMETER can be identified.

To make code debugging as simple as possible, compile the driver code with the lowest possible optimization level.

One approach is then to set a breakpoint at the beginning of the drivers EndpointConfigure function, when it is about the time the failure happens (for the USBD ADC class this is, when the host starts to use the audio device). When the program stops at the breakpoint, verify the "ep_addr" value from the error message in the Event Recorder:

identify ep_addr

If it is the "ep_addr" in question (0x81, endpoint 1 IN transfers), continue with single steps on assembly level to see, what path the code actually takes. This can then look like this:

find exit path

It can be seen, the code takes the "exit" after the check for the TX FIFO size:

if (ep_mps > USBD0_TX_FIFO_SIZE[ep_num]) { return ARM_DRIVER_ERROR_PARAMETER; }

So, in this case, in the driver, the configured transmit FIFO size is too small for the requested "ep_max_packet_size".

This FIFO configuration is a specific thing for some STM32 devices and can be resolved by adjusting the values via the C/C++ pre-processor defines:

USBD0_TX1_FIFO_SIZE=192, USBD0_TX5_FIFO_SIZE=64

This sets the transmit FIFO size for the endpoint 1 to the required 192 bytes. And because there is a limit for the combined transmit FIFO sizes of all endpoints, one other size needs to be decreased (see the device manual for details).

MORE INFORMATION

Last Reviewed: Wednesday, May 29, 2019


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.