Programming application for mini2440 by Qt creator

   Applications for mini2440 can easily be programmed by using Qt creator installed on Ubuntu. The harsh problem you should overcome is reading some books about programming Qt to be able to make some more complicated applications.


   Right now, I will show you build a "hello world" program by Qt creator. Firstly, you should install Qt creator. Then, opening Qt creator to make a simple program "hello world". And lastly, copying it from host computer (Ubuntu) to mini2440.


1. Installing Qt creator:
    On Ubuntu, click on "Applications" -> "Ubuntu Software Center". In the new window appearing, you should type "Qt creator" on the search section located on the top right. Searching results should be presented with "Qt creator" in the first line. Click on it, then you will see "Install" button lying on the right.
  After successful installing Qt creator on your computer, you could open it on "Applications" -> "Programming" -> "Qt creator".

2. Making a simple program:
   Before typing a new program, it should indicate Qt creator know the cross-tool you are using to compile. Because we use a cross-tool to build program for ARM processor on mini2440, we will signify Qt creator knowing where qmake is (qmake is a cross-tool that is in Qt4.6.2 directory which is cross-compiled already. To know compiling Qt4.6.2, please have a look here).
   Okay, on screen of Qt creator, choose "Tools" -> "Options". In "Options" window, click to "Qt4" -> "Qt Version", on the right part you will see "Auto-detected" and "Manual". Click on "Manual" and then choose plus (+) button located on the top right, in section "Version Name" you could let down what name you like (I typed "mini2440"). In section "QMake Location", click on "Browse..." and you should indicate Qt creator know where the directory of qmake is. For what i did, I choose /usr/local/Qt/bin/qmake (That directory is generated by cross-compiled Qt4.6.2, if possible, you can have a look cross-compiling Qt4.6.2 here). Okay, if there is no fault, you will see a noted line of "Found Qt version 4.6.2, using mkspec /usr/local/Qt/mkspecs/qws/linux-arm-g++" under "Debugging Helper". Click "Ok" to complete this mission.
   Now is time to make new project, choose "File" -> "New File or Project" -> "Qt Gui Application" in "Project" section. Save it with name "ex1"  (click Next...next.. until face to Finish). In the IDE environment, drag "Label" and drop it in main window, change it into "hello world".

   On task-bar, choose "Build" -> "Build All" to build the program. Click on "Run" button to see the result on Ubuntu, if there is no fault, you will receive a window appearing with "hello world" line.
   To cross-compile program for mini2440, choose "Project" section located on the left. In "Building Setting", click "Release" on "Edit Build Configuration" part. At "General", choose "Show Details" button and choose "mini2440" (as the name I made before) in "Qt Version" section.
Okay, now you could cross-compile program for mini2440 by: "Build" -> "Set Build Configuration" -> "Release", then "Build" -> (MUST CHOOSE) "Rebuild All". Right now, if you run program in Ubuntu, you will receive a fault with something like this (it's because the program run on ARM processor, not on Ubuntu):

Starting /home/phuc/ex4/ex4...
/home/phuc/ex4/ex4 exited with code 255

Okay, now you can use SDcard to copy ex1 program into mini2440 and run it with command:
$ ./ex1 -qws

Normally, it will run as in Ubuntu.

3. Loading automatically my own program before qtopia
The first thing we should do is to stop qtopia, do this:
$cd /etc/init.d/ $vi rcS
Comment last three lines:

#bin/qtopia& 
#echo" "> /dev/tty1 
#echo"Starting Qtopia, please waiting..." > /dev/tty1

Reset the board, you will see that there is no qtopia desktop anymore but a black screen.

The second thing we do is to add the code to run our own program, for example, our program has a name as "ex1" and it is located in /mnt/ex1. In this step, we will make some changes from the files in article Upgrade Qt4.6.2
$cd /etc/ 
$vi profile

Cut those line:
export LD_LIBRARY_PATH=/usr/local/tslib/lib
export QTDIR=/usr/local/Qt                 
export QWS_MOUSE_PROTO=tslib:/dev/input/event0
export TSLIB_CALIBFILE=/etc/pointercal        
export TSLIB_CONFFILE=/usr/local/etc/ts.conf  
export TSLIB_CONSOLEDEVICE=none               
export TSLIB_FBDEVICE=/dev/fb0              
export TSLIB_PLUGINDIR=/usr/local/tslib/lib/ts
export TSLIB_TSDEVICE=/usr/local/tslib/lib/ts 
export TSLIB_TSEVENTTYPE=INPUT                
export QWS_DISPLAY=LinuxFB:mmWidth=105:mmHeight=140

Close and save it. Then:
$cd /etc/init.d/
$vi rcS

Paste above lines into the end of this rcS file, and add following line into the end of rcS file too
./mnt/ex1 -qws
Close and save it. Reset the board, the program ex1 will be loaded automatically instead of Qtopia.

0 Comments: