Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old August 30th, 2006   #1
vodunvibe
First Cup of Ubuntu
 
vodunvibe's Avatar
 
Join Date: Aug 2006
Beans: 7
Ubuntu 6.06
Post Howto Fix the “No space left on device” error message and Install the Spca5xx driver

Spca5xx
The spca5xx driver included in the Dapper Drake (6.06) Ubuntu kernel works out of the box for most people, as it has been the case for myself until recently when I tried using my Webcam on an my other computers.

Unfortunately for some, trying to use their camera with the spca5xx driver when other USB devices are present on the same host controller bus as the camera, the following error appear:
No space left on device
can't open /dev/video0: No space left on device.


I have a Logitech QuickCam Communicate STX and an hp USB Multimedia Cordless Kit with a wireless keyboard and wireless mouse connected to the same host controller as my camera which. I also had the same error message as a result of this configuration.

The spca5xx driver supports a variety of cameras. For a full list of supported cameras, take a look at http://mxhaard.free.fr/spca5xx.html

Problem
When other USB devices are present on the same host controller bus as the camera, the bandwidth requirements of the spca5xx driver are not being met, with some hardware configurations. The spca5xx driver is asking for more bandwidth than is available which results in the following error messages:

No space left on device
can't open /dev/video0: No space left on device.


There is a very good howto for the Spca5xx driver at https://help.ubuntu.com/community/Spca5xx
if you haven't encountered the “No space left on device” error message.

Solutions
There are multiple solutions which will work depending on your hardware configuration.
Please be advised that it is best to connect the camera directly to the motherboard and not use a USB HUB.

The only solution which worked in my particular situation, was to dig into the spca5xx source code (spca5xx-20060501) and modify it by adding a fix, due to the fact that no matter which USB port I used, my camera always appeared on the same host controller bus as my USB keyboard and mouse.

If you've already unsuccessfully shuffled your USB devices from port to port, you might want to skip ahead to Solution 2 and compile and install the modified spca5xx source code.
  1. Solution 1 - Put the camera on a separate USB host controller bus.
  2. Solution 2 - Compile and install the modified spca5xx source code.
  3. Solution 3 - Buy an separate USB controller card. (This is a last resort solution which I wanted to avoid at all cost.)

Solution 1 - Put the camera on a separate USB host controller bus
Try to put the camera on a separate USB host controller bus with no other devices on it.
(Assuming you don't have a USB keyboard and USB mouse. If you do skip to the next section)
  1. Unplug all other USB devices from your computer, leaving only the camera.
  2. If the camera works, then you need to figure out which USB ports are connected to which controller. You need to use your other USB devices after all. Experiment by connecting your other USB devices one by one to another USB port and see if the camera still works. If the camera stops working after connecting a device it means that the port you just used is on the same USB host controller bus as you camera.
  3. If after trying different combination of USB ports, you are not successful, try one of the following solutions.

Solution 1 - Put the camera on a separate USB host controller bus (USB keyboard and USB mouse)
Try to put the camera on a separate USB host controller bus with no other devices on it.
(If you can find a set PS/2 keyboard and mouse, try the above solution if not continue)
  1. Unplug all other USB devices from your computer, leaving only the camera and USB keyboard or only the camera and USB mouse, not both.
  2. If the camera doesn't work, experiment by connecting the camera to another USB port. Try all the other ports until you find one that works.
  3. If the camera works, then you need to figure out which USB ports are connected to which controller. You need to use your other USB devices after all. Experiment by connecting your other USB devices one by one to another USB port and see if the camera still works. If the camera stops working after connecting a device it means that the port you just used is on the same USB host controller bus as you camera.
  4. If the camera still doesn't work, please do not despair. Try the following solution.

Solution 2 - Compile the modified spca5xx source code.
The fix works by gradually lowering the bandwidth requirements of the driver (spca5xx-20060501) and works even when other USB devices are present on the same host controller bus as the camera.
Then same method can also be used to resolve the same issue on the qc-usb QuickCam Express Driver.

The new driver will be installed at this location (kernel 2.6 +): /lib/modules/`uname -r`/kernel/drivers/media/video/spca5xx/
The new driver will be installed at this location (kernel 2.4): /lib/modules/`uname -r`/kernel/drivers/usb/

Please use one of the following 3 options:
  1. Automated Installation Script
  2. Manual Installation
  3. Patch


Automated Installation Script
  1. Download the modified spca5xx source code and save it on your desktop.
  2. Download the script or copy and paste it in a new file and save it on your desktop.
  3. If you downloaded the script extract it from the archive using:
    Code:
    tar xfvz  spca5xxvodunvibeFixScript.tar.gz
  4. Execute the script on your desktop or in the same directory as the archive spca5xx-20060501vodunvibeFix.tar.gz
    Code:
    ./spca5xxvodunvibeFix

Code:
#!/bin/sh
#spca5xxvodunvibeFix
#
# This Script to automatically installs spca5xxvodunvibeFix
#
## Exit if any command does not complete successfully.
#set -o errexit
#trap 'echo "The previous command did not complete successfully. "' ERR
echo "This script will extract and install spca5xx-20060501vodunvibeFix.tar.gz"
echo -e "\nThe following will also be downloaded and installed:"
echo "linux-headers-`uname -r` linux-restricted-modules-`uname -r` build-essential gcc"
echo "This script has been tested on Ubuntu Breezy Badger (5.10) and Dapper Drake (6.06)."
echo -e "\nPress enter to continue. CTRL-C to abort"
read
if grep -q "5.10" /etc/issue ; then
  sudo apt-get install linux-headers-`uname -r` linux-restricted-modules-`uname -r` build-essential gcc-3.4 
  export CC=gcc-3.4
else
  sudo apt-get install linux-headers-`uname -r` linux-restricted-modules-`uname -r` build-essential gcc
fi

KERNEL_VERSION=`uname -r`
MODULE_INSTALLDIR=/lib/modules/$KERNEL_VERSION/kernel/drivers/media/video/spca5xx
if [ -d /lib/modules/`uname -r`/build ]
then
    echo "The link Exists"
else
    echo "Creating link"
    ln -s /usr/src/linux-headers-`uname -r` /lib/modules/`uname -r`/build
fi
#Move the modified spca5xx source code from your home directory to /usr/src
cd /usr/src
sudo mv ~/Desktop/spca5xx-20060501vodunvibeFix.tar.gz .
#Extract it from the archive:
sudo tar xfvz spca5xx-20060501vodunvibeFix.tar.gz
cd spca5xx-20060501vodunvibeFix
#Compile the spca5xx source code
sudo make clean
sudo make
#Remove the old driver from memory
sudo modprobe -r spca5xx
echo -e "\nBacking up current spca5xx.ko kernel module\n"
#Backup the current spca5xx.ko kernel module
sudo cp -p $MODULE_INSTALLDIR/spca5xx.ko $MODULE_INSTALLDIR/spca5xx.ko.`date -Iseconds`
#Install the new driver at this location /lib/modules/`uname -r`/kernel/drivers/media/video/spca5xx/
sudo make install
#Load the new driver
sudo modprobe spca5xx
#Check dmesg and the system logs for errors
dmesg
echo spca5xxvodunvibeFix Finished!
read

Manual Installation
  1. Download the necessary packages.
    To compile the drivers we need to make sure that the following packages are installed from the Ubuntu repositories:
    Code:
    sudo apt-get install linux-headers-`uname -r` linux-restricted-modules-`uname -r` build-essential gcc
    If you are using Ubuntu Breezy Badger (5.10) you need gcc 3.4:
    Code:
    sudo apt-get install linux-headers-`uname -r` linux-restricted-modules-`uname -r` build-essential gcc-3.4
    export CC=gcc-3.4
  2. Create a link to the kernel source if it does not exist.
    Code:
    sudo ln -s /usr/src/linux-headers-`uname -r` /lib/modules/`uname -r`/build
  3. Download the modified spca5xx source code and save it on your desktop.
  4. Move the modified spca5xx-20060501vodunvibeFix.tar.gz from your home directory to /usr/src
    Code:
    cd /usr/src
    sudo mv ~/Desktop/spca5xx-20060501vodunvibeFix.tar.gz .
  5. Extract the files from the archive.
    Code:
    sudo tar xfvz spca5xx-20060501vodunvibeFix.tar.gz
  6. Enter the directory.
    Code:
    cd spca5xx-20060501vodunvibeFix
  7. Compile the spca5xx source code.
    Code:
    sudo make clean
    sudo make
  8. Remove the old driver from memory.
    Code:
    sudo modprobe -r spca5xx
  9. Backup the current spca5xx.ko kernel module.
    Code:
    sudo cp -p /lib/modules/`uname -r`/kernel/drivers/media/video/spca5xx/spca5xx.ko /lib/modules/`uname -r`/kernel/drivers/media/video/spca5xx/spca5xx.ko.`date -Iseconds`
  10. Install the new driver at this location: /lib/modules/`uname -r`/kernel/drivers/media/video/spca5xx/
    Code:
    sudo make install
  11. Load the new driver.
    Code:
    sudo modprobe spca5xx
  12. Check dmesg and the system logs for errors.
    Code:
    dmesg
    tail -f /var/log/syslog
  13. Enjoy your webcam.

Patch
The more experienced users can use the following patch and perform a manual installation.

To apply the patch from your current working directory, with a subdirectory called spca5xx-20060501 use:
Code:
patch -p0 < spca5xx-20060501-vodunvibe-Nospaceleftondevice.patch
To apply the patch, in the spca5xx-20060501 directory use:
Code:
patch -p1 < spca5xx-20060501-vodunvibe-Nospaceleftondevice.patch
This patch is currently against the spca5xx-20060501 source.
Code:
diff -urN spca5xx-20060501.orig/drivers/usb/spca5xx.c spca5xx-20060501/drivers/usb/spca5xx.c
--- spca5xx-20060501.orig/drivers/usb/spca5xx.c	2006-04-29 11:38:07.000000000 -0400
+++ spca5xx-20060501/drivers/usb/spca5xx.c	2006-09-05 13:19:04.000000000 -0400
@@ -1574,6 +1574,66 @@
       spca50x->funct.stopN(spca50x);
 }
 
+
+/**********************************************************************
+* spcaReducePacketSize
+* Function Fixes the bandwidth problem that occurs
+* when other USB devices are on the same host controller bus as the
+* camera by gradually lowering the bandwidth requirements of the driver.
+* It works even when other USB devices are present on the same
+* host controller bus as the camera. 
+*
+* Problem
+* When other USB devices are present on the same host controller
+* bus as the camera, the bandwidth requirements of the spca5xx driver
+* are not being met. The spca5xx driver is asking for more bandwidth
+* than is available which results in the following error messages:
+*
+* No space left on device
+* can't open /dev/video0: No space left on device.
+* usb_submit_urb(0) ret -28
+*
+* 
+* Many thanks to all the wonderful people contributing to this project.
+*
+* Great work!
+* vodunvibe [AT] NO@SPAM.PLEASE yahoo DOT com
+* 2006-08-27
+* 
+***********************************************************************/
+static int spcaReducePacketSize(struct usb_spca50x *spca50x, int n, int err)
+{
+    int size=896, fx, i;
+    err("spcaReducePacketSize: vodunvibe - The usb_submit_urb(%d) transfer request submission failed - You probably have another device sharing the same USB Host Controller Bus as your camera. Try using another USB port, on a different host controller bus.", n);
+    while (err == -ENOSPC && size >= 0) {
+	    err("spcaReducePacketSize: vodunvibe - Lowering the bandwidth requirements - New packet size (%d) ", size);
+        spca50x_set_packet_size(spca50x, size);
+    	spca50x->sbuf[n].urb->transfer_buffer_length = spca50x->packet_size * FRAMES_PER_DESC;
+    	for (fx = 0; fx < FRAMES_PER_DESC; fx++) {
+    	    spca50x->sbuf[n].urb->iso_frame_desc[fx].offset = spca50x->packet_size * fx;
+    	    spca50x->sbuf[n].urb->iso_frame_desc[fx].length = spca50x->packet_size;
+    	}
+        size-=128;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41)
+    	err = usb_submit_urb(spca50x->sbuf[n].urb, GFP_KERNEL);
+#else
+    	err = usb_submit_urb(spca50x->sbuf[n].urb);
+#endif
+    }
+
+	if (!err) {
+      for (i = 0; i < SPCA50X_NUMSBUF; i++) {
+    	spca50x->sbuf[i].urb->transfer_buffer_length = spca50x->packet_size * FRAMES_PER_DESC;
+    	for (fx = 0; fx < FRAMES_PER_DESC; fx++) {
+    	    spca50x->sbuf[i].urb->iso_frame_desc[fx].offset = spca50x->packet_size * fx;
+    	    spca50x->sbuf[i].urb->iso_frame_desc[fx].length = spca50x->packet_size;
+    	}
+      }
+    }
+    return err;
+}
+
+
 static int spca50x_init_isoc(struct usb_spca50x *spca50x)
 {
 
@@ -1649,7 +1709,15 @@
 #endif
 	if (err) {
 	    err("init isoc: usb_submit_urb(%d) ret %d", n, err);
-	    return err;
+	    if (err == -ENOSPC) {
+	        err = spcaReducePacketSize(spca50x, n, err);
+        	if (err) {
+	            err("init isoc: After spcaReducePacketSize - usb_submit_urb(%d) ret %d", n, err);
+         	    return err;
+        	}
+	    }else{
+	        return err;
+	    }
 	}
     }
Many thanks to all the wonderful people contributing to this project.
Attached Files
File Type: gz spca5xx-20060501-vodunvibe-Nospaceleftondevice.patch.tar.gz (1.4 KB, 182 views)
File Type: gz spca5xxvodunvibeFixScript.tar.gz (1,023 Bytes, 274 views)
File Type: gz spca5xx-20060501vodunvibeFix.tar.gz (191.7 KB, 487 views)

Last edited by vodunvibe; September 5th, 2006 at 04:29 PM.. Reason: I added a patch which can be used against the spca5xx-20060501 source
vodunvibe is offline   Reply With Quote
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:14 AM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. bilberry