This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM3352: How to restart USB interface

Part Number: AM3352

Tool/software: Linux

Hi!

I have experienced annoying problem with a am3352 based Linux (4.4.41) board working behind modem connection.  Modem firmware seems crashing frequently when connection field or bandwidth is low. Usually modem firmware crash triggers udev to reload usb drivers that re-builds the connection, but not always. Therefore, I do have a connection monitor observing connection periodically (10 minute period). If remote connection is missing, monitor sequences USB power using /sys/kernel/debug/musb-hdrc.YY.auto/softconnect interface. Usually this triggers udev and recovers modem connection, but not always. Therefore, monitor boots the card if connection has been lost for two hours. However, booting disturbs the the operation - all the processing starts from scratch. Most likely this randomly crashing modem crashes random modules. So, something close to kernel gets broken when power sequencing does not help anymore. This is shown from the logs that "new high-speed USB device number XX using musb-hdrc" does not appear anymore after power sequencing. Most likely some usb driver has been frozen - but it's impossible to pinpoint the guilty one? Therefore, whole usb interface should be re-started.

I have studied re-starting usb interface. I tried removing all the usb drivers and reloading them with following sequence:

a) Switch off usb power ( some usb drivers can't be removed otherwise)

b) Remove usb drivers (modprobe -r ...)

c) Reload usb drivers

d) Switch usb power on

The problem with d) is that removing usb driver removes also /sys/kernel/debug/musb-hdrc.YY.auto/softconnect that is not recovered in c).

So, my question are:

1) Is there any simple method reloading usb interface without rebooting card?

2) If not, how can I reload this /sys/kernel/debug/.... interface so that I could follow the sequence above?

Thanks,

Matti

  • Hi Matti,

    I suggest you the simplest software way to reset a USB device with the following commands:

    cd /sys/bus/usb/devices/

    echo 0 > 1-1.2/authorized

    echo 1 > 1-1.2/authorized

    If you are not sure about your USB device id (your modem) you could unplug and plug it and you will see some debug messages on the console like:

    usb 1-1.2: new low-speed USB device number 3 using xhci-hcd

    .......

    This will help you to find your modem id (1-1.2 for example).

    BR

    Tsvetolin Shulev

  • Thank you for your suggestion Tsvetolin.
    I experimented it with one card on my desk. I'm afraid that the problem with that method is that modem firmware may drop any time at all. When it drops, all the kernel structures this method requires are destroyed and connection can't be reseted. I could try it before driving usb power down that also destroys the structures needed by this. To repeat, the main problem really is that sometimes modem does not get enumerated anymore after power sequencing. So, either udev is confused or some kernel driver is too confused for providing event to udev or both. As booting helps I tried to get only usb interface "booted". Unfortunately it seems that I loose kernel/debug connection for controlling usb power when I simulate this usb-only boot by removing and inserting usb modules again.
    My kernel has CONFIG_DEBUG_FS set with "compiled to kernel" option, so I can't reload it and I don't know if it is possible to compile it as loadable module.
    Cheers,
    Matti
  • It's somewhat confusing, but kernel module needed to reload to get sysfs interface : /sys/kernel/debug/musb-hdrc.YY.auto/softconnect is musb_dsps that is child of musb_hdrc. Above interface gets created, power usb power switched on and modem enumerated after loading musb_dsps.
  • So, this was needed to get usb interface reloaded.