0

I have developed a kernel driver for a USB device. Such a device has some pins that can provide functionality both as CDC ACM serial port or as input buttons. So to implement that I had to use two different USB configuration descriptors.

The driver works as expected, but I have to hardcode the chosen setup before compiling and loading the firmware to the micro-controller. I am searching a mechanism to change that device configuration from userspace.

I read about a SET_CONFIGURATION message on USB documentation, but coudn't find any Linux tool to send such kind of standard USB messages from userspace to the USB bus.

Does some of you (with more experience on this topic) know some userspace Linux tool to send a SET_CONFIGURATION message to a device connected to the USB bus?

Thanks in advance! :)

aicastell
  • 2,182
  • 2
  • 21
  • 33
  • It seems it might be time for you to re-read ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). – Some programmer dude Sep 06 '18 at 11:17
  • Re-edited the question to include the background. Thanks for the information. – aicastell Sep 06 '18 at 11:22

3 Answers3

1

The function libusb_set_configuration() in LibUSB could do that in theory, but there is no need.

One can simply put both HID (for the button) and CDC (serial port) into one configuration using an "Interface association descriptor" (IAD).

Turbo J
  • 7,563
  • 1
  • 23
  • 43
  • libusb? Nice! I will check it. I know you can use several interfaces in a single configuration, but my device can use the same pins as CDC (serial port) or as input GPIOS, so that's because I need two different configurations. Thanks for the information! – aicastell Sep 06 '18 at 16:25
0

This github repo resolves my issue:

https://github.com/avtolstoy/usbtool
aicastell
  • 2,182
  • 2
  • 21
  • 33
0

No need for any special tools. You can simply do it via sysfs:

  • Find your device cd /sys/bus/usb/devices/X-Y/ where X is the bus number and Y is the device number.
  • Edit bConfigurationValue e.g., using sudoedit
  • Set the file contents to the desired configuration number and save it

That’s it!

Elist
  • 5,313
  • 3
  • 35
  • 73