Tuesday, September 25, 2012

Oscam card server on beaglebone

I own a Beaglebone (TI AM3358 ARM Cortex-A8). I was thinking about use of it.
It can control 4 PWMs (for servos for example), but I already have a servo robot (mega168 bot).
It is capable of running zoneminder - surveillance software. But all my USB cameras didn't work with it - they very old.
Here are the instructions to build oscam server with it.

1. Install ubuntu 12.04: http://elinux.org/BeagleBoardUbuntu#Demo_Image
2. Update kernel: http://elinux.org/BeagleBoardUbuntu#Advanced
3. Update ubuntu with
sudo apt-get update
sudo apt-get upgrade 
4. Install ftp server
sudo apt-get install vsftpd
5. Configure it (/etc/vsftpd.conf)
local_enable=YES
write_enable=YES
6. Restart vsftpd
sudo service vsftpd restart
7. Install all development stuff: build-essential, automake, subversion, etc
8. Install libusb from source:
wget http://downloads.sourceforge.net/project/libusb/libusb-1.0/libusb-1.0.9/libusb-1.0.9.tar.bz2
tar -xf libusb-1.0.9.tar.bz2
cd libusb-1.0.9
./configure
make
sudo make install 
9. Get oscam (http://www.streamboard.tv/oscam/wiki/GettingOscam)
svn checkout http://www.streamboard.tv/svn/oscam/trunk oscam-svn
cd oscam-svn
sudo make USE_LIBUSB=1 EXTRA_FLAGS="-I/usr/local/include -L/usr/local/lib"
10. Now you have oscam in "Distribution" folder
sudo cp ./Distribution/oscam-1.20-unstable_svn7488-arm-linux-gnueabihf-libusb /usr/local/bin/oscam
11. Put oscam configs in /usr/local/etc:  oscam.conf, oscam.server, oscam.user

12. Create oscam script (/etc/init.d/oscam):

#!/bin/sh
# Start/stop the OScam daemon.
#
### BEGIN INIT INFO
# Provides:          OScam
# Required-Start:    $syslog $network $pcscd
# Required-Stop:     $syslog $network $pcscd
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start and Stop OScam
# Description: OScam init script. This script start and stop OScam.
### END INIT INFO

NAME=oscam
DAEMON=/usr/local/bin/$NAME
CONFIG_DIR=/usr/local/etc
PIDFILE=/var/run/oscam.pid
LOG=/var/log/oscam/oscam.log
LOGUSR=/var/log/oscam/oscamuser.log
LOGCW=/var/log/oscam/cw.log
STARTAS="$DAEMON -- -b -c $CONFIG_DIR"

#test -f $DAEMON || exit 0
[ -x $DAEMON ] || exit 0
[ -d $CONFIG_DIR ] || exit 0

# Get lsb functions
. /lib/lsb/init-functions

echo $NAME

clear_file() {
    # Clear log and pid file if exists
    if [ -e $PIDFILE ]
then
   rm -f $PIDFILE
fi
if [ -e $LOG ]
then
   rm -f $LOG
fi
if [ -e $LOGUSR ]
then
   rm -f $LOGUSR
fi
if [ -e $LOGCW ]
then
   rm -f $LOGCW
fi
}
case "$1" in
start)
        clear_file
        log_daemon_msg "Starting OScam daemon" "OScam"
        start-stop-daemon --start --quiet --exe $DAEMON --startas $STARTAS
        log_end_msg $?
;;
stop)
        log_daemon_msg "Stopping OScam daemon" "OScam"
        start-stop-daemon --stop --quiet --exe $DAEMON
        log_end_msg $?
        ;;
restart)
        log_daemon_msg "Restarting OScam daemon" "OScam"
        start-stop-daemon --stop --retry 5 --quiet --exe $DAEMON
        clear_file
        start-stop-daemon --start --quiet --exe $DAEMON --startas $STARTAS
        log_end_msg $?
        ;;
status)
status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
        ;;
*)
        log_action_msg "Usage: /etc/init.d/OScam {start|stop|restart|status}"
        exit 2
        ;;
esac
exit 0
13. Set script permissions
sudo chmod 755 /etc/init.d/oscam

14. Add script to startup:
sudo update-rc.d oscam defaults

14. Restart the beaglebone and open the page in browser: http://XXX.XXX.X.XX:8888, with beaglebone IP. You should see the oscam running.

15. You can check oscam errors with:
 sudo service oscam start
or
sudo service oscam restart 

Update 07-Dec-2012: Smargo Card reader from ebay works great with this configuration. In file oscam.server should be written:
protocol=smartreader
device=002:003 (or something else depend on lsusb output)
Post a Comment