<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/doc/casestudyqws.doc:36 --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Qt/Embedded Case Study - Cassiopeia E-100</title> <style type="text/css"><!-- h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } body { background: #ffffff; color: black; } --></style> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr bgcolor="#E5E5E5"> <td valign=center> <a href="index.html"> <font color="#004faf">Home</font></a> | <a href="classes.html"> <font color="#004faf">All Classes</font></a> | <a href="mainclasses.html"> <font color="#004faf">Main Classes</font></a> | <a href="annotated.html"> <font color="#004faf">Annotated</font></a> | <a href="groups.html"> <font color="#004faf">Grouped Classes</font></a> | <a href="functions.html"> <font color="#004faf">Functions</font></a> </td> <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Qt/Embedded Case Study - Cassiopeia E-100</h1> <p> <h2> Introduction </h2> <a name="1"></a><p> This document describes the steps involved in installing Linux on an embedded device and building a Qt/Embedded application. The target device is the Cassiopeia E-100/E-105. The device has a MIPS Vr4121 processor, 16MB RAM (32MB in the E-105), a Compact Flash slot and a 240x320 16 bit per pixel LCD display. <p> The only part of this document that is specific to the Cassiopeia is the installation of Linux and the development tools. The example application can be compiled and run on your desktop machine. <p> <h2> Installing Linux </h2> <a name="2"></a><p> All the information and software required to get Linux running on the VR series of processors is available from the <a href="http://www.linux-vr.org/">Linux VR</a> web site. In Summary: <p> <h3> Install the tools </h3> <a name="2-1"></a><p> Follow the instructions at <a href="http://www.linux-vr.org/tools.html">http://www.linux-vr.org/tools.html</a>. <p> <h3> Build the kernel </h3> <a name="2-2"></a><p> Get a sample root ramdisk from <a href="ftp://ftp.ltc.com/pub/linux/mips/ramdisk/ramdisk">ftp://ftp.ltc.com/pub/linux/mips/ramdisk/ramdisk</a>. <p> Follow the instructions at <a href="http://www.linux-vr.org/ramdisk.html">http://www.linux-vr.org/ramdisk.html</a> to create a ramdisk.o file. <p> Now build your kernel <a href="http://www.linux-vr.org/kernel.html">http://www.linux-vr.org/kernel.html</a> using this ramdisk object. Make sure you have at least the following configuration: <p> <ul> <li> Development/incomplete drivers <li> Casio E105 Platform <li> Network and System V IPC <li> RAM disk and Initial RAM disk support <li> Support for console on virtual terminal (so that you can see boot messages) <li> <tt>/proc</tt> and ext2 filesystem support <li> Simple Frame Buffer with HPC device control </ul> <p> <h3> Booting Linux </h3> <a name="2-3"></a><p> Follow the instructions at <a href="http://www.linux-vr.org/booting.html">http://www.linux-vr.org/booting.html</a>. <p> You should see the linux boot messages on the LCD display. <p> <h2> A Qt/Embedded Application </h2> <a name="3"></a><p> Usually a device such as the Cassiopeia would have a shell, configured as the Qt/Embedded server, that allows client applications to be launched. For the purposes of this tutorial, we will write a simple application that serves as the Qt/Embedded server and client. A more complete Qt/Embbeded server can be found in <tt>$QTDIR/examples/compact</tt>. <p> The application that we will write is a simple note pad. It will allow notes to be created, viewed and deleted. Since the Cassiopeia doesn't have a keyboard, we will include a simple on-screen keyboard for input. <p> <h3> Note Pad </h3> <a name="3-1"></a><p> Our note pad user interface is very simple. It consists of a toolbar with "New" and "Delete" buttons, a combo box to select the note to view and an editing area. <p> Take a moment to browse the source code for Note Pad in <tt>$QTDIR/examples/notepad/</tt>. The code is quite simple, but there are some things worth noting: <p> <ol type=1> <li> Two fonts are set - helvetica 10 point as the application's default font, and helvetica 12 point for the editor. Since we will use prerendered fonts these fonts must be prepared as <a href="emb-fonts.html">described here</a>. <li> The <a href="qapplication.html">QApplication</a> is constructed with the QApplication::GuiServer type specified. This makes the note pad a Qt/Embedded server. One server must be running for Qt/Embedded clients to run. In this case our application is both server and client because it is the only application we wish to run on our device. <li> The Cassiopeia (usually) has no keyboard so we must provide some means of character input with the pen. The simplest method is to display a small keyboard. The compact example includes a keyboard, so we use this code. Key and pointer input is Qt/Embedded specific, so it is surrounded by #ifdef Q_WS_QWS ... #endif so that we can compile the example with Qt/X11 or Qt/Windows if we wish. <li> The touch panel needs to be calibrated. There is a calibration module included in the compact demo, so we use this. </ol> <p> <h3> Creating a suitable Qt/Embedded Library </h3> <a name="3-2"></a><p> Since our application is quite simple we can remove some unnecessary features from Qt/Embedded. Edit <tt>$QTDIR/src/tools/qconfig.h</tt> and disable the following features: <pre> #define QT_NO_IMAGEIO_BMP #define QT_NO_IMAGEIO_PPM #define QT_NO_IMAGEIO_XBM #define QT_NO_IMAGEIO_PNG #define QT_NO_ASYNC_IO #define QT_NO_ASYNC_IMAGE_IO #define QT_NO_TRUETYPE #define QT_NO_BDF #define QT_NO_FONTDATABASE #define QT_NO_MIME #define QT_NO_SOUND #define QT_NO_PROPERTIES #define QT_NO_CURSOR #define QT_NO_NETWORKPROTOCOL #define QT_NO_COLORNAMES #define QT_NO_TRANSFORMATIONS #define QT_NO_PSPRINTER #define QT_NO_PICTURE #define QT_NO_LISTVIEW #define QT_NO_CANVAS #define QT_NO_DIAL #define QT_NO_WORKSPACE #define QT_NO_TABLE #define QT_NO_LCDNUMBER #define QT_NO_STYLE_MOTIF #define QT_NO_STYLE_PLATINUM #define QT_NO_COLORDIALOG #define QT_NO_PROGRESSDIALOG #define QT_NO_TABDIALOG #define QT_NO_WIZARD #define QT_NO_EFFECTS </pre> <p> See <a href="emb-features.html">Qt Features</a> for a description of the features that can be disabled. This leaves us with a small set of widgets and dialogs necessary for our application. Cross-compile the library for the mips target on the x86 platform: <pre> cd $QTDIR ./configure -xplatform linux-mips-g++ -platform linux-x86-g++ make mipsel-linux-strip $QTDIR/lib/libqt.so.2.2.0 </pre> <p> The library is stripped to conserve ramdisk space. <p> <h3> Installation </h3> <a name="3-3"></a><p> Compile the application: <pre> cd examples/notepad make mipsel-linux-strip notepad </pre> <p> We have chosen to link the application dynamically. While this is important if we plan to run multiple applications, it is a waste of space in an application such as notepad that is supposed to be the only application running. You can link statically by configuring with: <pre> ./configure -static -xplatform linux-mips-g++ -platform linux-x86-g++ </pre> <p> We must install our application and its support files in the ramdisk. Mount the ramdisk using loopback device (you will need loopback device support in your kernel): <pre> mkdir /mnt/ramdisk mount -o loop ~/ramdisk /mnt/ramdisk </pre> <p> Copy the Qt/Embedded library to the ramdisk <tt>/lib</tt> directory and make the necessary links: <pre> cd /mnt/ramdisk/lib cp $QTDIR/lib/libqt.so.2.2.0 . ln -s libqt.so.2.2.0 libqt.so.2.2 ln -s libqt.so.2.2.0 libqt.so.2 </pre> <p> The fonts must be installed in <tt>/usr/local/qt-embedded/etc/fonts</tt>: <pre> cd /mnt/ramdisk mkdir usr/local mkdir usr/local/qt-embedded mkdir usr/local/qt-embedded/etc mkdir usr/local/qt-embedded/etc/fonts cp helvetica_100_50.qlf helvetica_120_50.qlf usr/local/qt-embedded/etc/fonts </pre> <p> When the kernel boots it looks for several files to run. In order to have our application run when the kernel boots, we change its name to <tt>/bin/sh</tt>. A <tt>/tmp</tt> directory is also used by Qt/Embedded: <pre> cp $QTDIR/examples/notepad/notepad /mnt/ramdisk/bin/sh mkdir /mnt/ramdisk/tmp umount /mnt/ramdisk </pre> <p> Create a ramdisk object, link it with the kernel, copy it to the compact flash and boot Linux. You should see the calibration screen appear on the LCD display. <p> <!-- eof --> <p><address><hr><div align=center> <table width=100% cellspacing=0 border=0><tr> <td>Copyright © 2001 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a> <td align=right><div align=right>Qt version 3.0.2</div> </table></div></address></body> </html>