0
votes

I created an small embedded WinUSB device which offers 2 bulk endpoints. This device can communicate with Linux and with Windows10 without installing driver, or a .inf file.

Now we want to use the same API with a embedded Linux. The USB-Gadget mode offers Serial CDC/ACM and RNDIS-Ethernet and many more.

I was able to create a USB-Gadget with the gadgetfs which had only bulk ep. I could communicate with Linux and Windows host. The USB-Device had /dev/ttyGS0 to communicate. But in Windows I had to install WinUSB driver manually.

I work with yocto to create embedded kernel. I added some line of code here: /linux-imx/drivers/usb/gadget/legacy/serial.c , f_serial.c, u_serial.h to add additional variable os_desc and parameter use_winusb. But the resulting g_serial still creates a COM-Port in Windows10 or a no WinUSB device. For our device we need WinUSB-Device only.

The RNDIS Gadget does has WinUSB support. So I tried to create a own USB-Gadget device with https://github.com/libusbgx/libusbgx. But if I use the USBG_F_SERIAL function type then it can't create WinUSB. See error:

Error setting function OS desc
Error: USBG_ERROR_NOT_FOUND : Not found (file or directory removed)

If I use USBG_F_RNDIS, it works, and with manipulated USB descriptor it'll recognized by Windows as WinUSB device. But Linux implement's it as USB-ETH ethernet device. The USB-Device get's no /dev/ttyGS0 serial connection to communicate.

I'm reading the Linux kernel driver source now, to find the position, where I can simply ann this WinUSB os-descriptor stuff into the USBG_F_SERIAL type. But I think it'll take month to get through.

Any solution would be ok. Patch for the Linux driver sources g_serial or how to configure a USB-Gadgetfs would be great. Any hint, where to put additional code would also be fine.

1
Did you attempt analyzing the exchange between a Windows host and your gadget using WireShark or Microsoft Event Analyzer? It will show the descriptors requested by the host and returned by the device. Please capture these and add these to your question. This will help find out what happens during USB devcie enumeration phase and will give you a clue on how to solve it. I recommend checking Microsoft documentation on OS Descriptors -- it will help you understand the happy flow and enable you to investigate the issue yourself.Alexey Adadurov

1 Answers

0
votes

I wanted to change the kernel, but fortunately found this: https://blog.soutade.fr/post/2016/07/create-your-own-usb-gadget-with-gadgetfs.html

This code made it easy to add WinUSB features.

Source of modified Version for WinUSB: https://github.com/rundekugel/gadgetfsd/tree/WinUSB