162306a36Sopenharmony_ci.. _usb-error-codes: 262306a36Sopenharmony_ci 362306a36Sopenharmony_ciUSB Error codes 462306a36Sopenharmony_ci~~~~~~~~~~~~~~~ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci:Revised: 2004-Oct-21 762306a36Sopenharmony_ci 862306a36Sopenharmony_ciThis is the documentation of (hopefully) all possible error codes (and 962306a36Sopenharmony_citheir interpretation) that can be returned from usbcore. 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ciSome of them are returned by the Host Controller Drivers (HCDs), which 1262306a36Sopenharmony_cidevice drivers only see through usbcore. As a rule, all the HCDs should 1362306a36Sopenharmony_cibehave the same except for transfer speed dependent behaviors and the 1462306a36Sopenharmony_ciway certain faults are reported. 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ciError codes returned by :c:func:`usb_submit_urb` 1862306a36Sopenharmony_ci================================================ 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ciNon-USB-specific: 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci=============== =============================================== 2462306a36Sopenharmony_ci0 URB submission went fine 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci``-ENOMEM`` no memory for allocation of internal structures 2762306a36Sopenharmony_ci=============== =============================================== 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ciUSB-specific: 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci======================= ======================================================= 3262306a36Sopenharmony_ci``-EBUSY`` The URB is already active. 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci``-ENODEV`` specified USB-device or bus doesn't exist 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci``-ENOENT`` specified interface or endpoint does not exist or 3762306a36Sopenharmony_ci is not enabled 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci``-ENXIO`` host controller driver does not support queuing of 4062306a36Sopenharmony_ci this type of urb. (treat as a host controller bug.) 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci``-EINVAL`` a) Invalid transfer type specified (or not supported) 4362306a36Sopenharmony_ci b) Invalid or unsupported periodic transfer interval 4462306a36Sopenharmony_ci c) ISO: attempted to change transfer interval 4562306a36Sopenharmony_ci d) ISO: ``number_of_packets`` is < 0 4662306a36Sopenharmony_ci e) various other cases 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci``-EXDEV`` ISO: ``URB_ISO_ASAP`` wasn't specified and all the 4962306a36Sopenharmony_ci frames the URB would be scheduled in have already 5062306a36Sopenharmony_ci expired. 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci``-EFBIG`` Host controller driver can't schedule that many ISO 5362306a36Sopenharmony_ci frames. 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci``-EPIPE`` The pipe type specified in the URB doesn't match the 5662306a36Sopenharmony_ci endpoint's actual type. 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci``-EMSGSIZE`` (a) endpoint maxpacket size is zero; it is not usable 5962306a36Sopenharmony_ci in the current interface altsetting. 6062306a36Sopenharmony_ci (b) ISO packet is larger than the endpoint maxpacket. 6162306a36Sopenharmony_ci (c) requested data transfer length is invalid: negative 6262306a36Sopenharmony_ci or too large for the host controller. 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci``-EBADR`` The wLength value in a control URB's setup packet does 6562306a36Sopenharmony_ci not match the URB's transfer_buffer_length. 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci``-ENOSPC`` This request would overcommit the usb bandwidth reserved 6862306a36Sopenharmony_ci for periodic transfers (interrupt, isochronous). 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci``-ESHUTDOWN`` The device or host controller has been disabled due to 7162306a36Sopenharmony_ci some problem that could not be worked around. 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci``-EPERM`` Submission failed because ``urb->reject`` was set. 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci``-EHOSTUNREACH`` URB was rejected because the device is suspended. 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci``-ENOEXEC`` A control URB doesn't contain a Setup packet. 7862306a36Sopenharmony_ci======================= ======================================================= 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ciError codes returned by ``in urb->status`` or in ``iso_frame_desc[n].status`` (for ISO) 8162306a36Sopenharmony_ci======================================================================================= 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ciUSB device drivers may only test urb status values in completion handlers. 8462306a36Sopenharmony_ciThis is because otherwise there would be a race between HCDs updating 8562306a36Sopenharmony_cithese values on one CPU, and device drivers testing them on another CPU. 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ciA transfer's actual_length may be positive even when an error has been 8862306a36Sopenharmony_cireported. That's because transfers often involve several packets, so that 8962306a36Sopenharmony_cione or more packets could finish before an error stops further endpoint I/O. 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ciFor isochronous URBs, the urb status value is non-zero only if the URB is 9262306a36Sopenharmony_ciunlinked, the device is removed, the host controller is disabled, or the total 9362306a36Sopenharmony_citransferred length is less than the requested length and the 9462306a36Sopenharmony_ci``URB_SHORT_NOT_OK`` flag is set. Completion handlers for isochronous URBs 9562306a36Sopenharmony_cishould only see ``urb->status`` set to zero, ``-ENOENT``, ``-ECONNRESET``, 9662306a36Sopenharmony_ci``-ESHUTDOWN``, or ``-EREMOTEIO``. Individual frame descriptor status fields 9762306a36Sopenharmony_cimay report more status codes. 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci=============================== =============================================== 10162306a36Sopenharmony_ci0 Transfer completed successfully 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci``-ENOENT`` URB was synchronously unlinked by 10462306a36Sopenharmony_ci :c:func:`usb_unlink_urb` 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci``-EINPROGRESS`` URB still pending, no results yet 10762306a36Sopenharmony_ci (That is, if drivers see this it's a bug.) 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci``-EPROTO`` [#f1]_, [#f2]_ a) bitstuff error 11062306a36Sopenharmony_ci b) no response packet received within the 11162306a36Sopenharmony_ci prescribed bus turn-around time 11262306a36Sopenharmony_ci c) unknown USB error 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci``-EILSEQ`` [#f1]_, [#f2]_ a) CRC mismatch 11562306a36Sopenharmony_ci b) no response packet received within the 11662306a36Sopenharmony_ci prescribed bus turn-around time 11762306a36Sopenharmony_ci c) unknown USB error 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci Note that often the controller hardware does 12062306a36Sopenharmony_ci not distinguish among cases a), b), and c), so 12162306a36Sopenharmony_ci a driver cannot tell whether there was a 12262306a36Sopenharmony_ci protocol error, a failure to respond (often 12362306a36Sopenharmony_ci caused by device disconnect), or some other 12462306a36Sopenharmony_ci fault. 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_ci``-ETIME`` [#f2]_ No response packet received within the 12762306a36Sopenharmony_ci prescribed bus turn-around time. This error 12862306a36Sopenharmony_ci may instead be reported as 12962306a36Sopenharmony_ci ``-EPROTO`` or ``-EILSEQ``. 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_ci``-ETIMEDOUT`` Synchronous USB message functions use this code 13262306a36Sopenharmony_ci to indicate timeout expired before the transfer 13362306a36Sopenharmony_ci completed, and no other error was reported 13462306a36Sopenharmony_ci by HC. 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci``-EPIPE`` [#f2]_ Endpoint stalled. For non-control endpoints, 13762306a36Sopenharmony_ci reset this status with 13862306a36Sopenharmony_ci :c:func:`usb_clear_halt`. 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_ci``-ECOMM`` During an IN transfer, the host controller 14162306a36Sopenharmony_ci received data from an endpoint faster than it 14262306a36Sopenharmony_ci could be written to system memory 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_ci``-ENOSR`` During an OUT transfer, the host controller 14562306a36Sopenharmony_ci could not retrieve data from system memory fast 14662306a36Sopenharmony_ci enough to keep up with the USB data rate 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci``-EOVERFLOW`` [#f1]_ The amount of data returned by the endpoint was 14962306a36Sopenharmony_ci greater than either the max packet size of the 15062306a36Sopenharmony_ci endpoint or the remaining buffer size. 15162306a36Sopenharmony_ci "Babble". 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ci``-EREMOTEIO`` The data read from the endpoint did not fill 15462306a36Sopenharmony_ci the specified buffer, and ``URB_SHORT_NOT_OK`` 15562306a36Sopenharmony_ci was set in ``urb->transfer_flags``. 15662306a36Sopenharmony_ci 15762306a36Sopenharmony_ci``-ENODEV`` Device was removed. Often preceded by a burst 15862306a36Sopenharmony_ci of other errors, since the hub driver doesn't 15962306a36Sopenharmony_ci detect device removal events immediately. 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_ci``-EXDEV`` ISO transfer only partially completed 16262306a36Sopenharmony_ci (only set in ``iso_frame_desc[n].status``, 16362306a36Sopenharmony_ci not ``urb->status``) 16462306a36Sopenharmony_ci 16562306a36Sopenharmony_ci``-EINVAL`` ISO madness, if this happens: Log off and 16662306a36Sopenharmony_ci go home 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_ci``-ECONNRESET`` URB was asynchronously unlinked by 16962306a36Sopenharmony_ci :c:func:`usb_unlink_urb` 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci``-ESHUTDOWN`` The device or host controller has been 17262306a36Sopenharmony_ci disabled due to some problem that could not 17362306a36Sopenharmony_ci be worked around, such as a physical 17462306a36Sopenharmony_ci disconnect. 17562306a36Sopenharmony_ci=============================== =============================================== 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_ci.. [#f1] 17962306a36Sopenharmony_ci 18062306a36Sopenharmony_ci Error codes like ``-EPROTO``, ``-EILSEQ`` and ``-EOVERFLOW`` normally 18162306a36Sopenharmony_ci indicate hardware problems such as bad devices (including firmware) 18262306a36Sopenharmony_ci or cables. 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_ci.. [#f2] 18562306a36Sopenharmony_ci 18662306a36Sopenharmony_ci This is also one of several codes that different kinds of host 18762306a36Sopenharmony_ci controller use to indicate a transfer has failed because of device 18862306a36Sopenharmony_ci disconnect. In the interval before the hub driver starts disconnect 18962306a36Sopenharmony_ci processing, devices may receive such fault reports for every request. 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci 19262306a36Sopenharmony_ci 19362306a36Sopenharmony_ciError codes returned by usbcore-functions 19462306a36Sopenharmony_ci========================================= 19562306a36Sopenharmony_ci 19662306a36Sopenharmony_ci.. note:: expect also other submit and transfer status codes 19762306a36Sopenharmony_ci 19862306a36Sopenharmony_ci:c:func:`usb_register`: 19962306a36Sopenharmony_ci 20062306a36Sopenharmony_ci======================= =================================== 20162306a36Sopenharmony_ci``-EINVAL`` error during registering new driver 20262306a36Sopenharmony_ci======================= =================================== 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_ci``usb_get_*/usb_set_*()``, 20562306a36Sopenharmony_ci:c:func:`usb_control_msg`, 20662306a36Sopenharmony_ci:c:func:`usb_bulk_msg()`: 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci======================= ============================================== 20962306a36Sopenharmony_ci``-ETIMEDOUT`` Timeout expired before the transfer completed. 21062306a36Sopenharmony_ci======================= ============================================== 211