Intro

In this blog post I will comment a bit on how I installed OpenELEC and Raspbian on the Raspberry Pi (2) using my ArchLinux based distro.

I also performed some benchmarks and measured some start/boot times.

 

Installation

Short intro on installation

It's really easy and fast to install these distros from scratch on any Linux OS (when you download the image). Alternatively you can also use NOOBS to install distros on the Raspberry Pi.

Advantage over using NOOBS: you can perform the installation offline (so without internet access) and the installation is faster, the disadvantage is that when you break your setup you might have to re-install.

NOOBS can be the best and easiest solution for some people. Personally I do not use NOOBS because the installation takes longer and the boot afterwards is also a few seconds slower beause of the added NOOBS menu.

I do recommend to read the info on the following link: NOOBS Setup | Raspberry Pi.

 

Downloading images

I've used OpenELEC (media center) and Raspbian. You can download these distros via the openelec.tv and raspberrypi.org websites. At the time I wanted to install the OpenELEC distro on my RPi2B, it had to be downloaded via the OpenELEC website (It wasn't available on the Raspberry Pi downloads page, or at least I did not see it immediately).

Dowloading OpenELEC

There are 2 images, one for the Pi version 1 and one for the Pi version 2 (make sure you download the correct one)!

OpenELEC-RPi.arm-5.0.6.img.gz / OpenELEC-RPi2.arm-5.0.6.img.gz

http://releases.openelec.tv/OpenELEC-RPi.arm-5.0.6.img.gz?mirrorlist

http://releases.openelec.tv/OpenELEC-RPi2.arm-5.0.6.img.gz?mirrorlist

Dowloading Raspbian

The Raspbian image works with both RPiB and RPi2B: http://downloads.raspberrypi.org/raspbian_latest

 

Find your (micro)SD device (really important step!):

Depending on your (micro)SD card reader, your drive might pop up as /dev/sdx or /dev/mmc*.

Check your dmesg | tail output right after your memory card is plugged in to your reader.

My internal card reader pops up in dmesg like:

[ 1952.245099] mmc0: new SDHC card at address 2320

[ 1952.249365] mmcblk0: mmc0:2320 SD08G 7.42 GiB

[ 1952.250439]  mmcblk0: p1

My USB memory card reader as:

[ 2084.797255] scsi7 : usb-storage 1-4:1.0

[ 2085.800321] scsi 7:0:0:0: Direct-Access     Generic- SD/MMC           1.00 PQ: 0 ANSI: 0 CCS

[ 2085.822107] sd 7:0:0:0: Attached scsi generic sg2 type 0

[ 2086.723674] sd 7:0:0:0: [sdc] 15556608 512-byte logical blocks: (7.96 GB/7.41 GiB)

[ 2086.724157] sd 7:0:0:0: [sdc] Write Protect is off

[ 2086.724167] sd 7:0:0:0: [sdc] Mode Sense: 03 00 00 00

[ 2086.724584] sd 7:0:0:0: [sdc] No Caching mode page found

[ 2086.724590] sd 7:0:0:0: [sdc] Assuming drive cache: write through

[ 2086.727604]  sdc: sdc1

[ 2086.729003] sd 7:0:0:0: [sdc] Attached SCSI removable disk

 

Additionally you can use parted to check how large your device is (if you have a SD card with 8GB inserted in your card reader you should see a size of more or less 8000MB)

 

parted /dev/mmcblk0 print

Model: SD SB08G (sd/mmc)

Disk /dev/mmcblk0: 7743MB

Sector size (logical/physical): 512B/512B

Partition Table: msdos

 

If you see a size of 120GB then it will probably your harddisk (so do NOT use this!)

parted /dev/sda print

Model: ATA WDC WD1200JB-00D (scsi)

Disk /dev/sda: 120GB

Sector size (logical/physical): 512B/512B

Partition Table: msdos

Disk Flags:

 

Number  Start   End     Size    Type      File system  Flags

1      32.3kB  12.6GB  12.6GB  primary   ntfs         boot

2      12.6GB  120GB   107GB   extended               lba

5      12.6GB  120GB   107GB   logical

 

So our card reader is at /dev/mmcblk0, 1 additional point to pay attention to: write to the sd device, not a partition on the device. /dev/mmcblk0p1 will indicate the first partition while /dev/mmcblk0 will indicate the device

 

Unpacking/Copying image to the SD card

In total I prepared 2 SD cards and 2 microSD cards.
Unpacking is done with gunzip (extension .gz) while copying the image can be done with dd or dcfldd.

(By default gunzip will remove the packed file and only leave the unpacked file.)

The dcfldd tool does exactly the same as dd, but in addition it also shows the progress.

Before using dd or dcfldd, make sure the device mentioned in "of=" is your (micro)SD card because you will lose all data on that device.

(bs is size to be read/writte at a time, if is the input file/device, of is the output file/device)

 

1) SD card 1

gunzip OpenELEC-RPi.arm-5.0.6.img.gz

dcfldd bs=1m if=OpenELEC-RPi.arm-5.0.6.img of=/dev/mmcblk0

2) microSD card 1

gunzip OpenELEC-RPi2.arm-5.0.6.img.gz

dcfldd bs=1m if=OpenELEC-RPi2.arm-5.0.6.img of=/dev/mmcblk0

3) SD card 2 and microSD card 2

gunzip 2015-02-16-raspbian-wheezy.img.gz

dcfldd bs=1m if=2015-02-16-raspbian-wheezy.img of=/dev/mmcblk0

The last command was used twice, since the same image can be used for both Raspberry Pi versions.

 

After the dd or dcfldd command is finished, you only need to plug the (micro)SD in your Raspberry Pi and boot it.

Most likely the file system will get expanded to the size of your SD card and you will be asked some questions on how to setup your system.

Depending on the distribution your Pi may restart 1 or more times.

 

Benchmarks

Default configuration is used unless otherwise specified.

Some overclocking was used, this was done by modifying the arm_freq=xxx parameter in the /boot/config.txt file.

I've not used overclocking before and there are also a lot of other parameters that I did not try (yet).

The reason why I tried to overclock is because I got a question from clem57 on my previous blog post.

 

Boot/Start times

Boot Test UntilRaspberryRaspberry Pi 2 B
1a Raspbian Login Prompt34s18.5s
1b Raspbian xinit11s5.5s
2 Raspbian Desktop44s23.5s
2 Raspbian Desktop (overclocked)43s (800MHz)23s (1000MHz)
3 OpenELEC (background)31s21s

4 OpenELEC (CEC connected)

35s24s

 

During the test a TV (with CEC support), keyboard, mouse and LAN cable were connected.

I modified the config of OpenELEC to use a mysql server (mysql is running on a pc in the network which hosts the Kodi/XBMC library) and changed some mappings of my TV remote.

On both the Raspberry Pi versions, the exact same config was used.


vi /storage/.kodi/userdata/advancedsettings.xml

<advancedsettings>
    <network>
        <disableipv6>true</disableipv6>
    </network>
      <videodatabase>
         <type>mysql</type>
        <host>192.168.0.40</host>
          <port>3306</port>
        <user>xbmc</user>
        <pass>somefancypassword</pass>
    </videodatabase> 
     <videolibrary>
          <importwatchedstate>true</importwatchedstate>
       </videolibrary>
</advancedsettings>






 

vi /storage/.kodi/userdata/keymaps/remote.xml

<keymap>
    <global>
        <remote>
              <skipminus>back</skipminus>
            <skipplus>ContextMenu</skipplus>
            <stop>XBMC.ActivateWindow(Home)</stop>
        </remote>
    </global>
  <home>
    <remote>
        <skipminus>XBMC.ActivateWindow(VideoLibrary,TvShowTitles)</skipminus>
        <skipplus>XBMC.ActivateWindow(VideoLibrary,addons://sources/video/)</skipplus>
          <reverse>XBMC.ActivateWindow(VideoLibrary,MovieTitles)</reverse>
    </remote>
  </home>
<FullScreenVideo>
    <remote>
        <pause>pause</pause>
          <stop>stop</stop>
        <skipminus>Info</skipminus>
        <skipplus>audiotoggledigital</skipplus>
        <reverse>aspectratio</reverse>
        <forward>VolumeUp</forward>
      </remote>
</FullScreenVideo>
</keymap>







To improve the boot times a bit more you can also edit the config.txt (in /boot or /flash, depends on the distro you're using) and add the following lines at the bottom:

disable_splash=1

boot_delay=0

Raspbian:

sudo vi /boot/config.txt

OpenELEC (In OpenELEC you need to remount the partition mounted on /flash as read/write. You do not need sudo because you're already the root user by default.):

mount -o remount,rw /flash

vi /flash/config.txt



Sysbench

I installed sysbench to run some CPU tests on the Raspberry Pis.

The command to install it:

sudo apt-get install sysbench

 

CPU

The command to start the CPU test with x threads is the following:

sysbench --test=cpu --cpu-max-prime=20000 --num-threads=x run

DeviceClock (in MHz)ThreadsExecution time (in seconds) : manual testExecution time (in seconds) : scriptCPU temp right after test (script only)
Raspberry Pi B70011334.62071332.243856.8'C
Raspberry Pi B7002-1336.483456.2'C
Raspberry Pi B80011166.66671163.122457.3'C
Raspberry Pi B80021171.2851 (*)
1166.393257.3'C
Raspberry Pi 2 B9001779.9761779.926149.2'C
Raspberry Pi 2 B9004196.2276-
Raspberry Pi 2 B9005-195.927456.8'C
Raspberry Pi 2 B10001707.0518701.849550.8'C
Raspberry Pi 2 B10004176.4975-
Raspberry Pi 2 B10005176.2414176.695960.0'C

(The lower the time, the better it is, because it means it can do the CPU test faster.)

(*) I'm not sure why this test with 2 threads is almost 5 seconds slower on the Raspberry Pi B compared to the test with 1 thread (I did read out the CPU temp while the test was busy, which I did not do during the other tests).


Memory

Memory transfer test of 2048MB

DeviceClock (in MHz)Transfer Speed (MB/s)Execution time (seconds)
Raspberry Pi B (1 threads) (*)700334.576.1213
Raspberry Pi B (2 threads)700335.876.0976
Raspberry Pi B (2 threads) (*)700333.886.1340
Raspberry Pi B (5 threads) (*)700334.006.1318

Raspberry Pi B (2 threads)

800335.376.1067
Raspberry Pi 2 B (5 threads)9001104.351.8545
Raspberry Pi 2 B (5 threads)10001183.481.7305

(*) Tests were executed manually afterwards. In general these tests seem to be worse compared to the previous tests executed during the script run.


Script

A script was written to execute some tests in bulk, the output is attachted to this blog (only the serial number was blanked out).

Below you can also find the script source. Feel free to (re-)use it.

#!/bin/bash
# v1.0 : 2015-03-21 : Johan Boeckx
DEBUG=0
TIME=1
THREADS=`cat /proc/cpuinfo | grep "processor.*:.*[0-9]" | wc -l`
THREADS=$((THREADS+1))
TIME=`date +%Y-%m-%d--%H-%M-%S`

seperator()
{
    local COLS=`tput cols`
    local IDX=0
    printf "\n"
    while [ ${IDX} -lt ${COLS} ] ; do
        printf "-"
        IDX=$((IDX+1))
    done
    printf "\n\n"
}

docmd()
{
echo "[CMD] $@"
echo
if [ ${DEBUG} -ne 0 ] ; then
    read -p "Run?" KEY
    if [[ $KEY == y* ]] ; then
        if [ ${TIME} -eq 0 ] ; then
            $@
        else
            time $@
            vcgencmd measure_temp
        fi
    fi
else
    if [ ${TIME} -eq 0 ] ; then
        $@
    else
        time $@
        vcgencmd measure_temp
    fi
fi
seperator
}

getInfo()
{
    TIME=0
    docmd cat /proc/cpuinfo
    docmd vcgencmd get_config arm_freq
    echo THREADS=${THREADS}
    TIME=1
}

doTests()
{
    getInfo
    docmd sysbench --test=threads --thread-locks=1 --max-time=20s --num-threads=${THREADS} run
    docmd sysbench --test=mutex --max-time=20s --num-threads=64 run
    docmd sysbench --test=memory --num-threads=${THREADS} --memory-block-size=1M --memory-total-size=512MB run
    docmd sysbench --test=memory --num-threads=${THREADS} --memory-block-size=1M --memory-total-size=1024MB run
    docmd sysbench --test=memory --num-threads=${THREADS} --memory-block-size=1M --memory-total-size=2048MB run
    docmd sysbench --test=memory --num-threads=${THREADS} --memory-block-size=1M --memory-total-size=4095MB run
    docmd sysbench --test=cpu --cpu-max-prime=20000 --num-threads=${THREADS} run
    docmd sysbench --test=cpu --cpu-max-prime=20000 run
}

doTests 2>&1 | tee res_sysbench_${TIME}.txt