USB initialisation settings and stalls

USB connected devices can report a stall condition to the host. Typically this means an error has occurred; the nature of, and the recovery from, these errors varies by device. Some devices never report stalls, some report stalls that can be ignored, and some need re-enumerating (re-initialising) after a stall.

This document describes the USB requests UPDD sends when it initialises a touch device, the settings that disable them for devices that stall, and how stalls while reading touch data are handled. It applies to UPDD V7, with the UPDD V6 behaviour kept as dated history.

When driver debugging is enabled or UPDD diagnostics is run, the debug log records the USB activity, and a stall is likely to be reported in it.

USB requests during initialisation

We have found that some USB controllers stall when the driver sends them certain USB requests. A stall at this point can lock up the USB interface used by the driver. The USB initialisation requests UPDD issues are as follows:

RequestDescription
Set alternate interfaceA feature we have never seen used for a touch screen, but we have seen devices where not explicitly setting alternate 0 caused a failure. In UPDD V6 the driver set alternate 0 on all the interfaces it uses unless this was disabled. In V7 on macOS the request is only sent when disable_set_alt0 is explicitly set to 0.
Get max contactsIssued to determine the number of supported contacts if the HID Report Descriptor indicates a multi-touch device.
Set device modeIssued to set multi-touch mode if the HID Report Descriptor indicates a multi-touch device.

We have seen Set Device Mode stall a TPK, a Fusion 4 and one other 'unknown' device. It is often the case that the device defaults to multi-touch mode and does not need, or is not expecting, the set device mode request.

Symptoms

When a device stalls on one of these requests the symptoms are:

  1. The UPDD Console shows 'No driver connection'.
    If the set alternate interface request is the cause, the debug log shows:
    2019/07/08-14:48:00: ERR: USB error: (setting alt=0) Other error
    2019/07/08-14:48:00: ERR: Skipping this interface
  2. The boot log has 'Issuing set device mode' as its last entry.

Disabling USB requests

If these requests are found to have a negative effect on the device, set the corresponding disable setting with the command line interface setall command. The settings are disable_set_alt0, disable_get_max_contacts and disable_set_device_mode respectively, and are set to 1 to disable the request:

upddutils setall disable_set_alt0 1
upddutils setall disable_set_device_mode 1
upddutils setall disable_get_max_contacts 1

The combination we found best for Sharp devices is listed in Known hardware issues.

Stalls while reading touch data

A stall while the driver reads touch data can result in UPDD disconnect notifications being issued (if notifications are enabled) or in occasional loss of touch. Enable debug logging and look at the log at the time of the error, or run diagnostics, which also creates a debug log.

In UPDD V7 on macOS, when a read fails because the endpoint stalled, the driver clears the stall and carries on reading. Any other read error closes the device and a disconnect notification is issued; the device is connected again when the system next reports it. If disconnections repeat, see USB connection problems.

Stall handling in UPDD 6

UPDD 6 used the libusb library for USB access, and a stall was identified with a message like those below:

2019/09/27-20:52:22: ***: USB: (LIBUSB_TRANSFER_ERROR)
2019/09/27-20:52:22: ***: USB: (LIBUSB_TRANSFER_ERROR closing device)
or
2019/09/27-20:52:29: ***: USB: (LIBUSB_TRANSFER_STALL)
2019/09/27-20:52:29: ***: USB: (LIBUSB_TRANSFER_STALL closing device)

The driver's stall behaviour was defined by the bootstrap setting usb.handle_stall, set with the setall command followed by a driver restart. Its values were:

ValueBehaviour
0The device is closed and the re-enumeration process invoked immediately.
1The driver issues a USB 'clear halt' and retries. This was assumed when no value was set, although some builds set 0.
2From build 516: the error is ignored and the next read issued as though no error occurred. In drivers built after February 2021 this value also disabled the stall handling of the Windows winusb.sys driver.
3From build 516: as 0, but no disconnect or connect notifications are issued.

Under Windows, the USB library enabled the stall recovery function of winusb.sys for all devices, and some devices have an issue with stall recovery that stops them working or affects performance, such as 0x14E1 0x5000 and 0x1204 0x9998 (Salt / AMT), 0x102E 0x0003 (Binstead / VP foil) and 0x04E7 0x0050 (ELO 2218). The best value had to be determined by experiment, and in the worst case a lockup caused by changing it needed the software to be reinstalled.

The setting does not exist in UPDD V7.

Delta mode devices

Controllers that operate in what we refer to as 'delta mode' do not transmit co-ordinates while the touch is held steady in the same position: they send a packet when touched, further packets while the stylus moves, and a final packet when it is lifted. When no data arrives during a steady touch, the driver generates a 'pen up' after the device's lift-off time (setting liftoff_time_ms, by default 500 ms).

For delta mode devices we recommend that the lift-off time is disabled, so that only a real lift-off generates a pen up. This is the device's Lift off time setting in the UPDD Console; see also Touch data filtering. Delta mode devices without this setting find it difficult to calibrate, as a calibration point is only accepted for a touch lasting more than 750 ms: either disable liftoff_time_ms or set it above 750.

Known controllers that operate in this mode are the Elo Touchsystems SmartSet 2216 (USB) and the Chengying IR touch controller (USB, Zaagtech) when it is in single touch mode.

For review

  • usb.handle_stall is not in 7.1 (review E8): the section is kept as dated UPDD 6 history, as the outline asks. The V6 setting screenshot (USBStallSetting.png) and the 'It is hoped that in some future release…' sentence are dropped.
  • The V7 macOS read-error handling is written from updd/macos/macusbreader.cpp:900-990: a stalled read is cleared by default; the controller setting usb.mac.read_error_actions (clear_stall, reset_pipe, reenumerate_code, ignore_code) changes this but has no description in the settings data. Decide whether to document it. The Windows and Linux V7 behaviour was not checked.
  • V7 macOS sends set alternate 0 only when disable_set_alt0 is set to 0 (macusbreader.cpp:1445-1448); the Windows USB reader does not read disable_set_alt0 at all (updd/win32/upddusbreader.cpp reads only the other two, lines 404 and 434). disable_get_max_contacts and disable_set_device_mode are also read by the macOS HID reader (updd/macos/machidreader.cpp:1022, 1096).