Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't work USB_Test program #20

Open
yamachan-hacomono opened this issue Jul 5, 2022 · 10 comments
Open

Don't work USB_Test program #20

yamachan-hacomono opened this issue Jul 5, 2022 · 10 comments

Comments

@yamachan-hacomono
Copy link

Hello,

We're testing with a keyboard connected to the ESP32-DevKit C-32E.
But when I type on the keyboard, I don't see the keys.
GPIO has DP connected to 16 and DM connected to 17, with the other pins disabled.
Do you have any advice?

[Env]
ESP32-DevKit C-32E
Arduino IDE 1.8.19 for windows

[Log]

ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1184
load:0x40078000,len:12812
load:0x40080400,len:3032
entry 0x400805e4
USB Soft Host Test for Default Wroom
USB#0 (pins 16 17) is OK!
READ_BOTH_PINS = 0100
READ_BOTH_PINS = 0000
READ_BOTH_PINS = 0000
READ_BOTH_PINS = 0000
cpu freq = 160 MHz
TIME_MULT = 77 
D=   0 4800 bits in 1885.000000 uSec 2.546419 MHz  6 ticks in 2.356250 uS
D= 127 4800 bits in 5720.000000 uSec 0.839161 MHz  6 ticks in 7.150000 uS
D=  63 4800 bits in 3775.000000 uSec 1.271523 MHz  6 ticks in 4.718750 uS
D=  31 4800 bits in 2802.000000 uSec 1.713062 MHz  6 ticks in 3.502500 uS
D=  47 4800 bits in 3294.000000 uSec 1.457195 MHz  6 ticks in 4.117500 uS
D=  39 4800 bits in 3042.000000 uSec 1.577909 MHz  6 ticks in 3.802500 uS
D=  43 4800 bits in 3174.000000 uSec 1.512287 MHz  6 ticks in 3.967500 uS
D=  45 4800 bits in 3223.000000 uSec 1.489296 MHz  6 ticks in 4.028750 uS
D=  44 4800 bits in 3204.000000 uSec 1.498127 MHz  6 ticks in 4.005000 uS
D=  43 4800 bits in 3168.000000 uSec 1.515152 MHz  6 ticks in 3.960000 uS
TRANSMIT_TIME_DELAY = 46 time = 4.005000 error = 0.125003% 
USB#1 is disabled by user configuration
USB#2 is disabled by user configuration
USB#3 is disabled by user configuration

Thanks.

@tobozo
Copy link
Owner

tobozo commented Jul 13, 2022

Hello @yamachan-hacomono,

thanks for your feedback 👍

Can you please specify the exact keyboard model along with more info on the VCC/GND wiring for this USB port?

⚠️ The keyboard has to be USB Low Speed otherwise it won't be detected by this library, which eliminates most wireless dongles and keyboards/mice for gamers.

@yamachan-hacomono
Copy link
Author

@tobozo
thank you for your reply!

VCC / GND is obtained from a regulated power supply and has a sufficient supply amount.
The connected device is a general USB keyboard. Maybe it's doing fast processing and you don't recognize it. The keyboard is Realforce 91UBK-S.

@tobozo
Copy link
Owner

tobozo commented Jul 15, 2022

VCC / GND is obtained from a regulated power supply

is GND shared between the ESP and the keyboard as it should?

Realforce 91UBK-S. Price | $200+

that's bad news, given the average price of that device it's probably a USB High Speed device.

one way to verify this is to plug said keyboard to a linux system while running tail -f /var/log/syslog and look for the device detection message: if it doesn't mention low-speed USB device then it's not compatible.

image

@danieltwagner
Copy link

danieltwagner commented Oct 15, 2024

Apologies for reviving an old thread but I have the same issue; I'm building against espressif32@5.2.0 as that's the last version using arudino framework v2.0.5 which is in turn based on the tested ESP-IDF 4.4.2.
I'm seeing no callbacks (read: serial output) when connecting or disconnecting a low-speed USB keyboard or typing on that keyboard. The keyboard is a Cherry Stream, and I confirmed syslog shows low-speed.

I tried various GPIO port combinations to no avail. Full serial output below:

TIMER_BASE_CLK: 80000000, TIMER_DIVIDER:2, TIMER_SCALE: 40000000
Attaching onDetectCB
Attaching onDataCB
Attaching onUSBMessageDecode
Attaching onTickCB
Creating message queue
Setting USB Delay
Setting up pins
USB#0 (pins 16 17) is OK!
READ_BOTH_PINS = 0000
READ_BOTH_PINS = 0000
READ_BOTH_PINS = 0000
READ_BOTH_PINS = 0000
cpu freq = 240 MHz
TIME_MULT = 51 
D=   0 4800 bits in 1290.000000 uSec 3.720930 MHz  6 ticks in 1.612500 uS
D= 127 4800 bits in 3806.000000 uSec 1.261167 MHz  6 ticks in 4.757500 uS
D=  63 4800 bits in 2512.000000 uSec 1.910828 MHz  6 ticks in 3.140000 uS
D=  95 4800 bits in 3159.000000 uSec 1.519468 MHz  6 ticks in 3.948750 uS
D= 111 4800 bits in 3480.000000 uSec 1.379310 MHz  6 ticks in 4.350000 uS
D= 103 4800 bits in 3327.000000 uSec 1.442741 MHz  6 ticks in 4.158750 uS
D=  99 4800 bits in 3239.000000 uSec 1.481939 MHz  6 ticks in 4.048750 uS
D=  97 4800 bits in 3199.000000 uSec 1.500469 MHz  6 ticks in 3.998750 uS
D=  98 4800 bits in 3219.000000 uSec 1.491146 MHz  6 ticks in 4.023750 uS
D=  97 4800 bits in 3208.000000 uSec 1.496259 MHz  6 ticks in 4.010000 uS
TRANSMIT_TIME_DELAY = 99 time = 3.998750 error = -0.031251% 
USB#1 is disabled by user configuration
USB#2 is disabled by user configuration
USB#3 is disabled by user configuration
Seleting SCL (blink) Pin #22
Creating timer config
Init timer
Enable interrupt
Register ISR
Start timer
Attaching Timer Task
USB Soft Host Group timer task is now running on core #1 with priority 5```

@tobozo
Copy link
Owner

tobozo commented Oct 15, 2024

@danieltwagner looks like the keyboard isn't detected

what keyboard model is this? usb information on that device can be collected from a computer using lsusb or similar utility, it will tell if that device supports USB 1.0 or not.

moreover, you can use build_flags = -DCORE_DEBUG_LEVEL=5 in platformio.ini to get more information in the serial console, it should print some information when the keyboard is plugged/unplugged

@danieltwagner
Copy link

Thank you for the quick response! Here's what lsusb says:

$ sudo lsusb -d 046a:c099 -v
Bus 009 Device 023: ID 046a:c099 CHERRY Stream Keyboard TKL
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 [unknown]
  bDeviceSubClass         0 [unknown]
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x046a CHERRY
  idProduct          0xc099 Stream Keyboard TKL
  bcdDevice            4.10
  iManufacturer           1 Cherry GmbH
  iProduct                2 CHERRY Corded Device
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x003b
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    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              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      65
          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     0x0008  1x 8 bytes
        bInterval              10
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 [unknown]
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      64
          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     0x0005  1x 5 bytes
        bInterval              10
Device Status:     0x0000
  (Bus Powered)

Full serial output with -DCORE_DEBUG_LEVEL=5:

USB Soft Host Test for Default Wroom
TIMER_BASE_CLK: 80000000, TIMER_DIVIDER:2, TIMER_SCALE: 40000000
Attaching onDetectCB
Attaching onDataCB
Attaching onUSBMessageDecode
Attaching onTickCB
Creating message queue
Setting USB Delay
Setting delay to 4 ticks
Free iram before alloc: 195868
Malloc MAX_DELAY_CODE_SIZE=640
Making xtensa Opcodes for ESP32/ESP32S2
moving opecodes to executable memory segment
Free iram after alloc and before realloc: 195868
Free iram after realloc to cap_exec: 195212
Setting up pins
USB#0 (pins 16 17) is OK!
READ_BOTH_PINS = 0000
READ_BOTH_PINS = 0000
READ_BOTH_PINS = 0000
READ_BOTH_PINS = 0000
cpu freq = 240 MHz
TIME_MULT = 51 
D=   0 Setting delay to 0 ticks
Free iram before alloc: 195212
Realloc MAX_DELAY_CODE_SIZE=640
Making xtensa Opcodes for ESP32/ESP32S2
moving opecodes to executable memory segment
Free iram after alloc and before realloc: 195868
Free iram after realloc to cap_exec: 195212
4800 bits in 1285.000000 uSec 3.735409 MHz  6 ticks in 1.606250 uS
D= 127 Setting delay to 127 ticks
Free iram before alloc: 195212
Realloc MAX_DELAY_CODE_SIZE=640
Making xtensa Opcodes for ESP32/ESP32S2
moving opecodes to executable memory segment
Free iram after alloc and before realloc: 195868
Free iram after realloc to cap_exec: 195212
4800 bits in 3819.000000 uSec 1.256873 MHz  6 ticks in 4.773750 uS
D=  63 Setting delay to 63 ticks
Free iram before alloc: 195212
Realloc MAX_DELAY_CODE_SIZE=640
Making xtensa Opcodes for ESP32/ESP32S2
moving opecodes to executable memory segment
Free iram after alloc and before realloc: 195868
Free iram after realloc to cap_exec: 195212
4800 bits in 2529.000000 uSec 1.897983 MHz  6 ticks in 3.161250 uS
D=  95 Setting delay to 95 ticks
Free iram before alloc: 195212
Realloc MAX_DELAY_CODE_SIZE=640
Making xtensa Opcodes for ESP32/ESP32S2
moving opecodes to executable memory segment
Free iram after alloc and before realloc: 195868
Free iram after realloc to cap_exec: 195212
4800 bits in 3178.000000 uSec 1.510384 MHz  6 ticks in 3.972500 uS
D= 111 Setting delay to 111 ticks
Free iram before alloc: 195212
Realloc MAX_DELAY_CODE_SIZE=640
Making xtensa Opcodes for ESP32/ESP32S2
moving opecodes to executable memory segment
Free iram after alloc and before realloc: 195868
Free iram after realloc to cap_exec: 195212
4800 bits in 3491.000000 uSec 1.374964 MHz  6 ticks in 4.363750 uS
D= 103 Setting delay to 103 ticks
Free iram before alloc: 195212
Realloc MAX_DELAY_CODE_SIZE=640
Making xtensa Opcodes for ESP32/ESP32S2
moving opecodes to executable memory segment
Free iram after alloc and before realloc: 195868
Free iram after realloc to cap_exec: 195212
4800 bits in 3337.000000 uSec 1.438418 MHz  6 ticks in 4.171250 uS
D=  99 Setting delay to 99 ticks
Free iram before alloc: 195212
Realloc MAX_DELAY_CODE_SIZE=640
Making xtensa Opcodes for ESP32/ESP32S2
moving opecodes to executable memory segment
Free iram after alloc and before realloc: 195868
Free iram after realloc to cap_exec: 195212
4800 bits in 3251.000000 uSec 1.476469 MHz  6 ticks in 4.063750 uS
D=  97 Setting delay to 97 ticks
Free iram before alloc: 195212
Realloc MAX_DELAY_CODE_SIZE=640
Making xtensa Opcodes for ESP32/ESP32S2
moving opecodes to executable memory segment
Free iram after alloc and before realloc: 195868
Free iram after realloc to cap_exec: 195212
4800 bits in 3211.000000 uSec 1.494861 MHz  6 ticks in 4.013750 uS
D=  96 Setting delay to 96 ticks
Free iram before alloc: 195212
Realloc MAX_DELAY_CODE_SIZE=640
Making xtensa Opcodes for ESP32/ESP32S2
moving opecodes to executable memory segment
Free iram after alloc and before realloc: 195868
Free iram after realloc to cap_exec: 195212
4800 bits in 3190.000000 uSec 1.504702 MHz  6 ticks in 3.987500 uS
D=  96 Setting delay to 96 ticks
Free iram before alloc: 195212
Realloc MAX_DELAY_CODE_SIZE=640
Making xtensa Opcodes for ESP32/ESP32S2
moving opecodes to executable memory segment
Free iram after alloc and before realloc: 195868
Free iram after realloc to cap_exec: 195212
4800 bits in 3198.000000 uSec 1.500938 MHz  6 ticks in 3.997500 uS
Setting delay to 98 ticks
Free iram before alloc: 195212
Realloc MAX_DELAY_CODE_SIZE=640
Making xtensa Opcodes for ESP32/ESP32S2
moving opecodes to executable memory segment
Free iram after alloc and before realloc: 195868
Free iram after realloc to cap_exec: 195212
TRANSMIT_TIME_DELAY = 98 time = 3.997500 error = -0.062501% 
USB#1 is disabled by user configuration
USB#2 is disabled by user configuration
USB#3 is disabled by user configuration
Seleting SCL (blink) Pin #22
Creating timer config
Init timer
Enable interrupt
Register ISR
Start timer
Attaching Timer Task
USB Soft Host Group timer task is now running on core #1 with priority 5
USB0: Ack = 0 Nack = 0 00 pcurrent->cb_Cmd = 0  state = 0 epCount = 0 --0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 

[connect keyboard]

USB0: Ack = 54 Nack = 1 02 pcurrent->cb_Cmd = 2  state = 2 epCount = 0 --000d 0001 005a 00ff 0080 0000 0040 0000 0000 0000 0010 00ea 00e7 00ff 0000 0000 0000 0000 0000 0000 
USB0: Ack = 109 Nack = 2 02 pcurrent->cb_Cmd = 2  state = 2 epCount = 0 --000d 0001 005a 00ff 0080 0000 0040 0000 0000 0000 0010 00ea 00e7 00ff 0000 0000 0000 0000 0000 0000 
USB0: Ack = 163 Nack = 4 02 pcurrent->cb_Cmd = 2  state = 3 epCount = 0 --000d 0001 005a 00ff 0080 0000 0040 0000 0000 0000 0010 00ea 00e7 00ff 0000 0000 0000 0000 0000 0000 

[disconnect keyboard]

USB0: Ack = 211 Nack = 10 00 pcurrent->cb_Cmd = 0  state = 0 epCount = 0 --0002 00ff 00ff 00ff 0080 0000 0040 0000 0000 0000 0010 00ea 00e7 00ff 0000 0000 0000 0000 0000 0000 
USB0: Ack = 211 Nack = 10 00 pcurrent->cb_Cmd = 0  state = 0 epCount = 0 --0002 00ff 00ff 00ff 0080 0000 0040 0000 0000 0000 0010 00ea 00e7 00ff 0000 0000 0000 0000 0000 0000
[...]

@danieltwagner
Copy link

And:

$ lsusb -t | grep "Dev 023"
        |__ Port 002: Dev 023, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
        |__ Port 002: Dev 023, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M

which is in line with the syslog low-speed message

@tobozo
Copy link
Owner

tobozo commented Oct 15, 2024

thanks for that information, it looks like an USB 2.0 device, only USB-LS (1.0) devices are supported

bcdUSB               2.00

USB-LS HID devices are typically vintage stuff from the 90's, anything newer than that has probably moved away from USB 1.0 and isn't supported

@danieltwagner
Copy link

danieltwagner commented Oct 15, 2024

Oh I see. I take it the "low-speed USB device" message in syslog was misleading then and even though it's using a slow (1.5mbit) transfer mode it's actually USB 2.0?

2024-10-15T16:42:58.645528+01:00 n5105 kernel: usb 9-1.2: new low-speed USB device number 26 using xhci_hcd
2024-10-15T16:42:58.785499+01:00 n5105 kernel: usb 9-1.2: New USB device found, idVendor=046a, idProduct=c099, bcdDevice= 4.10
2024-10-15T16:42:58.785511+01:00 n5105 kernel: usb 9-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
2024-10-15T16:42:58.785512+01:00 n5105 kernel: usb 9-1.2: Product: CHERRY Corded Device
2024-10-15T16:42:58.785513+01:00 n5105 kernel: usb 9-1.2: Manufacturer: Cherry GmbH

@tobozo
Copy link
Owner

tobozo commented Oct 15, 2024

indeed it is misleading

https://askubuntu.com/a/395754

this kind of cheap keyboard is quite recent and should work, I used one to develop this library

image

they're called "mini keyboard" and are made in China

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants