Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux 程式設計 >> Linux 程式設計

Mini2440 上移植 qt-extended 4.4.3 的完整筆記

因專案需求,前陣子在 Mini2440 開發板上移植了 qt-extended 4.4.3,這裡把過程簡單記錄下來,希望對從事相關工作的朋友有幫助。

一、開發環境

  • 上位機:Fedora 9.0
  • 交叉編譯器:arm-linux-gcc 4.4.3(友善之臂提供)
  • NFS 根目錄:/opt/root_nfs/root_qtopia(依自身情況調整)
  • 開發板 LCD 版本:w35
  • Bootloader:u-boot;核心:uImage;根檔案系統:root_qtopia(後三者由嵌入式家園提供,也可直接用友善之臂的版本)

這裡特別提醒:arm-linux-gcc 4.4.3 與 4.4.2 都是支援 ARM9 的,在 ARM9 上移植請勿使用友善之臂提供的 arm-linux-gcc 4.5,那個版本 targeting 的是 ARM11。

二、交叉編譯 tslib 1.4

要執行 qt-extended-4.4.3(也就是 Qtopia 4),必須先有 tslib。這個函式庫負責觸控螢幕的校正與資料濾波、去抖動,Qt 會去呼叫它。另外,安裝 Fedora 時建議完整安裝而非最小化安裝,因為編譯 tslib 需要多個第三方函式庫支援。

tar xzvf tslib-1.4.tar.gz
cd tslib/

# 設定環境變數並指定交叉編譯器
export PATH=/opt/toolchain/4.4.3/bin:$PATH
export TOOLCHAIN=/opt/toolchain/4.4.3
export TB_CC_PREFIX=arm-linux-
export PKG_CONFIG_PREFIX=$TOOLCHAIN/arm-linux

# 執行 tslib 內建的腳本
./autogen.sh
echo "ac_cv_func_malloc_0_nonnull=yes" > arm-linux.cache

# 配置
./configure --host=arm-linux \
            --cache-file=arm-linux.cache \
            --enable-inputapi=no \
            PLUGIN_DIR=/usr/local/arm/tslib/plugins \
            -prefix=/usr/local/arm/tslib/build \
            2>&1 | tee conf_log

# 編譯與安裝
make 2>&1 | tee make_log
make install

其中 -prefix 指定 tslib 的安裝位置,而將輸出導向 conf_log 與 make_log 則是為了方便日後檢查錯誤。成功後 /usr/local/arm/tslib 下會出現 build 目錄,進入其中的 etc 找到 ts.conf,把 module_rawinput 前面的 # 號與空白刪掉。接著把 build 改名為 tslib,並整個複製到 NFS 根目錄的 /opt/root_nfs/root_qtopia/usr/local 中:

mv build tslib
cp -r /usr/local/arm/tslib /opt/root_nfs/root_qtopia/usr/local/

三、交叉編譯 qt-extended 4.4.3

先建立工作目錄並解壓原始碼:

mkdir arm
cp qt-extended-opensource-src-4.4.3.tar.gz arm/
cd arm

為了做到一鍵編譯,我寫了一個名為 build 的腳本:

#!/bin/bash

rm -fr qt-extended-4.4.3
tar xvzf qt-extended-opensource-src-4.4.3.tar.gz

rm -fr builddir
mkdir builddir

# linux-arm-g++
export PATH=/opt/toolchain/4.4.3/bin:$PATH
export TOOLCHAIN=/opt/toolchain/4.4.3
export TB_CC_PREFIX=arm-linux-
export PKG_CONFIG_PREFIX=$TOOLCHAIN/arm-none-linux-gnueabi

QTOPIA_PREFIX_DIR=/opt/Qtopia4.4.3
export QTOPIA_DEPOT_PATH=$PWD/qt-extended-4.4.3
export QPEDIR=$PWD/builddir
export LC_CTYPE="en_US"
export LANG="en_US"
export LANGUAGE="en_US"

cd $QPEDIR
echo yes | $QTOPIA_DEPOT_PATH/configure \
    -ui-type mobile \
    -xplatform linux-arm-g++ \
    -arch arm \
    -release \
    -clean \
    -prefix ${QTOPIA_PREFIX_DIR} \
    -sound-system oss \
    -build-qt \
    -no-sxe \
    -no-ssl \
    -no-v4l2 \
    -no-vpn \
    -no-phonon \
    -no-libamr \
    -dynamic-rotation \
    -mediaengines cruxus \
    -remove-mediaengine gstreamer,helix \
    -pictureflow \
    -remove-module bluetooth,drm \
    -no-dbus \
    -no-dbusipc \
    -add-displaysize 240x320 \
    -extra-qt-embedded-config "-embedded arm -xplatform qws/linux-arm-g++ \
        -no-cups -nomake examples -nomake demos -qt-zlib -qt-libjpeg \
        -qt-libmng -qt-libpng -no-dbus -depths 16,32 -qt-gfx-linuxfb \
        -qt-gfx-transformed -no-gfx-qvfb -no-gfx-vnc -no-gfx-multiscreen \
        -qt-kbd-tty -no-kbd-usb -no-kbd-sl5000 -no-kbd-yopy -no-kbd-vr41xx \
        -no-kbd-qvfb -qt-mouse-tslib \
        -I/usr/local/arm/tslib/tslib/include \
        -L/usr/local/arm/tslib/tslib/lib \
        -no-webkit -no-openssl -no-phonon -no-phonon-backend \
        -no-nas-sound -no-exceptions -svg" \
    -extra-qt-config "-no-webkit" \
    2>&1 | tee ../qtopiaconfig.log

bin/qbuild 2>&1 | tee ../qtopia4.4.3makelog
bin/qbuild image

幾個參數的用意值得說明:-ui-type mobile 指定為手機式介面;-xplatform linux-arm-g++ 搭配 -arch arm 決定交叉編譯目標;-no-sxe 關掉 SXE 安全機制以免在開發板上增加負擔;-no-dbus 與 -no-phonon 之類則是裁掉板子上用不到的元件以縮小體積。最關鍵的是 -extra-qt-embedded-config 裡的 -qt-mouse-tslib 以及那兩行 tslib 的 include/lib 路徑——少了它,觸控就不會有反應;而 -depths 16,32 與 -add-displaysize 240x320 則必須和實際 LCD 規格一致。最後 bin/qbuild image 會把結果整理成可打包的映像,配置與編譯的輸出分別留在 qtopiaconfig.log 與 qtopia4.4.3makelog,出錯時優先查這兩個檔案。

Copyright © Linux教程網 All Rights Reserved