From NAS-Central Buffalo - The Linkstation Wiki
Revision as of 19:04, 29 June 2006 by Sylver (Talk) (Cron job to clean old files)

Jump to: navigation, search

The Sekuro-box

Here is my new contest entry !

What is the Sekuro-box ?

What can be that Sekuro-box ? It's a security center based on the fantastic Kuro-box, it will allow you to :

  • Remotely watch for a place using a Webcam
  • Record (in jpg or avi) any activity in front of the webcam (using a motion detection software)


What do you need for this project ?

  • A Kuro-box (standard or HG)
  • A Webcam supported by a Linux driver
  • Something or someone to watch
  • Reading this guide

For this project, I bought a Creative Webcam for Notebook (about 50€) as it's a tiny webcam and it is reported as providing a quite good quality picture under linux, but there is cheaper webcams available (you way already have one by the way, i was one of the latest person on earth without a webcam). fe_1.jpg

Some examples of how it looks like

Here is a sample of what you can get :


That what we call "caught in action" ! As you can see, this allowed me to have the proof that my cat was going on the sofa when we're away, even if he knows that it is totally forbidden ! With that proof, i finally applyied an immediate sanction : no meat for 1 month ! I guess you can think about some applications in your case :D

The easy way

For the guys who do not want to compile/install/configure things, i've done a complete disk image (for the Kuro-box HG only) that you'll just have to put in your kurobox, you can download it here (it's based on the debian image with some custom modifications explained in this article) : <add download link here>

Usage is simple :

  • As with this image, your kuro-box will ask for an IP adress using DHCP, make sure that you have a DHCP server to serve an IP to the kurobox :)
  • Plug your webcam in one of the USB connector (webcam support is done through SPCA5xx & PWC drivers, check the links to know if your webcam is supported)
  • Then go to http://kurobox_ip/motion
  • Here you'll have a record of past events, and you'll be able to watch the live stream from you webcam !

The hard way

First of all, you'll need a development environement with gcc & needed stuff ! I suggest you installing a Debian image as it will save a lot of time installing all needed applications ;) With Debian, install the developement tools this way :

apt-get install make automake gcc g++ patch libncurses5-dev

Also install some tools you will need later :

apt-get install wget bzip2

Then follow these guides :

Now you're ready for the next step.

Compile the kernel with video4linux support

You need to compile the kernel with the video4linux module !

  • First of all, download the vanilla linux kernel sources :
cd /usr/src
  • get the linux kernel patch for the kurobox
  • untar the kernel sources, apply the patch and create the symbolic link
tar xjf linux-
patch -Np0 < kurobox-sources-2.6.17.patch
ln -s linux- linux
  • now go to linux directory an copy the .config file according to the kurobox you have :

for the standard Kuro-box :

cd linux && cp config_kurobox .config

For the Kuro-box HG

cd linux && cp config_kuroboxhg .config
  • then you need to configure the kernel to support video4linux (needed for the webcam)
export ARCH=ppc
make menuconfig
Device Drivers > Multimedia Devices > Video For Linux and press "m" to build it as a module (you can press "y" to build it in the kernel)
  • now compile the kernel
make oldconfig
make vmlinux (or "make uImage" if running U-boot)
objcopy -O binary vmlinux /boot/vmlinux.bin (or "cp uImage /boot" is running U-boot)
cp /boot && cp .config /boot (could be usefull to rebuild your kernel later)
make modules 
sudo make modules_install
  • now reboot to run your new kernel :D

Build the kernel module for your webcam

SPCA5xx driver

If you need SPCA5xx driver :

  • Download module sources
  • Detar the archive
tar xzf spca5xx-20060501.tar.gz && cd spca5xx-20060501
  • compile module
export ARCH=ppc => as it will use kernel sources to compile, we need this line !
  • install module
make install
  • now plug your webcam and check that the spca5xx module is loaded :
> lsmod
Module Size Used by
spca5xx 677520 0
videodev 11072 1 spca5xx (will only be present if you built video4linux as a module)

PWC driver

If you need PWC driver :

  • Download PWC module (snapshot version would be better as it supports more webcams) :
wget (pick a version from the snapshot page
  • Detar the archive
tar xjf pwc-v4l2-20060627-042701.tar.bz2
  • Compile module
export ARCH=ppc => as it will use kernel sources to compile, we need this line !
  • Install module
make install
  • now plug your webcam and check that the spca5xx module is loaded :
> lsmod

Others drivers

If you need another driver : If you found another driver to handle your webcam, then the process to install it should be almost the same (don't forget the "export ARCH=ppc", it is really important if you want your driver to compile correctly. <to be completed...>

Motion application installation

Now that the webcam driver is installed, we will install the application that will process the output of the webcam ! We will choose motion as it allows to capture pictures/videos when a mouvement is detected in the field of the webcam, and its CPU needs are compatible with the Kuro-box CPU !

Application installation

  • Motion installation :
apt-get install motion

Motion configuration

<To be completed>

Video encoding application installation

If you want to be able to record videos, you'll also need to install ffmpeg !

  • ffmpeg installation :
apt-get install ffmpeg

Web survey pages installation

You'll need to install an http server with php support if you want to be able to check if your webcam have detected something ! For this, you should follow the firsts steps of my Install Torrentflux + Transmission + SQLite guide ! <To be completed>

Cron job to clean old files

If you let motion fills your hard disk with pictures/videos, i'll fast have the disk full problem ! To prevent that, we will set up a cron job to clean files older than 30 days (you can change that value for your needs) ! First, install cron :

apt-get install cron

Then add the cron job :

crontab -e

enter this line :

 00 20  *   *   *    find /mnt/motion -mtime +30 -exec rm {} \;

Every days at 20:00 (08:00PM), it'll check for files older than 30 days in /mnt/motion and delete them !