cancel
Showing results for 
Search instead for 
Did you mean: 

USB ethernet gadget stops working after replugging cable

BillR
Associate III

Not sure if this is the best forum for this question but I am using the USB OTG port in device mode as ethernet gadget. It works fine if plugged in from boot, or first plug in anytime after.

But if unplugged and plugged in again it will not come back without a board reboot:

[  46.766872] dwc2 49000000.usb-otg: new device is high-speed
[  46.771014] dwc2 49000000.usb-otg: dwc2_hsotg_enqueue_setup: failed queue (-11)

Error -11 is something like "resource temporarily unavailable". Ever seen this before?

12 REPLIES 12
BillR
Associate III

Thanks, Kevin.

I am a little confused though. That suspend interrupt handler is already where I insert the code to act as though its disconnected. 

Also I'm not sure what you mean by "changing an existing device". 

Bill

Hello @BillR​ ,

I understand that it is confused, my answer was not so clear.

Yes, you added your code to disconnect the hsotg in the existing driver usb: drivers/usb/dwc2/core_intr.c

So you modified the usb driver to behave like if it was disconnected when it is suspended.

Then you made a daemon program that periodically checks the file "/sys/class/udc/49000000.usb-otg/state".

It works and it is maybe enough for your case.

But since you asked for a proper way of doing, I think it will be better to do your own kernel module, that configures an Interrupt Service Route (ISR) for the same IRQ (GINTSTS_USBSUSP) and that notifies your daemon process with a signal when you have to stop or start you script shell. Instead of watching for a change on the file "/sys/class/udc/49000000.usb-otg/state".

Otherwise, your solution is good too :).

Regards,

Kevin

In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
BillR
Associate III

Kevin - OK, now I understand. I am not that familiar with kernel driver development and how to signal the daemon directly, but if I have some time I may look into that approach.

Thanks! Bill