Welcome
raspberry_pi_openelec_hd44780

Raspberry Pi OpenELEC – Using a HD44780 display

You might be familiar with XBMC, one of the best Media Center like systems/applications out there. You also might know about the $35 computer called Raspberry Pi, and that some folks managed to get XBMC to run on this little guy; RaspBMC and my favorite: OpenELEC.

Well, in this article I’ll show you how I got an LCD display (Hitachi HD44780 based) combined with LCD2USB for use with the Raspberry Pi running OpenELEC XBMC.

RaspBMC user might find this article useful as well.
If you want to use a HD44780 based display without LCD2USB then you might want to read this post that uses the GPIO port directly.
The lcdproc manual pages show more details on how to configure lcdproc to use the HD44780.

Note: These instructions should be very similar for other OpenELEC systems (Generic, ATV, Fusion, ION, etc).



Introduction

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).

Raspberry Pi running OpenELEC XBMC with a HD44780

The Basics

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.

Building an OpenELEC image

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.

Step 1. Get the tools to be able to build an OpenElec image

We first will go to our “home” directory and then use apt-get to install some tools we need to build an image.

  1. cd ~
  2. 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
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

Step 2. Download latest OpenElec source

We can get the source code from github as follows:

  1. cd ~
  2. git clone git://github.com/OpenELEC/OpenELEC.tv.git
cd ~
git clone git://github.com/OpenELEC/OpenELEC.tv.git

Step 3. Initial Project settings before building

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:

  1. cd projects/RPi/
  2. nano options
cd projects/RPi/
nano options

Find the line that starts with LCD_DRIVER and modify it to:

  1. LCD_DRIVER="all"
LCD_DRIVER="all"

Close nano with CTRL+O (save file) and CTRL+X (close nano).

Step 4. Make an initial build

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).

  1. PROJECT=RPi ARCH=arm make
PROJECT=RPi ARCH=arm make
Information Message
Mounting your build

After the build you can mount the system file – see Mounting Squashfs section below this article.

Step 5. Settings.xml: LCD settings

Edit settings.xml:

  1. cd ~/OpenELEC.tv/packages/mediacenter/xbmc-addon-settings/source/resources/
  2. nano 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):

  1. <setting id="LCD_DRIVER" type="labelenum" label="2051" values="none|irtrans|imon|imonlcd|mdm166a|MtxOrb|hd44780" sort="yes" default="none" />
<setting id="LCD_DRIVER" type="labelenum" label="2051" values="none|irtrans|imon|imonlcd|mdm166a|MtxOrb|hd44780" sort="yes" default="none" />

Step 6. lcdproc server configuration

Now we will change some default LCD settings in LCDd.conf, the configuration file of LCDproc.

  1. cd ~/OpenELEC.tv/packages/sysutils/lcdproc/config
  2. nano LCDd.conf
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:

  1. ## Hitachi HD44780 driver ##
  2. [hd44780]
  3. ConnectionType=lcd2usb
  4. Contrast=850
  5. Brightness=800
  6. OffBrightness=0
  7. Keypad=no
  8. Backlight=yes
  9. Size=20x4
## 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.

Tip or Idea Message
Some additional Default Settings

Set the hd44780 as a default:

  1. cd ~/OpenELEC.tv/packages/mediacenter/xbmc-addon-settings/config
cd ~/OpenELEC.tv/packages/mediacenter/xbmc-addon-settings/config

Edit the file default_settings.xml:

  1. nano default_settings.xml
nano default_settings.xml

Modify the LCD_DRIVER line to:

  1. <setting id="LCD_DRIVER" value="hd44780" />
<setting id="LCD_DRIVER" value="hd44780" />

You can also set a different hostname (default is OPENELEC), for example:

  1. <setting id="NET_HOSTNAME" value="RPiXBMC" />
<setting id="NET_HOSTNAME" value="RPiXBMC" />

Step 7. Rebuild image with the settings we made

This will go MUCH faster compared to the first time:

  1. PROJECT=RPi ARCH=arm make
PROJECT=RPi ARCH=arm make

Creating an SD card

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.

Step 1. Determine device name of you SD card (reader).

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.

Caution Message
CAUTION!

As of this point we will assume that the SD card device is /dev/sdb!

Step 2. Create mount points for the partitions

  1. mkdir /media
  2. mkdir /media/System
  3. mkdir /media/Storage
mkdir /media
mkdir /media/System
mkdir /media/Storage

Step 3. Create partitions on your SD Card

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.

  1. sudo umount /dev/sdb
  2. sudo umount /dev/sdb1
  3. sudo umount /dev/sdb2
  4. sudo parted -s /dev/sdb mklabel msdos
  5. sudo parted -s /dev/sdb unit cyl mkpart primary fat32 -- 0 16
  6. sudo parted -s /dev/sdb set 1 boot on
  7. sudo parted -s /dev/sdb unit cyl mkpart primary ext2 -- 16 -2
  8. sudo parted -s /dev/sdb print all
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:

  1. Model: Generic- Multi-Card (scsi)
  2. Disk /dev/sdb: 7965MB
  3. Sector size (logical/physical): 512B/512B
  4. Partition Table: msdos
  5. Number Start End Size Type File system Flags
  6. 1 1049kB 132MB 131MB primary boot, lba
  7. 2 132MB 7948MB 7816MB primary
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

Step 4. Format partitions

  1. sudo mkfs.vfat -n System /dev/sdb1
  2. sudo mkfs.ext4 -L Storage /dev/sdb2
  3. sudo partprobe
sudo mkfs.vfat -n System /dev/sdb1
sudo mkfs.ext4 -L Storage /dev/sdb2
sudo partprobe

Step 5. Mount the partitions

  1. sudo mount /dev/sdb1 /media/System
  2. sudo mount /dev/sdb2 /media/Storage
sudo mount /dev/sdb1 /media/System
sudo mount /dev/sdb2 /media/Storage

Step 6. Copy the files

  1. cd ~/OpenELEC.tv
  2. sudo cp build.OpenELEC-RPi.arm-devel/bcm2835-bootloader-*/arm128_start.elf /media/System/start.elf
  3. sudo cp build.OpenELEC-RPi.arm-devel/bcm2835-bootloader-*/bootcode.bin /media/System/
  4. sudo cp build.OpenELEC-RPi.arm-devel/bcm2835-bootloader-*/loader.bin /media/System/
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

  1. sudo cp target/OpenELEC-RPi.arm-devel-*.system /media/System/SYSTEM
  2. sudo cp target/OpenELEC-RPi.arm-devel-*.kernel /media/System/kernel.img
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:

  1. echo "boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p2 ssh quiet" | sudo tee /media/System/cmdline.txt
echo "boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p2 ssh quiet" | sudo tee /media/System/cmdline.txt

Step 7. unmount the SD card before removing it …

  1. sudo umount /dev/sdb1
  2. sudo umount /dev/sdb2
sudo umount /dev/sdb1
sudo umount /dev/sdb2

Step 8. Insert card in Raspberry Pi and boot …

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.

Step 9. Change some more settings

Enable the support for LCD:

Go to the shared network folder “userdata” and edit the file guisettings.xml. Change the line

  1. <haslcd>false</haslcd>
<haslcd>false</haslcd>

to:

  1. <haslcd>true</haslcd>
<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.

Scrolling to fast?

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:

  1. <lcd>
  2. <scrolldelay>8</scrolldelay>
  3. </lcd>
<lcd>
<scrolldelay>8</scrolldelay>
</lcd>

The higher the number (0 – 10), the slower the scroll.

LCD messages

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):

  1. <lcd>
  2.    <!-- set this to video,music to disable the LCD on playback of music and video-->
  3.    <disableonplay>video</disableonplay>
  4.    <navigation>
  5.       <line>$INFO[System.CurrentWindow]</line>
  6.       <line>$INFO[System.CurrentControl]</line>
  7.       <line>$INFO[System.Date(ddd mmm d)] - $INFO[System.time(hh:mm xx)]</line>
  8.       <line>IP:  $INFO[Network.IPAddress]</line>
  9.    </navigation>
  10.    <music>
  11.       <line>$INFO[MusicPlayer.Title]</line>
  12.       <line>$INFO[MusicPlayer.Artist]</line>
  13.       <line>$INFO[Player.Time]/$INFO[Player.Duration]</line>
  14.       <line>$INFO[LCD.ProgressBar]</line>
  15.    </music>
  16.    <video>
  17.       <line>$INFO[VideoPlayer.Title]</line>
  18.       <line>$INFO[VideoPlayer.Genre] </line>
  19.       <line>$INFO[Player.Time]/$INFO[Player.Duration]</line>
  20.       <line>$INFO[LCD.ProgressBar]</line>
  21.    </video>
  22.    <general>
  23.       <line>Hansie OpenELEC XBMC</line>
  24.       <line>$INFO[System.Date(ddd mmm d)] - $INFO[System.time(hh:mm xx)]</line>
  25.       <line>$INFO[System.ScreenWidth]x$INFO[System.ScreenHeight]</line>
  26.       <line>IP:  $INFO[Network.IPAddress]</line>
  27.    </general>
  28.    <screensaver>
  29.       <line>$INFO[System.CurrentWindow]</line>
  30.       <line>$INFO[System.Date(ddd mmm d)] - $INFO[System.time(hh:mm xx)]</line>
  31.       <line>$INFO[Player.Time]/$INFO[Player.Duration]</line>
  32.       <line>$INFO[LCD.ProgressBar]</line>
  33.    </screensaver>
  34.    <xbelaunch>
  35.       <line></line>
  36.       <line>Playing</line>
  37.       <line>$INFO[System.LaunchXBE]</line>
  38.       <line></line>
  39.    </xbelaunch>
  40. </lcd>
<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.

Raspberry Pi OpenELEC XBMC and a HD44780 LCD display

Raspberry Pi OpenELEC XBMC and a HD44780 LCD display

Mounting Squashfs

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):

  1. sudo mount ~/OpenELEC.tv/target/OpenELEC-RPi.arm-devel-20120903133050-r11850.system /media/System/ -t squashfs -o loop
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:

  1. sudo umount /media/System
sudo umount /media/System




Share this ...


DISCUSSION

Share your opinion ...

Here you can read comments, post comments, or respond to comments.
A comment can be placed by scrolling down to the comment form.
You can reply to a comment by clicking the Reply button underneath a comment.

So far 6 comments have been left.
By Will - September 13th, 2012 at 6:11 AM

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


Reply
By Hansaplastique - September 14th, 2012 at 1:57 PM

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.

:)


Reply
By jukka - November 4th, 2012 at 3:51 PM

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 ?


Reply
By Hansaplastique - November 4th, 2012 at 8:29 PM

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 :)


Reply
By Tom - January 6th, 2013 at 2:00 AM

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


Reply
By Hansaplastique - January 6th, 2013 at 3:13 PM

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.


Reply

Leave a Comment


   Subscribe to comments

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.

Follow Us and Share