Cannot open /dev/video0 (No such device) - linux

I am trying to install a webcam on a Synology NAS (arm, linux kernel 3.2.40).
I have compiled and installed the kernel modules, they seem to work. This is the kernel output when inserting the modules and plugging the camera (Logitech C270):
[ 130.963903] Linux video capture interface: v2.00
[ 136.098356] usbcore: registered new interface driver uvcvideo
[ 136.104135] USB Video Class driver (1.1.1)
[ 145.384393] usb 3-2: new high-speed USB device number 4 using etxhci_hcd_150119
[ 145.628583] uvcvideo: Found UVC 1.00 device USBDevice (046d:0825)
[ 145.726156] input: USBDevice as /devices/pci0000:00/0000:00:00.0/usb3/3-2/3-2:1.0/input/input0
This is the lsusb output:
# lsusb
libudev: udev_has_devtmpfs: name_to_handle_at on /dev: Function not implemented
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 004: ID 046d:0825 Logitech, Inc. Webcam C270
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
However, I cannot access the camera:
# v4l2-ctl --all
Failed to open /dev/video0: No such device
in strace:
open("/dev/video0", O_RDWR) = -1 ENODEV (No such device)
I have tried different camera model, the C270 on another computer (works fine), deleting /dev/video0 and re-creating it (mknod /dev/video0 c 81 0), changing permissions, etc. but I get the same error...
crw-rw-rw- 1 root video 81, 0 Jun 14 12:07 /dev/video0
lsmod shows that uvcvideo is not used for the camera:
# lsmod
Module Size Used by
uvcvideo 57657 0
videodev 72561 1 uvcvideo
usbcore 147080 7 ehci_hcd,etxhci_hcd,usb_storage,usblp,usbhid,uvcvideo
usb_common 592 1 usbcore
Any ideas?

Related

Adalm Pluto works on Ubuntu but NOT on Ubuntu Server 20.04 LTS

I'm running ubuntu server and have tried installing libiio packages from both source and apt-get repositories. I can detect the adalm pluto sdr device with iio_info -s (as root because I have not installed the udev rules) but it does not assume an ip address (e.g. 192.168.2.1) like it does on ubuntu 20.04 LTS.
>iio_info -s
Library version: 0.19 (git tag: v0.19)
Compiled with backends: local xml ip usb serial
Available contexts:
0: 0456:b673 (Analog Devices Inc. PlutoSDR (ADALM-PLUTO)), serial=104473b04a060006ffff1c00dd1f8473f8 [usb:3.2.5]
I've followed the instructions here: https://wiki.analog.com/university/tools/pluto/drivers/linux
The output of dmesg when the pluto is plugged in is this:
[380299.366375] usb 3-1: new high-speed USB device number 2 using xhci_hcd
[380299.520117] usb 3-1: New USB device found, idVendor=0456, idProduct=b673, bcdDevice= 4.19
[380299.520120] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[380299.520122] usb 3-1: Product: PlutoSDR (ADALM-PLUTO)
[380299.520123] usb 3-1: Manufacturer: Analog Devices Inc.
[380299.520124] usb 3-1: SerialNumber: 104473b04a060006ffff1c00dd1f8473f8
[380299.553556] usb-storage 3-1:1.2: USB Mass Storage device detected
[380299.555040] scsi host4: usb-storage 3-1:1.2
[380299.555206] usbcore: registered new interface driver usb-storage
[380299.555732] cdc_acm 3-1:1.3: ttyACM0: USB ACM device
[380299.558342] usbcore: registered new interface driver cdc_acm
[380299.558344] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[380299.560691] usbcore: registered new interface driver uas
[380299.569781] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[380299.570205] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[380299.574968] usbcore: registered new interface driver cdc_ether
[380299.578953] rndis_host 3-1:1.0 eth0: register 'rndis_host' at usb-0000:00:14.0-1, RNDIS device, 00:e0:22:81:0c:b6
[380299.579489] usbcore: registered new interface driver rndis_host
[380299.583238] usbcore: registered new interface driver rndis_wlan
[380299.595374] rndis_host 3-1:1.0 enx00e022810cb6: renamed from eth0
[380300.582838] scsi 4:0:0:0: Direct-Access Linux File-Stor Gadget 0419 PQ: 0 ANSI: 2
[380300.583349] sd 4:0:0:0: Attached scsi generic sg1 type 0
[380300.584030] sd 4:0:0:0: [sdb] 61441 512-byte logical blocks: (31.5 MB/30.0 MiB)
[380300.584266] sd 4:0:0:0: [sdb] Write Protect is off
[380300.584274] sd 4:0:0:0: [sdb] Mode Sense: 0f 00 00 00
[380300.584510] sd 4:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[380300.607978] sdb: sdb1
[380300.623364] sd 4:0:0:0: [sdb] Attached SCSI removable disk
This is not consistent with what the guide shows from analog devices' wiki.
I'm at a loss here as to what I'm doing wrong. The device shows up and I have the drivers and required kernel modules (I check with lsmod). Any ideas on what would make this work in ubuntu but not ubuntu server.

"failed to open this device: LIBUSB_ERROR_ACCESS" on ubuntu16.04, have tried some solutions

After searching for long time on internet I think there is no proper answer so I put up this problem. As being new here, I apology if I made any mistakes.
I have a tof camera connected to ubuntu16.04 through usb and a software to operate it. When I try to receive the image through software:
./smartTOFViewer
it gives these error repeatedly:
2018/07/06 20:27:20.297[3249948416][DBG] [dmcam_dev_open] open dmcam device # 0x7f8ab88e29c0
2018/07/06 20:27:20.297[3249948416][DBG] [_usb_ll_dev_open] create usb context
2018/07/06 20:27:20.300[3249948416][ERR] [dmcam_dev_open] open device failed!
2018/07/06 20:27:21.301[3249948416][DBG] [dmcam_dev_open] open dmcam device # 0x7f8ab88e29c0
2018/07/06 20:27:21.301[3249948416][DBG] [_usb_ll_dev_open] create usb context
2018/07/06 20:27:21.303[3249948416][ERR] [dmcam_dev_open] open device failed!
2018/07/06 20:27:22.304[3249948416][DBG] [dmcam_dev_open] open dmcam device # 0x7f8ab88e29c0
2018/07/06 20:27:22.304[3249948416][DBG] [_usb_ll_dev_open] create usb context
2018/07/06 20:27:22.307[3249948416][DBG] [_usb_ll_dev_open] found dmcam device (speed=3) # 001:002:020
2018/07/06 20:27:22.307[3249948416][WRN] [_usb_ll_dev_open] failed to open this device: LIBUSB_ERROR_ACCESS, try next ...
2018/07/06 20:27:22.308[3249948416][ERR] [dmcam_dev_open] open device failed!
but if I run this command:
sudo ./smartTOFViewer
it works normally. So I think it's a permission issue, and create a udev rule file:
sudo nano /etc/udev/rules.d/99-persistent-usb.rules
and content:
SUBSYSTEMS=="usb",ATTRS{idVendor}=="111b", \
ATTRS{idProduct}==1238",GROUP="root", OWNER="root", \
MODE="0666"
The idVendor and idProduct are checked with:
$ lsusb
Bus 001 Device 002: ID 8087:8001 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 006: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 002 Device 005: ID 8087:07dc Intel Corp.
Bus 002 Device 004: ID 064e:920b Suyin Corp.
Bus 002 Device 003: ID 046d:c530 Logitech, Inc.
Bus 002 Device 021: ID 111b:1238
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
I also tried setting something:
GROUP="dongtu" or "adm" or "usrs" or "plugdev",
OWNER="dongtu" or just removing it,
adding TAG+="uaccess",
putting in one line and remove " \"
I run this command for reload:
sudo udevadm control --reload
However, all these make no change. I observed that there is no change under /dev/ when I connect the tof, but I failed to figure out why.
I hope to do my job in anaconda with python, which means I can't use sudo in case run under system python environment. Is there any one could help me? Apologize again if I wasted your time.

GadgetFS on Allwinner H3 based linux board

I have the nanopi-neo which is an Allwinner H3 based linux board. It supports USB OTG mode so I wanted to try and convert it into slave by using GadgetFS.
From what I understand, I am supposed to rebuild the linux kernel provided by them with this option
<*> USB Gadget Drivers
<*> Gadget Filesystem
And for the rootfs use this
Package Selection for the target --->
Hardware handling --->
[*] gadgetfs-test
I then proceeded to build and boot the board.
I followed this guide and used these commands
root:/dev> mkdir /dev/gadget
root:/dev> mount -t gadgetfs gadgetfs /dev/gadget
[ 219.808688] WRN:L2558(drivers/usb/sunxi_usb/udc/sunxi_udc.c):ERR: Error in bind() : -120
[ 219.827939] nop sunxi_usb_udc: failed to start (null): -120
root:/dev> ls /dev/gadget/ -l
total 0
-rw------- 1 root root 0 Jan 1 00:03 sunxi_usb_udc
I am unable to find anything on this error. Most problems people face is regarding insmod but I have inbuilt the module inside the kernel. So I don't have this issue for sure.
I then found this post for sunxi i.e. allwinner sdk asking me to echo some values to otg_role, I did and i got this
echo 1 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role
[ 192.310934] sunxi-ehci sunxi-ehci.1: remove, state 4
[ 192.326666] usb usb1: USB disconnect, device number 1
[ 192.343775] sunxi-ehci sunxi-ehci.1: USB bus 1 deregistered
[ 192.370300] sunxi-ohci sunxi-ohci.1: remove, state 4
[ 192.385941] usb usb5: USB disconnect, device number 1
[ 192.402761] sunxi-ohci sunxi-ohci.1: USB bus 5 deregistered
[ 192.444442] sunxi-ehci sunxi-ehci.1: SW USB2.0 'Enhanced' Host Controller (EHCI) Driver
[ 192.458113] sunxi-ehci sunxi-ehci.1: new USB bus registered, assigned bus number 1
[ 192.471720] sunxi-ehci sunxi-ehci.1: irq 104, io mem 0xf1c1a000
[ 192.500050] sunxi-ehci sunxi-ehci.1: USB 0.0 started, EHCI 1.00
[ 192.511581] hub 1-0:1.0: USB hub found
[ 192.519996] hub 1-0:1.0: 1 port detected
[ 192.548993] sunxi-ohci sunxi-ohci.1: SW USB2.0 'Open' Host Controller (OHCI) Driver
[ 192.561898] sunxi-ohci sunxi-ohci.1: new USB bus registered, assigned bus number 5
[ 192.574365] sunxi-ohci sunxi-ohci.1: irq 105, io mem 0xf1c1a400
[ 192.644522] hub 5-0:1.0: USB hub found
[ 192.652612] hub 5-0:1.0: 1 port detected
root#kyloren:/$ # echo 2 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role
[ 195.940888] sunxi-ehci sunxi-ehci.1: remove, state 4
[ 195.956330] usb usb1: USB disconnect, device number 1
[ 195.976521] sunxi-ehci sunxi-ehci.1: USB bus 1 deregistered
[ 195.997477] sunxi-ohci sunxi-ohci.1: remove, state 4
[ 196.007624] usb usb5: USB disconnect, device number 1
[ 196.018520] sunxi-ohci sunxi-ohci.1: USB bus 5 deregistered
And I try to mount again but I get the same error.
Can someone guide me on this?
Sometime much later ...
The short answer is you are missing the usermode component which actually instantiates the USB endpoints and handles setup and control requests.
An example of such a beast is to be found in 3 parts, links below.
The long version:
To use the H3 board as a device, you need to modprobe gadgetfs, create a directory mkdir -p /dev/gadget, and then mount the device into that directory with mount -t gadgetfs gadgetfs /dev/gadget.
Finally enable the device role with echo 2 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role.
You will need to add the following to the autoconfig() function in usb.c as that code way predates AllWinner's very existence.
Once the usermode app (usb) is built, simply run it as sudo usb -v for verbose mode. If you are correctly plugged and powered your device should now show up on the host with 2 bulk endpoints and a single interrupt EP.
If you are trying to use mainline you will need to change the name of the controller in the code below (found in /dev/gadget) and add the right spell to the DTS file. Good luck with that as I've yet to get 4.11 to work in device mode on my NanoPi M1 and NanoPi Neo Air boards.
Hope this very belated is of use to someone at some point!
if (stat(DEVNAME = "sunxi_usb_udc", &statb) == 0)
{
HIGHSPEED = 1;
fs_source_desc.bEndpointAddress = hs_source_desc.bEndpointAddress = USB_DIR_IN | 1;
EP_IN_NAME = "ep1in-bulk";
fs_sink_desc.bEndpointAddress = hs_sink_desc.bEndpointAddress = USB_DIR_OUT | 1;
EP_OUT_NAME = "ep1out-bulk";
source_sink_intf.bNumEndpoints = 3;
fs_status_desc.bEndpointAddress = hs_status_desc.bEndpointAddress = USB_DIR_IN | 2;
EP_STATUS_NAME = "ep2in-interrupt";
}
Main usermode driver
USB descriptor strings
Header file for the above

How to configure embedded-linux USB?

Why doesn't this correctly configure file_storage device USB?
On the embedded-linux target:
/ # modprobe g_file_storage file=/dev/mmcblk0
musb_hdrc: version 6.0, cppi-dma, peripheral, debug=0
musb_hdrc: USB Peripheral mode controller at fec64000 using DMA, IRQ 12
g_file_storage gadget: File-backed Storage Gadget, version: 20 November 2008
g_file_storage gadget: Number of LUNs=1
g_file_storage gadget-lun0: ro=0, file: /dev/mmcblk0
/ # lsusb
lsusb: /sys/bus/usb/devices: No such file or directory
/ # cat /lib/modules/2.6.32-17-ridgerun/modules.dep | grep usb
kernel/drivers/usb/otg/nop-usb-xceiv.ko:
kernel/drivers/usb/musb/musb_hdrc.ko: kernel/drivers/usb/otg/nop-usb-xceiv.ko
kernel/drivers/usb/gadget/g_file_storage.ko: kernel/drivers/usb/musb/musb_hdrc.ko kernel/drivers/usb/otg/nop-usb-xceiv.ko
On the Ubuntu 10.04 host:
$ fgrep USB $DEVDIR/kernel/linux*/.config | grep -v '^#'
CONFIG_USB_SUPPORT=y
CONFIG_USB_ARCH_HAS_HCD=y
CONFIG_USB_MUSB_HDRC=m
CONFIG_USB_MUSB_SOC=y
CONFIG_USB_MUSB_PERIPHERAL=y
CONFIG_USB_GADGET_MUSB_HDRC=y
CONFIG_USB_TI_CPPI_DMA=y
CONFIG_USB_GADGET=m
CONFIG_USB_GADGET_VBUS_DRAW=2
CONFIG_USB_GADGET_SELECTED=y
CONFIG_USB_GADGET_DUALSPEED=y
CONFIG_USB_FILE_STORAGE=m
CONFIG_USB_OTG_UTILS=y
CONFIG_NOP_USB_XCEIV=m
$ lsusb
Bus 002 Device 003: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 002 Device 002: ID 8087:0024
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 005: ID 058f:6362 Alcor Micro Corp. Hi-Speed 21-in-1 Flash Card Reader/Writer (Internal/External)
Bus 001 Device 004: ID 04ca:003a Lite-On Technology Corp.
Needed usb_composite_msd_acm.patch (solved with help from RidgeRun).

Hacking USB devices: Any programs out there?

I would like to (A) run something under windows to eavesdrop on the communication between a USB device and windows, so I can then (B) write something to communicate with the USB device, under Linux. Can anybody recommend a program to do (A)?
Your best bet for watching USB traffic on Windows is Snoopy Pro which is based on USB Snoopy.
Once you move over to implementing your driver for Linux, you will want to make sure that usbmon is enabled in your kernel so you can get at the same information on your Linux box.
Make sure your kernel includes the necessary components:
$ cat /boot/config-`uname -r` | grep -P "CONFIG_USB_(MON|DEVICEFS)
CONFIG_USB_DEVICEFS=y
CONFIG_USB_MON=y
Mount the usbmon file system and make sure there is stuff in the usbmon directory:
$ sudo mount -t debugfs none_debugs /sys/kernel/debug
$ ls /sys/kernel/debug/usbmon/
0s 0u 1s 1t 1u 2s 2t 2u 3s 3t 3u 4s 4t 4u 5s 5t 5u 6s 6t 6u
Use lsusb to find the bus number of the device you are interested in:
$ lsusb
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 002: ID 045e:00d1 Microsoft Corp. Optical Mouse with Tilt Wheel
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 0a5c:2110 Broadcom Corp. Bluetooth Controller
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Start listening on the bus of your choice (I am listening on bus 4 below):
$ sudo cat /sys/kernel/debug/usbmon/4u > ~/Desktop/usbmon.txt
Stop collecting data with Control-C.
You can try:
usbsnoop
and
usbsnoopy
usbmon: http://biot.com/blog/usb-sniffing-on-linux

Resources