When the Raspberry Pi, a small computer for $35 (for the more advanced model) capable of handling 1080p video and capable of running Linux and applications like XBMC or MAME, was announced, I had to get my hands on one. As some of you; that wasn’t easy. They were pretty much sold out before they became available.
The beauty of this little guy that it’s price is equal or lower that much more limited microcontrollers like the Arduino and Basic Stamp microcontrollers.
For me this meant that this could be the best alternative to a computer for running XBMC.
Once I got that running smooth, I really wanted an LCD display connected, and bought a HD44780 based 20×4 display complete with LCD2USB adapter (I got this LCD display). I have worked with the HD44780 and a BasicStamp 2 before and figured; it couldn’t be all that complicated.
But since my first LCD project things have evolved segnificantly. Linux, through LCDproc, supports LCD’s now in a magnificent way. No more tinkering with the parallel port and half-assed self coded programs needed (see one of my older LCD projects).
We are going to use LCDproc, a client/server setup where the server handles the display of information on a LCD display (it can also handle some basic input through buttons). The LCD’s can be of different models and manufacturers, and be connected through several interfaces (like USB, serila port, I2C, GPIO, etc). Supported devices are simply added through drivers.
The client application(s) talk to the server through TCP sockets. LCDproc comes with such a client application to display things like CPU load, system load, memory usage, uptime, and a lot more. Another example of such a client is our beloved XBMC …
I’ll admit (see some posts here) that I’m not an expert, but I took the effort to write down all the steps I went through and hope it might be helpful for others.
Based on information found in the very informative OpenELEC Wiki page: Building and Installing OpenELEC for Raspberry Pi. This version is condensed and very much geared towards LCD support. All of this has been done running Ubuntu 12.04 as a virtual machine on VMWare Fusion on a Apple Mac.
We first will go to our “home” directory and then use apt-get to install some tools we need to build an image.
cd ~ sudo apt-get install g++ nasm flex bison gawk gperf autoconf automake m4 cvs libtool byacc texinfo gettext zlib1g-dev libncurses5-dev git-core build-essential xsltproc libexpat1-dev libusb-dev lcdproc git-core autopoint libxml-parser-perl xfonts-utils zip
We can get the source code from github as follows:
cd ~ git clone git://github.com/OpenELEC/OpenELEC.tv.git
Find the line that starts with LCD_DRIVER and modify it to:
Close nano with CTRL+O (save file) and CTRL+X (close nano).
This will download additional sources and such that we need to make some modifications.
Build time this first time can take several hours but following builds might go faster (specially when making minor modifications).
After the build you can mount the system file – see Mounting Squashfs section below this article.
cd ~/OpenELEC.tv/packages/mediacenter/xbmc-addon-settings/source/resources/ nano settings.xml
Find the line with LCD_DRIVER in it and add “|hd44780″ (so it will appear in the OpenELEC settings under XBMC):
<setting id="LCD_DRIVER" type="labelenum" label="2051" values="none|irtrans|imon|imonlcd|mdm166a|MtxOrb|hd44780" sort="yes" default="none" />
Now we will change some default LCD settings in LCDd.conf, the configuration file of LCDproc.
cd ~/OpenELEC.tv/packages/sysutils/lcdproc/config nano LCDd.conf
Change the line that says: Driver=irtrans
Replace the [hd44780] section with:
## Hitachi HD44780 driver ## [hd44780] ConnectionType=lcd2usb Contrast=850 Brightness=800 OffBrightness=0 Keypad=no Backlight=yes Size=20x4
Optionally you can change the welcome message (Hello=”") – keep the character width and row count in mind when doing so. There is also a GoodBye message but that appears to not work.
Set the hd44780 as a default:
Edit the file default_settings.xml:
Modify the LCD_DRIVER line to:
You can also set a different hostname (default is OPENELEC), for example:
This will go MUCH faster compared to the first time:
A quick description how to make an SD card to boot from – if you are experimenting then you’ll have to do this only once and for new builds just copy the kernel.img and the SYSTEM file again overwriting the previous versions. Be aware though that certain settings for OpenELEC from your previous set will remain on the SD card if you do this which may affect your experimentations.
I found the easiest way is to insert the card an use dmesg to determine what was added last.
On my computer is was /dev/sdb.
As of this point we will assume that the SD card device is /dev/sdb!
mkdir /media mkdir /media/System mkdir /media/Storage
Be careful; if your SD card device is not is not /dev/sdb then replace all occurrences in the following examples with the proper device name for your SD card.
Note: just incase you have used this SD card before, we will unmount all partitions first, unmount them all of if you had more than 2 partitions on yours.
sudo umount /dev/sdb sudo umount /dev/sdb1 sudo umount /dev/sdb2 sudo parted -s /dev/sdb mklabel msdos sudo parted -s /dev/sdb unit cyl mkpart primary fat32 -- 0 16 sudo parted -s /dev/sdb set 1 boot on sudo parted -s /dev/sdb unit cyl mkpart primary ext2 -- 16 -2 sudo parted -s /dev/sdb print all
It should look similar to:
Model: Generic- Multi-Card (scsi) Disk /dev/sdb: 7965MB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 1049kB 132MB 131MB primary boot, lba 2 132MB 7948MB 7816MB primary
sudo mkfs.vfat -n System /dev/sdb1 sudo mkfs.ext4 -L Storage /dev/sdb2 sudo partprobe
sudo mount /dev/sdb1 /media/System sudo mount /dev/sdb2 /media/Storage
cd ~/OpenELEC.tv sudo cp build.OpenELEC-RPi.arm-devel/bcm2835-bootloader-*/arm128_start.elf /media/System/start.elf sudo cp build.OpenELEC-RPi.arm-devel/bcm2835-bootloader-*/bootcode.bin /media/System/ sudo cp build.OpenELEC-RPi.arm-devel/bcm2835-bootloader-*/loader.bin /media/System/
Copy the SYSTEM file and the kernel, note that the * must be replaced with the build number, for example:
replace * with “20120902221901-r11850” when your build looks like this: OpenELEC-RPi.arm-devel-20120902221901-r11850.kernel
sudo cp target/OpenELEC-RPi.arm-devel-*.system /media/System/SYSTEM sudo cp target/OpenELEC-RPi.arm-devel-*.kernel /media/System/kernel.img
And we need to create smdline.txt:
echo "boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p2 ssh quiet" | sudo tee /media/System/cmdline.txt
The first time you boot from a previously empty SD card will be a bit slower since OpenELEC creates SSH key, swap, and XBMC folder structures. Following boots will be faster.
Go to the shared network folder “userdata” and edit the file guisettings.xml. Change the line
Verify in OpenELEC settings (on your TV when running OpenELEC) that the “hd44780” is selected as the LCD display. The OpenELEC settings can be found in the Programs menu.
I had it happen with my LCD display; I could barely decipher what the scrolling messages where. To slow this down you will have to edit the advancedsettings.xml file in the “userdata” shared network directory:
Add to advanced settings:
The higher the number (0 – 10), the slower the scroll.
You might also want to edit the LCD.xml file in the “userdata” shared network directory - just to make sure it matches your LCD rows and columns.
Below an example of what I have done with my (for now anyway) – I tried to have the lines as much as possible to stick to a 20 character width to prevent scrolling. Watch for example the use of the System.Date(ddd mmm d) and System.time(hh:mm xx):
<lcd> <!-- set this to video,music to disable the LCD on playback of music and video--> <disableonplay>video</disableonplay> <navigation> <line>$INFO[System.CurrentWindow]</line> <line>$INFO[System.CurrentControl]</line> <line>$INFO[System.Date(ddd mmm d)] - $INFO[System.time(hh:mm xx)]</line> <line>IP: $INFO[Network.IPAddress]</line> </navigation> <music> <line>$INFO[MusicPlayer.Title]</line> <line>$INFO[MusicPlayer.Artist]</line> <line>$INFO[Player.Time]/$INFO[Player.Duration]</line> <line>$INFO[LCD.ProgressBar]</line> </music> <video> <line>$INFO[VideoPlayer.Title]</line> <line>$INFO[VideoPlayer.Genre] </line> <line>$INFO[Player.Time]/$INFO[Player.Duration]</line> <line>$INFO[LCD.ProgressBar]</line> </video> <general> <line>Hansie OpenELEC XBMC</line> <line>$INFO[System.Date(ddd mmm d)] - $INFO[System.time(hh:mm xx)]</line> <line>$INFO[System.ScreenWidth]x$INFO[System.ScreenHeight]</line> <line>IP: $INFO[Network.IPAddress]</line> </general> <screensaver> <line>$INFO[System.CurrentWindow]</line> <line>$INFO[System.Date(ddd mmm d)] - $INFO[System.time(hh:mm xx)]</line> <line>$INFO[Player.Time]/$INFO[Player.Duration]</line> <line>$INFO[LCD.ProgressBar]</line> </screensaver> <xbelaunch> <line></line> <line>Playing</line> <line>$INFO[System.LaunchXBE]</line> <line></line> </xbelaunch> </lcd>
This is also a good time to copy other config files to for example the “userdata” network share (like sources.xml, advancedsettings.xml, passwords.xml etc.) – you might want to do this before making the other modifications.
Actually, the SYSTEM file contains a entire filesystem in the squashfs format.
You could mount it to a directory (Read only!) to verify certain files.
For example; with a few compile attempts I had to discover on the SD card that /usr/lib/lcdproc/hd44780.so did not exist.
Instead of pepping the SD card over and over again, I simply mounted the system file, for example (under the assumption that you have nothing mounted to /media/System):
sudo mount ~/OpenELEC.tv/target/OpenELEC-RPi.arm-devel-20120903133050-r11850.system /media/System/ -t squashfs -o loop
The version number and release number in the filename should of course match the build you just made or wish to mount and explore.
In /media/System you will now be able to browse through the file structure.
When done, don’t forget to unmount: