From Openmoko

Jump to: navigation, search

It is possible to plug and use a webcam on the Freerunner. This is a very rough list of the steps required to do so with Debian Lenny installed.

The webcam used to perform this example is a Philips SPC620NC, using the [UVC] driver.

The method described here is still rather ugly, feel free to improve it.


Make it work on a PC

To be safe, you just first ensure the webcam works on a regular PC, and Linux in particular. This will minimise the problems you are likely to face (though it may not eliminate them altogether). The regular documentation applies:

Add video support to the kernel

The 2.6.24 kernel is provided without video input support enabled. There is a way to add the necessary modules without recompiling everything:

  • download the source code for the kernel:
  1. wget
  • make sure you have bzip2 and development tools installed:
  1. apt-get install bzip2 gcc make libc6-dev libncurses5-dev
  • uncompress it in /usr/src:
  1. cd /usr/src
  2. tar -xjvf $OLDPWD/linux-2.6.24.tar.bz2
  • fix links bluntly in /lib/modules:
  1. ln -sf /usr/src/linux-2.6.24 /lib/modules/2.6.24/build
  • initialize the kernel sources with the current configuration:
  1. cd /usr/src/linux-2.6.24
  2. gzip -dc /proc/config.gz > .config
  3. make oldconfig # just say "n" to power management debugging support
  • add video support:
  1. make menuconfig

Basically, look for "Device drivers", "Multimedia devices", then enable "Video For Linux", "Video For Linux API 1", "Video For Linux API 1 compatible Layer", "Video capture adapters" as modules. If the driver for your webcam is found in the kernel already, also enable it there.

  • compile the relevant kernel modules:
  1. make drivers/media/video/v4l1-compat.ko
  2. make drivers/media/video/v4l2-common.ko
  3. make drivers/media/video/videodev.ko
  4. make drivers/media/video/compat_ioctl32.ko
  • load the modules:
  1. insmod drivers/media/video/v4l1-compat.ko
  2. insmod drivers/media/video/v4l2-common.ko
  3. insmod drivers/media/video/videodev.ko
  4. insmod drivers/media/video/compat_ioctl32.ko

The errors encountered while loading modules can be obtained with the "dmesg" command. They are typically also logged in /var/log/messages.

Compile the UVC driver

To obtain and compile the latest source tree for the driver:

  1. apt-get install subversion
  2. svn checkout svn://
  3. cd trunk
  4. make

And if all goes well:

  1. insmod uvcvideo.ko

Add the device node

In our case, the relevant device node was not created automatically. Here's how to do so:

  1. mkdir -p /dev/v4l
  2. mknod /dev/v4l/video0 c 81 0

Plug the camera itself

The Freerunner needs to run in USB host mode in order to do this. A special USB cable (or gender changer) is necessary to do so.

Again, you can use the command "dmesg" to verify that the camera is properly recognized.

Install and try a viewer

A good webcam test application is luvcview. You can install and test it this way:

  1. apt-get install luvcview
  2. luvcview -f yuv -d /dev/v4l/video0

Webcam in action: [1]

Known problems

  • the resolution was limited to 160x120 with our Philips SPC620NC

This limitation may depend on video format; for example, luvcvideo on FreeRunner&debian told me that Logitech QuickCam E3500+ supports up to 176x144 with YUV, and up to 640x480 with MJPG

Personal tools