[SOLVED] USB device 'reset' trouble

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
jerson
Level 3
Level 3
Posts: 154
Joined: Thu Dec 08, 2016 1:19 pm
Location: Bombay, India

[SOLVED] USB device 'reset' trouble

Post by jerson » Wed Aug 29, 2018 12:43 am

Greetings

I have now been using mint for almost 3 years. As an embedded systems coder, I have to use various USB devices as IC flashing tools. Now, I have run into a peculiar problem that I have managed to narrow down to the Linux system.

There is a device programmer that is detected well and shows up in 'lsusb'. It can be connected to a VM guest and used correctly. However, upgrading the firmware of the same device programmer to its newer version causes a USB device error in the VM guest. Investigating further, I decided to check if I could perform a USBreset of the device from the mint command line.

I use this attached code

Code: Select all

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

#include <linux/usbdevice_fs.h>


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

    if (argc != 2) {
        fprintf(stderr, "Usage: usbreset device-filename\n");
        return 1;
    }
    filename = argv[1];

    fd = open(filename, O_WRONLY);
    if (fd < 0) {
        perror("Error opening output file");
        return 1;
    }

    printf("Resetting USB device %s\n", filename);
    rc = ioctl(fd, USBDEVFS_RESET, 0);
    if (rc < 0) {
        perror("Error in ioctl");
        return 1;
    }
    printf("Reset successful\n");

    close(fd);
    return 0;
}
What I found is that when the usb reset command is run, the program returns with a message
Resetting USB device /dev/bus/usb/003/012
Error in ioctl: No such device
There are other devices that fall in the same category. These fail when the reset command goes out to the device.

I need help to find out how this can be fixed. It is definitely an issue with the underlying USB sources of mint
Last edited by jerson on Fri Oct 19, 2018 10:28 am, edited 1 time in total.
Regards
Jerson

jerson
Level 3
Level 3
Posts: 154
Joined: Thu Dec 08, 2016 1:19 pm
Location: Bombay, India

Re: USB device 'reset' trouble

Post by jerson » Wed Aug 29, 2018 12:55 am

Sorry, forgot to add that the same devices work well natively under Windows without any errors.
Regards
Jerson

jerson
Level 3
Level 3
Posts: 154
Joined: Thu Dec 08, 2016 1:19 pm
Location: Bombay, India

Re: USB device 'reset' trouble

Post by jerson » Wed Oct 10, 2018 4:21 am

Greetings all

Realized that the specific device support under linux itself is suspect. If I command a reset to the device, it comes back with a IOCTL failure.

Question is - where do I ask this question so as to find a resolution to the problem?

Is this issue generic to all linux or only to LMint?
usbproblem.jpg
Regards
Jerson

jerson
Level 3
Level 3
Posts: 154
Joined: Thu Dec 08, 2016 1:19 pm
Location: Bombay, India

Re: USB device 'reset' trouble

Post by jerson » Thu Oct 11, 2018 7:50 am

Just to be sure, it is not the OS which is creating the issue, perhaps the underlying hardware which is not supported, I tried Lubuntu 18.04 LiveCD running kernel 4.15.0-20 generic. The same device can be reset using the usbreset executable without any errors.

This problem seems specific to LM versions using kernel 4.4, 4.9. :| Will changing the kernel help?
Regards
Jerson

jerson
Level 3
Level 3
Posts: 154
Joined: Thu Dec 08, 2016 1:19 pm
Location: Bombay, India

[SOLVED]Re: USB device 'reset' trouble

Post by jerson » Fri Oct 19, 2018 10:28 am

Update. I've been able to fix the trouble by updating to the 4.15.20 kernel which worked in Lubuntu.
Regards
Jerson

Post Reply

Return to “Newbie Questions”