RISC-V搭建嵌入式QT开发环境
安装环境:
Ubuntu18.04
GCC:gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
CROOSS-tools:gcc version 8.3.0 (crosstool-NG 1.24.0)
下载5.12安装包,解压后修改qmake.conf配置参数,将编译工具修改为交叉编译器
/qt-everywhere-src-5.12.12$ vi qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf
#
# qmake configuration for building with arm-linux-gnueabi-g++
#
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib
QT_QPA_DEFAULT_PLATFORM = linuxfb #eglfs
QMAKE_CFLAGS_RELEASE += -O2 -march=armv7-a
QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv7-a
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
# modifications to g++.conf
QMAKE_CC = /home/luckfox/workspace/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc
QMAKE_CXX = /home/luckfox/workspace/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-g++
QMAKE_LINK = /home/luckfox/workspace/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-g++
QMAKE_LINK_SHLIB = /home/luckfox/workspace/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-g++
# modifications to linux.conf
QMAKE_AR = /home/luckfox/workspace/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-ar cqs
QMAKE_OBJCOPY = /home/luckfox/workspace/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-objcopy
QMAKE_NM = /home/luckfox/workspace/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-nm -P
QMAKE_STRIP = /home/luckfox/workspace/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-strip
load(qt_config)
添加编译配置文件
QT_Tools/qt-everywhere-src-5.12.12$ vi build.sh
#!/bin/bash
./configure -prefix /usr/local/Trolltech/QtEmbedded-5.12-arm \
-opensource \
-confirm-license \
-release \
-strip \
-shared \
-xplatform linux-arm-gnueabi-g++ \
-optimized-qmake \
-c++std c++11 \
--rpath=no \
-pch \
-skip qt3d \
-skip qtactiveqt \
-skip qtandroidextras \
-skip qtcanvas3d \
-skip qtdoc \
-skip qtconnectivity \
-skip qtdatavis3d \
-skip qtdoc \
-skip qtgamepad \
-skip qtlocation \
-skip qtmacextras \
-skip qtnetworkauth \
-skip qtpurchasing \
-skip qtremoteobjects \
-skip qtscript \
-skip qtscxml \
-skip qtsensors \
-skip qtspeech \
-skip qtsvg \
-skip qttools \
-skip qttranslations \
-skip qtwayland \
-skip qtwebengine \
-skip qtwebview \
-skip qtwinextras \
-skip qtx11extras \
-skip qtxmlpatterns \
-make libs \
-make examples \
-nomake tools -nomake tests \
-gui \
-widgets \
-dbus-runtime \
--glib=no \
--iconv=no \
--pcre=qt \
--zlib=qt \
-no-openssl \
--freetype=qt \
--harfbuzz=qt \
-no-opengl \
-linuxfb \
--xcb=no \
配置完成后,执行make && sudo make install安装到指定的目录。
luckfox@luckfox:~$ ls /usr/local/Trolltech/QtEmbedded-5.12-arm/
bin doc examples include lib mkspecs plugins qml
luckfox@luckfox:~$ ls /usr/local/Trolltech/QtEmbedded-5.12-arm/bin/
canbusutil moc qdbusxml2cpp qmake qmlcachegen qmllint qmlpreview qmltestrunner rcc uic
fixqt4headers.pl qdbuscpp2xml qlalr qml qmlimportscanner qmlmin qmlscene qvkgen syncqt.pl
luckfox@luckfox:~$
luckfox@luckfox:~$
luckfox@
将配置安装完成的QT环境移植到开发板中。
将lib 和 plugins 移植到开发板中,并配置启动参数。
新建存放QtEmbedded-5.12-arm的目录
luckfox@luckfox:~/workspace/luckfox-pico/output/out/rootfs_uclibc_rv1106$ mkdir -p usr/local/Trolltech/QtEmbedded-5.12-arm
将QtEmbedded-5.12-arm目录中的lib 和 plugins 目录拷贝到需要移植的目录中
:~/workspace/luckfox-pico/output/out/rootfs_uclibc_rv1106/usr/local/Trolltech/QtEmbedded-5.12-arm$ cp -rf /usr/local/Trolltech/QtEmbedded-5.12-arm/lib ./
:~/workspace/luckfox-pico/output/out/rootfs_uclibc_rv1106/usr/local/Trolltech/QtEmbedded-5.12-arm$ ls
lib
:~/workspace/luckfox-pico/output/out/rootfs_uclibc_rv1106/usr/local/Trolltech/QtEmbedded-5.12-arm$
:~/workspace/luckfox-pico/output/out/rootfs_uclibc_rv1106/usr/local/Trolltech/QtEmbedded-5.12-arm$
:~/workspace/luckfox-pico/output/out/rootfs_uclibc_rv1106/usr/local/Trolltech/QtEmbedded-5.12-arm$ cp -rf /usr/local/Trolltech/QtEmbedded-5.12-arm/plugins ./
配置相应的启动文件支持QT
~/workspace/luckfox-pico/output/out/rootfs_uclibc_rv1106$ vi etc/init.d/rcS
~/workspace/luckfox-pico/output/out/rootfs_uclibc_rv1106$ vi bin/qt5
#!/bin/sh
export QTDIR=/usr/local/Trolltech/QtEmbedded-5.12-arm
#set Lib PATH
export LD_LIBRARY_PATH=$QTDIR/lib:/usr/lib:$LD_LIBRARY_PATH
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0
export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins
export PATH=$QTDIR/bin:$PATH
export CAMERA_DEVICE=/dev/video3
#export QWS_KEYBOARD=TTY:/dev/tty1
export HOME=/root
/demo_qt5 &
添加执行权限
:~/workspace/luckfox-pico/output/out/rootfs_uclibc_rv1106$ chmod +x bin/qt5
拷贝例程测试是否能够运行QT程序
examples
打包rootfs镜像,烧写到SD卡中
打包前的镜像时间
luckfox@luckfox:~/workspace/luckfox-pico$ ls output/image/rootfs.img -l
-rw-rw-r-- 1 luckfox luckfox 82214912 12月 21 14:40 output/image/rootfs.img
luckfox@luckfox:~/workspace/luckfox-pico$ ./build.sh rootfs
cp -af /home/luckfox/workspace/luckfox-pico/sysdrv/source/busybox/busybox-1.27.2/_install/* /home/luckfox/workspace/luckfox-pico/sysdrv/out/rootfs_uclibc_rv1106
arm-rockchip830-linux-uclibcgnueabihf-gcc -march=armv7-a -mfpu=neon -mfloat-abi=hard -march=armv7-a -mfpu=neon -mfloat-abi=hard -Os io.c -o out/usr/bin/io
打包后的,单独打包不能生成rootfs.img
luckfox@luckfox:~/workspace/luckfox-pico$ ls output/image/rootfs.img -l
-rw-rw-r-- 1 luckfox luckfox 82214912 12月 21 14:40 output/image/rootfs.img
luckfox@luckfox:~/workspace/luckfox-pico$
需要
打包整个镜像:
~/luckfox-pico$ ./build.sh firmware
打包是将out目录下的文件夹打包,显示的命令如下:
mkfs.ext4 -d /home/luckfox/workspace/luckfox-pico/output/out/oem -r 1 -N 0 -m 5 -L "" -O ^64bit,^huge_file /home/luckfox/workspace/luckfox-pico/output/image/oem.img "1024M"
mkfs.ext4 -d /home/luckfox/workspace/luckfox-pico/output/out/rootfs_uclibc_rv1106 -r 1 -N 0 -m 5 -L "" -O ^64bit,^huge_file /home/luckfox/workspace/luckfox-pico/output/image/rootfs.img "2048M"
mkfs.ext4 -d /home/luckfox/workspace/luckfox-pico/output/out/userdata -r 1 -N 0 -m 5 -L "" -O ^64bit,^huge_file /home/luckfox/workspace/luckfox-pico/output/image/userdata.img "2048M"
需要打包整个固件才能够生成rootfs.img文件
luckfox@luckfox:~/workspace/luckfox-pico$ ls output/image/rootfs.img -l
-rw-rw-r-- 1 luckfox luckfox 123564032 12月 22 10:22 output/image/rootfs.img
luckfox@luckfox:~/workspace/luckfox-pico$
烧写rootfs.img文件到SD卡,启动开发板查看配置信息
# ls /usr/local/Trolltech/QtEmbedded-5.12-arm/
lib plugins
调试方便编写一个运行QT脚本
# chmod +x runPrg
运行QT测试程序,支持QT开发
# ./runPrg
Qt Demo test
^C
#