FBDirectOnConsoleLCD

=Intro=

Oh... one quick one... before we start here, I'm going to assume that you have a working Linux box with the latest GumStix build. You can find information about how to download and compile the canonical GumStix codebase by looking at the Getting The ConsoleLCD-VX Working page or the Buildroot page at GumStix' Wiki.

Specifically... I'm going to assume that you have a working environment for cross compiling. Once you've compiled gcc to be a cross-compiler, you setup the environment as described in the GumStix Programming page and use the command  to compile with. Actually... there's a cross-compiling version of all of the dev tools in the  directory, so including it in your path is probably a good idea. Here's a brief shell script I have that sets up the environment... you should change the value of  to reflect where you installed the gumstix source.

If you source this from the command line after you login, this should setup your environment to allow you to use the arm-linux-gcc command.

=Does the Frame Buffer Device Work?=

Well... this is a pretty simple question to answer... Yes, the frame buffer works, otherwise we wouldn't get the GumStix logo on the screen after booting. But I figured it might be prudent to spend a little time verifying that it works the way I think it's supposed to work.

Getting Frame Buffer Info
You can get information about the frame buffer via the command line by looking at the pseudo-files available in the directory:

For instance, if you wanted to know the size of the screen and the bits per pixel, you could cat two of the files in the directory like this:

Drawing Stuff on the Screen By Writing to /dev/fb0
Here's some code I wrote to exercise the frame buffer device. You can see the results on episode 2 of the hbmobile vlog.

When you want to draw stuff on the screen, you take the following steps:


 * 1) Include the appropriate headers
 * 2) Open the "/dev/fb0" device file
 * 3) Use the   syscall to get information about the device
 * 4) Use   to map the frame buffer into your process' memory space
 * 5) Poke pixels into screen memory

You can download a tar file with this code (which is released under a BSD style license) and a Makefile to help compile it.

Include Headers, Create a main, Yadda, Yadda, Yadda
So one of the things you can see that I do is I made an "App" data structure that's supposed to store the state of the application. You don't have to do this, I just thought it made things a little easier to deal with.

The most important part of the following code fragment is that it lists the headers you're supposed to use.

Initializing Things
For my money, this is where the most interesting stuff relating to frame buffer access occurs.. and it's not really that interesting. It's just boilerplate code.

Clearing the Screen
This code demonstrates simple access to the screen. We put a 0xFF in every byte in the frame buffer. It's pretty straight forward...

Drawing a Rainbow
This code shows how I draw a rainbow pattern.

Cleaning Up
Before we quit, we unmap the screen and close the device file. I think that Linux is smart enough to do this automagically when your process quits, but hey, it's always polite to explicitly tell the system your intentions.

=Does DirectFB Work on your Desktop Linux?=

After spending a bit of time trying to get DirectFB to work on the GumStix platform (and getting strange results,) I thought I would make sure I understand how it's supposed to work on a Desktop x86 system. So, to get DirectFB to work with the image we created on the VMWareImage page, we follow these steps.

Install PNG, JPEG, and FreeType2 Libraries
Execute the command:""

Download, Configure and Compile the DirectFB Source
Download version 1.1.0 of the DirectFB source by going to the web site and downloading it through your browser, or by executing the following commands:""

Now change directories to the DirectFB source directory and configure, make and make install it. I chose to install it in  and encountered some problems with getting X11 support to compile. So.. here's how I did it:""

Download, Configure and Compile the DirectFB Examples Source
Download version 1.0.0 of the DirectFB examples by going to the web site and downloading it through your browser, or by executing the following commands:""

Now change directories to the DirectFB examples directory and configure, make and make install it. Again, I chose to install the binaries into

Modify your Grub Settings and Reboot
In the file, find the line that begins with:""and append"" to it.

Now reboot your machine.

Change To Virtual Terminal 1
I tried changing the virtual terminal with the Ctrl-Alt-F1 using VMWare, but it didn't work especially well. Ctrl-Alt is key sequence that escapes the mouse from moving the virtual pointer, so I guess VMWare is gobbling that key sequence. I wonder if there's a way to tell VMWare to use a different key sequence?

You can, however, use the  command to change virtual terminals from the command line. So this command should do the trick:""

Login, Set Some Variables, Test the DirectFB Example Code
You should see a login screen. Go ahead and login with the username mobo and the password hbmobile.

You'll need to set some environment variables:""

And now you should be able to execute the example DirectFB applications in. My favorite is x86df_dok, it spits a lot of stuff on the screen and performs some simple benchmarking. w00t!

=Building DirectFB for the Verdex=

Okay, now that we know that DirectFB works, let's get it working for the Verdex. There are a couple ways we could do this. We could, for instance, integrate DirectFB into the buildroot system. I tried that, it's a fair amount of work; I'll let someone else handle that. Rather, what I'm going to do here is to simply configure the source packages to use the arm-linux build tools and compile them like I would any other package.

So what we're going to do is:


 * 1) download the right packages
 * 2) modify the source, where needed
 * 3) develop some build scripts to make our lives easier
 * 4) build
 * 5) prune the output of the build process
 * 6) transfer the files to the Verdex
 * 7) create some config files

Download Some Packages
We're going to be downloading the source for five packages: DirectFB, DirectFB Examples, FreeType, libjpeg and libpng. Here's a quick script that uses wget to grab all these files:""

Once they're downloaded, you'll want to untar them:""

Patch The DirectFB Source
There are three files in the DirectFB distribution that seem to be "sub-optimal" with respect to the arm-linux tools. I have a tar file you can download that overwrites them with the problematic bits turned off. Go ahead and download it and untar it in the directory you untarred the source packages into. This is what I did""

Build the Build Scripts
If you look closely, you'll see that I put some BUILD scripts in each of the directories we downloaded. You should probably look at each of the build scripts and do a sanity check. I'm assuming your configuration is like mine; make sure that the  directory is empty!

Build
We're going to build them in this order:


 * 1) libpng
 * 2) jpeg
 * 3) Freetype
 * 4) DirectFB
 * 5) DirectFB Examples (optional)

For each package, you'll do the same thing:


 * 1) change directories into the top level source directory
 * 2) execute the   command
 * 3) then execute the   command

Prune the Output of the Build Process
The build process creates a bunch of files we don't need on the platform: man pages, static libraries, etc. So... before we tar this stuff up for transfer to the Verdex, we might want to save a little space by pruning the tree a bit. What I do is I copy the contents of /opt to /tmp and then start deleting files...""

Move Things to the Verdex
You now have a tar file with the libraries you need to get DirectFB working. You can copy it over the serial link, or do what I did, put it on a thumb drive and hook it up to the Verdex's USB port. The default location for mounting USB storage devices seems to be, so here's what I did to unpack the contents of the opt.tar.gz file:""

Create Some Config Files
Now.. before you go on, it's very important to setup the  file. Specifically, you want to set it up so DirectFB knows we're dealing with eighteen bits per pixel. So, create a file  and put the following line in it:""

You'll also need to add  to the   and   to the.

(Optional) Run the DirectFB Examples
If you compiled the directFB examples, they should be in the  directory. Most of them start with the prefix. Knock yerself out!