18c2ecf20Sopenharmony_ci.. _usb-error-codes: 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ciUSB Error codes 48c2ecf20Sopenharmony_ci~~~~~~~~~~~~~~~ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci:Revised: 2004-Oct-21 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ciThis is the documentation of (hopefully) all possible error codes (and 98c2ecf20Sopenharmony_citheir interpretation) that can be returned from usbcore. 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ciSome of them are returned by the Host Controller Drivers (HCDs), which 128c2ecf20Sopenharmony_cidevice drivers only see through usbcore. As a rule, all the HCDs should 138c2ecf20Sopenharmony_cibehave the same except for transfer speed dependent behaviors and the 148c2ecf20Sopenharmony_ciway certain faults are reported. 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ciError codes returned by :c:func:`usb_submit_urb` 188c2ecf20Sopenharmony_ci================================================ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ciNon-USB-specific: 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci=============== =============================================== 248c2ecf20Sopenharmony_ci0 URB submission went fine 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci``-ENOMEM`` no memory for allocation of internal structures 278c2ecf20Sopenharmony_ci=============== =============================================== 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ciUSB-specific: 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci======================= ======================================================= 328c2ecf20Sopenharmony_ci``-EBUSY`` The URB is already active. 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci``-ENODEV`` specified USB-device or bus doesn't exist 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci``-ENOENT`` specified interface or endpoint does not exist or 378c2ecf20Sopenharmony_ci is not enabled 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci``-ENXIO`` host controller driver does not support queuing of 408c2ecf20Sopenharmony_ci this type of urb. (treat as a host controller bug.) 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci``-EINVAL`` a) Invalid transfer type specified (or not supported) 438c2ecf20Sopenharmony_ci b) Invalid or unsupported periodic transfer interval 448c2ecf20Sopenharmony_ci c) ISO: attempted to change transfer interval 458c2ecf20Sopenharmony_ci d) ISO: ``number_of_packets`` is < 0 468c2ecf20Sopenharmony_ci e) various other cases 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci``-EXDEV`` ISO: ``URB_ISO_ASAP`` wasn't specified and all the 498c2ecf20Sopenharmony_ci frames the URB would be scheduled in have already 508c2ecf20Sopenharmony_ci expired. 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci``-EFBIG`` Host controller driver can't schedule that many ISO 538c2ecf20Sopenharmony_ci frames. 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci``-EPIPE`` The pipe type specified in the URB doesn't match the 568c2ecf20Sopenharmony_ci endpoint's actual type. 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci``-EMSGSIZE`` (a) endpoint maxpacket size is zero; it is not usable 598c2ecf20Sopenharmony_ci in the current interface altsetting. 608c2ecf20Sopenharmony_ci (b) ISO packet is larger than the endpoint maxpacket. 618c2ecf20Sopenharmony_ci (c) requested data transfer length is invalid: negative 628c2ecf20Sopenharmony_ci or too large for the host controller. 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci``-ENOSPC`` This request would overcommit the usb bandwidth reserved 658c2ecf20Sopenharmony_ci for periodic transfers (interrupt, isochronous). 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci``-ESHUTDOWN`` The device or host controller has been disabled due to 688c2ecf20Sopenharmony_ci some problem that could not be worked around. 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci``-EPERM`` Submission failed because ``urb->reject`` was set. 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci``-EHOSTUNREACH`` URB was rejected because the device is suspended. 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci``-ENOEXEC`` A control URB doesn't contain a Setup packet. 758c2ecf20Sopenharmony_ci======================= ======================================================= 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ciError codes returned by ``in urb->status`` or in ``iso_frame_desc[n].status`` (for ISO) 788c2ecf20Sopenharmony_ci======================================================================================= 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ciUSB device drivers may only test urb status values in completion handlers. 818c2ecf20Sopenharmony_ciThis is because otherwise there would be a race between HCDs updating 828c2ecf20Sopenharmony_cithese values on one CPU, and device drivers testing them on another CPU. 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ciA transfer's actual_length may be positive even when an error has been 858c2ecf20Sopenharmony_cireported. That's because transfers often involve several packets, so that 868c2ecf20Sopenharmony_cione or more packets could finish before an error stops further endpoint I/O. 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ciFor isochronous URBs, the urb status value is non-zero only if the URB is 898c2ecf20Sopenharmony_ciunlinked, the device is removed, the host controller is disabled, or the total 908c2ecf20Sopenharmony_citransferred length is less than the requested length and the 918c2ecf20Sopenharmony_ci``URB_SHORT_NOT_OK`` flag is set. Completion handlers for isochronous URBs 928c2ecf20Sopenharmony_cishould only see ``urb->status`` set to zero, ``-ENOENT``, ``-ECONNRESET``, 938c2ecf20Sopenharmony_ci``-ESHUTDOWN``, or ``-EREMOTEIO``. Individual frame descriptor status fields 948c2ecf20Sopenharmony_cimay report more status codes. 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci=============================== =============================================== 988c2ecf20Sopenharmony_ci0 Transfer completed successfully 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci``-ENOENT`` URB was synchronously unlinked by 1018c2ecf20Sopenharmony_ci :c:func:`usb_unlink_urb` 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci``-EINPROGRESS`` URB still pending, no results yet 1048c2ecf20Sopenharmony_ci (That is, if drivers see this it's a bug.) 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci``-EPROTO`` [#f1]_, [#f2]_ a) bitstuff error 1078c2ecf20Sopenharmony_ci b) no response packet received within the 1088c2ecf20Sopenharmony_ci prescribed bus turn-around time 1098c2ecf20Sopenharmony_ci c) unknown USB error 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci``-EILSEQ`` [#f1]_, [#f2]_ a) CRC mismatch 1128c2ecf20Sopenharmony_ci b) no response packet received within the 1138c2ecf20Sopenharmony_ci prescribed bus turn-around time 1148c2ecf20Sopenharmony_ci c) unknown USB error 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci Note that often the controller hardware does 1178c2ecf20Sopenharmony_ci not distinguish among cases a), b), and c), so 1188c2ecf20Sopenharmony_ci a driver cannot tell whether there was a 1198c2ecf20Sopenharmony_ci protocol error, a failure to respond (often 1208c2ecf20Sopenharmony_ci caused by device disconnect), or some other 1218c2ecf20Sopenharmony_ci fault. 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci``-ETIME`` [#f2]_ No response packet received within the 1248c2ecf20Sopenharmony_ci prescribed bus turn-around time. This error 1258c2ecf20Sopenharmony_ci may instead be reported as 1268c2ecf20Sopenharmony_ci ``-EPROTO`` or ``-EILSEQ``. 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci``-ETIMEDOUT`` Synchronous USB message functions use this code 1298c2ecf20Sopenharmony_ci to indicate timeout expired before the transfer 1308c2ecf20Sopenharmony_ci completed, and no other error was reported 1318c2ecf20Sopenharmony_ci by HC. 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci``-EPIPE`` [#f2]_ Endpoint stalled. For non-control endpoints, 1348c2ecf20Sopenharmony_ci reset this status with 1358c2ecf20Sopenharmony_ci :c:func:`usb_clear_halt`. 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci``-ECOMM`` During an IN transfer, the host controller 1388c2ecf20Sopenharmony_ci received data from an endpoint faster than it 1398c2ecf20Sopenharmony_ci could be written to system memory 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci``-ENOSR`` During an OUT transfer, the host controller 1428c2ecf20Sopenharmony_ci could not retrieve data from system memory fast 1438c2ecf20Sopenharmony_ci enough to keep up with the USB data rate 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci``-EOVERFLOW`` [#f1]_ The amount of data returned by the endpoint was 1468c2ecf20Sopenharmony_ci greater than either the max packet size of the 1478c2ecf20Sopenharmony_ci endpoint or the remaining buffer size. 1488c2ecf20Sopenharmony_ci "Babble". 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci``-EREMOTEIO`` The data read from the endpoint did not fill 1518c2ecf20Sopenharmony_ci the specified buffer, and ``URB_SHORT_NOT_OK`` 1528c2ecf20Sopenharmony_ci was set in ``urb->transfer_flags``. 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci``-ENODEV`` Device was removed. Often preceded by a burst 1558c2ecf20Sopenharmony_ci of other errors, since the hub driver doesn't 1568c2ecf20Sopenharmony_ci detect device removal events immediately. 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci``-EXDEV`` ISO transfer only partially completed 1598c2ecf20Sopenharmony_ci (only set in ``iso_frame_desc[n].status``, 1608c2ecf20Sopenharmony_ci not ``urb->status``) 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci``-EINVAL`` ISO madness, if this happens: Log off and 1638c2ecf20Sopenharmony_ci go home 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci``-ECONNRESET`` URB was asynchronously unlinked by 1668c2ecf20Sopenharmony_ci :c:func:`usb_unlink_urb` 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci``-ESHUTDOWN`` The device or host controller has been 1698c2ecf20Sopenharmony_ci disabled due to some problem that could not 1708c2ecf20Sopenharmony_ci be worked around, such as a physical 1718c2ecf20Sopenharmony_ci disconnect. 1728c2ecf20Sopenharmony_ci=============================== =============================================== 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci.. [#f1] 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci Error codes like ``-EPROTO``, ``-EILSEQ`` and ``-EOVERFLOW`` normally 1788c2ecf20Sopenharmony_ci indicate hardware problems such as bad devices (including firmware) 1798c2ecf20Sopenharmony_ci or cables. 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci.. [#f2] 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci This is also one of several codes that different kinds of host 1848c2ecf20Sopenharmony_ci controller use to indicate a transfer has failed because of device 1858c2ecf20Sopenharmony_ci disconnect. In the interval before the hub driver starts disconnect 1868c2ecf20Sopenharmony_ci processing, devices may receive such fault reports for every request. 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ciError codes returned by usbcore-functions 1918c2ecf20Sopenharmony_ci========================================= 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ci.. note:: expect also other submit and transfer status codes 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci:c:func:`usb_register`: 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci======================= =================================== 1988c2ecf20Sopenharmony_ci``-EINVAL`` error during registering new driver 1998c2ecf20Sopenharmony_ci======================= =================================== 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci``usb_get_*/usb_set_*()``, 2028c2ecf20Sopenharmony_ci:c:func:`usb_control_msg`, 2038c2ecf20Sopenharmony_ci:c:func:`usb_bulk_msg()`: 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci======================= ============================================== 2068c2ecf20Sopenharmony_ci``-ETIMEDOUT`` Timeout expired before the transfer completed. 2078c2ecf20Sopenharmony_ci======================= ============================================== 208