OpenElec on the Raspberry Pi

OpenElec on the Raspberry Pi

The Home Theatre PC (HTPC) software distribution from OpenElec.tv is currently the easiest way to get high definition videos to play on the Raspberry Pi. Not only can you play your own videos from Windows or NFS shares, but by using add-ons you can stream video from many web sites. I previously have posted about OpenElec and some other distributions available for the Raspberry Pi in How the Raspberry Pi Spins. Recently, I posted about Playing HD Videos in Debian on the Raspberry Pi, which unlike XMBC does not provide a convenient way of browsing or creating play lists.

This post covers how to get started using OpenElec. First, it will cover how to download, extract and install it to your sd card. Next, it covers how to login remotely. For the security conscious, the next topic covers how to update the passwords on the system, or any other files on it's squashed root file system. A couple of Video Add-ons are also discussed. Finally, last but not least it explains how to calibrate your video output.

How do you install it?

The version of OpenElec for the Raspberry Pi does not appear on the http://openelec.tv/get-openelec page. At the bottom of that page is a link to Official Daily Builds, and on that page is the directory for openelec-rpi.  When you look at the filenames, they include the date of the build. The most recent one that works for me, including Video Add-ons, was built 2012-06-14. The two that were built on 2012-6-23, did not allow me to use Video Add-ons.

How do you login?

The console automatically logs in to the XMBC interface to be able to view or hear media, and to configure the system as well. Despite what the /flash/README.md file says, SSH is enabled in the build that is covered in this post.

From a remote machine, it is possible to login as the root user using SSH. Since OpenElec advertises using Avahi (ZeroConf), most systems should be able to resolve it's name as openelec.local. Otherwise, you can use the console to discover your network address under System Info. Windows users may want to install Putty to be able to have SSH capabilities.
  • ssh root@openelec.local
  • ssh root@ # address found in System Info

login: root
password: openelec

What if you want to change the password(s)?

The busybox executable that provides most of the commands for OpenElec does not have a passwd command, and the root file system is a read-only mounted squashfs file system. So, while you are running OpenElec, you cannot change the password. 

One way to set the password is to build OpenElec yourself, but I have an easier way. It is still not easy, but if you want to be able to have a secure system, then it is important to do.

First, you have to have squashfs-tools installed on your Linux system, then you can use the following procedure to change the password without having to rebuild OpenElec.  
  • Become the root user and make some directories to mount file systems
    • sudo su -
    • mkdir /openelec
    • cd /openelec
    • mkdir flash original updated newsquashfs
    • cd /
  • Insert the SD card with OpenElec installed on it and determine it's name
    • fdisk -l 
    • Should be the last device listed, in my case /dev/sdb
  • Mount the flash partition 
    • mount /dev/sdb1 /openelec/flash
  • Mount the squashfs SYSTEM file from the flash partition with loop option
    • mount -o loop /openelec/flash/SYSTEM /openelec/original
  • Copy the original root file system to /mnt/updated
    • cp -a /openlec/original/* /openelec/updated
  • (Optionally) Create a new user whose password you will use
    • useradd username
  • Set a password for this username
    • passwd username
  • Extract the password for the /etc/shadow file for the username
    • grep username /etc/shadow | cut -f2 -d:
  • Select and copy the password 
    • Use the mouse to select 
    • Right click, Copy or CTRL+SHIFT+c
  • Edit the updated file system shadow file
    • I use vim, but any editor will do: 
      • vim /openelec/updated/etc/shadow
    • On the line that starts with root, replace what is between the first and second colon(:) with what you have copied. (Right click, Paste or SHIFT-INSERT)
    • Save your changes
  • Edit any other user's passwords, or any other files you want to update. I also changed the password for the openelec user.
  • Make an updated squashfs SYSTEM file
    • mksquashfs /openelec/updated/  /openelec/newsquashfs/SYSTEM
  • Unmount the original SYSTEM squashfs file
    • umount /openelec/original 
  • Copy the new SYSTEM file over the old file 
    • cp /openelec/newsquashfs/SYSTEM /openelec/flash/SYSTEM
  • Unmount the flash partition
    • umount /openelec/flash
  • (Optional) Clean up the /openelec directory
    • rm -rf /openelec

What Video Add-ons?

In a working build, if you go to Videos, then Video Add-ons, Get More, then you can select numerous Add-ons to view videos from many sites. In the past, I was able to get the You Tube add-on working. Despite it warning me that the You Tube add-on was broken, everything I tried worked, although slowly.

I have also installed a video add-on for the Khan Academy. The Khan Academy has tons of educational videos nicely organized by this add-on. This could be another great way to use your Raspberry Pi for educational purposes.

How to Adjust the Video Output?

One of my early grievances with using OpenElec was that the video was not synchronized properly to my television. I discovered that it is easy to correct this problem. Simply navigate to the System, Settings, System, Video Output. Here you can change the Resolution, Refresh Rate, Vertical blank sync, Video calibration, Test patterns, and Enable LCD/VFD. 

Shortcut to video calibration:
  • While watching a video, move the mouse so the controls appear
  • Click on the icon in the lower right corner that looks like a film reel
  • Choose video calibration from the menu
Here's how to perform the video calibration:
  • Top left corner
    • The process begins by using the up and down arrows to align the top edge of a blue right angle. I had to press down many times before I even saw the blue right angle in the upper left corner of the screen. Next, use your right and left arrow keys to align the left edge of the blue right angle to the left edge of the screen. 
    • Press Enter
  • Bottom right corner
    • Aligning the bottom right corner of the screen with your arrow keys like the top left corner was aligned
    • Press Enter
  • Subtitle position
    • Use the up and down arrows to move the position of subtitles up or down the screen
    • Press Enter
  • Pixel adjustment ratio
    • Adjusting the width of the rectangle to make it a square can be done two ways
      • Hold down mouse button 1, and drag left or right and release when correct
      • Press left or right arrow keys
    • Press Enter
  • Press the ESC key to return to the menu 

1 comment:

xGhOsTkiLLeRx said...

Thanks for the great tutorial on how to change the password.
Saved some headache! :)