Skip to content

usb.host.find() OK for MIDI keyboards in 9.2.4, but fails for some in CP>=9.2.5 on Feather RP2040 USB Host #10494

@RobCranfill

Description

@RobCranfill

CircuitPython version and board name

Adafruit CircuitPython 9.2.5 on 2025-03-19; Adafruit Feather RP2040 USB Host with rp2040

Code/REPL

import usb.core
import time

time.sleep(5) # needed for USB to settle? I don't think so, but whatev.

print("Looking for midi devices")
while True:
    i = 0
    for device in usb.core.find(find_all=True):
	print("Found a device")
	i += 1
    print(f"Found {i} devices; going around again...")
    time.sleep(1)

Behavior

Adafruit CircuitPython 9.2.5 on 2025-03-19; Adafruit Feather RP2040 USB Host with rp2040
>>> 
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Looking for midi devices
Found 0 devices; going around again...
Found 0 devices; going around again...
Found 0 devices; going around again...
Traceback (most recent call last):
  File "code.py", line 2, in <module>
  File "super_simple_test.py", line 14, in <module>
KeyboardInterrupt: 

Description

usb.core.find() does not see the device under CP>=9.2.5, but did under <=9.2.4.

Additional information

The following test code runs correctly with all MIDI keyboards I have tried it on under CP 9.2.4 and earlier, but fails on some MIDI keyboards under CP 9.2.5 and later.

Test code


import usb.core
import time

time.sleep(5) # needed for USB to settle? I don't think so, but whatev.

print("Looking for midi devices")
while True:
    i = 0
    for device in usb.core.find(find_all=True):
	print("Found a device")
	i += 1
    print(f"Found {i} devices; going around again...")
    time.sleep(1)

Testing with Akai MPKMini2 MIDI keyboard

Test run 1 (success)

Adafruit CircuitPython 9.2.4 on 2025-01-28; Adafruit Feather RP2040 USB Host with rp2040
>>> 
>>> 
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Looking for midi devices
Found a device
Found 1 devices; going around again...
Found a device
Found 1 devices; going around again...
Traceback (most recent call last):
  File "code.py", line 2, in <module>
  File "super_simple_test.py", line 14, in <module>
KeyboardInterrupt: 
...

Test run 2 (failure)

	Adafruit CircuitPython 9.2.5 on 2025-03-19; Adafruit Feather RP2040 USB Host with rp2040
	>>> 
	soft reboot

	Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
	code.py output:
	Looking for midi devices
	Found 0 devices; going around again...
	Found 0 devices; going around again...
	Found 0 devices; going around again...

Test run 3 (failure)

	Adafruit CircuitPython 10.0.0-alpha.8 on 2025-07-08; Adafruit Feather RP2040 USB Host with rp2040
	>>> 
	>>> 
	soft reboot

	Auto-reload is off.
	code.py output:
	Looking for midi device
	Found 0 devices; going around again...
	Found 0 devices; going around again...
	...

Output from lsusb --vvv for Akai MPKMini2

As per suggestion/request of @tannewt here is some info on the device from a Linux box:

rob@ScreamerIVU:~$ sudo lsusb -vvv >mpkmini.lsusb.text
 (and then edited to show only the pertinent device)

...
Bus 001 Device 009: ID 2011:0715 AKAI MPKmini2
Negotiated speed: Full Speed (12Mbps)
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 [unknown]
  bDeviceSubClass         0 [unknown]
  bDeviceProtocol         0 
  bMaxPacketSize0        32
  idVendor           0x2011 AKAI
  idProduct          0x0715 MPKmini2
  bcdDevice            0.00
  iManufacturer           1 AKAI
  iProduct                2 MPKmini2
  iSerial                 3 0001
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0085
    bNumInterfaces          3
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x00
      (Missing must-be-set bit!)
      (Bus Powered)
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      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 (null)
	  wDescriptorLength      52
	  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     0x0020  1x 32 bytes
	bInterval               1
      Endpoint Descriptor:
	bLength                 7
	bDescriptorType         5
	bEndpointAddress     0x02  EP 2 OUT
	bmAttributes            3
	  Transfer Type            Interrupt
	  Synch Type               None
	  Usage Type               Data
	wMaxPacketSize     0x0020  1x 32 bytes
	bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      1 Control Device
      bInterfaceProtocol      0 
      iInterface              0 
      AudioControl Interface Descriptor:
	bLength                 9
	bDescriptorType        36
	bDescriptorSubtype      1 (HEADER)
	bcdADC               1.00
	wTotalLength       0x0009
	bInCollection           1
	baInterfaceNr(0)        2
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         1 Audio
      bInterfaceSubClass      3 MIDI Streaming
      bInterfaceProtocol      0 
      iInterface              0 
      MIDIStreaming Interface Descriptor:
	bLength                 7
	bDescriptorType        36
	bDescriptorSubtype      1 (HEADER)
	bcdADC               1.00
	wTotalLength       0x0041
      MIDIStreaming Interface Descriptor:
	bLength                 6
	bDescriptorType        36
	bDescriptorSubtype      2 (MIDI_IN_JACK)
	bJackType               1 Embedded
	bJackID                 1
	iJack                   0 
      MIDIStreaming Interface Descriptor:
	bLength                 6
	bDescriptorType        36
	bDescriptorSubtype      2 (MIDI_IN_JACK)
	bJackType               2 External
	bJackID                 2
	iJack                   0 
      MIDIStreaming Interface Descriptor:
	bLength                 9
	bDescriptorType        36
	bDescriptorSubtype      3 (MIDI_OUT_JACK)
	bJackType               1 Embedded
	bJackID                 3
	bNrInputPins            1
	baSourceID( 0)          2
	BaSourcePin( 0)         1
	iJack                   0 
      MIDIStreaming Interface Descriptor:
	bLength                 9
	bDescriptorType        36
	bDescriptorSubtype      3 (MIDI_OUT_JACK)
	bJackType               2 External
	bJackID                 4
	bNrInputPins            1
	baSourceID( 0)          1
	BaSourcePin( 0)         1
	iJack                   0 
      Endpoint Descriptor:
	bLength                 9
	bDescriptorType         5
	bEndpointAddress     0x03  EP 3 OUT
	bmAttributes            2
	  Transfer Type            Bulk
	  Synch Type               None
	  Usage Type               Data
	wMaxPacketSize     0x0040  1x 64 bytes
	bInterval               0
	bRefresh                0
	bSynchAddress           0
	MIDIStreaming Endpoint Descriptor:
	  bLength                 5
	  bDescriptorType        37
	  bDescriptorSubtype      1 (Invalid)
	  bNumEmbMIDIJack         1
	  baAssocJackID( 0)       1
      Endpoint Descriptor:
	bLength                 9
	bDescriptorType         5
	bEndpointAddress     0x84  EP 4 IN
	bmAttributes            2
	  Transfer Type            Bulk
	  Synch Type               None
	  Usage Type               Data
	wMaxPacketSize     0x0040  1x 64 bytes
	bInterval               0
	bRefresh                0
	bSynchAddress           0
	MIDIStreaming Endpoint Descriptor:
	  bLength                 5
	  bDescriptorType        37
	  bDescriptorSubtype      1 (Invalid)
	  bNumEmbMIDIJack         1
	  baAssocJackID( 0)       3
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy