2011년 6월 7일 화요일

Qt 2.2.0 포팅 가이드

       
 
이 매뉴얼은 JK전자(JK Electronics) 에 의해서 번역, 수정, 작성 되었고 소유권 또한
JK전자(JK Electronics)
의 것입니다. 소유권자의 허가를 받지 않고 무단으로 수정, 삭제하거나 배포 할 수 없습니다.

제품 구매 : http://www.toolparts.co.kr
 

S3C6410 Start Kit QT 2.2.0 Porting Guide


 

* Update history

- 2011.4.18 : 초기 Release


  이 메뉴얼은 Qtopia-2.2.0, Qt-Extendded-4.4.3 (Qtopia Phone Edition), Qt 4.7.0를 S3C6410 Start Kit 개발보드에 포팅하는 일반적인 방법에 대한 내용을 설명하는 메뉴얼 입니다.

1. Qt/Qtopia 소개
1.1 What is Qt

Qt 는 1995년에 TrollTech에서 개발하고 2008년에 NOKIA에 의해서 좀더 강력하게 개선된 cross-platform C + + graphical user interface library 입니다.

(1) cross-platform features
Qt라이브러리는 소스코드의 수정없이 Qt가 지원하는 여러 플랫폼에서 컴파일만 다시 하면 사용 할 수 있고, 자동으로 컴파일된 플랫폼에 맞는 GUI Interface를 지원 합니다. 아래 플랫폼들은 현재 Qt에서 지원하고 있는 플랫폼 리스트들 입니다.

- Linux/X11: X Window System (such as Solaris, AIX, HP-UX, Linux, BSD). Support for KDevelop and Eclipse IDE integration.
- Mac: Apple Mac OS X. Cocoa-based framework. Supports Universal Binary. Support to Xcode editing, compiling, and testing.
- Windows: Microsoft Windows. Support the Visual Studio integration.
- Embedded Linux: Embedded Linux. You can remove unused components compile and function.
  Through their own window system QWS, without relying on X Window System, directly into the Linux frame buffer.
  Can reduce memory consumption. And to provide a virtual frame buffer QVFb, easy embedded on the desktop testing.
- Windows CE/Mobile: Windows CE.
- Symbian: Symbian platform.
- Meego: Meego.

(2) Object-Oriented
Qt Qt good package mechanism makes a very high degree of modularity, reusability, well, for users to develop, it is very convenient. Qt provides a known signals/slots to replace the security type of callback, which makes interoperability between the various components becomes very simple.

(3) Rich API
Qt가 처음 개발되었을 때는 단지 잘 구조화된 C++ graphics library 였습니다. 하지만 이후에 많은 것들이 업그레이드 되고 통합되어져서 최근에는 Database, OpenGL library, multimedia database, network, script library, XML library, WebKit library 등을 지원하고 있고 코어 라이브러리 또한 프로세스간 통신, multi-threading module 등을 지원하고 있습니다. 그리고 Qt는 "Code Less; Create More; Deploy Anywhere." 의 목적을 가지고 개발되어 지고 있습니다.

Qt development resources:
1) Qt development tools Download: http://qt.nokia.com/
2) Qt development documents: http://doc.qt.nokia.com/

1.2 What is Qtopia 2.2

Qtopia는 Qt cross-platform library 를 베이스로한 소프트웨어 플랫폼 입니다. 주로 embedded Linux system, PDA or mobile phone 등에서 사용되어 지고 있습니다. Qtopia는 games and multimedia, ynchronization framework, PIM applications, Internet applications , development environment, input method, Java integration, localization support, personalization options, and wireless support 기능들을 개발자가 최대한 개발 시간을 단축 시킬수 있도록 윈도와 비슷한 운영 플랫폼을 지원합니다. 최초의 Qt 개발 회사는 TrollTech 이었는데, TrollTech 은 2008년도에 Nokia에 이해서 인수되어 졌고, 그 이후에 Qtopia는 Qt Extended로 이름이 변경 되었습니다. Nokia는 최근에 Qt Extended 의 가장 최신 버젼인 Qt Extended 4.4.3 을 릴리즈 하였습니다.

2 Qt 개발환경 설치

2.1 Installing Linux operating system

Qt개발 환경을 꾸미기 전에 아래 2가지가 기본적으로 필요합니다. 여기서 테스트한 개발용 PC의 환경은 VMware에 설치된 Fedora9 환경 입니다. 다른 환경에서는 테스트 되지 않아서 에러가 발생 할 수 있습니다.
1) Install Fedora9
2) install some arm cross-compiler

2.1.1 Installation Fedora9

Fedora9의 자세한 설치 방법은 Install Fedora 9 문서를 참조하세요.

2.1.2 Install Cross-compiler

개발보드와 함께 제공된 CD에서 "arm-linux-gcc-v6-vfp-20101103.tgz" 파일을 개발용 리눅스 PC의 "/opt" 에 복사 합니다. 그리고 나서 tar 압축을 해제 합니다. 리눅스 개발 환경설정에서 이미 크로스 컴파일러를 설치 하였다면 이 과정은 다시 하지 않아도 됩니다.

# cd /
# tar xvzf /opt/arm-linux-gcc-v6-vfp-20101103.tgz


컴파일러가 어느 디렉토리에서나 실행 될 수 있도록 합니다. 아래 처럼 명령해에서 export를 하면 매번 로그인 할때마다 실행해 주어야 하는 불편함이 있습니다. 가능 하면 사용자의 프로파일에 추가하도록 합니다. ".bash_profile" 등. 프로파일 이름은 개발용 PC의 환경에 따라서 달라 질 수 있습니다.

# export /opt/FriendlyARM/toolschain/4.5.1/bin/:$PATH

컴파일러와 Path 설정이 잘 되었는지 확인 합니다.

# arm-linux-gcc -v

3. Qtopia2.2.0 Compile

Qtopia2.2.0 의 X86 과 ARM version 을 어떻게 컴파일 해서 실행시키는지 알아 봅니다. 컴파일 하는데 필요한 파일 리스트 드립니다.

qtopia-free-src-2.2.0.tar.gz : Qtopia2.2.0 official original package source code
qtopia2.2.0.friendlyarm.patch : Used to repair Qtopia2.2.0 compile error in Fedora9 patch

3.1 Qtopia for X86

3.1.1 qtopia2.2.0 소스코드 설치 for X86

# cd /opt
# tar xvzf qtopia-free-src-2.2.0.tar.gz


3.1.2 qtopia2.2.0 컴파일 for X86

configure 와 make 2가지를 실행해야 합니다. configure하는 명령어가 많이 기네요.

# cd /opt/qtopia-free-2.2.0/
# echo yes | ./configure -qte '-embedded -no-xft -qconfig qpe -depths 16,32 -system-jpeg -gif' -qpe '-edition pda -displaysize 240x320' -qt2 '-no-opengl -no-xft' -dqt '-no-xft -thread'
# make


Fedora9 에서는 원본 소스를 그대로 컴파일 하면 아래와 같은 에러가 발생 합니다. 에러를 없애기 위해서는 약간의 패치가 필요 합니다.

 

/opt/qtopia-free-2.2.0/qt2/include/qwindowsystem_qws.h: 214: warning: typedef in this statement is ignored
/opt/qtopia-free-2.2.0/qt2/include/qwindowsystem_qws.h: 230
: Error: 'QWSInputMethod' not declared
/opt/qtopia-free-2.2.0/qt2/include/qwindowsystem_qws.h: 237:
error: 'QWSGestureMethod' undeclared
make [1]: *** [allmoc.o]
error 1


위와 같은 컴파일 에러가 발생하는 이유는 Qtopia2.2.0 가 약간은 오래된 몇년전의 버젼이고 Fedora9 리눅스의 기본 gcc 컴파일러는 4.3 버젼으로 옛날 버젼의 C/C++ 문법을 지원하지 않기 때문에 발생하는 것입니다. 그래서 오래된 버젼의 C/C++ 문법을 사용하는 Qtopia2.2.0 의 소스코드를 수정해 주어야 합니다.

3.1.3 qtopia2.2.0 컴파일 에러 Patch

제공 CD의 "qtopia2.2.0.friendlyarm.patch" 파일을 개발용 PC의 "/opt" 디렉토리에 복사하고 다음 명령을 실행 시킵니다.

# cd /opt/qtopia-free-2.2.0
# patch -p1 < /opt/qtopia2.2.0.friendlyarm.patch

패치가 완료되면 다시 컴파일을 위해서 configure 를 합니다.

# echo yes | ./configure -qte '-embedded -no-xft -qconfig qpe -depths 16,32 -system-jpeg -gif' -qpe '-edition pda -displaysize 240x320' -qt2 '-no-opengl -no-xft' -dqt '-no-xft -thread'
# make
# make install

configure 파라미터에 대한 자세한 설명은 명령행에서 "./configure - help " 를 하면 자세한 설명이 나옵니다.

3.1.4 qtopia2.2.0 실행

PC환경에서 qtopia2.2.0를 실행 시키기 위해서는 Qtopia simulator qvfb가 필요하고, QTDIR 등의 약간의 환경변수도 설정 해야 합니다. 그래서 run 스크립트 파일일 미리 작성해 놓았습니다. 그 내용을 보면 아래와 같습니다.

# cd /opt/qtopia-free-2.2.0
# vi run

run 스크립트 파일의 내용 입니다.

#!/bin/sh

./qt2/bin/qvfb -width 480 -height 272 -depth 16 &
cd qtopia/image
mkdir root 2>/dev/null || true

export HOME=$PWD/root cd opt/Qtopia
export PATH=$PWD/bin:$PATH
export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBARAY_PATH
export QTDIR=$PWD export QPEDIR=$PWD
export KDEDIR=$PWD/../kde

sleep 3
qpe


위의 내용을 입력하고 저장 합니다. 그리고 나서 run 스크립트 파일에 실행 권한을 부여하고 실행 합니다.

# chmod +x ./run
# ./run


qtopia2.2.0 시뮬레이터가 실행된 화면 입니다.



X86버젼의 Qtopia에 대한 컴파일 과정과 실행과정은 설명하였으므로 다음은 ARM용(S4C6410 Start Kit)용 에 대한 컴파일 과정과 실행 방법에 대해서 설명 하도록 하겠습니다.

3.2 Qtopia for ARM

3.2.1 qtopia2.2.0 소스코드 설치 for ARM

# mkdir /opt/mini6410
# cd /opt/mini6410
# tar xvzf /opt/qtopia-free-src-2.2.0.tar.gz
# cd /opt/mini6410/qtopia-free-2.2.0
# patch -p1 < /opt/qtopia2.2.0.friendlyarm.patch

3.2.2 qtopia2.2.0 컴파일 for ARM

configure 수행

# echo yes | ./configure -qte '-embedded -no-xft -qconfig qpe -depths 16,32 -system-jpeg -qt-zlib -qt-libpng -gif -no-g++-exceptions -no-qvfb -xplatform linux-arm-g++ -tslib' -qpe '-edition pda -displaysize 480x272 -xplatform linux-arm-g++ -luuid' -qt2 '-no-opengl -no-xft' -dqt '-no-xft -thread'

컨피규어 파라미터중 tslib에 대한 설정이 없는 것은 이미 관련 라이브러리와 헤더 파일이 소스에 포함 되어 있기 때문에 빠진 것입니다. 나머지 자세한 파라미터에 관한 내용은 ./configure - help 의 내용을 참조 하시기 바랍니다.

컴파일 하고 설치 합니다.

# make
# make install


컴파일이 성공적으로 끝나면 "/opt/mini6410/qtopia-free-2.2.0/qtopia/image" 에 결과 이미지 파일이 생성 됩니다.

3.2.3 Run qtopia2.2.0 on development board

크로스 컴파일한 qt 바이너리 이미지를 압축 해서 SD메모리 카드로 복사 합니다.

# cd /opt/mini6410/qtopia-free-2.2.0/qtopia/image
# tar cvzf opt.tgz op
t

개발보드에 SD메모리 카드를 삽입하고 개발보드의 터미널에서 다음 명령을 입력 합니다.

# killall qpe qss quicklauncher
# rm /opt -rf
# tar xvzf /sdcard/opt.tgz


"run_my_qtopia" 라는 이름으로 실행 스크립트를 생성 합니다.

# vi /bin/run_my_qtopia

#!/bin/sh

export TSLIB_TSDEVICE=/dev/touchscreen-1wire
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/lib/ts
export TSLIB_CALIBFILE=/etc/pointercal
export QTDIR=/opt/Qtopia
export QPEDIR=/opt/Qtopia
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:/usr/local/lib:$LD_LIBRARY_PATH
export QWS_MOUSE_PROTO="TPanel:/dev/input/mice"
export QWS_KEYBOARD=TTY:/dev/tty1
export HOME=/root

exec $QPEDIR/bin/qpe


"run_my_qtopia" 스크립트를 실행 합니다.

run 스크립트에서 첫번째로 tslib parameters 에 대한 설정이 필요 합니다. "TSLIB_TSDEVICE" 환경 변수는 터치 스크린 디바이스 드라이버 파일 입니다. S3C6410 Start Kit 개발보드는 터치 구현을 위해서 다음과 같이 3개의 디바이스 드라이버를 제공 합니다. 일반적으로는 "/dev/touchscreen-1wire" 로 설정 하면 됩니다. 나머지 2개는 특별한 하드웨어가 필요 합니다.

First-line touch screen: TSLIB_TSDEVICE = /dev/touchscreen-1wire
ADC touch screen use: TSLIB_TSDEVICE = /dev/touchscreen
touch screen with serial: TSLIB_TSDEVICE = /dev/ttySAC3

Qtopia실행 이미지가 위치한 "QTDIR", "QPEDIR" 환경 변수를 설정 합니다.
"QWS_MOUSE_PROTO", "QWS_KEYBOARD" 는 Qtopia 입력 디바이스 환경 변수 입니다.
마지막으로 실제로 Qtopia를 실행 시는 "qpe" 를 실행 합니다.

"run_my_qtopia" 파일에 실행 권한을 주고 시스템 부팅시 자동으로 Qtopia가 실행 될 수 있도록 "rcS" 파일을 수정 합니다.

# chmod +x /bin/run_my_qtopia
# vi /etc/init.d/rcS


원래의 내용

/bin/qtopia &


"run_my_qtopia" 를 실행 하도록 수정

/bin/run_my_qtopia &


시스템(개발보드)를 재부팅 하면 자동으로 내가 작성한 Qtopia가 실행 될 것입니다.


       
       

댓글 없음:

댓글 쓰기