Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 44

Thread: USBHost_t36 with Circuitpython serial device Keybow2040

  1. #1

    USBHost_t36 with Circuitpython serial device Keybow2040

    I have been using the USBHost_t36 library with Teensy 3.6 and more recently 4.1. This has been with HID and serial devices with good success.
    I want to connect a Pimoroni Kewbow2040 (https://shop.pimoroni.com/products/k...32399559589971) to my setup.
    There is currently only a Circuitpython library for the Keybow so I am trying to connect the Keybow to the Teensy4.1 host (via a USB hub) and communicate via CDC serial.

    I have disabled all other USB devices that the Keybow (running Circuitpython) would present(HID, Mass storage, REPL etc) in the boot.py files leaving only a serial data (CDC) device.

    When I plug the Keybow2040 in to the Teensy host the Teensy becomes unresponsive and has to be power cycled.

    To try to debug this I have loaded HIDDeviceInfo with debug enabled onto the Teensy host.
    I have discovered that if the Teensy is powered with the Keybow2040 already plugged in then it remains responsive.
    The Teensy remains responsive if the Keybow 2040 is then disconnected.
    If however the Keybow is re-connected or plugged in after the Teensy is powered then the Teensy becomes unresponsive.

    I would be very grateful for any help in getting this running reliably.
    Thanks
    Files Below.

    Keybow2040 running Circuitpython 7.2.2(latest)
    Code:
    Boot.py
    import usb_cdc
    
    usb_cdc.enable(console=False, data=True)    # Disable Repl enable serial data
    
    import storage
    storage.disable_usb_drive()
    
    import usb_midi
    usb_midi.disable()
    
    import usb_hid
    usb_hid.disable()
    Using 1.56 Teensyduino
    Output from HIDDevice info
    Keybow already plugged in when Teensy powered.
    Code:
    USB HID Device Info Program
    
    This Sketch shows information about plugged in HID devices
    
    *** You can control the output by simple character input to Serial ***
    R - Turns on or off showing the raw data
    C - Toggles showing changed data only on or off
    <anything else> - toggles showing the Hid formatted breakdown of the data
    
    USB2 PLL running
     reset waited 6
    USBHS_ASYNCLISTADDR = 0
    USBHS_PERIODICLISTBASE = 20004000
    periodictable = 20004000
    port change: 10001803
        connect
      begin reset
    port change: 18001205
      port enabled
      end recovery
    new_Device: 480 Mbit/sec
    new_Pipe
    enumeration:
    enumeration:
    enumeration:
    Device Descriptor:
      12 01 00 02 09 00 02 40 40 1A 01 02 00 01 00 01 00 01 
        VendorID = 1A40, ProductID = 0201, Version = 0100
        Class/Subclass/Protocol = 9(Hub) / 0 / 2(Multi-TT)
        Number of Configurations = 1
    enumeration:
    enumeration:
    Product: USB 2.0 Hub [MTT]
    enumeration:
    Config data length = 41
    enumeration:
    Configuration Descriptor:
      09 02 29 00 01 01 00 E0 32 
        NumInterfaces = 1
        ConfigurationValue = 1
      09 04 00 00 01 09 00 01 00 
        Interface = 0
        Number of endpoints = 1
        Class/Subclass/Protocol = 9(Hub) / 0 / 1(Single-TT)
      07 05 81 03 01 00 0C 
        Endpoint = 1 IN
        Type = Interrupt
        Max Size = 1
        Polling Interval = 12
      09 04 00 01 01 09 00 02 00 
        Interface = 0
        Number of endpoints = 1
        Class/Subclass/Protocol = 9(Hub) / 0 / 2(Multi-TT)
      07 05 81 03 01 00 0C 
        Endpoint = 1 IN
        Type = Interrupt
        Max Size = 1
        Polling Interval = 12
    enumeration:
    USBHub memory usage = 960
    USBHub claim_device this=2000B760
    found possible interface, altsetting=0
    found possible interface, altsetting=1
    number of interfaces found = 2
    best interface is 0 using altsetting 1
    *** Device Hub1 1a40: 201 - connected ***
      product: USB 2.0 Hub [MTT]
    USBHub control callback
    09 29 07 88 00 32 64 00 FF 00 00 00 00 00 00 00 
    Hub ports = 7
    USBHub control callback
    unhandled setup, message = 10B01
    USBHub control callback
    USBHub control callback
    USBHub control callback
    USBHub control callback
    USBHub control callback
    USBHub control callback
    USBHub control callback
    power turned on to all ports
    device addr = 1
    new_Pipe
    allocate_interrupt_pipe_bandwidth
      ep interval = 12
      interval = 256
     best_bandwidth = 2, at offset = 0
    pipe cap1 = F0012101
    HUB Callback (member)
    status = 20
    getstatus, port = 5
    USBHub control callback
    01 01 01 00 
    New Port Status
      status=10101  port=5
      state=0
      Device is present: 
      Has Power
    USBHub control callback
    Port Status Cleared, port=5
    timer event (19999 us): Debounce Timer, this = 2000B760, timer = 2000BA78
    ports in use bitmask = 20
    getstatus, port = 5
    USBHub control callback
    01 01 00 00 
    New Port Status
      status=101  port=5
      state=2
      Device is present: 
      Has Power
    timer event (20000 us): Debounce Timer, this = 2000B760, timer = 2000BA78
    ports in use bitmask = 20
    getstatus, port = 5
    USBHub control callback
    01 01 00 00 
    New Port Status
      status=101  port=5
      state=3
      Device is present: 
      Has Power
    timer event (20000 us): Debounce Timer, this = 2000B760, timer = 2000BA78
    ports in use bitmask = 20
    getstatus, port = 5
    USBHub control callback
    01 01 00 00 
    New Port Status
      status=101  port=5
      state=4
      Device is present: 
      Has Power
    timer event (20000 us): Debounce Timer, this = 2000B760, timer = 2000BA78
    ports in use bitmask = 20
    getstatus, port = 5
    USBHub control callback
    01 01 00 00 
    New Port Status
      status=101  port=5
      state=5
      Device is present: 
      Has Power
    timer event (20000 us): Debounce Timer, this = 2000B760, timer = 2000BA78
    ports in use bitmask = 20
    getstatus, port = 5
    USBHub control callback
    01 01 00 00 
    New Port Status
      status=101  port=5
      state=6
      Device is present: 
      Has Power
    sending reset
    send_setreset
    USBHub control callback
    unhandled setup, message = 40323
    timer event (20000 us): Debounce Timer, this = 2000B760, timer = 2000BA78
    ports in use bitmask = 0
    HUB Callback (member)
    status = 20
    getstatus, port = 5
    USBHub control callback
    03 01 10 00 
    New Port Status
      status=100103  port=5
      state=7
      Device is present: 
      Enabled, speed = 12 Mbit/sec
      Has Power
    USBHub control callback
    unhandled setup, message = 140123
    timer event (24999 us): Hello, I'm resettimer, this = 2000B760, timer = 2000BA98
    port_doing_reset = 5
    PORT_RECOVERY
    new_Device: 12 Mbit/sec
    new_Pipe
    enumeration:
    enumeration:
    enumeration:
    Device Descriptor:
      12 01 00 02 00 00 00 40 D0 16 C6 08 00 01 01 02 03 01 
        VendorID = 16D0, ProductID = 08C6, Version = 0100
        Class/Subclass/Protocol = 0 / 0 / 0
        Number of Configurations = 1
    enumeration:
    enumeration:
    Manufacturer: Pimoroni
    enumeration:
    Product: Keybow 2040
    enumeration:
    Serial Number: E6609103C3924127
    enumeration:
    Config data length = 75
    enumeration:
    Configuration Descriptor:
      09 02 4B 00 02 01 00 80 32 
        NumInterfaces = 2
        ConfigurationValue = 1
      08 0B 00 02 02 02 00 00 
        Interface Association = 0 through 1
        Class / Subclass / Protocol = 2 / 2 / 0
      09 04 00 00 01 02 02 00 04 
        Interface = 0
        Number of endpoints = 1
        Class/Subclass/Protocol = 2 / 2 / 0
      05 24 00 10 01 
      05 24 01 01 01 
      04 24 02 02 
      05 24 06 00 01 
      07 05 81 03 40 00 10 
        Endpoint = 1 IN
        Type = Interrupt
        Max Size = 64
        Polling Interval = 16
      09 04 01 00 02 0A 00 00 05 
        Interface = 1
        Number of endpoints = 2
        Class/Subclass/Protocol = 10 / 0 / 0
      07 05 02 02 40 00 00 
        Endpoint = 2 OUT
        Type = Bulk
        Max Size = 64
        Polling Interval = 0
      07 05 82 02 40 00 00 
        Endpoint = 2 IN
        Type = Bulk
        Max Size = 64
        Polling Interval = 0
    enumeration:
    USBHub memory usage = 960
    USBHub claim_device this=2000BB20
    
    USBDeviceInfo claim this=2000CA48
    
    ****************************************
    ** Device Level **
      vid=16D0
      pid=8C6
      bDeviceClass = 0
      bDeviceSubClass = 0
      bDeviceProtocol = 0
    08 0B 00 02 02 02 00 00 09 04 00 00 01 02 02 00 04 05 24 00 10 01 05 24 01 01 01 04 24 02 02 05
    24 06 00 01 07 05 81 03 40 00 10 09 04 01 00 02 0A 00 00 05 07 05 02 02 40 00 00 07 05 82 02 40
    00 00 
    HIDParser claim this=200095A0
    HIDParser claim this=20009C60
    HIDParser claim this=2000A320
    HIDParser claim this=2000A9E0
    HIDParser claim this=2000B0A0
    Descriptor 11 = IAD
    Descriptor 4 = INTERFACE
    
    USBDeviceInfo claim this=2000CA48
    
    ****************************************
    ** Interface Level **
    09 04 00 00 01 02 02 00 04 05 24 00 10 01 05 24 01 01 01 04 24 02 02 05 24 06 00 01 07 05 81 03
    40 00 10 09 04 01 00 02 0A 00 00 05 07 05 02 02 40 00 00 07 05 82 02 40 00 00 
     bInterfaceNumber = 0
     number end points = 1
     bInterfaceClass =    2
     bInterfaceSubClass = 2
        Communicatons and CDC
     bInterfaceProtocol = 0
    HIDParser claim this=200095A0
    HIDParser claim this=20009C60
    HIDParser claim this=2000A320
    HIDParser claim this=2000A9E0
    HIDParser claim this=2000B0A0
    Descriptor 36 =  ???
    Descriptor 36 =  ???
    Descriptor 36 =  ???
    Descriptor 36 =  ???
    Descriptor 5 = ENDPOINT
    Descriptor 4 = INTERFACE
    
    USBDeviceInfo claim this=2000CA48
    
    ****************************************
    ** Interface Level **
    09 04 01 00 02 0A 00 00 05 07 05 02 02 40 00 00 07 05 82 02 40 00 00 
    HIDParser claim this=200095A0
    HIDParser claim this=20009C60
    HIDParser claim this=2000A320
    HIDParser claim this=2000A9E0
    HIDParser claim this=2000B0A0
    Descriptor 5 = ENDPOINT
    Descriptor 5 = ENDPOINT
    Keybow2040 then disconnected

    Code:
    HUB Callback (member)
    status = 20
    getstatus, port = 5
    USBHub control callback
    00 01 01 00 
    New Port Status
      status=10100  port=5
      state=9
      Has Power
    disconnect_Device:
    USBDriver (available_drivers) list: 2000BB20 -> 2000CA48 -> 200095A0 -> 20009C60 -> 2000A320 -> 2000A9E0 -> 2000B0A0
    USBDriver (dev->drivers) list: (empty
    USBDriver (available_drivers) list: 2000BB20 -> 2000CA48 -> 200095A0 -> 20009C60 -> 2000A320 -> 2000A9E0 -> 2000B0A0
    delete_Pipe 2000B4E0
      remove QH from async schedule
      Free transfers
        * 536904800
      Free transfers attached to QH
        * 536887584
    * Delete Pipe completed
    removed Device_t from devlist
    USBHub control callback
    Port Status Cleared, port=5
    Keybow plugged in after Teensy powered up
    Code:
    HUB Callback (member)
    status = 40
    getstatus, port = 6
    USBHub control callback
    01 01 01 00 
    New Port Status
      status=10101  port=6
      state=0
      Device is present: 
      Has Power
    USBHub control callback
    Port Status Cleared, port=6
    timer event (19999 us): Debounce Timer, this = 2000B760, timer = 2000BA78
    ports in use bitmask = 40
    getstatus, port = 6
    USBHub control callback
    01 01 00 00 
    New Port Status
      status=101  port=6
      state=2
      Device is present: 
      Has Power
    timer event (20000 us): Debounce Timer, this = 2000B760, timer = 2000BA78
    ports in use bitmask = 40
    getstatus, port = 6
    USBHub control callback
    01 01 00 00 
    New Port Status
      status=101  port=6
      state=3
      Device is present: 
      Has Power
    timer event (20000 us): Debounce Timer, this = 2000B760, timer = 2000BA78
    ports in use bitmask = 40
    getstatus, port = 6
    USBHub control callback
    01 01 00 00 
    New Port Status
      status=101  port=6
      state=4
      Device is present: 
      Has Power
    timer event (20000 us): Debounce Timer, this = 2000B760, timer = 2000BA78
    ports in use bitmask = 40
    getstatus, port = 6
    USBHub control callback
    01 01 00 00 
    New Port Status
      status=101  port=6
      state=5
      Device is present: 
      Has Power
    timer event (20000 us): Debounce Timer, this = 2000B760, timer = 2000BA78
    ports in use bitmask = 40
    getstatus, port = 6
    USBHub control callback
    01 01 00 00 
    New Port Status
      status=101  port=6
      state=6
      Device is present: 
      Has Power
    sending reset
    send_setreset
    USBHub control callback
    unhandled setup, message = 40323
    timer event (20000 us): Debounce Timer, this = 2000B760, timer = 2000BA78
    ports in use bitmask = 0
    HUB Callback (member)
    status = 40
    getstatus, port = 6
    USBHub control callback
    03 01 10 00 
    New Port Status
      status=100103  port=6
      state=7
      Device is present: 
      Enabled, speed = 12 Mbit/sec
      Has Power
    USBHub control callback
    unhandled setup, message = 140123
    timer event (24999 us): Hello, I'm resettimer, this = 2000B760, timer = 2000BA98
    port_doing_reset = 6
    PORT_RECOVERY
    new_Device: 12 Mbit/sec
    new_Pipe
    enumeration:
    enumeration:
    ERROR Followup
        remove from followup list
        stray halted 20004120
      qtd: 200084A0, token=80120180, next=20004120
      qtd: 20004120, token=80008080, next=20008460
      dummy halt: 20008460
    enumeration:
    Device Descriptor:
      12 01 00 02 00 00 00 40 32 08 0B 00 02 02 02 00 00 09 
        VendorID = 0832, ProductID = 000B, Version = 0202
        Class/Subclass/Protocol = 0 / 0 / 0
        Number of Configurations = 9
        remain on followup list
        remain on followup list
        remain on followup list
        remain on followup list
    ERROR Followup
        remain on followup list
        remove from followup list
        stray halted 20009520
      qtd: 200073E0, token=87FC0180, next=20009520
      qtd: 20009520, token=80008080, next=200040E0
      dummy halt: 200040E0
    enumeration:
        remain on followup list
        remain on followup list
        remain on followup list
        remain on followup list
    ERROR Followup
        remain on followup list
        remain on followup list
        remove from followup list
        stray halted 20004120
      qtd: 200073A0, token=80090180, next=20004120
      qtd: 20004120, token=80008080, next=20008460
      dummy halt: 20008460
    enumeration:
    Config data length = 512
        remain on followup list
        remain on followup list
        remain on followup list
        remain on followup list
    ERROR Followup
        remain on followup list
        remain on followup list
        remain on followup list
        remove from followup list
        stray halted 20009520
      qtd: 20006320, token=82000180, next=20009520
      qtd: 20009520, token=80008080, next=200040E0
      dummy halt: 200040E0
    enumeration:
    Configuration Descriptor:
      02 00 
    error: config must be 9 bytes
        remain on followup list
        remain on followup list
        remain on followup list
    ERROR Followup
        remain on followup list
        remain on followup list
        remain on followup list
        remain on followup list
        remove from followup list
        stray halted 20004120
      qtd: 20004120, token=80008180, next=20008460
      dummy halt: 20008460
    enumeration:
    USBHub memory usage = 960
    USBHub claim_device this=2000BB20
    
    USBDeviceInfo claim this=2000CA48
    
    ****************************************
    ** Device Level **
      vid=832
      pid=B
      bDeviceClass = 0
      bDeviceSubClass = 0
      bDeviceProtocol = 0
    08 0B 00 02 02 02 00 00 09 04 00 00 01 02 02 00 04 05 24 00 10 01 05 24 01 01 01 04 24 02 02 05
    24 06 00 01 07 05 81 03 40 00 10 09 04 01 00 02 0A 00 00 05 07 05 02 02 40 00 00 07 05 82 02 40
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
    HIDParser claim this=200095A0
    HIDParser claim this=20009C60
    HIDParser claim this=2000A320
    HIDParser claim this=2000A9E0
    HIDParser claim this=2000B0A0
    Descriptor 11 = IAD
    Descriptor 4 = INTERFACE
    
    USBDeviceInfo claim this=2000CA48
    
    ****************************************
    ** Interface Level **
    09 04 00 00 01 02 02 00 04 05 24 00 10 01 05 24 01 01 01 04 24 02 02 05 24 06 00 01 07 05 81 03
    40 00 10 09 04 01 00 02 0A 00 00 05 07 05 02 02 40 00 00 07 05 82 02 40 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
     bInterfaceNumber = 0
     number end points = 1
     bInterfaceClass =    2
     bInterfaceSubClass = 2
        Communicatons and CDC
     bInterfaceProtocol = 0
    HIDParser claim this=200095A0
    HIDParser claim this=20009C60
    HIDParser claim this=2000A320
    HIDParser claim this=2000A9E0
    HIDParser claim this=2000B0A0
    Descriptor 36 =  ???
    Descriptor 36 =  ???
    Descriptor 36 =  ???
    Descriptor 36 =  ???
    Descriptor 5 = ENDPOINT
    Descriptor 4 = INTERFACE
    
    USBDeviceInfo claim this=2000CA48
    
    ****************************************
    ** Interface Level **
    09 04 01 00 02 0A 00 00 05 07 05 02 02 40 00 00 07 05 82 02 40 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 
     bInterfaceNumber = 1
     number end points = 2
     bInterfaceClass =    10
     bInterfaceSubClass = 0
        CDC-Data
     bInterfaceProtocol = 0
    HIDParser claim this=200095A0
    HIDParser claim this=20009C60
    HIDParser claim this=2000A320
    HIDParser claim this=2000A9E0
    HIDParser claim this=2000B0A0
    Descriptor 5 = ENDPOINT
    Descriptor 5 = ENDPOINT
    Descriptor 0 =  ???
    Descriptor 0 =  ???
    Descriptor 0 =  ???
    Descriptor 0 =  ???
    Descriptor 0 =  ???
    "Loops forever printing this and floods the USB port"

  2. #2

    Can any of you USB gurus help to shed any light, please!

    Can any of you USB gurus help to shed any light, please!

    This is the enumeration I get from a USB HOST Sheild (https://chome.nerpa.tech/category/mc...no/usb-shield/)
    Code:
    01
    --
    
    Device descriptor: 
    Descriptor Length:	12
    Descriptor type:	01
    USB version:		0200
    Device class:		00
    Device Subclass:	00
    Device Protocol:	00
    Max.packet size:	40
    Vendor  ID:		16D0
    Product ID:		08C6
    Revision ID:		0100
    Mfg.string index:	01
    Prod.string index:	02
    Serial number index:	03
    Number of conf.:	01
    
    Configuration descriptor:
    Total length:		004B
    Num.intf:		02
    Conf.value:		01
    Conf.string:		00
    Attr.:			80
    Max.pwr:		32
    Unknown descriptor:
    Length:		08
    Type:		0B
    Contents:	0002020200000904
    
    Interface descriptor:
    Intf.number:		00
    Alt.:			00
    Endpoints:		01
    Intf. Class:		02
    Intf. Subclass:		02
    Intf. Protocol:		00
    Intf.string:		04
    Unknown descriptor:
    Length:		05
    Type:		24
    Contents:	0010010524
    Unknown descriptor:
    Length:		05
    Type:		24
    Contents:	0101010424
    Unknown descriptor:
    Length:		04
    Type:		24
    Contents:	02020524
    Unknown descriptor:
    Length:		05
    Type:		24
    Contents:	0600010705
    
    Endpoint descriptor:
    Endpoint address:	81
    Attr.:			03
    Max.pkt size:		0040
    Polling interval:	10
    
    Interface descriptor:
    Intf.number:		01
    Alt.:			00
    Endpoints:		02
    Intf. Class:		0A
    Intf. Subclass:		00
    Intf. Protocol:		00
    Intf.string:		05
    
    Endpoint descriptor:
    Endpoint address:	02
    Attr.:			02
    Max.pkt size:		0040
    Polling interval:	00
    
    Endpoint descriptor:
    Endpoint address:	82
    Attr.:			02
    Max.pkt size:		0040
    Polling interval:	00
    
    
    Addr:1(0.0.1)
    End of USB enumeration

  3. #3
    Senior Member
    Join Date
    Oct 2020
    Posts
    175
    I'm familiar with keyboards and scanners. This isn't one of them. Also, the extra zeros in Teensy descriptors printout, that could be the reason for the endless loop. Teensy should be requesting the exact amount of You also have a "smart card" descriptor "08 0B ..." and a bunch of unknown descriptors before getting to the first EP descriptor in interface 0. Those are not the things Teensy was expecting. This will screw up its enumeration of the device.

    I have a theory. The 2040 enumerates as some strange interface probably for programming purposes, and then re-enumerates as a simulated HID device. If you have it connected to a hub that's powered, the initial strange enumeration is not seen because the 2040 probably boots up and soon enumerates as simulated HID. But if you plug in the device, it receives power and then enumerates as a strange device first, which tripped up Teensy. In your setup(), add a 10 second delay before myusb.begin(); and you may decrease the delay if it works until it stops working.

  4. #4
    Many thanks liudr.

    Under Window and Linux i see the one com port ok, so as you say, I guess the teensy host code is seeing something unexpected that the OS can cope with ok.

    Paul if you do read this, is an update to USBHost_t36 to be more robust with these sort issues on you radar at all? I am afraid that given the complexity of USB its above me.

    Window USB treeview output
    Code:
    =========================== USB Port3 ===========================
    
    Connection Status        : 0x01 (Device is connected)
    Port Chain               : 1-2-3
    Properties               : 0x01
     IsUserConnectable       : yes
     PortIsDebugCapable      : no
     PortHasMultiCompanions  : no
     PortConnectorIsTypeC    : no
    ConnectionIndex          : 0x03 (Port 3)
    CompanionIndex           : 0
     CompanionHubSymLnk      : USB#VID_0BDA&PID_0411#6&2760bdae&0&6#{f18a0e88-c30c-11d0-8815-00a0c906bed8}
     CompanionPortNumber     : 0x03 (Port 3)
     -> CompanionPortChain   : 1-6-3
    
          ========================== Summary =========================
    Vendor ID                : 0x16D0 (Unknown Vendor)
    Product ID               : 0x08C6
    USB Version              : 2.00 -> wrong, Device is Full-Speed only
    Port maximum Speed       : High-Speed (Companion Port 1-6-3 supports SuperSpeed)
    Device maximum Speed     : Full-Speed
    Device Connection Speed  : Full-Speed
    Self powered             : no
    Demanded Current         : 100 mA
    Used Endpoints           : 4
    
          ======================== USB Device ========================
    
            +++++++++++++++++ Device Information ++++++++++++++++++
    Device Description       : USB Composite Device
    Device Path              : \\?\USB#VID_16D0&PID_08C6#E6609103C3924127#{a5dcbf10-6530-11d2-901f-00c04fb951ed} (GUID_DEVINTERFACE_USB_DEVICE)
    Kernel Name              : \Device\USBPDO-9
    Device ID                : USB\VID_16D0&PID_08C6\E6609103C3924127
    Hardware IDs             : USB\VID_16D0&PID_08C6&REV_0100 USB\VID_16D0&PID_08C6
    Driver KeyName           : {36fc9e60-c465-11cf-8056-444553540000}\0054 (GUID_DEVCLASS_USB)
    Driver                   : \SystemRoot\System32\drivers\usbccgp.sys (Version: 10.0.19041.488  Date: 2020-10-09)
    Driver Inf               : C:\Windows\inf\usb.inf
    Legacy BusType           : PNPBus
    Class                    : USB
    Class GUID               : {36fc9e60-c465-11cf-8056-444553540000} (GUID_DEVCLASS_USB)
    Service                  : usbccgp
    Enumerator               : USB
    Location Info            : Port_#0003.Hub_#0006
    Location IDs             : PCIROOT(0)#PCI(0801)#PCI(0003)#USBROOT(0)#USB(2)#USB(3), ACPI(_SB_)#ACPI(PCI0)#ACPI(GP13)#ACPI(XHC0)#ACPI(RHUB)#ACPI(PRT2)#USB(3)
    Container ID             : {6cb1b2c2-3303-5a08-b2da-d72c5d878c34}
    Manufacturer Info        : (Standard USB Host Controller)
    Capabilities             : 0x94 (Removable, UniqueID, SurpriseRemovalOK)
    Status                   : 0x0180600A (DN_DRIVER_LOADED, DN_STARTED, DN_DISABLEABLE, DN_REMOVABLE, DN_NT_ENUMERATOR, DN_NT_DRIVER)
    Problem Code             : 0
    Address                  : 3
    HcDisableSelectiveSuspend: 0
    EnableSelectiveSuspend   : 0
    SelectiveSuspendEnabled  : 0
    EnhancedPowerMgmtEnabled : 0
    IdleInWorkingState       : 0
    WakeFromSleepState       : 0
    Power State              : D0 (supported: D0, D2, D3, wake from D0, wake from D2)
     Child Device 1          : USB Serial Device (COM25)
      Device Path            : \\?\USB#VID_16D0&PID_08C6&MI_00#9&24da34ec&0&0000#{86e0d1e0-8089-11d0-9ce4-08003e301f73} (GUID_DEVINTERFACE_COMPORT)
      Kernel Name            : \Device\000003ed
      Device ID              : USB\VID_16D0&PID_08C6&MI_00\9&24DA34EC&0&0000
      Class                  : Ports
      Driver KeyName         : {4d36e978-e325-11ce-bfc1-08002be10318}\0024 (GUID_DEVCLASS_PORTS)
      Service                : usbser
      Location               : 000d.0000.0003.002.003.000.000.000.000
      LocationPaths          : PCIROOT(0)#PCI(0801)#PCI(0003)#USBROOT(0)#USB(2)#USB(3)#USBMI(0)  PCIROOT(0)#PCI(0801)#PCI(0003)#USBROOT(0)#USB(2)#USB(3)#USB(3)  ACPI(_SB_)#ACPI(PCI0)#ACPI(GP13)#ACPI(XHC0)#ACPI(RHUB)#ACPI(PRT2)#USB(3)#USBMI(0)  ACPI(_SB_)#ACPI(PCI0)#ACPI(GP13)#ACPI(XHC0)#ACPI(RHUB)#ACPI(PRT2)#USB(3)#USB(3)
      COM-Port               : COM25 (\Device\USBSER003)
    
            +++++++++++++++++ Registry USB Flags +++++++++++++++++
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\16D008C60100
     osvc                    : REG_BINARY 00 00
    
            ---------------- Connection Information ---------------
    Connection Index         : 0x03 (Port 3)
    Connection Status        : 0x01 (DeviceConnected)
    Current Config Value     : 0x01 (Configuration 1)
    Device Address           : 0x06 (6)
    Is Hub                   : 0x00 (no)
    Device Bus Speed         : 0x01 (Full-Speed)
    Number Of Open Pipes     : 0x03 (3 pipes to data endpoints)
    Pipe[0]                  : EndpointID=1  Direction=IN   ScheduleOffset=0  Type=Interrupt  wMaxPacketSize=64   bInterval=16
    Pipe[1]                  : EndpointID=2  Direction=OUT  ScheduleOffset=0  Type=Bulk       wMaxPacketSize=64   bInterval=0
    Pipe[2]                  : EndpointID=2  Direction=IN   ScheduleOffset=0  Type=Bulk       wMaxPacketSize=64   bInterval=0
    Data (HexDump)           : 03 00 00 00 12 01 00 02 00 00 00 40 D0 16 C6 08   ...........@....
                               00 01 01 02 03 01 01 01 00 06 00 03 00 00 00 01   ................
                               00 00 00 07 05 81 03 40 00 10 00 00 00 00 07 05   .......@........
                               02 02 40 00 00 00 00 00 00 07 05 82 02 40 00 00   ..@..........@..
                               00 00 00 00                                       ....
    
            --------------- Connection Information V2 -------------
    Connection Index         : 0x03 (3)
    Length                   : 0x10 (16 bytes)
    SupportedUsbProtocols    : 0x03
     Usb110                  : 1 (yes, port supports USB 1.1)
     Usb200                  : 1 (yes, port supports USB 2.0)
     Usb300                  : 0 (no, port not supports USB 3.0) -> but Companion Port 1-6-3 does
     ReservedMBZ             : 0x00
    Flags                    : 0x00
     DevIsOpAtSsOrHigher     : 0 (Device is not operating at SuperSpeed or higher)
     DevIsSsCapOrHigher      : 0 (Device is not SuperSpeed capable or higher)
     DevIsOpAtSsPlusOrHigher : 0 (Device is not operating at SuperSpeedPlus or higher)
     DevIsSsPlusCapOrHigher  : 0 (Device is not SuperSpeedPlus capable or higher)
     ReservedMBZ             : 0x00
    Data (HexDump)           : 03 00 00 00 10 00 00 00 03 00 00 00 00 00 00 00   ................
    
        ---------------------- Device Descriptor ----------------------
    bLength                  : 0x12 (18 bytes)
    bDescriptorType          : 0x01 (Device Descriptor)
    bcdUSB                   : 0x200 (USB Version 2.00) -> wrong, device is Full-Speed only
    bDeviceClass             : 0x00 (defined by the interface descriptors)
    bDeviceSubClass          : 0x00
    bDeviceProtocol          : 0x00
    bMaxPacketSize0          : 0x40 (64 bytes)
    idVendor                 : 0x16D0 (Unknown Vendor)
    idProduct                : 0x08C6
    bcdDevice                : 0x0100
    iManufacturer            : 0x01 (String Descriptor 1)
     Language 0x0409         : "Pimoroni"
    iProduct                 : 0x02 (String Descriptor 2)
     Language 0x0409         : "Keybow 2040"
    iSerialNumber            : 0x03 (String Descriptor 3)
     Language 0x0409         : "E6609103C3924127"
    bNumConfigurations       : 0x01 (1 Configuration)
    Data (HexDump)           : 12 01 00 02 00 00 00 40 D0 16 C6 08 00 01 01 02   .......@........
                               03 01                                             ..
    
        ------------------ Configuration Descriptor -------------------
    bLength                  : 0x09 (9 bytes)
    bDescriptorType          : 0x02 (Configuration Descriptor)
    wTotalLength             : 0x004B (75 bytes)
    bNumInterfaces           : 0x02 (2 Interfaces)
    bConfigurationValue      : 0x01 (Configuration 1)
    iConfiguration           : 0x00 (No String Descriptor)
    bmAttributes             : 0x80
     D7: Reserved, set 1     : 0x01
     D6: Self Powered        : 0x00 (no)
     D5: Remote Wakeup       : 0x00 (no)
     D4..0: Reserved, set 0  : 0x00
    MaxPower                 : 0x32 (100 mA)
    Data (HexDump)           : 09 02 4B 00 02 01 00 80 32 08 0B 00 02 02 02 00   ..K.....2.......
                               00 09 04 00 00 01 02 02 00 04 05 24 00 10 01 05   ...........$....
                               24 01 01 01 04 24 02 02 05 24 06 00 01 07 05 81   $....$...$......
                               03 40 00 10 09 04 01 00 02 0A 00 00 05 07 05 02   .@..............
                               02 40 00 00 07 05 82 02 40 00 00                  .@......@..
    
            ------------------- IAD Descriptor --------------------
    bLength                  : 0x08 (8 bytes)
    bDescriptorType          : 0x0B (Interface Association Descriptor)
    bFirstInterface          : 0x00 (Interface 0)
    bInterfaceCount          : 0x02 (2 Interfaces)
    bFunctionClass           : 0x02 (Communications and CDC Control)
    bFunctionSubClass        : 0x02
    bFunctionProtocol        : 0x00
    iFunction                : 0x00 (No String Descriptor)
    Data (HexDump)           : 08 0B 00 02 02 02 00 00                           ........
    
            ---------------- Interface Descriptor -----------------
    bLength                  : 0x09 (9 bytes)
    bDescriptorType          : 0x04 (Interface Descriptor)
    bInterfaceNumber         : 0x00 (Interface 0)
    bAlternateSetting        : 0x00
    bNumEndpoints            : 0x01 (1 Endpoint)
    bInterfaceClass          : 0x02 (Communications and CDC Control)
    bInterfaceSubClass       : 0x02 (Abstract Control Model)
    bInterfaceProtocol       : 0x00 (No class specific protocol required)
    iInterface               : 0x04 (String Descriptor 4)
     Language 0x0409         : "CircuitPython CDC2 control"
    Data (HexDump)           : 09 04 00 00 01 02 02 00 04                        .........
    
            -------------- CDC Interface Descriptor ---------------
    bFunctionLength          : 0x05 (5 bytes)
    bDescriptorType          : 0x24 (Interface)
    bDescriptorSubType       : 0x00 (Header Functional Descriptor)
    bcdCDC                   : 0x110 (CDC Version 1.10)
    Data (HexDump)           : 05 24 00 10 01                                    .$...
    
            -------------- CDC Interface Descriptor ---------------
    bFunctionLength          : 0x05 (5 bytes)
    bDescriptorType          : 0x24 (Interface)
    bDescriptorSubType       : 0x01 (Call Management Functional Descriptor)
    bmCapabilities           : 0x01
     D7..2                   : 0x00 (Reserved)
     D1                      : 0x00 (sends/receives call management information only over the Communication Class interface)
     D0                      : 0x01 (handles call management itself)
    bDataInterface           : 0x01
    Data (HexDump)           : 05 24 01 01 01                                    .$...
    
            -------------- CDC Interface Descriptor ---------------
    bFunctionLength          : 0x04 (4 bytes)
    bDescriptorType          : 0x24 (Interface)
    bDescriptorSubType       : 0x02 (Abstract Control Management Functional Descriptor)
    bmCapabilities           : 0x02
     D7..4                   : 0x00 (Reserved)
     D3                      : 0x00 (not supports the notification Network_Connection)
     D2                      : 0x00 (not supports the request Send_Break)
     D1                      : 0x01 (supports the request combination of Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding, and the notification Serial_State)
     D0                      : 0x00 (not supports the request combination of Set_Comm_Feature, Clear_Comm_Feature, and Get_Comm_Feature)
    Data (HexDump)           : 04 24 02 02                                       .$..
    
            -------------- CDC Interface Descriptor ---------------
    bFunctionLength          : 0x05 (5 bytes)
    bDescriptorType          : 0x24 (Interface)
    bDescriptorSubType       : 0x06 (Union Functional Descriptor)
    bControlInterface        : 0x00
    bSubordinateInterface[0] : 0x01
    Data (HexDump)           : 05 24 06 00 01                                    .$...
    
            ----------------- Endpoint Descriptor -----------------
    bLength                  : 0x07 (7 bytes)
    bDescriptorType          : 0x05 (Endpoint Descriptor)
    bEndpointAddress         : 0x81 (Direction=IN EndpointID=1)
    bmAttributes             : 0x03 (TransferType=Interrupt)
    wMaxPacketSize           : 0x0040 (64 bytes)
    bInterval                : 0x10 (16 ms)
    Data (HexDump)           : 07 05 81 03 40 00 10                              ....@..
    
            ---------------- Interface Descriptor -----------------
    bLength                  : 0x09 (9 bytes)
    bDescriptorType          : 0x04 (Interface Descriptor)
    bInterfaceNumber         : 0x01 (Interface 1)
    bAlternateSetting        : 0x00
    bNumEndpoints            : 0x02 (2 Endpoints)
    bInterfaceClass          : 0x0A (CDC-Data)
    bInterfaceSubClass       : 0x00
    bInterfaceProtocol       : 0x00
    iInterface               : 0x05 (String Descriptor 5)
     Language 0x0409         : "CircuitPython CDC2 data"
    Data (HexDump)           : 09 04 01 00 02 0A 00 00 05                        .........
    
            ----------------- Endpoint Descriptor -----------------
    bLength                  : 0x07 (7 bytes)
    bDescriptorType          : 0x05 (Endpoint Descriptor)
    bEndpointAddress         : 0x02 (Direction=OUT EndpointID=2)
    bmAttributes             : 0x02 (TransferType=Bulk)
    wMaxPacketSize           : 0x0040 (64 bytes)
    bInterval                : 0x00 (ignored)
    Data (HexDump)           : 07 05 02 02 40 00 00                              ....@..
    
            ----------------- Endpoint Descriptor -----------------
    bLength                  : 0x07 (7 bytes)
    bDescriptorType          : 0x05 (Endpoint Descriptor)
    bEndpointAddress         : 0x82 (Direction=IN EndpointID=2)
    bmAttributes             : 0x02 (TransferType=Bulk)
    wMaxPacketSize           : 0x0040 (64 bytes)
    bInterval                : 0x00 (ignored)
    Data (HexDump)           : 07 05 82 02 40 00 00                              ....@..
    
        ----------------- Device Qualifier Descriptor -----------------
    Error                    : ERROR_GEN_FAILURE  (*!*ERROR   USB 2.0 devices must provide a Device Qualifier Descriptor)
    
          -------------------- String Descriptors -------------------
                 ------ String Descriptor 0 ------
    bLength                  : 0x04 (4 bytes)
    bDescriptorType          : 0x03 (String Descriptor)
    Language ID[0]           : 0x0409 (English - United States)
    Data (HexDump)           : 04 03 09 04                                       ....
                 ------ String Descriptor 1 ------
    bLength                  : 0x12 (18 bytes)
    bDescriptorType          : 0x03 (String Descriptor)
    Language 0x0409          : "Pimoroni"
    Data (HexDump)           : 12 03 50 00 69 00 6D 00 6F 00 72 00 6F 00 6E 00   ..P.i.m.o.r.o.n.
                               69 00                                             i.
                 ------ String Descriptor 2 ------
    bLength                  : 0x18 (24 bytes)
    bDescriptorType          : 0x03 (String Descriptor)
    Language 0x0409          : "Keybow 2040"
    Data (HexDump)           : 18 03 4B 00 65 00 79 00 62 00 6F 00 77 00 20 00   ..K.e.y.b.o.w. .
                               32 00 30 00 34 00 30 00                           2.0.4.0.
                 ------ String Descriptor 3 ------
    bLength                  : 0x22 (34 bytes)
    bDescriptorType          : 0x03 (String Descriptor)
    Language 0x0409          : "E6609103C3924127"
    Data (HexDump)           : 22 03 45 00 36 00 36 00 30 00 39 00 31 00 30 00   ".E.6.6.0.9.1.0.
                               33 00 43 00 33 00 39 00 32 00 34 00 31 00 32 00   3.C.3.9.2.4.1.2.
                               37 00                                             7.
                 ------ String Descriptor 4 ------
    bLength                  : 0x36 (54 bytes)
    bDescriptorType          : 0x03 (String Descriptor)
    Language 0x0409          : "CircuitPython CDC2 control"
    Data (HexDump)           : 36 03 43 00 69 00 72 00 63 00 75 00 69 00 74 00   6.C.i.r.c.u.i.t.
                               50 00 79 00 74 00 68 00 6F 00 6E 00 20 00 43 00   P.y.t.h.o.n. .C.
                               44 00 43 00 32 00 20 00 63 00 6F 00 6E 00 74 00   D.C.2. .c.o.n.t.
                               72 00 6F 00 6C 00                                 r.o.l.
                 ------ String Descriptor 5 ------
    bLength                  : 0x30 (48 bytes)
    bDescriptorType          : 0x03 (String Descriptor)
    Language 0x0409          : "CircuitPython CDC2 data"
    Data (HexDump)           : 30 03 43 00 69 00 72 00 63 00 75 00 69 00 74 00   0.C.i.r.c.u.i.t.
                               50 00 79 00 74 00 68 00 6F 00 6E 00 20 00 43 00   P.y.t.h.o.n. .C.
                               44 00 43 00 32 00 20 00 64 00 61 00 74 00 61 00   D.C.2. .d.a.t.a.

  5. #5
    Senior Member
    Join Date
    Oct 2020
    Posts
    175
    Have you tried my suggested delay(10000) before myusb.begin() in setup()?

  6. #6
    Senior Member
    Join Date
    Oct 2020
    Posts
    175
    I confirmed with my USB analyzer that when micropython firmware is loaded it would enumerate like the way you saw in teensy. I don't have the Pimoroni Kewbow2040 so I imagine it would re-enumerate as an HID keyboard. I believe a delay in your teensy code will fix it. I hope you will give this simple fix a try.

  7. #7
    liudr

    Thanks for taking the trouble to look at with your analyser. Yes it works with a delay in setup. When Circuitpython runs it first loads the "boot.py" file which sets the USB configuration (in mycase only 1 CDC serial). I guess the teensy tries to enumerate it before it has completed this. It would be nice to be able to plug in on the fly but will have to live with it. Which analyser do you have by he way and would you recomend it for someone starrting to try to leard the USB protocol.
    Thanks

  8. #8
    Senior Member
    Join Date
    Oct 2020
    Posts
    175
    You really need to read my responses better. I said, if delay(10000) works, then try lower the time until it stops working and decide the minimal delay, for the thing to switch over to HID mode. Maybe you only need a couple of seconds. If that's still too long for you, then it's not your problem to solve, it's the micropython and RP2040. Your teensy can't operate the thing as an HID until the thing itself claims to be an HID.

    My USB analyzer is this one:

    https://www.totalphase.com/products/beagle-usb480/

    If you ONLY want USB 1.1 at 12Mbps max, you can get away with a less expensive model:

    https://www.totalphase.com/products/beagle-usb12/

    This less expensive model also has software limitations that I don't like.

    If you're broke, try the software analyzers first, such as wireshark with USB addon. It's free but you can only have you PC hosting the device so it's no help trying to develop host code because for that you need to probe between the teensy host and the device, not between your PC and the device.

  9. #9
    Thanks for the info.

    I did read what you said but maybe i am a bit confused. I thought "Setup" is only executed at boot so was not sure how this could help when the Teensy is already powered and I then connect the device.

  10. #10
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,543
    Sorry I am a bit lazy right now looking at USBHost stuff...

    Some of the things that might help, gather more data include:

    plug it in to your linux box and do the lsusb like stuff, you already did. In addition see what system messages it produces, with something like: dmesg | tail -40
    And see what devices it creates

    It it generates a Serial port like: /dev/ttyUSBx or /dev/ttyACMx
    Then try the Serial example of the USBHost library and see if it connects... also make sure to have debug output turned on in usbhost_t36.h

    If however you expect it to show up as something like a disk drive, then you probably need to see if the MSC work by wwatson and a few of us works for you or not.
    This stuff is not currently in the build, but lots of information up on the thread: https://forum.pjrc.com/threads/68139...ng-MTP-and-MSC

    Note: the above thread shows the work with MSC stuff integrated into USBHost_t36, As this has been pending for awhile now there is another posting where I moved the stuff back to @wwatson's
    github project. UsbMscFat in the decouple branch... May have to search for posting I did on that.

  11. #11
    Senior Member
    Join Date
    Oct 2020
    Posts
    175
    I'm somewhat a current with the host library.
    So assume you run HIDDeviceInfo sample code, and it freezes up, I examined the printouts. There were multiple errors during enumeration.

    Starting with your "Keybow already plugged in when Teensy powered." posting, there are initially two "enumeration:" before the first error:

    Code:
    PORT_RECOVERY
    new_Device: 12 Mbit/sec
    new_Pipe
    enumeration:
    enumeration:
    ERROR Followup
    DEV DESC: device descriptor
    CONF DESC: configuration descriptor

    The first "enumeration:" was "got DEV DESC 8 bytes and enqueuing a request to set address to the device", which was successful.
    The second "enumeration:" was "successfully setting address and enqueuing a request to get 18-byte version of DEV DESC".
    Then there is an error, I guess triggered by the the request for 18-byte DEV DESC.
    But then another "enumeration:" was printed out, which is the "successfully received 18-byte of DEV DESC and parsing the DESC".

    But, this received DEV DESC is INCORRECT!

    Code:
    enumeration:
    Device Descriptor:
      12 01 00 02 00 00 00 40 32 08 0B 00 02 02 02 00 00 09
    The last byte is bNumConfigurations, number of configurations. This should be 1. I've not seen anything with multiple configurations. I have loaded micropython to an RP2040 board adafruit produces and the enumeration is 1 config only. I can check circuitpython but doubt there's a difference.
    The errors just keep compounding, where next teensy was asking for string descriptor and got nothing, then asked for conf desc and got 512 bytes, apparently not all of them were even data, with lots of zeros. What followed was complete train wrack. Teensy follows a pretty linear way without much error handling.

    Code:
    enumeration:
    Configuration Descriptor:
      02 00 
    error: config must be 9 bytes
    So this is another error. As to what caused the errors, I'm unsure. Try wireshark with USB protocol and plug the device into a PC, see what you can get.

  12. #12
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,543
    As I already mentioned above, I am not much of a Python person.

    But thought I would play here with plugging in a Circuit Python board into the USB Host code. And see what devices it tries to USB Interfaces it creates...

    So far it appears like it creates a drive, plus a mouse object, plus a keyboard object.

    Note: I am discussing more of it up on the thread: https://forum.pjrc.com/threads/68139...006#post303006

    Right now looking into issues associated with the created drive, which is attempted to be picked up by the MSC library. The main one is that the Circuit Python drive created is a Fat12 format drive. By default Fat12 is turned off in the SDFat library.

    Which we can turn on in the config file:
    Code:
    //------------------------------------------------------------------------------
    /**
     * Set FAT12_SUPPORT nonzero to enable use if FAT12 volumes.
     * FAT12 has not been well tested and requires additional flash.
     */
    #ifndef FAT12_SUPPORT
    #define FAT12_SUPPORT 1
    #endif  // FAT12_SUPPORT
    I turned on still did not work, as it was requiring #FAT to be 2, where this one is 1... Fixed that and it shows up. But some of the code that actually then works with the File System then thinks it must be a Fat16 as it has > N clusters... So need to change code to maybe retrieve drive type from MBR...

    Then debug all of the code that SDFat says is not well tested....

    But note in current test sketch I added stuff to the USB host code list to see what devices might connect:
    Code:
    *** end Interval Timer ***
    loop:3634 CMD: 1005(GET_STORAGE_INFO)l: 16 T:6 : 10001
    65537 0 name:RAM
    3634 RESP:2001(RSP:OK)l: 12 T:6
    *** Device HID1 239a:80ae - connected ***
      manufacturer: PJRC
      product: Teensy 4.1
      Serial: 2F057F67D28111299000005002004200
    *** Device KB1 239a:80ae - connected ***
      manufacturer: PJRC
      product: Teensy 4.1
      Serial: 2F057F67D28111299000005002004200
    *** HID Device Mouse1 239a:80ae - connected ***
      manufacturer: PJRC
      product: Teensy 4.1
      Serial: 2F057F67D28111299000005002004200

  13. #13
    Many thanks for looing at this. I dug out my old Scanaplus V2 logic analyser and I could'nt believe it, but mangaged to get it set up and capture the USB traffic. I am still looking at the results (and trying to learn the USB protocol) but will post shortly.
    In short it works ok connected directly to the Teensy and Fails if you put any hub inbetween

    @KurtE. I had guessed that there could be issues with all the USB interfaces Circuitpython creates so I limited it to the one serial interface. This is done by editing the "boot.py" file (see my first post in the thread)
    I will check out the other thread and see if there is anything I can contribute. It would be great if all the Circuitpython interfaces work.

  14. #14
    So as said this will work ok plugged directly into the Teensy host port. I have tried 3 Hubs, two USB 2 hubs and 1 USB 3 Hub, all powered so its not a power delivery issue.
    Here is a screen shot of the sucessfull Emuneration.
    Click image for larger version. 

Name:	Teensy_Keybow_Sucessfull Setup.jpg 
Views:	7 
Size:	76.9 KB 
ID:	28040

    With a hub inbetween it fails all the time and locks up the teensy and saturates the USB port if #Debug is on.
    What I see is that there is a sucessfull "Setup - Get Descriptor", followed by a sucessfull "Setup - Set Address". However the next "Setup - Get Descriptor" is incomplete. The Teensy then sits there and send out endless incomplete "Setup - Get Descriptors" (I assume).
    Here is the screenshot of the failed enumeration with the hub in use.

    Click image for larger version. 

Name:	Teensy_Keybow_Sucessfull Setup.png 
Views:	9 
Size:	47.8 KB 
ID:	28036

    If I drill down into the incomplete setup the data packet of the setup looks correct but there is no "Ack" back from the device. Apart from that the only differece I can see is whats happening betwen the end of the "Setup - Set Address" and the start of the "Setup - Get Descriptor" is completely different between the two (no hub ok, hub bad). There is much more activity going on with the hub than without.
    Without the hub, after the end of the "Set Address" sequence there is approx 1ms of no activity. There is then a small sequece which the decoder on my analyser does not identify.
    The below screen shot hopefully shows this clearly between the two markers.
    Click image for larger version. 

Name:	Teensy_Keybow_Sucessfull Setup_between.png 
Views:	6 
Size:	2.7 KB 
ID:	28037

    and the following is the unkown sequence

    Click image for larger version. 

Name:	Teensy_Keybow_Sucessfull Setup_Unknown_Sequence.png 
Views:	5 
Size:	4.9 KB 
ID:	28038

    Now with the Hub inbetween there are 10 of these unknown sequences 1ms appart before the "Setup - Get Descriptor" is tried.

    Click image for larger version. 

Name:	Teensy_Keybow_UNSucessfull Setup_between.png 
Views:	4 
Size:	3.0 KB 
ID:	28039

    So thats about all I know so far. Any help at this point is really appreciated. I guess I can try with the Logic Analyser between the Teensy and the Hub and see what I get!!

  15. #15
    Ok tried capturing between the Hub and the teensy, but of course got nothing. Even my oldest hub supports USB High speed 480Mbit and I guess the Teensy negotiates at the highest speed, so my poor old Logic analyser is going to see nothing.
    Any of you guys with a High Speed USB analyser have the time to look ?

  16. #16

    SOLVED - DOH!! put 5 second delay before loading "Keybow2040.py"

    So I managed to to look at the traffic between the Teensy and the Hub and could see problems with the a stall in the "Set Address" split packet (which i think is part of the high speed to full speed management that the hub does). The Teensy never recovers from this! To veryfy this I put a full speed USB isolator between the Teensy and Hub, to force 12mbit and yes it all works fine.
    If you look at the same hub on Win10 with the Keybow2040, the same split packet works fine. The only diffeence I could see is the timeing between the two.
    Anyway after lots of playing around I am guessing that with the teensy timing the keybow is trying to load a python library (Keybow2040.py) that causes some timing issues .
    In the end its as simple as putting a 5 second delay in the python code to let USB enumeration complete before tryng to load this library. Doh! wish i had tried that weeks ago!

    High Speed Enumeration Teensy
    Click image for larger version. 

Name:	HighSpeed_Enumeration_Teensy.png 
Views:	9 
Size:	106.9 KB 
ID:	28208

    High Speen Enumeration Windows
    Click image for larger version. 

Name:	HighSpeed_Enumeration_Win10.png 
Views:	5 
Size:	109.9 KB 
ID:	28209

  17. #17
    Senior Member
    Join Date
    Oct 2020
    Posts
    175
    I'm not sure what took the same device so much longer to respond to Teensy than PC. The error was not the setup packet of "set address" that got stalled. The one after it got stalled. It's a request for device descriptor. Good thing you have access to a beagle so I can easily understand your screen grabs.

  18. #18
    @liudr
    Thanks for the help and the correction. Yes you are right its the device descriptor request. I dont pretent to understand all the why's but delaying that python lib from loading allows succesfull enumeratiuon from Windows, Linux and Teensy all ok.
    I took the plunge and bought a Beagle USB480 as I would like to understand the USB protocol better and this seems to be the the analyser of choice here. At least it helped me see that it was some sort of timing issue.

    Many thanks and Regards

  19. #19
    Senior Member
    Join Date
    Oct 2020
    Posts
    175
    Could you post your successful enumeration with the 5-second delay? I am curious whether it is the rp2040 that is too slow to respond with USB requests when it starts up circuitpython and usb device. If you wait 5 seconds after booting, then maybe the CPU is more or less idling so it processes the requests more timely. In theory, control requests should be responded within 50ms of time. There is a separate issue with teensy. It doesn't wait for 2ms after issuing "set address" before it sends the next request. Standard requires a 2ms recovery time for the device to get into operational mode after receiving a new address. This upsets some older devices and causes enumeration to fail. I raised this issue on git:

    https://github.com/PaulStoffregen/USBHost_t36/issues/87

    I think with a delay the host library can be more stable and less prone to failure.

    So about learning USB, that was an EXPENSIVE toy! I suggest you to capture every HID device you have, such as keyboards, mice, other types of controllers. Then you can open them up with separate data center windows to kind of compare what they are doing. I learned my USB by using beagle to sniff everything and read/compare with USB 2.0 document. Read chapters 8 and 9. You can start with reading all requests at the top level, without expanding them, then expand a request to see what the setup packet contains, confirm you understand it against chapter 9. USB HID has its own document, version 1.1 All of these are downloadable:

    https://www.usb.org/document-library...-specification

    It's a lot of work to learn USB but the analyzer makes it bearable

  20. #20
    @Liudr

    Thanks for the usefull suggestions on becoming more familiar with USB.

    Here is screen shot of succesfull enumeration on both sides of the hub.

    High Speed Enumeration 480Mbit/s
    Click image for larger version. 

Name:	HighSpeed_Enumeration_Teensy41_Keybow2040_ok.png 
Views:	7 
Size:	136.7 KB 
ID:	28264


    Full Speed Enumeration 12Mbit/s
    Click image for larger version. 

Name:	FullSpeed_Enumeration_Teensy41_Keybow2040_ok.png 
Views:	6 
Size:	127.5 KB 
ID:	28265

  21. #21
    Senior Member
    Join Date
    Oct 2020
    Posts
    175
    So when successful, it took 0.1ms to go from set address to get dev desc. I'm suspecting that it WAS circuitpython running startup routines in the background that caused the device to respond too slowly. If you're interested in trying, gradually reduce the 5 seconds until it starts to fail and grab a failed 12Mbps side result. At least this gives you a limit to how soon you can enumerate as a device after booting into circuitpython.

  22. #22
    @Liudr, many thanks again for all the help!
    Its does'nt need much delay.
    130ms - Fails all the time
    150ms - Borderline
    175ms - ok all the time
    Its also importing a specific support file that causes the issue (keybow2040.py). I can import other libs and run code without any delays and its all ok.

  23. #23
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,398
    Is it possible to reproduce this problem using a Raspberry Pi Pico? Even if it lacks the keyboard pushbuttons and LEDs, all that's needed is USB enumeration, right?

    I have a couple Picos here, still in the original bag, never used. I've only run Circuit Python on Teensy 4, and only a few times to try very basic things. So far I've never used a RP2040 chip in any way. Can anyone give me a step-by-step process to get all the software and libraries needed onto one of these virgin Raspberry Pi Picos?

    Once I can get it all set up here and observe the problem on my Beagle 480 analyzer, I can work on a fix in USBHost_t36. It's been a few years since I wrote ehci.cpp (which is quite complicated), so might take a little while to get back into it. But first I just need a way to reproduce this problem, and I really don't have time to do much fiddling with RP2040 hardware. Clear step-by-step instructions and direct links to the files needed to get the hardware set up with the Circuit Python code & libraries would really help.

  24. #24
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,543
    Good morning Paul,

    You can program the RPI2040 Pico with CircuitPython.

    Instructions as well links to downloads are on the page: https://circuitpython.org/board/raspberry_pi_pico/

    Short answer is you download a .uf2 file (either released, beta, or from the automatic builds). I just downloaded the latest one.

    You then hold down the program button while plugging it in, which brings it up in bootloader mode.
    You then simply copy the .uf2 file into the drive that shows up for the RPI and when it finishes the copy it will reboot and run that image.

    EDIT: Note: I have not tried creating a CircuitPython setup with boot.py file on it. So not sure how much that changes things.

    You in theory once you setup the CircuitPython, and it brings up a disk, you should then be able to either use the Mu Editor on the board, to edit file and do a save to that file, or create it external and copy it on.

    The interesting thing with the boot.py file is it helps to control what interfaces/end points that are created by the device.

    Not sure what it does
    Boot.py
    Code:
    import usb_cdc
    
    usb_cdc.enable(console=False, data=True)    # Disable Repl enable serial data
    
    import storage
    storage.disable_usb_drive()
    
    import usb_midi
    usb_midi.disable()
    
    import usb_hid
    usb_hid.disable()
    Unclear what some of these things do, like after doing this,
    Does it now not allow you to use REPL to talk to the device, by doing Serial edits and the like?
    And then what the storage disable USB_drive() does that disable the main storage? If so again wondering how you update....

    But again I only know enough to be dangerous
    Last edited by KurtE; 05-13-2022 at 01:24 PM.

  25. #25
    @Paul

    I have not been able to reproduce so far on a vanilla Pico! Its loading the library specific to the keybow2040 while in emumeration that seems to cause the issue (only thru a high speed hub).
    I tried uploading the beagle files but get an invalid file message, even when archived ?

    Regards
    Robert.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •