Imx-4.1.15 Yocto-2.1 系统使用
该yocto系统是基于x11显示协议的嵌入式系统。系统集成的qt支持x11显示插件。
基础信息
用户密码
系统默认使用root用户登录,并支持root用户ssh远程登录,给目标系统root用户设置密码为root
$ passwd root
> root
> root
QT开发
搭建qt开发环境
x86主机或虚拟机的系统用Ubuntu16.0或Ubuntu18.04进行交叉编译开发,开发环境配置参考如下:
Ubuntu16.04系统主机编译环境建议安装
sudo apt-get install repo git-core gitk git-gui gcc-arm-linux-gnueabihf u-boot-tools device-tree-compiler gcc-aarch64-linux-gnu mtools parted libudev-dev libusb-1.0-0-dev python-linaro-image-tools linaro-image-tools autoconf autotools-dev libsigsegv2 m4 intltool libdrm-dev curl sed make binutils build-essential gcc g++ bash patch gzip bzip2 perl tar cpio python unzip rsync file bc wget libncurses5 libqt4-dev libglib2.0-dev libgtk2.0-dev libglade2-dev cvs git mercurial rsync openssh-client subversion asciidoc w3m dblatex graphviz python-matplotlib libc6:i386 libssl-dev texinfo liblz4-tool genext2fs expect patchelf gawk
Ubuntu18.04系统主机编译环境建议安装
sudo apt-get install asciidoc autoconf autotools-dev bash bc binfmt-support binutils bison build-essential bzip2 chrpath cmake cpio curl cvs dblatex device-tree-compiler diffstat expect fakeroot file flex g++ gawk gcc genext2fs git git-gui gitk g++-multilib graphviz gzip intltool libdrm-dev libglade2-dev libglib2.0-dev libgtk2.0-dev liblz4-tool libncurses5 libqt4-dev libsigsegv2 libssl-dev libudev-dev libusb-1.0-0-dev linaro-image-tools live-build m4 make mercurial mtools ncurses-dev openssh-client parted patch patchelf perl python python-linaro-image-tools python-matplotlib python-pip qemu-user-static repo rsync sed ssh subversion tar texinfo u-boot-tools unzip w3m wget libdb1-compat python3-pyelftools
主机PC端环境以Ubuntu16.04为例,目标板系统为buildroot嵌入式系统,默认使用root用户登录,并支持root用户ssh远程登录,给目标系统root用户配置密码为root
$ passwd root
> root
> root
SDK与系统镜像一同发布,从相应的烧录包中获取SDK。SDK中包含交叉编译工具链、qmake、与目标板系统的rootfs。解压SDK到任意目录$TOP_DIR(示例中以路径/home/lin/trash为例),并运行开发环境配置脚本
$ tar host.tar.gz -C $TOP_DIR
$ cd $TOP_DIR/host
$ ./relocate-sdk.sh
使用终端命令行编译运行qt程序
qt程序使用SDK中的qt5 examples例程,通过qmake、make命令进行编译
$ export PATH=$TOP_DIR/host/bin:$PATH
$ cd $TOP_DIR/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/qt/examples/opengl/hellowindow
$ qmake
$ make
生成hellowindow程序,可通过scp拷贝到目标板中直接运行
$ scp hellowindow root@10.168.1.247:
$ ssh root@10.168.1.247
$ ./hellowindow
系统在/etc/init.d/S50launcher开机启动服务中,启动了wayland显示服务,并运行了QLauncher桌面,若使用eglfs或linuxfb显示插件,则需要移除S50launcher服务
$ mv /etc/init.d/S50launcher ~
$ sync
$ reboot
指定eglfs显示插件运行程序
$ ./hellowindow -platform eglfs
$ ./calculator -platform linuxfb
使用qtcreator开发调试qt程序
qtcreator集成编辑、编译、运行、调试环境于一体,提升开发效率
安装qtcreator
$ sudo apt-get install qtcreator
添加Qt Versions
Tools --> Options --> Build & Run --> Qt Versions --> Add --> 选中qmake路径 --> Apply
添加Compilers
Tools --> Options --> Build & Run --> Compilers --> Add --> GCC -- 选中g++路径 --> Apply
注意:选中g++路径,并修改ABI一栏明确指示平台架构为arm
添加Devices(可选项)
Tools --> Options --> Devices --> Add --> General Linux Device --> start Wizard
并点击"Test"测试设备联通
添加Kits
Tools --> Options --> Build & Run --> Kits --> Add --> Apply
打开 hellowindow 工程并选择Kits
Welcome --> Open Porject --> 选择工程路径 /home/lin/trash/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/qt/examples/opengl/hellowindow/hellowindow.pro --> Configure Project
编译运行 hellowindow
Build --> Build Project "hellowindow" --> 重启qtcreator --> Build --> Run