Running a C program on mini2440

Am creating a simple Hello World program in C.This is the program

#include<stdio.h>
int main(){
 printf("Hello World\n");
}

saved it as hello.c..Now compiling it for our target or mini2440.

open terminal and change directory to the folder where c program is presnt and issue this command

arm-linux-gcc hello.c -o hello

The arm-linux-gcc command was present bcoz we setup the toolchain early.Now a binary hello will be present in the folder.use file command to know the type of the binary it will suitable for ARM.

Move the bianry to mini2440 using pendrive or sdcard.To see the output execute the binary like this..

./hello

Download a Full Website Using wget â€“mirror

Using wget command we can download an entire website which will be useful for local viewing

$ wget --mirror -p --convert-links -P ./LOCAL-DIR WEBSITE-URL

Chnage the LOCAL-DIR with your local folder name or if you are in that folder simply use a dot(.) then add wesite url at end….

Happy Hacking 🙂

Developing a Qt hello world App for mini2440

We must have precompiled Qt on our /usr/local/Qt as said in earlier post.Install Qt creator on your system from Ubuntu software centre

After sucessful installation you could open it on “Applications” -> “Programming” -> “Qt creator”.

Now we need to configure our new Qt creator to use the cross compiled Qt libraries for mini2440 and its qmake.Bcoz the target for our app is mini2440.

So now on Qt creator select ools > 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

If there is no errors we can see “Found Qt version 4.6.3, 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 some name

On clicking “Finish” you will reach here

Now doble click on Mainwindow.ui on the lefthand side

Now a QtDesigner window opens like this

Am adding a pushbutton to the gui window just drag and drop pushbutton from leftside

On task-bar, choose “Build” -> “Build All” to build the program. Click on “Run” button to see the result.we can see our gui window as a popup.

To cross-compile program for mini2440, choose “Project” section located on the left.In “Building Setting” change Qt version and edit build configuration to mini2440.

Okay, now you could cross-compile program for mini2440 by: “Build” ->  “Rebuild All“. Then select qmake.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)

you can check the filetype of the executable by using file command it will show ARM

Copy the binary to the mini2440 using pendrive or sd card.To execute the binary run like this..

$ ./ex1 -qws

Compiling Qt and tslib for mini2440 and run a demo app

We will create a Qt app that is compatible on mini2440 on our host computer then we will copy the libraries and binary of the app to mini2440 and will run the app….

So first we need to set up the Qt environment that we have in our mini2440(Qtopia) to our host computer…

These are the steps we must follow

1. tslib compilation
2. Qt4.6.2 compilation
3. Copy library of tslib and Qt4.6.2 into mini2440 board.
4. Configure the environment in mini2440 board.
5. Run Qt example program

1. tslib compilation

Tslib is an abstraction layer for touchscreen panel events, as well as a filter stack for the manipulation of those events. It was created by Russell King, of arm.linux.org.uk. Tslib is generally used on embedded devices to provide a common user space interface to touchscreen functionality.

$sudo apt-get install git-core
$cd /usr/local
$git clone http://github.com/kergoth/tslib.git
$export PATH=/usr/local/arm/4.3.2/bin:$PATH
$export CROSS_COMPILE=arm-none-linux-gnueabi-
$export CC=${CROSS_COMPILE}gcc
$export CFLAGS=-march=armv4t
$export CXX=${CROSS_COMPILE}"g++" 
$export AR=${CROSS_COMPILE}"ar" 
$export AS=${CROSS_COMPILE}"as"
$export RANLIB=${CROSS_COMPILE}"ranlib"
$export LD=${CROSS_COMPILE}"ld"
$export STRIP=${CROSS_COMPILE}"strip"
$export ac_cv_func_malloc_0_nonnull=yes
$cd /usr/local/tslib
$./autogen-clean.sh
$./autogen.sh
$./configure --host=arm-linux --prefix=/home/tslib --enable-shared=yes --enable-static=yes
$make
$make install

If everything went ok you will see tslib in you will see tsblib in /home/tslib

2.Qt Compilation

$wget http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.6.3.tar.gz
$mv qt-everywhere-opensource-src-4.6.3.tar.gz /usr/local
$cd /usr/local
$tar -zxvf  qt-everywhere-opensource-src-4.6.3.tar.gz
$cd qt-everywhere-opensource-src-4.6.3
$cd mkspecs/common/
$gedit g++.conf

Edit that file

change         QMAKE_CFLAGS_RELEASE += -O2
into               QMAKE_CFLAGS_RELEASE += -O0
Then save the file

$cd /usr/local/qt-everywhere-opensource-src-4.6.3/mkspecs/qws/linux-arm-g++/
$gedit qmake.conf

Edit the file.Copy paste the below content , note that, the path /usr/local/arm/4.3.2/ is the path which you installed tool chain.Remember that the PATH variable should have the location of arm-none-linux-gnueabi-gcc

#
# qmake configuration for building with arm-linux-g++
#

include(../../common/g++.conf)
include(../../common/linux.conf)
include(../../common/qws.conf)

# modifications to g++.conf
QMAKE_CC = /usr/local/arm/4.3.2/bin/arm-none-linux-gnueabi-gcc -msoft-float -D__GCC_FLOAT_NOT_NEEDED -march=armv4t -mtune=arm920t -O0 -lts
QMAKE_CXX = /usr/local/arm/4.3.2/bin/arm-none-linux-gnueabi-g++ -msoft-float -D__GCC_FLOAT_NOT_NEEDED -march=armv4t -mtune=arm920t -O0 -lts
QMAKE_LINK = /usr/local/arm/4.3.2/bin/arm-none-linux-gnueabi-g++ -msoft-float -D__GCC_FLOAT_NOT_NEEDED -march=armv4t -mtune=arm920t -O0 -lts
QMAKE_LINK_SHLIB = /usr/local/arm/4.3.2/bin/arm-none-linux-gnueabi-g++ -msoft-float -D__GCC_FLOAT_NOT_NEEDED -march=armv4t -mtune=arm920t -O0 -lts

# modifications to linux.conf
QMAKE_AR = /usr/local/arm/4.3.2/bin/arm-none-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = /usr/local/arm/4.3.2/bin/arm-none-linux-gnueabi-objcopy
QMAKE_STRIP = /usr/local/arm/4.3.2/bin/arm-none-linux-gnueabi-strip

QMAKE_INCDIR += /home/tslib/include/
QMAKE_LIBDIR += /home/tslib/lib/

QMAKE_CFLAGS_RELEASE += -march=armv4 -mtune=arm920t
QMAKE_CFLAGS_DEBUG += -march=armv4t -mtune=arm920t
QMAKE_CFLAGS_MT += -march=armv4t -mtune=arm920t
QMAKE_CFLAGS_MT_DBG += -march=armv4t -mtune=arm920t
QMAKE_CFLAGS_MT_DLL += -march=armv4t -mtune=arm920t
QMAKE_CFLAGS_MT_DLLDBG += -march=armv4t -mtune=arm920t
QMAKE_CFLAGS_SHLIB += -march=armv4t -mtune=arm920t
QMAKE_CFLAGS_THREAD += -march=armv4t -mtune=arm920t
QMAKE_CFLAGS_WARN_OFF += -march=armv4t -mtune=arm920t
QMAKE_CFLAGS_WARN_ON += -march=armv4t -mtune=arm920t

QMAKE_CXXFLAGS_DEBUG += -march=armv4t -mtune=arm920t
QMAKE_CXXFLAGS_MT += -march=armv4t -mtune=arm920t
QMAKE_CXXFLAGS_MT_DBG += -march=armv4t -mtune=arm920t
QMAKE_CXXFLAGS_MT_DLL += -march=armv4t -mtune=arm920t
QMAKE_CXXFLAGS_MT_DLLDBG += -march=armv4t -mtune=arm920t
QMAKE_CXXFLAGS_RELEASE += -march=armv4t -mtune=arm920t
QMAKE_CXXFLAGS_SHLIB += -march=armv4t -mtune=arm920t
QMAKE_CXXFLAGS_THREAD += -march=armv4t -mtune=arm920t
QMAKE_CXXFLAGS_WARN_OFF += -march=armv4t -mtune=arm920t
QMAKE_CXXFLAGS_WARN_ON += -march=armv4t -mtune=arm920t

load(qt_config)

Save the file

$mkdir /usr/local/Qt
$cd /usr/local/qt-everywhere-opensource-src-4.6.3

Then issue this command

$./configure -embedded arm -xplatform qws/linux-arm-g++ -prefix /usr/local/Qt -qt-mouse-tslib -little-endian -no-webkit -no-qt3support -no-cups -no-largefile -optimized-qmake -no-openssl -nomake tools -qt-sql-sqlite -no-3dnow -system-zlib -qt-gif -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -no-opengl -gtkstyle -no-openvg -no-xshape -no-xsync -no-xrandr -qt-freetype -qt-gfx-linuxfb -qt-kbd-tty -qt-kbd-linuxinput -qt-mouse-tslib -qt-mouse-linuxinput

chose ‘o’ Open Source Edition
chose ‘yes’ to accept license offer

$make
$make install

Now the compilation is done, you will see the result files in /usr/local/Qt.

3 .Copy library of tslib and Qt4.6.3 into mini2440 board

Use sd card,pendrive or you can copy through network

copy library and example program of Qt to pendrive

$cd /usr/local/Qt/lib
$cp *4.6.3   /media/Pendrive/
$cp -r fonts/   /media/Pendrive/
$cd /usr/local/Qt
$cp -r demos/   /media/Pendrive/

copy tslib into pendrive

$mkdir /media/Pendrive/tslib/lib/
$cd /home/tslib/lib/
$cp -r * /media/Pendrive/tslib/lib/
$cp * /media/Pendrive/tslib/lib/

Now connect the pendrive to the usb port of Mini2440 and in mini2440’s console

$mkdir /usr/local/Qt/lib/
$cp /sdcard/*4.6.3 /usr/local/Qt/lib/
rename all *.4.6.3 in /usr/local/Qt/lib into *.4, for example
$mv libQtCore.so.4.6.3 libQtCore.so.4 
$cp -r /udisk/fonts/ /usr/local/Qt/lib/
$cp -r /udisk/demos/ /mnt/
$cp -r /udisk/tslib/ /usr/local/

On mini2440 the pendrive will appear as /udisk instead of /media/Pendrive

4. Configure the environment in mini2440 board.

Below instructions will make mini2440 board not load its desktop so that our example Qt programs not conflict screen with the desktop

$cd /etc/init.d/
$vi rcS
comment last three lines:

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

Configure the environment in mini2440:

$cd /etc/
$vi profile

add those lines at the end of file

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

Save it

5. Run Qt example program:

Now we can test Qt example programs

$cd /mnt/demos/embedded/fluidlauncher/
$./fluidlauncher -qws

Get shutdown option in Fedora 16 Desktop

In Fedora 16 there is no shutdown option by deafult..We have to logout first and then need to shutdown from the gdm.

This can be tweaked in two ways

First easy way:

By pressing “Alt” key the suspend changes to poweroff

And if we need a permanent poweroff button we must install these two as root user

yum install gnome-tweak-tool
yum install gnome-shell-extensions-alternative-status-menu

After installation you will get an advanced setting menu..Enable alternative status menu in it…Then you will get poweroff..

Happy Hacking 🙂