Zoneminder on an old OLPC XO-1

We had a few XO-1’s lying around the techspace, and were in need of a low powered webcam monitoring solution.

Why not install Ubuntu on an XO-1 along with zoneminder and get it working with the built in webcam? Great idea! Quick instructions below while I still remember them:

  • Read through these instructions, they are for getting desktop Ubuntu working on the OLPC: http://wiki.laptop.org/go/Ubuntu_Lucid_on_OLPC_XO
  • We want a light weight server install with no GUI, so we’ll skip some of those instructions (eg: the gnome-netbook stuff)  and make sure you use the ubuntu server ISO image, not the desktop one.
  • Install VirtualBox on your Ubuntu desktop or laptop computer. We’ll use VirtualBox to install Ubuntu on our 4GB USB stick which will plug into our XO-1
  • Plug in your 4GB+ USB stick, find out which device it is running (eg: /dev/sdd) then let VirtualBox access this device so we can install it:
  • VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/HardDisks/olpc-xo-usb.vmdk -rawdisk /dev/sdd
  • Launch VirtualBox and install Ubuntu on your USB stick as per instructions above.
  • In VirtualBox when you select your hard disk, choose “existing” and browse for the “~/.VirtualBox/HardDisks/olpc-xo-usb.vmdx” file created above
  • During server edition installer: Don’t create a swap file, just create one big “/” partition manually. Make sure it’s bootable ext3. Select the LAMP option (apache + mysql) to be installed.
  • Then follow the “Adapting Ubuntu to the XO” instructions on the above wiki, skipping gnome-netbook
  • While ubuntu is running in VirtualBox install zoneminder (apt-get install zoneminder)
  • Make sure your XO-1 is unlocked with a developer key, you can do this from the browser in your XO-1 http://wiki.laptop.org/go/Activation_and_Developer_Keys
  • Plug your new USB stick with ubuntu into the XO-1 and turn it on – no need to press any keys
  • If all goes well you will see a little linux tux and be presented with a login screen! yay!
  • Follow the iwconfig commands on http://wiki.laptop.org/go/Ubuntu_On_OLPC_XO to get your XO-1 on the network (this was tricky! lots of rebooting and typing the same thing over and over again. eventually started working).
  • You can now SSH into your OLPC and it’ll be easier than working on the built in keyboard.
  • Now to configure zoneminder.
  • if the file /etc/apache2/conf.d/zoneminder.conf doesn’t exist then run this on the olpc:
    sudo ln -s /etc/zm/apache.conf /etc/apache2/conf.d/zoneminder.conf
  • Restart apache
  • Visit the your new zoneminder install in firefox (it’s the best for zm). http://192.168.0.11/zm/  (or whatever your olpc IP is)
  • Click “add new monitor”
  • Settings are:
  • General > Source Type: local
  • Source > Device Path: /dev/video0
  • Source > Capture Method: Video for linux version 2
  • Source > Channel: 0
  • Source > Format: NTSC M
  • Source > Palette: YUYV
  • Source > Width: 640
  • Source > Height: 480
  • save.
  • Make sure shm settings are correct: http://www.zoneminder.com/wiki/index.php/FAQ#What_does_a_.27Can.27t_shmget:_Invalid_argument.27_error_in_my_logs_mean.3F_and_my_cameras_won.27t_display_video_at_higher_resolutions.
  • The main ZM window will refresh and if all works well the “Source” column should be orange or green. If it’s red then something probably didn’t work. And you can spend hours trying to fix it like I did. I suggest ssh -X ‘ing into the olpc, install xawtv, and run “xawtv -d /dev/video0 -remote” to see if the webcam is working at all.
  • You can also try this, which was a quick fix that worked for me:
    chmod +s /usr/bin/perl
    chmod +s /usr/bin/zmu
    chmod +s /usr/bin/zma
    chmod +s /usr/lib/cgi-bin/zms
    chmod +s /usr/lib/cgi-bin/nph-zms
    chmod 777 /dev/video0
    Yes I know – bad bad bad. But it was late and my last resort, and it worked.
  • Now you should have a working zoneminder camera! woo! Click the “Name” in zoneminder and it will bring up your webcam image, like this:

Thanks to the guys on Freenode #zoneminder for helpful hints!

 

Process list on the OLPC:

# ps axf
 PID TTY      STAT   TIME COMMAND
   2 ?        S<     0:00 [kthreadd]
   3 ?        S<     0:03  \_ [ksoftirqd/0]
   4 ?        S<     0:00  \_ [events/0]
   5 ?        S<     0:00  \_ [khelper]
   8 ?        S<     0:00  \_ [async/mgr]
  93 ?        S<     0:00  \_ [kblockd/0]
 100 ?        S<     0:00  \_ [kseriod]
 104 ?        S<     0:00  \_ [kmmcd]
 155 ?        S<     0:00  \_ [kswapd0]
 156 ?        S<     0:00  \_ [aio/0]
 157 ?        S<     0:00  \_ [crypto/0]
 285 ?        S<     0:00  \_ [mtdblockd]
 435 ?        S<     0:00  \_ [ksuspend_usbd]
 436 ?        S<     0:00  \_ [khubd]
 443 ?        S<     0:00  \_ [kpsmoused]
 460 ?        S<     0:00  \_ [scsi_eh_0]
 461 ?        S<     0:00  \_ [usb-storage]
 465 ?        S<     0:03  \_ [lbs_main]
 466 ?        S<     0:00  \_ [lbs_worker]
 486 ?        S<     0:00  \_ [kjournald]
2994 ?        S<     0:00  \_ [kjournald]
1919 ?        S      0:00  \_ [pdflush]
1921 ?        S      0:00  \_ [pdflush]
   1 ?        Ss     0:01 /sbin/init
2905 ?        S      0:00 upstart-udev-bridge --daemon
2913 ?        Ss    0:00 udevd --daemon
3024 ?        S     0:00  \_ udevd --daemon
3033 ?        S     0:00  \_ udevd --daemon
3115 ?        Sl     0:00 rsyslogd -c4
3138 tty4     Ss+    0:00 /sbin/getty -8 38400 tty4
3142 tty5     Ss+    0:00 /sbin/getty -8 38400 tty5
3146 tty2     Ss+    0:00 /sbin/getty -8 38400 tty2
3147 tty3     Ss+    0:00 /sbin/getty -8 38400 tty3
3150 tty6     Ss+    0:00 /sbin/getty -8 38400 tty6
3163 ?        Ss     0:00 cron
3164 ?        Ss     0:00 atd
3197 ?        S      0:00 /usr/sbin/nullmailer-send -d
3208 ?        Ssl    0:04 /usr/sbin/mysqld
3301 tty1     Ss     0:00 /bin/login --
3471 tty1     S      0:02  \_ -bash
3769 tty1     S      0:00      \_ su
3770 tty1     S+     0:00          \_ bash
3596 ?        Ss     0:00 /usr/sbin/sshd -D
4028 ?        Ss     0:00  \_ sshd: olpc [priv]
 310 ?        S      0:49      \_ sshd: olpc@pts/0
 311 pts/0    Ss     0:02          \_ -bash
1929 pts/0    S      0:00              \_ su
1930 pts/0    R      0:00                  \_ bash
2810 pts/0    R+     0:00                      \_ ps axf
3823 ?        Ss     0:00 wpa_supplicant -Dwext -ieth1 -c/etc/wpa_supplicant.conf -B
3843 ?        Ss     0:00 dhclient eth1
2524 ?        Ss     0:00 /usr/sbin/apache2 -k start
2527 ?        S      0:08  \_ /usr/sbin/apache2 -k start
2579 ?        S      0:07  \_ /usr/sbin/apache2 -k start
2588 ?        S      0:02  \_ /usr/sbin/apache2 -k start
2589 ?        S      0:01  \_ /usr/sbin/apache2 -k start
2590 ?        S      0:13  \_ /usr/sbin/apache2 -k start
2546 pts/0    S      0:00 /usr/bin/perl -wT /usr/bin/zmdc.pl startup
2568 pts/0    R     41:56  \_ /usr/bin/zmc -d /dev/video0
2570 pts/0    S      0:02  \_ /usr/bin/perl -wT /usr/bin/zmfilter.pl
2572 pts/0    S      0:01  \_ /usr/bin/perl -wT /usr/bin/zmaudit.pl -c
2574 pts/0    S      0:01  \_ /usr/bin/perl -wT /usr/bin/zmwatch.pl

The top output from the OLPC XO-1 running zoneminder, no connections or movement on the webcam:

top - 23:40:23 up  2:36,  2 users,  load average: 1.04, 1.04, 1.14
Tasks:  62 total,   2 running,  60 sleeping,   0 stopped,   0 zombie
Cpu(s): 97.7%us,  0.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  2.3%si,  0.0%st
Mem:    208632k total,   190740k used,    17892k free,     5356k buffers
Swap:   524280k total,      188k used,   524092k free,    99876k cached

 PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
2568 root      20   0  152m  50m  42m R 99.6 24.9  44:46.37 zmc

We’re getting quite a high load on this OLPC – especially since no zones or recording is in place yet. So we’ll try some of these suggestions http://www.zoneminder.com/wiki/index.php/Managing_Load to see if it’ll increase performance.

Download the latest .deb package of libjpeg-turbo and install it on your OLPC: http://sourceforge.net/projects/libjpeg-turbo/files/

Change YUYV to GREY so we get black and white images.

Load has been reduced by 3/4! wow!