Power & Source of Big Ideas

Nanopi Neo 2 OTG HID STATUS_DEVICE_DATA_ERROR

Moderators: chensy, FATechsupport

I'm using nanopi-neo2_FriendlyCore-Xenial_4.14.0_20171208 kernel.

Code: Select all

uname -a
Linux NanoPi-NEO2 4.14.0 #82 SMP Fri Dec 8 14:33:14 CST 2017 aarch64 aarch64 aarch64 GNU/Linux


OTG mass storage works, the device is visible on a Windows PC and functional.

Then I try to configure an HID gadget:

Code: Select all

modprobe -r g_mass_storage
modprobe libcomposite

mkdir /sys/kernel/config/usb_gadget/mykeyboard
cd /sys/kernel/config/usb_gadget/mykeyboard

# Add basic information
echo 0x0100 > bcdDevice # Version 1.0.0
echo 0x0200 > bcdUSB # USB 2.0
echo 0x00 > bDeviceClass
echo 0x00 > bDeviceProtocol
echo 0x00 > bDeviceSubClass
echo 0x08 > bMaxPacketSize0
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x1d6b > idVendor # Linux Foundation

# Create English locale
mkdir strings/0x409

echo "My manufacturer" > strings/0x409/manufacturer
echo "My virtual keyboard" > strings/0x409/product
echo "0123456789" > strings/0x409/serialnumber

# Create HID function
mkdir functions/hid.usb0

echo 1 > functions/hid.usb0/protocol
echo 8 > functions/hid.usb0/report_length # 8-byte reports
echo 1 > functions/hid.usb0/subclass

# Create configuration
mkdir configs/c.1
mkdir configs/c.1/strings/0x409

echo 0x80 > configs/c.1/bmAttributes
echo 200 > configs/c.1/MaxPower # 200 mA
echo "Example configuration" > configs/c.1/strings/0x409/configuration

# Link HID function to configuration
ln -s functions/hid.usb0 configs/c.1

# Enable gadget
ls /sys/class/udc > UDC


Windows PC recognizes an HID device, but says that the device cannot start (Code 10), STATUS_DEVICE_DATA_ERROR.

USB capture shows no errors, but there are only 12 packets:

Code: Select all

No.     Time           Source                Destination           Protocol Length Info
      1 0.000000       host                  1.4.0                 USB      36     GET DESCRIPTOR Request DEVICE

Frame 1: 36 bytes on wire (288 bits), 36 bytes captured (288 bits) on interface 0
USB URB
    [Source: host]
    [Destination: 1.4.0]
    USBPcap pseudoheader length: 28
    IRP ID: 0xffffc6823d8f5b40
    IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
    URB Function: URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE (0x000b)
    IRP information: 0x00, Direction: FDO -> PDO
    URB bus id: 1
    Device address: 4
    Endpoint: 0x00, Direction: OUT
    URB transfer type: URB_CONTROL (0x02)
    Packet Data Length: 8
    [Response in: 2]
    Control transfer stage: Setup (0)
URB setup
    bmRequestType: 0x80
    bRequest: GET DESCRIPTOR (6)
    Descriptor Index: 0x00
    bDescriptorType: 0x01
    Language Id: no language specified (0x0000)
    wLength: 18

No.     Time           Source                Destination           Protocol Length Info
      2 0.000165       1.4.0                 host                  USB      46     GET DESCRIPTOR Response DEVICE

Frame 2: 46 bytes on wire (368 bits), 46 bytes captured (368 bits) on interface 0
USB URB
    [Source: 1.4.0]
    [Destination: host]
    USBPcap pseudoheader length: 28
    IRP ID: 0xffffc6823d8f5b40
    IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
    URB Function: URB_FUNCTION_CONTROL_TRANSFER (0x0008)
    IRP information: 0x01, Direction: PDO -> FDO
    URB bus id: 1
    Device address: 4
    Endpoint: 0x80, Direction: IN
    URB transfer type: URB_CONTROL (0x02)
    Packet Data Length: 18
    [Request in: 1]
    [Time from request: 0.000165000 seconds]
    Control transfer stage: Data (1)
DEVICE DESCRIPTOR

No.     Time           Source                Destination           Protocol Length Info
      3 0.000184       1.4.0                 host                  USB      28     GET DESCRIPTOR Status

Frame 3: 28 bytes on wire (224 bits), 28 bytes captured (224 bits) on interface 0
USB URB
    [Source: 1.4.0]
    [Destination: host]
    USBPcap pseudoheader length: 28
    IRP ID: 0xffffc6823d8f5b40
    IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
    URB Function: URB_FUNCTION_CONTROL_TRANSFER (0x0008)
    IRP information: 0x01, Direction: PDO -> FDO
    URB bus id: 1
    Device address: 4
    Endpoint: 0x80, Direction: IN
    URB transfer type: URB_CONTROL (0x02)
    Packet Data Length: 0
    [Request in: 1]
    [Time from request: 0.000184000 seconds]
    Control transfer stage: Status (2)

No.     Time           Source                Destination           Protocol Length Info
      4 0.000189       host                  1.4.0                 USB      36     GET DESCRIPTOR Request CONFIGURATION

Frame 4: 36 bytes on wire (288 bits), 36 bytes captured (288 bits) on interface 0
USB URB
    [Source: host]
    [Destination: 1.4.0]
    USBPcap pseudoheader length: 28
    IRP ID: 0xffffc6823da08b40
    IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
    URB Function: URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE (0x000b)
    IRP information: 0x00, Direction: FDO -> PDO
    URB bus id: 1
    Device address: 4
    Endpoint: 0x00, Direction: OUT
    URB transfer type: URB_CONTROL (0x02)
    Packet Data Length: 8
    [Response in: 5]
    Control transfer stage: Setup (0)
URB setup
    bmRequestType: 0x80
    bRequest: GET DESCRIPTOR (6)
    Descriptor Index: 0x00
    bDescriptorType: 0x02
    Language Id: no language specified (0x0000)
    wLength: 9

No.     Time           Source                Destination           Protocol Length Info
      5 0.000319       1.4.0                 host                  USB      37     GET DESCRIPTOR Response CONFIGURATION

Frame 5: 37 bytes on wire (296 bits), 37 bytes captured (296 bits) on interface 0
USB URB
    [Source: 1.4.0]
    [Destination: host]
    USBPcap pseudoheader length: 28
    IRP ID: 0xffffc6823da08b40
    IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
    URB Function: URB_FUNCTION_CONTROL_TRANSFER (0x0008)
    IRP information: 0x01, Direction: PDO -> FDO
    URB bus id: 1
    Device address: 4
    Endpoint: 0x80, Direction: IN
    URB transfer type: URB_CONTROL (0x02)
    Packet Data Length: 9
    [Request in: 4]
    [Time from request: 0.000130000 seconds]
    Control transfer stage: Data (1)
CONFIGURATION DESCRIPTOR

No.     Time           Source                Destination           Protocol Length Info
      6 0.000319       1.4.0                 host                  USB      28     GET DESCRIPTOR Status

Frame 6: 28 bytes on wire (224 bits), 28 bytes captured (224 bits) on interface 0
USB URB
    [Source: 1.4.0]
    [Destination: host]
    USBPcap pseudoheader length: 28
    IRP ID: 0xffffc6823da08b40
    IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
    URB Function: URB_FUNCTION_CONTROL_TRANSFER (0x0008)
    IRP information: 0x01, Direction: PDO -> FDO
    URB bus id: 1
    Device address: 4
    Endpoint: 0x80, Direction: IN
    URB transfer type: URB_CONTROL (0x02)
    Packet Data Length: 0
    [Request in: 4]
    [Time from request: 0.000130000 seconds]
    Control transfer stage: Status (2)

No.     Time           Source                Destination           Protocol Length Info
      7 0.000322       host                  1.4.0                 USB      36     GET DESCRIPTOR Request CONFIGURATION

Frame 7: 36 bytes on wire (288 bits), 36 bytes captured (288 bits) on interface 0
USB URB
    [Source: host]
    [Destination: 1.4.0]
    USBPcap pseudoheader length: 28
    IRP ID: 0xffffc6823da08b40
    IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
    URB Function: URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE (0x000b)
    IRP information: 0x00, Direction: FDO -> PDO
    URB bus id: 1
    Device address: 4
    Endpoint: 0x00, Direction: OUT
    URB transfer type: URB_CONTROL (0x02)
    Packet Data Length: 8
    [Response in: 8]
    Control transfer stage: Setup (0)
URB setup
    bmRequestType: 0x80
    bRequest: GET DESCRIPTOR (6)
    Descriptor Index: 0x00
    bDescriptorType: 0x02
    Language Id: no language specified (0x0000)
    wLength: 44

No.     Time           Source                Destination           Protocol Length Info
      8 0.000450       1.4.0                 host                  USB      72     GET DESCRIPTOR Response CONFIGURATION

Frame 8: 72 bytes on wire (576 bits), 72 bytes captured (576 bits) on interface 0
USB URB
    [Source: 1.4.0]
    [Destination: host]
    USBPcap pseudoheader length: 28
    IRP ID: 0xffffc6823da08b40
    IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
    URB Function: URB_FUNCTION_CONTROL_TRANSFER (0x0008)
    IRP information: 0x01, Direction: PDO -> FDO
    URB bus id: 1
    Device address: 4
    Endpoint: 0x80, Direction: IN
    URB transfer type: URB_CONTROL (0x02)
    Packet Data Length: 44
    [Request in: 7]
    [Time from request: 0.000128000 seconds]
    Control transfer stage: Data (1)
CONFIGURATION DESCRIPTOR
UNKNOWN DESCRIPTOR
INTERFACE DESCRIPTOR (0.0): class HID
HID DESCRIPTOR
ENDPOINT DESCRIPTOR
ENDPOINT DESCRIPTOR

No.     Time           Source                Destination           Protocol Length Info
      9 0.000468       1.4.0                 host                  USB      28     GET DESCRIPTOR Status

Frame 9: 28 bytes on wire (224 bits), 28 bytes captured (224 bits) on interface 0
USB URB
    [Source: 1.4.0]
    [Destination: host]
    USBPcap pseudoheader length: 28
    IRP ID: 0xffffc6823da08b40
    IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
    URB Function: URB_FUNCTION_CONTROL_TRANSFER (0x0008)
    IRP information: 0x01, Direction: PDO -> FDO
    URB bus id: 1
    Device address: 4
    Endpoint: 0x80, Direction: IN
    URB transfer type: URB_CONTROL (0x02)
    Packet Data Length: 0
    [Request in: 7]
    [Time from request: 0.000146000 seconds]
    Control transfer stage: Status (2)

No.     Time           Source                Destination           Protocol Length Info
     10 0.000475       host                  1.4.0                 USB      36     SET CONFIGURATION Request

Frame 10: 36 bytes on wire (288 bits), 36 bytes captured (288 bits) on interface 0
USB URB
    [Source: host]
    [Destination: 1.4.0]
    USBPcap pseudoheader length: 28
    IRP ID: 0xffffc6823d7f2b40
    IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
    URB Function: URB_FUNCTION_SELECT_CONFIGURATION (0x0000)
    IRP information: 0x00, Direction: FDO -> PDO
    URB bus id: 1
    Device address: 4
    Endpoint: 0x80, Direction: IN
    URB transfer type: URB_CONTROL (0x02)
    Packet Data Length: 8
    [Response in: 11]
    Control transfer stage: Setup (0)
URB setup
    bmRequestType: 0x00
    bRequest: SET CONFIGURATION (9)
    bConfigurationValue: 1
    wIndex: 0 (0x0000)
    wLength: 0

No.     Time           Source                Destination           Protocol Length Info
     11 0.001210       1.4.0                 host                  USB      28     SET CONFIGURATION Status

Frame 11: 28 bytes on wire (224 bits), 28 bytes captured (224 bits) on interface 0
USB URB
    [Source: 1.4.0]
    [Destination: host]
    USBPcap pseudoheader length: 28
    IRP ID: 0xffffc6823d7f2b40
    IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
    URB Function: URB_FUNCTION_SELECT_CONFIGURATION (0x0000)
    IRP information: 0x01, Direction: PDO -> FDO
    URB bus id: 1
    Device address: 4
    Endpoint: 0x80, Direction: IN
    URB transfer type: URB_CONTROL (0x02)
    Packet Data Length: 0
    [Request in: 10]
    [Time from request: 0.000735000 seconds]
    Control transfer stage: Status (2)

No.     Time           Source                Destination           Protocol Length Info
     12 0.001228       host                  1.4.0                 USBHID   36     SET_IDLE Request

Frame 12: 36 bytes on wire (288 bits), 36 bytes captured (288 bits) on interface 0
USB URB
    [Source: host]
    [Destination: 1.4.0]
    USBPcap pseudoheader length: 28
    IRP ID: 0xffffc6823d7f2b40
    IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
    URB Function: URB_FUNCTION_CLASS_INTERFACE (0x001b)
    IRP information: 0x00, Direction: FDO -> PDO
    URB bus id: 1
    Device address: 4
    Endpoint: 0x00, Direction: OUT
    URB transfer type: URB_CONTROL (0x02)
    Packet Data Length: 8
    Control transfer stage: Setup (0)
    [bInterfaceClass: HID (0x03)]
URB setup
    bmRequestType: 0x21
bRequest: SET_IDLE (0x0a)
wValue: 0x0000
    ReportID: 0
    Duration: 0
wIndex: 0
wLength: 0


dmesg:

Code: Select all

[  131.288695] configfs-gadget gadget: high-speed config #1: c
 

lsmod:

Code: Select all

Module                  Size  Used by
usb_f_hid              20480  2
libcomposite           45056  10 usb_f_hid
rtl8xxxu              106496  0
snd_soc_simple_card    16384  0
ir_lirc_codec          16384  0
lirc_dev               16384  1 ir_lirc_codec
sunxi_cir              16384  0
snd_soc_simple_card_utils    16384  1 snd_soc_simple_card
rc_core                32768  4 ir_lirc_codec,lirc_dev,sunxi_cir


Any help would be appreciated.
I think you should check in android/xda forums for this question. I know, these xda forums are not nanopi, but you would get more chances to get replies on gadget features in linux kernel. I did such usb stuffs professionally in the past, I think you will have little luck to find proper help :(

Who is online

In total there are 4 users online :: 0 registered, 0 hidden and 4 guests (based on users active over the past 5 minutes)
Most users ever online was 106 on Tue Jun 04, 2019 5:48 pm

Users browsing this forum: No registered users and 4 guests