Streaming UVC webcam video over 802.11n with a BeagleBoard

Here’s an overview of the general setup:

And a closeup of the BeagleBoard and the various bits and pieces required to stream the webcam images:


Physical components:

  • BeagleBoard (revision C4)
  • 2GB SD Card
  • USB Hub (USB 2.0, High Speed, powered). You’ll most likely need an externally powered hub as USB ports are only required to supply up to 100mA.
  • ASUS USB-N10 Wireless N USB adaptor
  • Logitech C600 webcam
  • 5V power supply
  • USB to RS-232 Serial cable.
  • IDC10 to DB9 cable.

Software:

  • Angstrom demo image.
    Angstrom is an embedded linux distribution. You’ll want the demo image to verify that your board is ok, and to use as a fallback if your generated system misbehaves.
  • Angstrom development environment.
    Used to rebuild and customize the Angstrom image, and you can also use its toolchain to cross-compile your own code.
  • Driver for N10 wireless adapter
    This is included in later linux kernels, but doesn’t seem to be available in Angstrom (you could probably modify the kernel config and recompile the kernel as an alternative to building the driver).
  • MJPG Streamer
    An application which can stream UVC web cam images over HTTP.

Correcting USB Issue on Revision C4 BeagleBoards
There appears to be an issue with C4 revision BeagleBoards that prevents the EHCI USB port from functioning. This can be fixed with a newer version of U-Boot – I’ll write a short blog post about this soon.

Cross Compiling the ASUS N10 driver
The most difficult part of getting this working was the ASUS N10 wireless N driver. This driver doesn’t appear to be available in the Angstrom distribution, so we have to compile it ourselves. This is made more complicated than usual because the BeagleBoard has an ARM architecture, not x86 (well, complicated for me since I haven’t done a cross compile before).

There are a few ways to build a driver for the ARM architecture:

  • Compile the code on the target architecture (ie on the BeagleBoard).
    While this doesn’t have the complication of cross-compiling ARM code on an x86 machine, the compile will be slow, and requires installing gcc, binutils, linux-headers, etc.. on the BeagleBoard. This is tempting, but some how it doesn’t feel like something the big boys would do.
  • Build our own cross-compile toolchain.
    A cross-compiler toolchain is the set of applications and libraries required to build source for a different machine architecture. This includes gcc, binutils, glibc and friends. You’ll also need the appropriate kernel headers if you’re building a driver. Building your own is apparently quite painful, as certain combinations of tool versions and machine architectures don’t play well together. Perhaps a project for a rainy weekend.
  • Download a pre-built toolchain.
    You can download a prebuilt toolchain from Angstrom. This is probably the easiest way to go, though it doesn’t give you the option of rebuilding your Angstrom images, and I’m not sure if it includes the kernel headers. Another popular source of prebuilt toolchains is CodeSourcery. I’m not sure what happens if you use this with a kernel built with a different toolchain (eg the toolchain used to build Angstrom). Bad things, I imagine.
  • Use Angstrom’s build environment.
    Angstrom’s build environment is based on OpenEmbedded, a build environment for embedded Linux distributions. OpenEmbedded consists of a make-like utility called bitbake, and a huge library of files which define properties of different machines and distributions, and instructions for building packages (called recipies).
    You can either write your own recipies and use bitbake, or you can use the toolchain which it generates (which is what I ended up doing).

Cross Compiling with the Angstrom Development Environment
You can get started with:

git clone git://gitorious.org/angstrom/angstrom-setup-scripts.git
cd angstrom-setup-scripts
./oebb.sh config beagleboard
source ~/.oe/environment
bitbake console-image

Bitbake will take a long time to run the first time (a couple of hours on my dogey internet connection), as it has to download the various packages and patches required to build everything. When its done, you’ll find the output images in

./build/tmp-angstrom_2008_1/sysroots/beagleboard-angstrom-linux-gnueabi/kernel/

The generated toolchain is in:

./build/tmp-angstrom_2008_1/sysroots/i686-linux/usr/armv7a/bin

And the kernel headers are in:

./build/tmp-angstrom_2008_1/sysroots/beagleboard-angstrom-linux-gnueabi/kernel

To compile the ASUS-N10 wireless driver, download it from here, add the toolchain path to your system PATH, then:

make \
CROSS_COMPILE=arm-angstrom-linux-gnueabi- \
KSRC={path to the kernel source} \
KVER={the output of 'uname -r' on the beagleboard} \
ARCH=arm

You can verify that the resulting module is suitable for ARM with file:

$ file 8712u.ko
8712u.ko: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped

Copy the resulting 8712u.ko to the beagleboard and insmod the module.

Streaming the Images
The application MJPG Streamer can stream UVC web cam images over HTTP (and UDP). It’s only dependency is libjpeg which you can install on the BeagleBoard by running opkg install libjpeg8 (assuming you have a network connection). To cross-compile the application, ensure the toolchain created earlier is in your PATH, then edit the Makefile, replacing:

CC = gcc

with

CC = arm-angstrom-linux-gnueabi-gcc

Remember to modify the Makefiles in the plugins sub directories as well. Run make and the binaries should be ready to run on the beagleboard.

Advertisements
This entry was posted in BeagleBoard and tagged , , , . Bookmark the permalink.

25 Responses to Streaming UVC webcam video over 802.11n with a BeagleBoard

  1. Dat says:

    Thanks for the article. Did you have to install any drivers for the C600 webcam to work. I am trying to use the same webcam for my beagleboard-xm but I don’t see any /dev/video* device after I plug it in.

    thanks.

    • bengalvin says:

      I got no response the first time I plugged it in (including nothing in the system log to acknowledge a USB device had been plugged in). Turns out this was an issue with the C4 release beagleboards, and was fixed with a new u-boot. Once I’d fixed that, the device showed up straight away.

      What distro are you using, and do you have anything in your system log?

  2. Dat says:

    Thanks for your fast reply. I finally got it to work. When I bitbaked my linux image it did not include a lot of kernel modules. The modules were in a separate tar file which I have to add manually to my filesystem. The particular module is called “uvcvideo.ko”

    Thanks again.

  3. zair says:

    I want to try this work with my beagle board C4.. I already have BELKIN G USB Network Adapter. I need driver for that. what is the procedure to get driver for that device.. pls help me in this regard..

    • bengalvin says:

      There’s a post here on getting the Belkin adapter running on linux. Once you identify which driver you need you can check the Angstrom website to see if there is a package which supports it for the beagleboard. If not, you’ll either have to rebuild your kernel with support for the driver (assuming its in the kernel tree), or build the driver by itself. You can either use bitbake, or download the angstrom toolchain and the appropriate kernel headers and build it yourself. Good luck!

  4. zair says:

    And I have Microsoft Lifecam VX-500 . Its not detected when i connect to BB. can U pls tell me which version of U-boot I should use.. I am using angstrom distribution . pls help me in this regard..

  5. kevin fang says:

    I am a beginner
    can you tell me how to work uvc(no driver) on beagleboard xm
    STEP?

    • bengalvin says:

      Hi Kevin – hard to give directions without knowing what distribution and webcam you’re using. If you’re new to Linux, your best bet may be to install Ubuntu, as this will already include the uvcvideo driver.

  6. Pingback: Source information for the project « Project Firewall 3

  7. viherlans says:

    Please help !
    I’m trying to build a module for beagleboard xm for WiFi rtl8192cu , but compile fails with the following error.

    CC [M] /opt/rtl/os_dep/linux/os_intfs.o
    CC [M] /opt/rtl/os_dep/linux/usb_intf.o
    CC [M] /opt/rtl/os_dep/linux/ioctl_linux.o
    CC [M] /opt/rtl/os_dep/linux/xmit_linux.o
    CC [M] /opt/rtl/os_dep/linux/mlme_linux.o
    CC [M] /opt/rtl/os_dep/linux/recv_linux.o
    LD [M] /opt/rtl/8192cu.o
    Building modules, stage 2.
    MODPOST 1 modules
    /bin/sh: scripts/mod/modpost: No such file or directory
    make[2]: *** [__modpost] Error 127
    make[1]: *** [modules] Error 2
    make[1]: Leaving directory `/home/park/setup-scripts/build/tmp-angstrom_2011_x-eglibc/sysroots/beagleboard/kernel’
    make: *** [modules] Error 2

    This directory does not have a file modpost. There modpost.h, modpost.c and others. How can i get file modpost ?

    • bengalvin says:

      It sounds like either you need to do a full kernel build first, or run ‘sudo make scripts’.

      • viherlans says:

        Thanks for help.
        How can i do a full kernel build ?
        In what directory should I run – “sudo make scripts” ?

      • bengalvin says:

        You can build a kernel with ‘bitbake virtual/kernel’. If that doesn’t work, try building a full image with ‘bitbake console-image’.

  8. viherlans says:

    before compiling, I ran the following commands :
    MACHINE=beagleboard ./oebb.sh bitbake virtual/kernel
    MACHINE=beagleboard ./oebb.sh bitbake console-image
    MACHINE=beagleboard ./oebb.sh bitbake systemd-gnome-image
    now my beagleboard works on my systemd-gnome-image.

  9. Jediator says:

    THanks for the article! Is this going to work on BeagleBone?

  10. Max says:

    Thanks for article.
    I am trying to build RTL8188SU driver for Angstrom for my Beaglebone.
    uname -r on Beaglebone returns 3.2.14

    I have following errors when trying to make driver after full kernel build described in this article:

    max@hackintosh1:~/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401$ make CROSS_COMPILE=arm-angstrom-linux-gnueabi- KSRC=~/setup-scripts/build/tmp-angstrom_v2012_05-eglibc/sysroots/beaglebone/kernel KVER=3.2.14 ARCH=arm
    make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- -C /home/max/setup-scripts/build/tmp-angstrom_v2012_05-eglibc/sysroots/beaglebone/kernel M=/home/max/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401 modules
    make[1]: Entering directory `/home/max/setup-scripts/build/tmp-angstrom_v2012_05-eglibc/sysroots/beaglebone/kernel’
    CC [M] /home/max/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/cmd/rtl871x_cmd.o
    In file included from /home/max/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/include/drv_types.h:70:0,
    from /home/max/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/cmd/rtl871x_cmd.c:24:
    /home/max/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/include/rtl871x_cmd.h:107:25: error: field ‘event_tasklet’ has incomplete type
    In file included from /home/max/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/include/drv_types.h:72:0,
    from /home/max/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/cmd/rtl871x_cmd.c:24:
    /home/max/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/include/rtl871x_xmit.h:355:24: error: field ‘xmit_tasklet’ has incomplete type
    In file included from /home/max/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/include/drv_types.h:73:0,
    from /home/max/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/cmd/rtl871x_cmd.c:24:
    /home/max/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/include/rtl871x_recv.h:204:24: error: field ‘recv_tasklet’ has incomplete type
    In file included from /home/max/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/include/drv_types.h:77:0,
    from /home/max/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/cmd/rtl871x_cmd.c:24:
    /home/max/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/include/rtl871x_io.h:35:28: fatal error: linux/smp_lock.h: No such file or directory
    compilation terminated.
    make[2]: *** [/home/max/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/cmd/rtl871x_cmd.o] Error 1
    make[1]: *** [_module_/home/max/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401/driver/rtl8712_8188_8191_8192SU_usb_linux_v2.6.6.0.20110401] Error 2
    make[1]: Leaving directory `/home/max/setup-scripts/build/tmp-angstrom_v2012_05-eglibc/sysroots/beaglebone/kernel’
    make: *** [modules] Error 2

    As far as i understand it is because of kernel incompatibility.
    Could you please advise me something ? How could i make my Asus USB N10 works with beaglebone.
    Thanks

  11. Max says:

    Hi, bengalvin.
    It seems to me i figured out whats wrong. I’ve build kernel with bitbake (not make) and possible bitbake does not use fixdep for building (file fixdep.c exist, but not compilled).
    Also i figure out that earliest version of Angstrom demo image for Beaglebone have 3.1 kernel (not 2.6). Should build it myself. Could you advise how to set build use 2.6 kernel ? Thanks

  12. Technoshaman says:

    Hello, and thank you for this helpful article.
    All is fine until I run bitbake, I get the following error…

    ERROR: OE-core’s config sanity checker detected a potential misconfiguration.
    Either fix the cause of this error or at your own risk disable the checker (see sanity.conf).
    Following is the list of potential problems / advisories:

    Failed to create a file with a long name in TMPDIR. Please use a filesystem that does not unreasonably limit filename length.
    Failed to create a file with a long name in SSTATE_DIR. Please use a filesystem that does not unreasonably limit filename length.

    ERROR: Execution of event handler ‘check_sanity_eventhandler’ failed

    any ideas?

    Thank you in advance 🙂

    • bengalvin says:

      Hi. I haven’t seen that error before – which filesystem are you using? You might also be able to get under the path length limit by moving the OE folder to a folder closer to the root. Ben

  13. Pingback: mjpeg-streamer on beaglebone | Flesh and machines

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s