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 …
So for the server side of LCDproc we need a display driver (for example the driver for the HD44780).
By default OpenELEC only has a very few drivers included (to conserve space), and unfortunately for us; the HD44780 is not included. To include this drive we need to go build our own image.
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
For the Raspberry Pi OpenELEC image to support the HD44780 LCD display we should first do some initial settings before we start our initial build:
cd projects/RPi/ nano options
Find the line that starts with LCD_DRIVER and modify it to:
LCD_DRIVER="all"
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).
PROJECT=RPi ARCH=arm make

After the build you can mount the system file – see Mounting Squashfs section below this article.
Edit settings.xml:
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
to: Driver=hd44780
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:
cd ~/OpenELEC.tv/packages/mediacenter/xbmc-addon-settings/config
Edit the file default_settings.xml:
nano default_settings.xml
Modify the LCD_DRIVER line to:
<setting id="LCD_DRIVER" value="hd44780" />
You can also set a different hostname (default is OPENELEC), for example:
<setting id="NET_HOSTNAME" value="RPiXBMC" />
This will go MUCH faster compared to the first time:
PROJECT=RPi ARCH=arm make
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
sudo umount /dev/sdb1 sudo umount /dev/sdb2
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
<haslcd>false</haslcd>
to:
<haslcd>true</haslcd>
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:
<lcd> <scrolldelay>8</scrolldelay> </lcd>
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.
A good source for available data for a LCD display: XBMC LCD.xml, XBMC Infolabels.
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:
sudo umount /media/System
Hi,
this looks like exactly what I want to do with my RaspPi and OpenElec. I’m new to the use of displays like this, so hope you can answer one question I have around the hardware aspect. The screen you purchased from http://www.lcdmodkit.com – did it come with a lcd2usb physical adaptor? Or do I still need to learn how to create one of these out of the bare bits? Presumably this sits between the screen and my RaspPi allowing me to connect it directly to the usb port…?
Cheers,
Will
Hi Will,…
Yes, mine came with the lcd2usb attached to it. The downside is that the one I got had a USB cable attached, intended to be plugged in to a mainboard (for internal USB ports).
It wasn’t difficult to work around that problem, just watch the pin-layout.
Mine lcd project was 14 years ago so this might be stupid question.
Isn’t that hd4… controller used via parallert port. So how can it even work with only 4 wires shown in the pic ?
Well, controllers can be either serial or parallel. Parallel doesn’t require 8 pins perse, for example if only the first 4 bits are relevant.
In this setup though it’s all handled by the USB adapter.
You could use the IO pins of the Raspberry Pi of course as well – the driver would be a different one of course and it would save you the USB adapter. The kit used in this article I bought had it all already combined. My old project did not; that LCD I ripped from an old company phone
Hello,
as far as I know the 4 highest bits are relevant, when using 4bit mode for the Hitachi compatible displays.
http://arduino.cc/en/Tutorial/LiquidCrystal
Next question: where can I get such an lcd2usb adaptor? Or does someone have schematics (preferably Atmel 328P?) for it?
Bye,
Tom
You are probably correct, about the 4 highest bits, that’s how I used to control it with the parallel port in the old days, way back when …
As for getting the LCD2USB adaptor; I got mine as a complete kit on eBay.
But I understand it’s based on this LCD2USB Project.
You’ll find schematics, PCB, etc there.
The one I got from eBay looked like a much more compact SMD version though.
Leave a Comment
AVATAR - We use Gravatar.com for our Avatars. Gravatar is free and globally used.
CODE - We support some Basic HTML, and code highlighting (use <PRE>).
LINKS - Links are clickable if you start them with "http:\\". Example: http:\\www.tweaking4all.com
EMOTICONS - Smileys/Emoticons convert to images after placing your comment.