OpenWrt Forum Archive

Topic: SOLVED - Rebooting with usb camera

The content of this topic has been archived on 29 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

One problem with using a mini router with a usb camera remotely is that the camera seems to have to be unplugged and reconnected every time the router starts in order for the driver to be seen.

Meaning,

# ls /dev/video*
shows nothing until I unplug then reconnect the usb camera.

# ls /dev/video*
/dev/video0

The question is, how can I change this behavior so that I can use this remotely without having to reconnect each time?

(Last edited by projects on 30 Mar 2018, 23:45)

Have you already tried usbreset?
Is the camera connected directly or via hub?

No, I didn't find anything like usbreset when looking around for a solution. Sounds like I would just need to put that into the rc.local as well.

For now, the camera is usually always connected directly.
I'm trying to find a way to use a PTZ camera as well at some point which would probably mean having to use a 2-3 port usb hub.

I lost track of which condition causes me to have to reconnect the camera but I was testing before installing the package you mentioned and now it works.

Rebooting I can reach the camera by refreshing the browser window.
Power down and back up, same thing.

What ever the case may be, sounds like your suggestion would take care of the problem so thanks very much for that.

(Last edited by projects on 18 Mar 2018, 21:50)

I know why I lost track now, there is no consistency. It works, then it just stops and sometimes I can get it going again, other times not. I'm at a case where not is happening.

I ran usbreset before the camera died so that I'd know what to use for reset values.

# ls -la /dev/video*
crw-r--r--    1 root     root       81,   0 Mar 19 21:03 /dev/video0
# usbreset
Usage:
  usbreset PPPP:VVVV - reset by product and vendor id
  usbreset BBB/DDD   - reset by bus and device number
  usbreset "Product" - reset by product name

Devices:
  Number 001/002  ID 045e:076f  Microsoft® LifeCam HD-6000 for Notebooks

When the camera died, I tried the following but nothing works.

# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

# usbreset 001/002
No such device found

# usbreset 045e:076f
No such device found

After rebooting the device remotely, nothing works. usbreset shows nothing what so ever, restarting mjpeg leads to 'no /dev/video' etc. What the heck am I missing?

(Last edited by projects on 19 Mar 2018, 22:27)

What's in the logs when the camera disconnects?

Hey, I was able to get the following.

Mon Mar 19 22:33:54 2018 user.info MJPG-streamer [1204]: serving client: 192.168.1.205
Mon Mar 19 22:38:22 2018 kern.err kernel: [  506.880000] usb usb1-port1: disabled by hub (EMI?), re-enabling...
Mon Mar 19 22:38:22 2018 kern.info kernel: [  506.890000] usb 1-1: USB disconnect, device number 2
Mon Mar 19 22:38:22 2018 kern.err kernel: [  506.900000] uvcvideo: Failed to resubmit video URB (-19).
Mon Mar 19 22:38:22 2018 kern.err kernel: [  506.900000] uvcvideo: Failed to resubmit video URB (-19).
Mon Mar 19 22:38:22 2018 kern.err kernel: [  506.910000] uvcvideo: Failed to resubmit video URB (-19).
Mon Mar 19 22:38:22 2018 kern.err kernel: [  506.910000] uvcvideo: Failed to resubmit video URB (-19).
Mon Mar 19 22:38:22 2018 kern.err kernel: [  506.920000] uvcvideo: Failed to resubmit video URB (-19).
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.010000] ------------[ cut here ]------------
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.020000] WARNING: CPU: 0 PID: 1990 at drivers/media/v4l2-core/videobuf2-core.c:2135 vb2_queue_init+0x468/0xc50 [videobuf2_core]()
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.030000] Modules linked in: rt2800soc rt2800pci rt2800mmio rt2800lib nf_nat_ipv4 nf_conntrack_ipv4 ip_tables x_tables uvcvideo rt2x00soc rt2x00pci rt2x00mmio rt2x00lib nf_nat_ftp nf_nat nf_defrag_ipv4 nf_conntrack_rtcache nf_conntrack_ftp nf_conntrack input_core crc_itu_t crc_ccitt videobuf2_vmalloc videobuf2_memops videobuf2_core v4l2_common videodev i2c_dev i2c_core mt76x2e mt76 mac80211 cfg80211 compat eeprom_93cx6 dma_shared_buffer arc4 crypto_blkcipher Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.080000] CPU: 0 PID: 1990 Comm: mjpg_streamer Not tainted 3.18.27 #10
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.090000] Stack : 00000000 00000000 00000000 00000000 803741f2 0000003c 00000000 831b96cc
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.090000]         00000001 8326f828 802cf8b4 80328b83 000007c6 80373420 83008248 8326f828
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.090000]         80330000 80320000 802d2014 80047800 00000003 800243e8 00000857 8326f828
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.090000]         802d2dcc 8324dbec 00000000 00000000 00000000 00000000 00000000 00000000
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.090000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.090000]         ...
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.120000] Call Trace:
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.120000] [<80014230>] show_stack+0x50/0x84
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.130000] [<800244f0>] warn_slowpath_common+0x84/0xb4
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.130000] [<800245a8>] warn_slowpath_null+0x18/0x24
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.140000] [<831b96cc>] vb2_queue_init+0x468/0xc50 [videobuf2_core]
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.150000]
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.150000] ---[ end trace 89c983255ce2dae5 ]---
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.150000] ------------[ cut here ]------------
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.160000] WARNING: CPU: 0 PID: 1990 at fs/sysfs/group.c:219 sysfs_remove_group+0x60/0xbc()
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.170000] sysfs group 83bbd6cc not found for kobject 'input0'
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.170000] Modules linked in: rt2800soc rt2800pci rt2800mmio rt2800lib nf_nat_ipv4 nf_conntrack_ipv4 ip_tables x_tables uvcvideo rt2x00soc rt2x00pci rt2x00mmio rt2x00lib nf_nat_ftp nf_nat nf_defrag_ipv4 nf_conntrack_rtcache nf_conntrack_ftp nf_conntrack input_core crc_itu_t crc_ccitt videobuf2_vmalloc videobuf2_memops videobuf2_core v4l2_common videodev i2c_dev i2c_core mt76x2e mt76 mac80211 cfg80211 compat eeprom_93cx6 dma_shared_buffer arc4 crypto_blkcipher Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.220000] CPU: 0 PID: 1990 Comm: mjpg_streamer Tainted: G        W      3.18.27 #10
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.230000] Stack : 00000000 00000000 00000000 00000000 803741f2 00000049 00000000 800f6688
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.230000]         00000001 8326f828 802cf8b4 80328b83 000007c6 80373420 83008248 8326f828
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.230000]         80330000 80320000 802d2014 80047800 00000003 80024374 000000db 8326f828
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.230000]         802d2dcc 8324db54 00000000 00000000 00000000 00000000 00000000 00000000
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.230000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.230000]         ...
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.270000] Call Trace:
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.270000] [<80014230>] show_stack+0x50/0x84
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.280000] [<800244f0>] warn_slowpath_common+0x84/0xb4
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.280000] [<8002454c>] warn_slowpath_fmt+0x2c/0x38
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.290000] [<800f6688>] sysfs_remove_group+0x60/0xbc
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.290000] [<800f671c>] sysfs_remove_groups+0x38/0x54
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.300000] [<801997d8>] device_remove_attrs+0x54/0x94
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.300000] [<8019a6ec>] device_del+0x108/0x18c
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.310000] [<83bbb068>] input_unregister_device+0x68/0x610 [input_core]
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.310000] [<830c0310>] 0x830c0310
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.320000]
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.320000] ---[ end trace 89c983255ce2dae6 ]---
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.320000] ------------[ cut here ]------------
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.330000] WARNING: CPU: 0 PID: 1990 at fs/sysfs/group.c:219 sysfs_remove_group+0x60/0xbc()
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.340000] sysfs group 83bbd604 not found for kobject 'input0'
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.340000] Modules linked in: rt2800soc rt2800pci rt2800mmio rt2800lib nf_nat_ipv4 nf_conntrack_ipv4 ip_tables x_tables uvcvideo rt2x00soc rt2x00pci rt2x00mmio rt2x00lib nf_nat_ftp nf_nat nf_defrag_ipv4 nf_conntrack_rtcache nf_conntrack_ftp nf_conntrack input_core crc_itu_t crc_ccitt videobuf2_vmalloc videobuf2_memops videobuf2_core v4l2_common videodev i2c_dev i2c_core mt76x2e mt76 mac80211 cfg80211 compat eeprom_93cx6 dma_shared_buffer arc4 crypto_blkcipher Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.390000] CPU: 0 PID: 1990 Comm: mjpg_streamer Tainted: G        W      3.18.27 #10
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.400000] Stack : 00000000 00000000 00000000 00000000 803741f2 00000049 00000000 800f6688
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.400000]         00000001 8326f828 802cf8b4 80328b83 000007c6 80373420 83008248 8326f828
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.400000]         80330000 80320000 802d2014 80047800 00000003 80024374 000000db 8326f828
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.400000]         802d2dcc 8324db54 00000000 00000000 00000000 00000000 00000000 00000000
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.400000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.400000]         ...
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.440000] Call Trace:
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.440000] [<80014230>] show_stack+0x50/0x84
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.440000] [<800244f0>] warn_slowpath_common+0x84/0xb4
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.450000] [<8002454c>] warn_slowpath_fmt+0x2c/0x38
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.450000] [<800f6688>] sysfs_remove_group+0x60/0xbc
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.460000] [<800f671c>] sysfs_remove_groups+0x38/0x54
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.460000] [<801997d8>] device_remove_attrs+0x54/0x94
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.470000] [<8019a6ec>] device_del+0x108/0x18c
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.470000] [<83bbb068>] input_unregister_device+0x68/0x610 [input_core]
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.480000] [<830c0310>] 0x830c0310
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.490000]
Mon Mar 19 22:38:22 2018 kern.warn kernel: [  507.490000] ---[ end trace 89c983255ce2dae7 ]---

(Last edited by projects on 19 Mar 2018, 23:40)

I'm running the camera at 1280x720 and 25fps. Maybe it's killing the CPU?

EDIT: Nope, I had nothing else running and the CPU usage was next to nothing and it died while watching.

(Last edited by projects on 19 Mar 2018, 23:40)

Now running the exact same setup on a tp-link as well.

So far, the tp-link has been up since I last posted, the video has not crashed once.

I'm starting to think it might be the camera, maybe the resolution size.
The tp-link camera is the one that was running on the gl-inet which kept crashing and is a 1280x720 microsoft lifecam.
I have a lower res lifecam now running on the gl-inet which has yet to crash.

I have been digging deep down in my notes from back then when I had quite a number of usb webcams and other stuff on my DIR-505 (years ago...).

I found the same error, but didn't note a solution:

[131561.730000] hub 1-1.4.1.3:1.0: port 5 disabled by hub (EMI?), re-enabling...
[131561.740000] usb 1-1.4.1.3.5: USB disconnect, device number 69
[131561.750000] uvcvideo: Failed to resubmit video URB (-19).

I remembered that I also had problems with a pl2303 usb adapter:

[917031.130000] hub 1-1:1.0: port 3 disabled by hub (EMI?), re-enabling...
[917031.140000] usb 1-1.3: USB disconnect, device number 4
[917031.140000] usb 1-1.3: pl2303_read_int_callback - usb_submit_urb failed with result -19
[917031.150000] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0

Solution for this: usbreset the hub the pl2303 is connected to, not the device itself.
I scripted this to be done up to 3 times in a row, since sometimes 1x or 2x would not suffice.
I only needed to do this at startup. Once it was running, it was running, IIRC.



How to reset an usb hub (Example from my notes; adapt to your situation)

First, lookup the bus + device number of the hub, to which the cams are connected. In this case, our cams are connected to the hubs at Bus/Dev 001/052 and 001/053.

root@DIR-505:~# lsusb -t -v
Bus#  1
`-Dev#   1 Vendor 0x1d6b Product 0x0002 Linux Foundation 2.0 root hub
  `-Dev#   2 Vendor 0x05e3 Product 0x0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
    `-Dev#  50 Vendor 0x05e3 Product 0x0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
      |-Dev#  51 Vendor 0x04a9 Product 0x3110 Canon, Inc. EOS Digital Rebel XTi
      |-Dev#  52 Vendor 0x05e3 Product 0x0608 Genesys Logic, Inc. USB-2.0 4-Port HUB                             <--- the 1st hub we want to reset
      | |-Dev#  66 Vendor 0x04fa Product 0x2490 Dallas Semiconductor DS1490F 2-in-1 Fob, 1-Wire adapter
      | |-Dev#  67 Vendor 0x046d Product 0x0821 Logitech, Inc. HD Webcam C910                                      <--- cam #1
      | |-Dev#  68 Vendor 0x046d Product 0x0994 Logitech, Inc. QuickCam Orbit/Sphere AF                            <--- cam #2
      | `-Dev#  69 Vendor 0x046d Product 0x0825 Logitech, Inc. Webcam C270                                         <--- cam #3
      `-Dev#  53 Vendor 0x05e3 Product 0x0608 Genesys Logic, Inc. USB-2.0 4-Port HUB                             <--- the 2nd hub we want to reset
        |-Dev#  62 Vendor 0x045e Product 0x076d Microsoft Corp. LifeCam HD-5000                                    <--- cam #4
        |-Dev#  63 Vendor 0x0403 Product 0x6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
        |-Dev#  64 Vendor 0x0458 Product 0x708c KYE Systems Corp. (Mouse Systems)                                  <--- cam #5
        `-Dev#  65 Vendor 0x046d Product 0x0809 Logitech, Inc. Webcam Pro 9000                                     <--- cam #6

Now you can reset the hubs by issuing the usbreset command, followed by bus/device number:

usbreset 001/052
usbreset 001/053


Last but not least: When you try to usbreset the cam (not the hub) via VID:PID, try it just the other way round, ie.

usbreset 076f:045e

(Last edited by tmo26 on 21 Mar 2018, 00:15)

Ok so, I've been doing it right then.

Yes, I had done both using usbreset and nothing.

Once the camera is gone, the only way to get it back is to reboot the router with the camera disconnected, once the router is up, reconnect it.

Interestingly, the cameras have been up all day long without issue so far. The gl-inet has not once lost the camera which is why I wonder about the resolution or something to do with that particular camera.

Just to be sure: The camera is connected to the router with an additional USB hub (not the hub inside the router)?

No, the camera is connected directly, no hub between it and the router.
Interestingly, it has worked perfectly on tp-link since I posted about testing that.

I'm going to try another higher resolution lifecam on the gl-inet later to see what would happen.

(Last edited by projects on 23 Mar 2018, 23:22)

By the way, the camera has a microphone. Can audio be transmitted too?

The mysteries continue as mjpeg keeps dying.

Tue Mar 27 15:58:17 2018 user.info MJPG-streamer [4651]: starting application
Tue Mar 27 15:58:17 2018 user.info MJPG-streamer [4651]: MJPG Streamer Version: svn rev: exported
Tue Mar 27 15:58:17 2018 user.info MJPG-streamer [4651]: Using V4L2 device.: /dev/video0
Tue Mar 27 15:58:17 2018 user.info MJPG-streamer [4651]: Desired Resolution: 1680 x 1050
Tue Mar 27 15:58:17 2018 user.info MJPG-streamer [4651]: Frames Per Second.: 30
Tue Mar 27 15:58:17 2018 user.info MJPG-streamer [4651]: Format............: JPEG
Tue Mar 27 15:58:17 2018 user.info MJPG-streamer [4651]: TV-Norm...........: DEFAULT
Tue Mar 27 15:58:17 2018 user.info MJPG-streamer [4651]: init_VideoIn failed

It crashed after a few hours at 1920x1080, worked for many days at 1680x1050 and is now down to 1280x720.

So far, lowering the resolution has worked. I've kept the frame rate at 30fps so that I'm pushing it a little.
In the end, it seems to only mean that the device is not able to handle the load so need something a little
better.

Thanks for the leads above, I'll take a look at those. I think this is a solved mystery smile

Darn, usbreset doesn't seem to work in some cases. For one, the device is now remote so I can reconnect the camera.
For two, I changed the camera to a LifeCam Studio and didn't make a note of the product.

Now I've lost access and /dev/video is no longer found and no way to reset.

logread

Sun Apr  1 18:04:31 2018 kern.err kernel: [   93.110000] usb 1-1: device not accepting address 5, error -145
Sun Apr  1 18:04:31 2018 kern.err kernel: [   93.110000] usb usb1-port1: unable to enumerate USB device

(Last edited by projects on 1 Apr 2018, 19:06)

I guess I had made a note of the new camera.

# usbreset
Usage:
  usbreset PPPP:VVVV - reset by product and vendor id
  usbreset BBB/DDD   - reset by bus and device number
  usbreset "Product" - reset by product name

Devices:
  Number 001/006  ID 045e:0772  Microsoft® LifeCam Studio(TM)

If it helps anyone since I didn't find anything for this particular camera.

Oh, forgot to update that absolutely, knowing the device ID does let me use usbreset to reset the camera from remote.

The discussion might have continued from here.