2
votes

I want to restart USB modem like a power on restart without rebooting and unplugging it physically in Linux machine. I have tried doing this procedure :

  • echo -n 0 > /sys/devices/platform/omap/ti81xx-usbss/musb-hdrc.0/usb1/bConfigurationValue
  • echo -n 1 > /sys/devices/platform/omap/ti81xx-usbss/musb-hdrc.0/usb1/bConfigurationValue

But i was only able to disconnect it but the 2nd command failed. Giving the following prints :

hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
usb 1-1: new full speed USB device using musb-hdrc and address 4
usb 1-1: device descriptor read/64, error -19
usb 1-1: device descriptor read/64, error -19
usb 1-1: new full speed USB device using musb-hdrc and address 5
usb 1-1: device descriptor read/64, error -19
usb 1-1: device descriptor read/64, error -19
usb 1-1: new full speed USB device using musb-hdrc and address 6
usb 1-1: device not accepting address 6, error -19
usb 1-1: new full speed USB device using musb-hdrc and address 7
usb 1-1: device not accepting address 7, error -19
hub 1-0:1.0: unable to enumerate USB device on port 1

Is there any way in which I can automate this resetting procedure. Such that if I insmod a module, it should register the USB device and when I rmmod a module it shall disconnect the USB device.

Is there any such Module ?

1
What do you mean by "reset"? That seems to be a different question than "disconnect/reconnect" and may refer to restarting the device as a power-on reset, disconnecting the remote connection, or re-enumerating the USB device. What are you actually trying to retrieve? My answer was going to be toggle the DTR; but I am not sure what you are asking. - Clifford
Thank u for replying. I mean to restart a USB modem/port like power-on reset. without reboot and without unplugging the device. - swapneel mashalkar
How would that be related to embedded systems? - too honest for this site
You should clarify the question by editing the question rather than by commenting. Your comment however is no clearer; looks like an XY problem - you have perhaps invented a solution to your real problem and made the problem one of how to implement your solution; ask about the real problem. - Clifford

1 Answers

0
votes

This is like any other interface where you want to shutdown/no-shutdown on an interface administratively.

#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/usbdevice_fs.h>

void main(int argc, char **argv)
{
    const char *filename;
    int fd;

     filename = argv[1];
    fd = open(filename, O_WRONLY);
    ioctl(fd, USBDEVFS_RESET, 0);
    close(fd);
    return;
}

Compile the code:

$ gcc -o usb-reset usb-reset.c

I have Arduino connected to my ubuntu machine at /dev/ttyACM0, i will try to reset Arduino in the following way:

sudo ./usb-reset /dev/ttyACM0

This reset the board!