T3.6 USB Host - New USB Keyboard

Status
Not open for further replies.

jdev

Member
The USB HOST support in Teensyduino 3.6 has been fantastic, testing has gone well with a few MIDI devices and keyboards so far.

I picked up a new USB 48-key Mechanical Keyboard (https://www.amazon.com/Koolertron-Single-Handed-Programmable-Mechanical-Keyboard/dp/B076LRJ528), it's connecting but fails after the first Key Press with ERROR Followup no matter which initial key is pressed.

Teensyduino 3.6 (180 Mhz)/Loader 1.45
Arduino 1.88
USBHost_t36/blob/master/examples/Test/Test.ino

I've enabled USBHOST_PRINT_DEBUG in USBHost_t36.h and captured connecting, keypress and disconnect. I'm hoping the log picks what the problem could be, happy to make any code changes to get this keyboard working.

Code:
USB Host Testing
sizeof Device = 36
sizeof Pipe = 96
sizeof Transfer = 64
power up USBHS PHY
port change: 10001803
    connect
  begin reset
port change: 10001805
  port enabled
  end recovery
new_Device: 12 Mbit/sec
new_Pipe
enumeration:
enumeration:
enumeration:
Device Descriptor:
  12 01 00 02 00 00 00 08 B4 04 18 08 10 60 01 02 03 01 
    VendorID = 04B4, ProductID = 0818, Version = 6010
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: LingYao ShangHai
enumeration:
Product: Thumb Keyboard
enumeration:
Serial Number: 000000000000
enumeration:
Config data length = 59
enumeration:
Configuration Descriptor:
  09 02 3B 00 02 01 00 80 32 
    NumInterfaces = 2
    ConfigurationValue = 1
  09 04 00 00 01 03 01 01 04 
    Interface = 0
    Number of endpoints = 1
    Class/Subclass/Protocol = 3(HID) / 1(Boot) / 1(Keyboard)
  09 21 11 01 21 01 22 3F 00 
    HID, 1 report descriptor
  07 05 81 03 12 00 0A 
    Endpoint = 1 IN
    Type = Interrupt
    Max Size = 18
    Polling Interval = 10
  09 04 01 00 01 03 01 02 05 
    Interface = 1
    Number of endpoints = 1
    Class/Subclass/Protocol = 3(HID) / 1(Boot) / 2(Mouse)
  09 21 11 01 21 01 22 32 00 
    HID, 1 report descriptor
  07 05 82 03 08 00 02 
    Endpoint = 2 IN
    Type = Interrupt
    Max Size = 8
    Polling Interval = 2
enumeration:
USBHub memory usage = 960
USBHub claim_device this=1FFF8700
KeyboardController claim this=1FFFA540
KeyboardController claim this=1FFFA7C0
KeyboardController claim this=1FFFAA40
Descriptor 4 = INTERFACE
KeyboardController claim this=1FFFA540
ep = 81
packet size = 18
polling interval = 10
new_Pipe
allocate_interrupt_pipe_bandwidth
 best_bandwidth = 3, at offset = 0, shift= 0
Descriptor 33 = HID
Descriptor 5 = ENDPOINT
Descriptor 4 = INTERFACE
KeyboardController claim this=1FFFA7C0
KeyboardController claim this=1FFFAA40
MIDIDevice claim this=1FFF94C0
len = 25
Descriptor 33 = HID
Descriptor 5 = ENDPOINT
control callback (keyboard)
  mesg = B21

KeyboardController Callback (member)
  KB Data: 00 00 00 5C 00 00 00 00 
  press, key=92
  unicode = 216
key '⸮'  216
key ⸮  
ERROR Followup

port change: 1C00100A
    disconnect
disconnect_Device:
USBDriver (available_drivers) list: 1FFF8700 -> 1FFFA7C0 -> 1FFFAA40 -> 1FFF94C0
USBDriver (dev->drivers) list: 1FFFA540
disconnect driver 1FFFA540
USBDriver (available_drivers) list: 1FFFA540 -> 1FFF8700 -> 1FFFA7C0 -> 1FFFAA40 -> 1FFF94C0
delete_Pipe 1FFF9920
  Free transfers
    * 536855680 * remove * defer free until QH
  Free transfers attached to QH
    * 536855680
    * 536844992
* Delete Pipe completed
delete_Pipe 1FFFC400
  shut down async schedule
  Free transfers
  Free transfers attached to QH
    * 536855744
* Delete Pipe completed
removed Device_t from devlist
  disable
 
My Gut tells me, this one might be problematic and maybe requires someone who has it to debug it...

When you look at the product page, it shows that it requires Windows 7, 8, 10. And if you are going to try to use it with Linux or MAC, you first must configure it with a Windows machine...

Also wondering how the code is handling the mapping of raw input to unicode...
 
Ok thanks, I tried the T3-6-USB-Host-Bluetooth fork with similar results. I did however enable a bit more debugging, seems to exit at stat & USBHS_USBSTS_UEI error check in ehci.cpp. I'm a bit new to HID programming, so it's unclear what next steps might be.

The programmer that comes with the SMKD72-A 48-Key runs on Windows and allows customization and persistent writing to the MCU. I've loaded a Default config, and it runs on my Mac as well as Windows without issues. I think the idea is the USB keyboard is intended (and should work) with any USB Host but the programmer is available on Windows.

The manufacturer provides a helpful public link to manuals, HID guide, and software in a RAR file here: https://amazonfiles.s3.amazonaws.com/smkd72.rar

There is quite a bit to configuration beyond key assignments, like Key Rate (1-100ms), Mouse Rate (2-100ms), etc. I've been experimenting with bouncing between Default and custom configurations to see if it helps get USB Keyboard working.

Code:
ISR: 408C
 Port Change
port change: 10001803
    connect

ISR: 1004088
 Timer0
  begin reset

ISR: 408C
 Port Change
port change: 10001805
  port enabled

ISR: 1004080
 Timer0
  end recovery
new_Device: 12 Mbit/sec
new_Pipe

ISR: 4E081
 USB Async
Async Followup
Transfer Followup List 1FFF2620 to 1FFF44C0
    forward:
    1FFF2620 SETUP
    1FFF4480 IN 0
    1FFF44C0 OUT 0
    backward:
    1FFF44C0 OUT 0
    1FFF4480 IN 0
    1FFF2620 SETUP
enumeration:

ISR: 4E081
 USB Async
Async Followup
Transfer Followup List 1FFF4540 to 1FFF2620
    forward:
    1FFF4540 SETUP
    1FFF2620 IN 0
    backward:
    1FFF2620 IN 0
    1FFF4540 SETUP
enumeration:

ISR: 4E081
 USB Async
Async Followup
Transfer Followup List 1FFF4480 to 1FFF44C0
    forward:
    1FFF4480 SETUP
    1FFF2660 IN 0
    1FFF44C0 OUT 0
    backward:
    1FFF44C0 OUT 0
    1FFF2660 IN 0
    1FFF4480 SETUP
enumeration:
Device Descriptor:
  12 01 00 02 00 00 00 08 B4 04 18 08 10 60 01 02 03 01 
    VendorID = 04B4, ProductID = 0818, Version = 6010
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 1

ISR: 4E081
 USB Async
Async Followup
Transfer Followup List 1FFF4540 to 1FFF4480
    forward:
    1FFF4540 SETUP
    1FFF2620 IN 504
    1FFF4480 OUT 0
    backward:
    1FFF4480 OUT 0
    1FFF2620 IN 504
    1FFF4540 SETUP
enumeration:

ISR: 4E081
 USB Async
Async Followup
Transfer Followup List 1FFF2660 to 1FFF4540
    forward:
    1FFF2660 SETUP
    1FFF44C0 IN 474
    1FFF4540 OUT 0
    backward:
    1FFF4540 OUT 0
    1FFF44C0 IN 474
    1FFF2660 SETUP
enumeration:
Manufacturer: LingYao ShangHai

ISR: 4E081
 USB Async
Async Followup
Transfer Followup List 1FFF2620 to 1FFF2660
    forward:
    1FFF2620 SETUP
    1FFF4480 IN 478
    1FFF2660 OUT 0
    backward:
    1FFF2660 OUT 0
    1FFF4480 IN 478
    1FFF2620 SETUP
enumeration:
Product: Thumb Keyboard

ISR: 4E081
 USB Async
Async Followup
Transfer Followup List 1FFF44C0 to 1FFF2620
    forward:
    1FFF44C0 SETUP
    1FFF4540 IN 482
    1FFF2620 OUT 0
    backward:
    1FFF2620 OUT 0
    1FFF4540 IN 482
    1FFF44C0 SETUP
enumeration:
Serial Number: 081820131130

ISR: 4E081
 USB Async
Async Followup
Transfer Followup List 1FFF4480 to 1FFF44C0
    forward:
    1FFF4480 SETUP
    1FFF2660 IN 0
    1FFF44C0 OUT 0
    backward:
    1FFF44C0 OUT 0
    1FFF2660 IN 0
    1FFF4480 SETUP
enumeration:
Config data length = 59

ISR: 4E081
 USB Async
Async Followup
Transfer Followup List 1FFF4540 to 1FFF4480
    forward:
    1FFF4540 SETUP
    1FFF2620 IN 0
    1FFF4480 OUT 0
    backward:
    1FFF4480 OUT 0
    1FFF2620 IN 0
    1FFF4540 SETUP
enumeration:
Configuration Descriptor:
  09 02 3B 00 02 01 00 80 32 
    NumInterfaces = 2
    ConfigurationValue = 1
  09 04 00 00 01 03 01 01 04 
    Interface = 0
    Number of endpoints = 1
    Class/Subclass/Protocol = 3(HID) / 1(Boot) / 1(Keyboard)
  09 21 11 01 21 01 22 3F 00 
    HID, 1 report descriptor
  07 05 81 03 12 00 0A 
    Endpoint = 1 IN
    Type = Interrupt
    Max Size = 18
    Polling Interval = 10
  09 04 01 00 01 03 01 02 05 
    Interface = 1
    Number of endpoints = 1
    Class/Subclass/Protocol = 3(HID) / 1(Boot) / 2(Mouse)
  09 21 11 01 21 01 22 32 00 
    HID, 1 report descriptor
  07 05 82 03 08 00 02 
    Endpoint = 2 IN
    Type = Interrupt
    Max Size = 8
    Polling Interval = 2

ISR: 4E081
 USB Async
Async Followup
Transfer Followup List 1FFF2660 to 1FFF4540
    forward:
    1FFF2660 SETUP
    1FFF4540 IN 0
    backward:
    1FFF4540 IN 0
    1FFF2660 SETUP
enumeration:
KeyboardController claim this=1FFF26E0
USBHub memory usage = 960
USBHub claim_device this=1FFF2960
USBHub memory usage = 960
USBHub claim_device this=1FFF2D20
USBHub memory usage = 960
USBHub claim_device this=1FFF30E0
Descriptor 4 = INTERFACE
KeyboardController claim this=1FFF26E0
09 04 00 00 01 03 01 01 04 09 21 11 01 21 01 22 3F 00 07 05 81 03 12 00 0A 09 04 01 00 01 03 01 02 05 09 21 11 01 21 01 22 32 00 07 05 82 03 08 00 02 
ep = 81
packet size = 18
polling interval = 10
new_Pipe
allocate_interrupt_pipe_bandwidth
 best_bandwidth = 3, at offset = 0, shift= 0
Descriptor 33 = HID
Descriptor 5 = ENDPOINT
Descriptor 4 = INTERFACE
MIDIDevice claim this=1FFF2020
len = 25
Descriptor 33 = HID
Descriptor 5 = ENDPOINT
control callback (keyboard)
  mesg = A21

ISR: 4E081
 USB Async
Async Followup
Transfer Followup List 0 to 0
    forward:
    backward:

ISR: 8E08B
 USB Error
 USB Periodic
Periodic Followup
KeyboardController Callback (member)
  KB Data: 00 00 00 16 00 00 00 00 
  release, key=20
  press, key=22
  unicode = 115
key 's'  115
stat & USBHS_USBSTS_UEI
ERROR Followup
ERROR Followup End
 
A follow-up, also tried the SMKD72-A keyboard with Raspberry Pi 3 B+ without issue (as above, also works on macos and Win10).

Any tips for USB debugging & T3-6-USB-Host-Bluetooth?
 
Forgot to add the raspberrypi lsusb output, which appears to treat the device as a USB keyboard HID and a mouse HID:

Code:
pi@raspberrypi:~ $ lsusb -v -d  04b4:0818

Bus 001 Device 005: ID 04b4:0818 Cypress Semiconductor Corp.
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x04b4 Cypress Semiconductor Corp.
  idProduct          0x0818
  bcdDevice           60.10
  iManufacturer           1
  iProduct                2
  iSerial                 3
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           59
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      1 Keyboard
      iInterface              4
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode           33 US
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      63
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0012  1x 18 bytes
        bInterval              10
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      2 Mouse
      iInterface              5
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode           33 US
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      50
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               2
pi@raspberrypi:~ $
 
Probably without one of these, the next thing I would try, is to see if it trying to force keyboard to use boot mode would help.

I did not look at your data close enough, but look in keyboard.cpp there is a force boot table with one entry. Try adding your vid and see if it makes a difference
 
Status
Not open for further replies.
Back
Top