USB storage can't detected - linux

I have a usb mass storage, and today I insert into usb port, the usb can't be open, I using "dmesg" to see infomation
adan#adan-Latitude-D630:~$ dmesg | tail
[ 409.001220] composite sync not supported
[ 616.340074] usb 2-1: new high-speed USB device number 5 using ehci-pci
[ 617.392967] usb 2-1: New USB device found, idVendor=090c, idProduct=3000
[ 617.392979] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 617.392987] usb 2-1: Product: SM3255AA MEMORY BAR
[ 617.392994] usb 2-1: Manufacturer: Silicon Motion,Inc.
[ 617.393558] scsi5 : usb-storage 2-1:1.0
[ 618.393265] scsi 5:0:0:0: Direct-Access USB MEMORY BAR 1000 PQ: 0 ANSI: 0 CCS
[ 618.397967] sd 5:0:0:0: Attached scsi generic sg2 type 0
[ 618.399479] sd 5:0:0:0: [sdb] Attached SCSI removable disk
On windows, the usb mass storage was be detected as USB disk drive, can't open usb in file browser too.
what's wrong with my usb? how to fix it? thank you.

Related

How I can interface a USB device that does not expose a serial interface?

I want to make a custom program that will allow me to interface a Salae Logic usb logic analyzer. So first and foremost I looked upon for any info regarding the usb in my linux box:
$ lsusb
Bus 002 Device 002: ID 05e3:0732 Genesys Logic, Inc. All-in-One Cardreader
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 002: ID 4e53:5407
Bus 001 Device 004: ID 0925:3881 Lakeview Research Saleae Logic
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Dmesg:
[ 428.549560] usb 1-6: new high-speed USB device number 4 using xhci_hcd
[ 428.697722] usb 1-6: New USB device found, idVendor=0925, idProduct=3881, bcdDevice= 0.01
[ 428.697727] usb 1-6: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Is seems that does not expose a serial device like arduino (or any other FTDI interfacing device) like modems:
[ 766.906266] usb 1-5: new full-speed USB device number 5 using xhci_hcd
[ 767.056746] usb 1-5: New USB device found, idVendor=2341, idProduct=0043, bcdDevice= 0.01
[ 767.056752] usb 1-5: New USB device strings: Mfr=1, Product=2, SerialNumber=220
[ 767.056756] usb 1-5: Manufacturer: Arduino (www.arduino.cc)
[ 767.056759] usb 1-5: SerialNumber: 7533131313335170A061
[ 767.088804] cdc_acm 1-5:1.0: ttyACM0: USB ACM device
[ 767.089110] usbcore: registered new interface driver cdc_acm
[ 767.089110] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
So supposedly I want to make a C++ (or any other language) software where I can read data from it how I can make my application to have access to a non usb-to-serial interfacing device?
I mean for an arduino I could use the POSIX open as the example shows from this link:
#include <stdio.h> /* Standard input/output definitions */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
/*
* 'open_port()' - Open serial port 1.
*
* Returns the file descriptor on success or -1 on error.
*/
int open_port(void){
int fd; /* File descriptor for the port */
fd = open("/dev/ttyACM0", O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1)
{
/*
* Could not open the port.
*/
perror("open_port: Unable to open /dev/ttyS0 - ");
} else{
fcntl(fd, F_SETFL, 0);
}
return (fd);
}
But in my case I have no such a file descriptor to begin with according to dmesg.
Normally something like this is done with libusb, at least when you are in userspace (which your question suggests you are).
USB transfers are a lot more complicated than a USB UART though, so brace yourself to deal with different endpoints, pipes, transfer modes and co

Some USB devices will automatically reconnect after I unbind it, how to disable it long time?

I'm try to disable my two USB keyboard on my linux system, the one can unbind long time until I unplug then plugin and the number lock light is off during this time. But the other one can not unbind long time, maybe after 5 seconds, it will reconnect again and the number lock light is on during this time, the other lights will flash once, the log shown below:
[505545.210490] usb 3-3.1: USB disconnect, device number 47
[505547.687005] usb 3-3.1: new low-speed USB device number 49 using xhci_hcd
[505547.984255] usb 3-3.1: New USB device found, idVendor=17ef, idProduct=6099
[505547.984258] usb 3-3.1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[505547.984260] usb 3-3.1: Product: Lenovo Traditional USB Keyboard
[505548.019948] input: Lenovo Traditional USB Keyboard as /devices/pci0000:00/0000:00:15.0/0000:03:00.0/usb3/3-3/3-3.1/3-3.1:1.0/input/input40
[505548.071999] hid-generic 0003:17EF:6099.002A: input,hidraw1: USB HID v1.10 Keyboard [Lenovo Traditional USB Keyboard] on usb-0000:03:00.0-3.1/input0
Below is my shell command to disable the keyboard:
echo "3-3.1" > /sys/bus/usb/drivers/usb/unbind
or
echo "0003:17EF:6099.002A" > /sys/bus/hid/drivers/hid-generic/unbind
What is the reason for this difference? Is have a way to disable the second keyboard?
Thank a lot

USB device enumeration fails: "device descriptor read/64, error -32"

I'm developing a ttyACM device with ST microcontroller, and with the same code, my host could sometimes enumerate it successfully (below) but sometimes it just dump the below message. What does error -32 mean?
[FAIL TO ENUMERATE]
usb 1-2.1: new full speed USB device number 62 using ehci_hcd
usb 1-2.1: device descriptor read/64, error -32
usb 1-2.1: device descriptor read/64, error -32
usb 1-2.1: new full speed USB device number 63 using ehci_hcd
usb 1-2.1: device descriptor read/64, error -32
usb 1-2.1: device descriptor read/64, error -32
usb 1-2.1: new full speed USB device number 64 using ehci_hcd
usb 1-2.1: device not accepting address 64, error -32
usb 1-2.1: new full speed USB device number 65 using ehci_hcd
usb 1-2.1: device not accepting address 65, error -32
hub 1-2:1.0: unable to enumerate USB device on port 1
[SUCCESSFUL RESULT]
usb 1-3.1: new full speed USB device number 45 using ehci_hcd
usb 1-3.1: New USB device found, idVendor=0483, idProduct=5740
usb 1-3.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-3.1: Product: ChibiOS/RT Virtual COM Port
usb 1-3.1: Manufacturer: HelloWord
usb 1-3.1: SerialNumber: 262
usb 1-3.1: configuration #1 chosen from 1 choice
cdc_acm 1-3.1:1.0: This device cannot do calls on its own. It is not a modem.
cdc_acm 1-3.1:1.0: ttyACM0: USB ACM device
Thanks a lot.
AFAIK status -32 means "Broken pipe" (EPIPE). It means that there are problems with usb communication (protocol). For example usb-device doesn't answer correctly for usb-request, and sending some data that are not expected by host or sends not enough data. There may be also other reasons.
The first message tells that there are problems with "get device descriptor" and "set address" requests from host. Those are basic requests sending by host at the very beginning of enumeration process. You can't go further if those requests cannot be succesfully serviced by usb-device.
This error can be caused by clocking the on-chip USB device at the wrong frequency. Check your clock tree configuration. The frequency should be 48MHz. If it's slightly off, it's possible that enumeration would sometimes be successful and sometimes fail. If it's way off, enumeration will always fail. Various errors are possible including the ones you listed.
I have installed the XCP-NG server in one laptop and my system was not booting either due to this error: USB 3-1 device descriptor read/64, error 32
I tried a lot of things. Even disconnecting the USB ports.
Until I recalled that I have removed the default SR repository for Xen. So I went to check the /etc/fstab file
[root#xcpserver2 ~]# cat /etc/fstab
LABEL=root-jvgtod / ext3 defaults,noatime 1 1
LABEL=swap-jvgtod swap swap defaults 0 0
LABEL=logs-jvgtod /var/log ext3 defaults,noatime 0 2
/opt/xensource/packages/iso/XenCenter.iso /var/xen/xc-install iso9660 loop,ro 0 0
The default SR repository was trying to get the content of the last line. I tried to comment it and it worked!! :) I concluded that this error it also showing when there is a problem at the /etc/fstab file. I hope it helps!
So, my /etc/fstab file looks like this now and it solved the issue:
[root#xcpserver2 ~]# cat /etc/fstab
LABEL=root-jvgtod / ext3 defaults,noatime 1 1
LABEL=swap-jvgtod swap swap defaults 0 0
LABEL=logs-jvgtod /var/log ext3 defaults,noatime 0 2
#/opt/xensource/packages/iso/XenCenter.iso /var/xen/xc-install iso9660 loop,ro 0 0

How to detect which pixel format my webcam supports?

I am writing a C application that capture video from my webcam.
I am not able to determine which pixel format my webcam is able to process.
lsusb:
Bus 002 Device 003: ID 1e4e:0100 Cubeternet WebCam
dmesg
[ 1064.735472] usb 2-1.4: new high speed USB device using ehci_hcd and address 4
[ 1064.837577] usb 2-1.4: New USB device found, idVendor=1e4e, idProduct=0100
[ 1064.837583] usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 1064.837587] usb 2-1.4: Product: USB2.0 Camera
[ 1064.837589] usb 2-1.4: Manufacturer: Etron Technologies
[ 1064.837715] usb 2-1.4: configuration #1 chosen from 1 choice
[ 1064.838484] uvcvideo: Found UVC 1.00 device USB2.0 Camera (1e4e:0100)
[ 1064.843070] uvcvideo: UVC non compliance - GET_DEF(PROBE) not supported. Enabling workaround.
[ 1064.844229] input: USB2.0 Camera as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4:1.0/input/input7
I was able to determine the image size '640x480' but not the pixel format:
I have tried
YUV420
RGB565
RGB32
with no success. Any help Please.
I am using Debian latest version
Since it is a UVC video, by looking up the wiki here:
http://www.wikiwand.com/en/USB_video_device_class
You will see that UVC supports
Uncompressed YUV formats YUY2, NV12.
Actually YUY2 is also called YUYV which is YUV 4:2:2.
You can find a conversion to RGB here:
https://bitbucket.org/neuralassembly/simplewebcam/src/a940256eda0d/jni/ImageProc.h
You can use:
v4l2-ctl --list-formats
That should give you the supported pixel formats
In addition, you can also use:
v4l2-ctl --list-formats-ext
which should give you the supported pixel formats a resolutions.

Register an user space call back function with USB driver

How to register an user space call back function with USB driver for mass storage devices in Linux?
I got follwing messages on to console when usb stick is attached.
usb 1-1: new high speed USB device using ehci_hcd and address 2
usb 1-1: Product: DataTraveler G2
usb 1-1: Manufacturer: Kingston
usb 1-1: SerialNumber: 0019E06B07F7A961877C02A9
usb 1-1: configuration #1 chosen from 1 choice
scsi0 : SCSI emulation for USB Mass Storage devices
scsi 0:0:0:0: Direct-Access Kingston DataTraveler G2 1.00 PQ: 0 ANSI: 2
SCSI device sda: 7818240 512-byte hdwr sectors (4003 MB)
sda: Write Protect is off
sda: assuming drive cache: write through
SCSI device sda: 7818240 512-byte hdwr sectors (4003 MB)
sda: Write Protect is off
sda: assuming drive cache: write through sda:sda1
sd 0:0:0:0: Attached scsi removable disk sda
sd 0:0:0:0: Attached scsi generic sg0 type 0
You could create an udev rule which executes a command when it is inserted. Basically you create a file containing a set of rules for matching, and the path to a program/script to run. It'll look something like this:
KERNEL=="sd?1", ATTRS{serial}=="0019E06B07F7A961877C02A9", RUN+="/path/to/script arg1 arg2 ... argN"
This will run /path/to/script with the arguments arg1 to argN when a device node named sd?1 is created, where ? is any character, with the serial number given in your data. You can get a lot of info from the udevinfo program to incorporate in the rule if you need better control over when it should fire. Such as if you want it to fire for all Kingston drives, for instance. Then you'd need to find the vendorID and maybe some more information unique to these drives.

Resources