Raspberry Pi and Oscam

I have recently acquired a couple of Raspberry Pi to play with, and I must say I am quite impressed with this cheap little device.

You can use it as a desktop, a small server, a media center and you also have GPIO interface to control external hardware, like sensors and motor drivers (like the Arduino but with much more processing power and memory).

The first experiment I did when I got my hands on the Raspberry was to compile and install Oscam so I could have a server with little energy consumption but still has the processing power required to sustain a large number of Oscam users and readers.

This post is the report of my experiment and will allow you to reproduce my steps.

This tutorial is organized in 4 steps :

Step 1 – Prepare an SD-Card with a Raspbian official image and boot your Raspberry for the first time.
Step 2 – Install the packages required to compile Oscam for the Raspberry.
Step 3 – Get the source, compile and install Oscam on the Raspberry.
Step 4 – Final tweaks on your new Oscam server.

So, before we start, you are going to need to download a few tools and the Raspberry Image.
Below is the list of tools I used, there are others but these ones worked for me.

Tools Required

Win32DiskImagerhttps://launchpad.net/win32-image-writer

This tool will be used to load the Raspbian Image into the SD-Card.

Puttyhttp://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

This is an SSH and Telnet client which will be used to remotely access the Raspberry.

Filezilla FTP Client- http://filezilla-project.org/download.php?type=client

This is an FTP client that supports SFTP which will be used to send files to the Raspberry using the SFTP protocol.

Raspbian Imagehttp://www.raspberrypi.org/downloads

This is the Raspbian image which will be loaded into the SD Card (need a 2Gb card or higher).

 Ok, now that you have downloaded the tools, let´s get started.

Step 1 - Prepare an SD-Card with a Raspbian official image and boot your Raspberry for the first time.

There are several images for the Raspberry. On this tutorial we are using the official Raspbian image. It comes with alot of stuff you will not use on a dedicated Oscam server, like the X server and the LXDE Enviroment but we will use this image and not remove anything because you might want to use your raspberry for other stuff while running Oscam at the same time.

  1. Extract the Raspbian image you downloaded into a folder on the computer.
  2. Insert your SD Card on the computer card reader or an external card reader.
  3. Launch the Win32DiskImager and select the image you extracted (ex: 2012-09-18-wheezy-raspbian.img).
  4. Select the drive letter of the SD Card you want to flash.
  5. Click on “Write” and wait for the process to terminate.

There are many other ways to flash the image on the SD Card as you can see here.

Now that the image is flashed, it is time to insert the card into the Raspberry and connect the power, display and network cable.

Remember that the default login for this image is :

Username : pi
Password : raspberry

At the raspberry first boot you will see a configuration menu which will allow you to setup your system (this is the raspi-config tool which you can call at any time by using the “sudo raspi-config” command).

The only changes I made on this menu was the “expand_rootfs” option because I have an 8Gb SD-Card and wanted to use the full space (by default it uses just 2Gb) and I changed my password and the timezone to correct the date/time for my country and zone.

After setting your changes I advise you to restart your raspberry.

 

Now that you have installed your image on the Raspberry it is time to prepare the system for Oscam.
You will obviously need to type some commands to install the packages, you can do this by using a keyboard connected on one of the USB ports or you can do it remotely using SSH and I recommend the SSH method because you will be able to copy & paste commands which is very useful. In order to remotely access the Raspberry SSH server, it should be connected to the network and you need to know which IP address it has acquired from the DHCP server.

After booting the raspberry there will be a message on the console which says something like “My IP address is xxx.xxx.xxx.xxx”.
After logging into the raspberry you can also type “ifconfig” and you will see the network configuration for the eth0 device. The second line should be something like “inet addr: xxx.xxx.xxx.xxx”. That is the raspberry IP address.

Now that you know which IP address is being used by your raspberry :

  1. Launch putty.exe.
  2. Type the IP address of the raspberry in the Hostname field.
  3. Click on “Open“.
  4. Accept the certificate and login with the “pi/raspberry” account.

 

The first step of this tutorial is done.
You have successfully loaded an image into your raspberry and now have remote access to the system.

Step 2 - Install the packages required to compile Oscam for the Raspberry.

Now that you are logged into the system, you will install all the packages required to compile Oscam.

You can paste the following commands into Putty by clicking the right mouse button.

First, you will update the package repositories of the APT system.

sudo apt-get update

The sudo command is used when you need to do something that requires permissions of a superuser. We use it because the “pi” account is not a superuser and system level operations like installing packages need a superuser account.

Now, let´s install the packages for compiling Oscam.

sudo apt-get install subversion cmake build-essential libssl-dev libpcsclite1 libpcsclite-dev dialog

If you are using USB smartcard readers, you will need to compile libusb.

Go to your home directory.

cd ~

Download libusb sources from sourceforge.

wget http://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-1.0.9/libusb-1.0.9.tar.bz2

Extract the sources.

tar xjvf libusb-1.0.9.tar.bz2

Compile libusb and install.

cd libusb-1.0.9
./configure
make
sudo make install

Back to home directory.

cd ~

All packages required for compiling Oscam have been installed.

Step 3 - Get the source, compile and install Oscam on the Raspberry.

Now that you have all the required tools to compile Oscam, let´s get the source from the SVN repository.

svn checkout http://www.streamboard.tv/svn/oscam/trunk oscam-svn

Get inside the sources folder.

cd oscam-svn

Make the folder where the compiled binaries will be created.

mkdir build

Get inside the folder.

cd build

Prepare the build using cmake.

cmake ..

Compile Oscam

make

Install Oscam

sudo make install

If everything went smooth without any errors, you should now have Oscam installed on your system.
The oscam binary should now be located at /usr/local/bin.

By default oscam will attempt to read the configuration files located at /usr/local/etc so we have to copy the files into it.

Let´s change the ownership of the configuration folder so you are able to upload files using the SFTP client using the pi account.

sudo chown pi.pi /usr/local/etc –R
  1. Launch Filezilla FTP Client
  2. Open the Site Manager and create a new site.
  3. Select protocol “SFTP – SSH File Transfer Protocol”.
  4. Select Logon Type “Normal”.
  5. Type your raspberry username and password and click “OK”.
  6. Navigate to /usr/local/etc folder and upload your oscam configuration files.

Note : If you don´t have any configuration files already created, check /home/pi/oscam-svn/Distribution/doc/example.

 

To test you new Oscam server, type

sudo oscam

Congratulations, you have successfully compiled and installed Oscam on your Raspberry.
If you want to learn how to setup oscam to start on boot and set a fixed IP address, check the next step.

Step 4 - Final tweaks on your new Oscam server.

On this step you will be able to set oscam like a daemon which will be started when the system boots and set a fixed IP address.

Setting up a fixed IP address.

This is quite simple. You just need to edit a file and restart the interface.

Edit the network configuration file.

sudo nano /etc/network/interfaces

Find the line that reads “iface eth0 inet dhcp” and replace with the following lines.

iface eth0 inet static
address 192.168.1.130
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

Replace the IP address to reflect your own network settings.

Now restart the network service.

sudo /etc/init.d/networking restart

If you are using SSH to edit the settings, you will be disconnected because you restarted the network.
You can now connect to the Raspberry using the new IP address.

Start Oscam with system boot.

To start Oscam automatically when your system boots is quite useful because if you have a power failure you make sure that Oscam will start when the power comes back and your system reboots.

To do this, we just need to copy a script to the /etc/init.d/ folder and set it´s runlevel.

Copy the following script and save it on your computer with the name “oscam”.

#! /bin/sh
### BEGIN INIT INFO
# Provides:          Oscam
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Oscam init script
# Description:       Launch oscam at startup
### END INIT INFO
 
DAEMON=/usr/local/bin/oscam
DEAMON_OPTS="-b -r 2"
PIDFILE=/var/run/oscam.pid
 
test -x ${DAEMON} || exit 0
 
. /lib/lsb/init-functions
 
case "$1" in
    start)
	log_daemon_msg "Starting OScam"
	start-stop-daemon --start --quiet --background --pidfile ${PIDFILE} --make-pidfile --exec ${DAEMON} -- ${DAEMON_OPTS}
	log_end_msg $?
    ;;
    stop)
	log_daemon_msg "Stopping OScam"
	start-stop-daemon --stop --exec ${DAEMON}
	log_end_msg $?
    ;;
    force-reload|restart)
    $0 stop
    $0 start
    ;;
  *)
    echo "Usage: /etc/init.d/oscam {start|stop|restart|force-reload}"
    exit 1
    ;;
esac
 
exit 0

On putty type the commands :

sudo touch /etc/init.d/oscam
sudo chown pi.pi /etc/init.d/oscam

Open Filezilla and upload “oscam” file to “/etc/init.d”.

Type the command

sudo chmod 755 /etc/init.d/oscam

Now that you have the script and have setup the correct execute permissions, type :

sudo update-rc.d oscam defaults

Oscam is now setup to run at system boot.

If you come into any problems or find mistakes or have any suggestion to improve this tutorial, please leave a comment below.
Thank you for your time.
:-P
This entry was posted in Cardsharing, Oscam.

56 Responses to Raspberry Pi and Oscam

  1. bernhard says:

    thank you for the very good guide!

  2. Cccam says:

    Thanks for sharing a very good guide of Oscam server.

  3. Dude says:

    Great Tutorial! Thanks!

  4. t_kirk says:

    Hi
    Thank you for your excellent tutorial, couldn’t be better =D

    But I have a question for you:

    After all the steps every thing went OK, no errors, but when I execut oscam it takes about 5 minutes to start working as it should, same thing when the raspberry boots (only 5 minutes afterr boot the oscam starts working)!!!

    Any sugestion?

    Once again thank you very mutch

    t_kirk

  5. Nigmo says:

    I am just experimenting with Pi and this is helping me ALOT. Thanks for your contribution!

  6. sw says:

    Card Reader is connect direct to pi or to hub ?

  7. Ant says:

    Great Tutorial! Thanks!
    I have a question. How many users can connect to it?

  8. Hassia says:

    Hello,
    great Tutorial.
    Most of the stuff worked. But it sadly didn’t work out completely.
    I did exact the same steps you say, to start OScam on boot. But I never got it running. There was always an error message. Could it be, that there is a mistake in your code?

    How do I have to modify “Step 3″ to load the latest stable version of OScam and not the latest unstable version !?

    Thanks a lot!
    Keep up the good work!

    Regards
    Hassia

  9. glen browne says:

    Absolutely brilliant thanks a million. even a linux noob like me managed to get this up and running. The only challenge I had was findin out what my USB device setting should be in oscam.server after moving from windows to linux. (device = /dev/ttyUSB0).

  10. clickclack says:

    Thanks for this great tutorial!

  11. vladimir says:

    Hi. Great tutorial !
    But I’ve got a problem. Oscam is running 24 of 36 hours and then it crash. Removing power off, oscam starts and at last in 1 or 2 hourscrashed again. Any solutions?
    PS. running oscam on asus WL-500g an on it is oscam forking for 2 week without estart

  12. Chris says:

    Can you please Add a Tutorial for Adding a Webinterface to Watch the Status from Oscam ?

    And Create a Tutorial for bind a Smargo on PI with HD+ (Black)

    big Thanks

  13. Gerhard says:

    Thanks for this brilliant tutorial!

    Everything works fine during installation.

    Many thanks!

  14. Cardsharing says:

    Hi
    Thank you for your excellent tutorial. You have providing useful step.

    Thanks.

  15. Klaus says:

    Best tutorial i read for a long time. oscam runs without any problem. thanks for the fantastic description.

    regards,
    Klaus

  16. Peter says:

    After compilation the oscam file was not in /usr/local/bin but in /home/pi/oscam-svn/build
    Please fix this in your guide.

    Also give us hints how to update oscam revision when it is already installed.

    thx

  17. Peter says:

    Sorry, I forgot “sudo make install”. So only the update is what I need…

  18. Peter says:

    1.
    In your guide you have wrong syntax:

    sudo chown pi.pi /usr/local/etc -R

    it should be

    sudo chown -R pi.pi /usr/local/etc

    2.
    can you update your Guide to let us know how to install and use ‘dialog’ to configure oscam before compiling?

    thanks

    • Hello Peter.

      “sudo chown pi.pi /usr/local/etc -R” should also work. But you are right, people usually do it the way you did.

      As for the dialog package. I believe you can install it using “apt-get install dialog”.

  19. Peter says:

    Yes but I want to know how to select options before compiling oscam (like pcsc suport on off, debug on off etc). I suppose there should be way via dialog how to do this (dialog is already installed by this guide).

    ANOTHER thing: oscam won’t start after reboot, later I found that in this instruction:
    “Copy the following script and save it on your computer with the name “oscam”.” should be written also “be sure Line endings is set to Linux (LF)”

    • Hi again. In order to config oscam with the dialog interface just execute the config.sh inside the oscam-svn folder with the “-g” parameter.

      Like :
      cd ~/oscam-svn
      ./config.sh -g

  20. Peter says:

    Warning!

    I followed this guide step by step but pcsc device was not working (omnikey). After I installed package “pcscd” (and for convenience “pcsc_tools”) omnikey was working, please update your guide.

    • Thank you for your feedback, I believe oscam will still be compiled with pcsc support but in order to use it you will need the pcscd daemon installed.

      I will soon update the tutorial.
      Thank you for your great feedback.

      • Peter says:

        hi,

        yes, oscam was compiled with pcsc even without pcscd. Can you also re-check if is still needed install libpcsclite1 libpcsclite-dev, in some another tutorial I saw only pcscd, but I did not tested this.

        Thank YOU for this great article. FYI this page is Number 1 result in google from 45000 results for search term “raspberry pi oscam” :)

  21. Peter says:

    Hello

    please fix one more thing, the oscam script, the restart command need to be fixed to wait (or detect) until oscam is killed and only then start, as for now it doesn’t work:

    pi@raspberrypi ~ $ sudo /etc/init.d/oscam restart
    [ ok ] Stopping OScam:.
    [FAIL] Starting OScam: failed!

    • Peter says:

      maybe changing stop like this will work

      stop)
      log_daemon_msg “Stopping OScam”
      start-stop-daemon –stop –exec ${DAEMON}
      sleep 5
      start-stop-daemon –stop –signal 9 –exec ${DAEMON}
      log_end_msg $?

  22. Bioshock says:

    i have installed only oscam whit this guide. Pcduino is armv7 such as raspberry pi…i need only Oscam or Oscam + CCcam. Thanks :D

  23. Steve says:

    Hi – Thanks for the Tuto above. Could you maybe include a script for checking the Oscam is running and IF not restart Oscam?

    Thanks

  24. Peter says:

    Hugo

    for libusb installation, is not faster just install apt-get -y install libusb-1.0-0-dev
    and then create symlink
    ln -s /usr/lib/arm-linux-gnueabihf/libusb-1.0.a /usr/local/lib/libusb-1.0.a

    or your way is somehow better than from apt-get?

    thanks

  25. Roger says:

    Superb guide :-)

    Do you know if “Argolis Smargo Triple Smartcard Reader” will work OK with the PI or do i need an external power for the cardreader?

    Thanks

  26. Ashley says:

    Great article. Just got the pi serving nicely. One disappointment though.. Under windows I was getting times of around 160ms. Under the pi, I’m seeing exactly the same times. This is using an omnikey3121.. I was sort of hoping for better response under the pi. I’m guessing that to get better, I’ll need to being out the smargo and powered hub and try over clocking? Just wondered if anyone has run some actual comparisons between win and the pi?

    • Ashley says:

      after testing with the Smargo, I can only get times equal to the Omnikey by overclocking the smart card to 700mhz (using a powered hub). All lower settings results in slower ECM times than the Omnikey.. so for the sake of simplicity and a few dollars, junk your Smargo and replace with an Omnikey 3121!

      • Peter says:

        I don’t think you can get better times than with Omnikey. And of course it’s not work like when you have linux it will be faster ecm than with windows, linux is recommended for stability.
        Omnikey is good but it can not handle irdeto cards.
        I think Omnikey is always clocking card to max frequency (what it got from ATR, and you can not change Omnikey frequency in settings), with smargo not for all cards you set card to max frequency, so that is why Omnikey has good times.

    • Peter says:

      Interesting, I had 3121 and it caused horrible instability for me, it was stable max 24 hours, then internal USB HUB was stopped, so reader and LAN was disconnected. I’m curious what are your experiences?

      They tried fix this in firmware issued about 2 weeks ago, but before it was a nightmare. And even now, it should be fixed only that HUB is not disconnected, but error still will be there, check your syslog files and let me know, thanks.

  27. Ashley says:

    Omnikey 3121 has been stable for weeks under windows and has been stable for days under Linux (this is using nds sky blue nz card). No difference between windows or Linux in terms of ecm. As said ecm under smargo is not better despite overclocking. I compiled oscam under win7 using latest cygwin etc rather than using binaries from tekreader, and compiled under Linux using instructions here. I am temped to look at oscam source code to see where the 160ms is being sucked up, but I’m sure there must be lots of people much cleverer than me that can look at that.

    • Peter says:

      I’m not 100% sure about this, but I think delay is cause by fact, that Smargo is just USB-Serial FTDI converter and reader is attachet to this COM port.

      Omnikey use PCSC protocol so speed of USB port is used, so basically the delay times what you see with Omnikey is caused just by smartcard, not by communication between reader and computer.

  28. GA says:

    Hi! I’ve followed this guide, but ends up with this error: PCSC failed establish context (8010001d)

    I’ve tried both with Cardman 2020 and Cardman 3121..

    Any suggestions?

  29. Chris says:

    Hello

    I have read your article with interest although I am a total beginner with all of this and was just practising. I have got up to the FTP bit and it says Note : If you don´t have any configuration files already created, check /home/pi/oscam-svn/Distribution/doc/example. I don’t have a card readre currently so should I just be copying the files above into /usr/local/etc and expect something to happen when I type sudo oscam, as it seems to throw an error of some sort then the command prompt (pi – $) bit doesn’t come back.

    I apologise if this is something obvious, but I was just trying to try it out before I actually bought a card reader and looked into what else I would need to do.

    Thanks

  30. M.J says:

    Type

    sudo oscam &

  31. Phil says:

    How do you update oscam to latest version once its been installed?

  32. Mario says:

    Great work and thank you for this manual.

  33. luetter says:

    Hi, i have the same question:

    How do you update oscam to latest version once its been installed?

    Thanks for your reply

  34. lachambre says:

    hello jai execute the entire operation, the problem of that jarive with fillezilla it vaus not copy file in usr / local / etc, you know the copy manuelemnd vias usb key?

  35. yba says:

    Can Oscam and some torrent app work together on same Pi?

  36. Bhushan says:

    I just want to know that Is it OK if I install OSCAD instead of Scilab on Raspberry Pi or Oscad also needs Java?

  37. andhy says:

    Thanks for sharing this tutorial, whith this I was able to install oscam on my Cubieboard (allwinner a10) with cubian (based on Debian wheezy) with just following your tutorial.

    Thanks again

  38. Phil says:

    Hi followed your tutorial to the letter but Oscam was not starting for me

  39. ndesorden says:

    Hi! great tutorial…

    But please….fix this because i spent a fuck*ng hour…wondering whats happening LOL

    DEAMON_OPTS=”-b -r 2″

  40. BASKA says:

    Many thanks for this stuff!
    Did everything as written, immediately started to work.
    Great job.

  41. Hi there to all, how is everything, I think every one
    is getting more from this website, and your views are pleasant for new viewers.

  42. BiLLY says:

    I have Banana Pi, everything went well, but oscam doesn’t start after the restart. What did I miss here?

  43. BiLLY says:

    The oscam script doesn’t work in Banana Pi – oscam does not start after reboot.

Leave a Reply

Your email address will not be published. Required fields are marked *


four × 4 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">