“Debian Base 系统使用”的版本间的差异

来自ARM Wiki
跳转至: 导航搜索
搭建qt开发环境
使用示例
 
(未显示同一用户的8个中间版本)
第1行: 第1行:
 
==基础信息==
 
==基础信息==
*用户密码
+
 
 +
===用户密码===
 +
 
 +
系统使用root用户在tty终端自动登录,同时也支持root用户ssh远程登录。
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
user: root
+
用户:root
passwd: root
+
密码:root
 
</syntaxhighlight>
 
</syntaxhighlight>
==使用示例==
+
 
===视频硬件编解码===
+
==网络设置==
*使用gstreamer播放视频
+
 
 +
系统使用NetworkManager管理网络,默认为以太网配置了动态IP,可以使用nmcli命令来配置网络。
 +
 
 +
{{模板:使用nmcli命令配置网络}}
 +
 
 +
==图形多媒体==
 +
 
 +
===Gstreamer===
 +
 
 +
使用Gstreamer播放视频:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ gst-play-1.0 /usr/local/test.mp4
+
gst-play-1.0 /usr/local/test.mp4
 
</syntaxhighlight>
 
</syntaxhighlight>
 
[[文件:277317066.jpg|frameless|650px]]<br />
 
[[文件:277317066.jpg|frameless|650px]]<br />
 
<br />
 
<br />
*播放4K视频
+
 
 +
Gstreamer命令举例:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ gst-launch-1.0 playbin uri=file:///root/4k.mp4
+
gst-launch-1.0 playbin uri=file:///usr/local/test.mp4
 +
gst-launch-1.0 uridecodebin uri=file:///usr/local/test.mp4 ! kmssink
 +
gst-launch-1.0 filesrc location=/usr/local/test.mp4 ! queue ! qtdemux  name=dmux dmux.video_0 ! queue ! h264parse ! mppvideodec ! kmssink dmux.audio_0 ! queue ! aacparse ! faad ! autoaudiosink
 +
gst-inspect-1.0 kmssink
 +
gst-discoverer-1.0 /usr/local/test.mp4
 
</syntaxhighlight>
 
</syntaxhighlight>
[[文件:531422585.jpg|frameless|650px]]<br />
+
 
<br />
+
===OpenCL===
*列出一些gstreamer命令
+
 
 +
查看OpenCL相关信息:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ gst-launch-1.0 playbin uri=file:///usr/local/test.mp4
+
apt install clinfo
$ gst-launch-1.0 uridecodebin uri=file:///usr/local/test.mp4 ! kmssink
 
$ gst-launch-1.0 filesrc location=/usr/local/test.mp4 ! queue ! qtdemux  name=dmux dmux.video_0 ! queue ! h264parse ! mppvideodec ! kmssink dmux.audio_0 ! queue ! aacparse ! faad ! autoaudiosink
 
$ gst-inspect-1.0 kmssink
 
  # 查看插件信息
 
$ gst-discoverer-1.0 /usr/local/test.mp4
 
  # 查看视频信息
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
===OpenCL===
 
*安装并运行<code>clinfo</code>,查看OpenCL相关信息
 
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ sudo apt-get install -f -y clinfo
+
clinfo
$ clinfo
+
...
 
Number of platforms                              1
 
Number of platforms                              1
 
   Platform Name                                  ARM Platform
 
   Platform Name                                  ARM Platform
第64行: 第74行:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{模板:RKDebianNetworkConfiguration}}
+
==固件打包烧录==
 +
 
 
{{模板:RKExportPackFirmware}}
 
{{模板:RKExportPackFirmware}}
 +
 +
==开发环境==
 +
 +
{{模板:Ubuntu主机开发环境搭建}}
  
 
==QT开发==
 
==QT开发==
第99行: 第114行:
  
 
===使用终端命令行编译运行qt程序===
 
===使用终端命令行编译运行qt程序===
qt程序使用SDK中的qt5 examples例程,通过qmake、make命令进行编译
+
 
 +
qt程序使用SDK中的qt5 examples例程,通过qmake、make命令进行编译:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ export PATH=$TOP_DIR/host/bin:$PATH
+
export PATH=$TOP_DIR/host/bin:$PATH
$ cd $TOP_DIR/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/qt/examples/opengl/hellowindow
+
cd $TOP_DIR/host/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/qt/examples/widgets/widgets/calculator
$ qmake
+
qmake
$ make
+
make
 
</syntaxhighlight>
 
</syntaxhighlight>
生成hellowindow程序,可通过scp拷贝到目标板中,并配置qt运行环境变量后运行<br />
+
 
 +
生成calculator程序,可通过scp拷贝到目标板中,并配置qt运行环境变量后运行:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ scp hellowindow root@10.168.1.157:
+
scp calculator root@10.168.1.157:
$ ssh root@10.168.1.157
+
ssh root@10.168.1.157
$ export LD_LIBRARY_PATH=/opt/data/target/usr/lib
+
export LD_LIBRARY_PATH=/opt/data/target/usr/lib
$ export QT_QPA_PLATFORM_PLUGIN_PATH=/opt/data/target/usr/lib/qt/plugins
+
export QT_QPA_PLATFORM_PLUGIN_PATH=/opt/data/target/usr/lib/qt/plugins
 
</syntaxhighlight>
 
</syntaxhighlight>
指定eglfs显示插件运行程序<br />
+
 
 +
指定linuxfb显示插件运行程序:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ ./hellowindow -platform eglfs
+
./calculator -platform linuxfb
</syntaxhighlight>
 
[[文件:Projects 0.jpg|frameless|650px]]<br />
 
<br />
 
指定linuxfb显示插件运行程序<br />
 
<syntaxhighlight lang="bash">
 
$ ./calculator -platform linuxfb
 
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
[[文件:481762326.jpg|frameless|650px]]
 +
 
===使用qtcreator开发调试qt程序===
 
===使用qtcreator开发调试qt程序===
qtcreator集成编辑、编译、运行、调试环境于一体,提升开发效率<br />
+
 
<br />
+
qtcreator集成编辑、编译、运行、调试环境于一体,提升开发效率。
'''安装qtcreator'''<br />
+
 
 +
'''安装qtcreator'''
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ sudo apt-get install qtcreator
+
sudo apt install qtcreator qtbase5-dev qt5-default qtbase5-examples
 
</syntaxhighlight>
 
</syntaxhighlight>
<br />
+
 
 
'''添加Qt Versions'''<br />
 
'''添加Qt Versions'''<br />
Tools --> Options --> Build & Run --> Qt Versions --> Add --> 选中qmake路径 --> Apply<br />
+
Tools --> Options --> Kits --> Qt Versions --> Add --> 选中qmake路径 --> Apply<br />
[[文件:Screenshot from 2020-08-11 14-23-21.png|frameless|650px]]<br />
+
[[文件:Screenshot_from_2023-02-09_19-26-12.png|frameless|650px]]
<br />
+
 
<br />
 
 
'''添加Compilers'''<br />
 
'''添加Compilers'''<br />
Tools --> Options --> Build & Run --> Compilers --> Add --> GCC -- 选中g++路径 --> Apply<br />
+
Tools --> Options --> Kits --> Compilers --> Add --> GCC --> C++ --> 选中g++路径 --> Apply<br />
注意:选中g++路径,并修改ABI一栏明确指示平台架构为arm<br />
+
[[文件:Screenshot_from_2023-02-09_19-35-47.png|frameless|650px]]
[[文件:Screenshot from 2020-08-11 14-21-33.png|frameless|650px]]<br />
+
 
<br />
+
'''添加Debuggers'''<br />
<br />
+
Tools --> Options --> Kits --> Debuggers --> Add --> 选中gdb路径 --> Apply<br />
'''添加Debuggers(可选项)'''<br />
+
[[文件:Screenshot_from_2023-02-09_19-41-35.png|frameless|650px]]
Tools --> Options --> Build & Run --> Debuggers --> Add --> 选中gdb路径 --> Apply<br />
+
 
[[文件:Screenshot from 2020-08-11 14-21-51.png|frameless|650px]]<br />
+
'''添加Devices'''<br />
<br />
+
Tools --> Options --> Devices --> Add --> General Linux Device --> start Wizard --> 输入设备IP和用户名 --> Next --> Next --> Finish --> 输入root用户密码进行测试 --> Close
<br />
+
[[文件:Screenshot_from_2023-02-09_20-21-38.png|frameless|650px]]<br />
'''添加Devices(可选项)'''<br />
 
Tools --> Options --> Devices --> Add --> General Linux Device --> start Wizard<br />
 
GDB Server executable路径为: /opt/data/target/usr/bin/gdbserver<br />
 
[[文件:Screenshot from 2020-08-11 14-24-23.png|frameless|650px]]<br />
 
<br />
 
并点击"Test"测试设备联通'''<br />
 
[[文件:Device Test.png]]<br />
 
 
<br />
 
<br />
 +
[[文件:Screenshot_from_2023-02-09_20-23-35.png|frameless|650px]]<br />
 
<br />
 
<br />
 +
[[文件:Screenshot_from_2023-02-09_20-23-39.png|frameless|650px]]
 +
 
'''添加Kits'''<br />
 
'''添加Kits'''<br />
Tools --> Options --> Build & Run --> Kits --> Add --> Apply<br />
+
Tools --> Options --> Kits --> Add --> 如图示添加各项配置 --> Apply<br />
[[文件:Screenshot from 2020-08-11 14-25-12.png|frameless|650px]]<br />
+
[[文件:Screenshot_from_2023-02-09_20-29-36.png|frameless|650px]]
<br />
+
 
<br />
+
'''打开calculator工程并选择Kits'''<br />
'''打开 calculator 工程并选择Kits'''<br />
+
Welcome --> Projects --> Open --> 选择工程路径 /home/lin/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/qt/examples/widgets/widgets/calculator/calculator.pro --> Configure Project<br />
Welcome --> Open Porject --> 选择工程路径 /opt/data/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/qt/examples/widgets/widgets/calculator/calculator.pro --> Configure Project<br />
+
[[文件:Screenshot_from_2023-02-09_19-58-43.png|frameless|650px]]
[[文件:Screenshot from 2020-08-11 17-04-50.png|frameless|650px]]<br />
+
 
<br />
+
'''配置设备运行环境变量'''<br />
<br />
+
Projects --> Active Project --> calculator --> Build & Run --> Unnamed --> Run --> Run Environment --> Details --> Batch Edit --> 添加QT程序运行环境变量 --> OK
'''编译运行 calculator'''<br />
+
<syntaxhighlight lang="bash">
Build --> Build Project "calculator" --> 重启qtcreator<br />
+
LD_LIBRARY_PATH=/opt/data/target/usr/lib
Projects --> debian-kit --> Run<br />
+
QT_QPA_PLATFORM_PLUGIN_PATH=/opt/data/target/usr/lib/qt/plugins
注意:找到 Run Environment --> Details --> Batch Edit 添加QT运行环境变量<br />
+
QT_QPA_PLATFORM=linuxfb
[[文件:Screenshot from 2020-08-11 17-13-29.png|1560px|frameless|650px]]<br />
+
PATH=/opt/data/target/usr/bin
<br />
+
</syntaxhighlight>
Build --> Run<br />
+
[[文件:Screenshot_from_2023-02-09_21-48-17.png|1560px|frameless|650px]]
[[文件:481762326.jpg|1560px|frameless|650px]]<br />
+
 
<br />
+
'''编译运行calculator'''<br />
 +
Projects --> Run --> 输入root用户密码 --> 程序构建后会部署到设备上并运行<br />
 +
[[文件:Screenshot_from_2023-02-09_20-57-10.png|1560px|frameless|650px]]<br />
 
<br />
 
<br />
 +
[[文件:Screenshot_from_2023-02-09_20-57-15.png|1560px|frameless|650px]]
 +
 
'''配置debug模式'''<br />
 
'''配置debug模式'''<br />
Projects --> debian-kit --> Build<br />
+
Projects --> Active Project --> calculator --> Build & Run --> Unnamed --> Build --> Build Steps --> qmake --> Details --> qmake build configuration --> 选中Debug --> Additional arguments --> 添加 QMAKE_CXXFLAGS+=-g<br />
注意:找到 Build Steps --> qmake --> Details --> Additional arguments --> 添加 QMAKE_CXXFLAGS+=-g<br />
+
[[文件:Screenshot_from_2023-02-09_21-30-06.png|1560px|frameless|650px]]
[[文件:Screenshot from 2020-08-11 17-36-06.png|1560px|frameless|650px]]<br />
+
 
<br />
 
<br />
 
 
'''重新编译并调试运行'''<br />
 
'''重新编译并调试运行'''<br />
 
Build --> Clean Project "calculator"<br />
 
Build --> Clean Project "calculator"<br />
Debug --> Start Debugging --> Start Debugging<br />
+
Debug --> Start Debugging --> Start Debugging of startup project<br />
[[文件:Screenshot from 2020-08-11 17-33-48.png|1560px|frameless|650px]]<br />
+
[[文件:Screenshot_from_2023-02-09_21-38-28.png|1560px|frameless|650px]]
<br />
 
[[文件:378111369.jpg|1560px|frameless|650px]]<br />
 
<br />
 
<br />
 

2023年2月13日 (一) 18:21的最新版本

基础信息

用户密码

系统使用root用户在tty终端自动登录,同时也支持root用户ssh远程登录。

用户:root
密码:root

网络设置

系统使用NetworkManager管理网络,默认为以太网配置了动态IP,可以使用nmcli命令来配置网络。

使用nmcli命令配置网络

设置静态IP示例

查看已创建的连接:

nmcli connection show
...
有线连接 1  36ff5fe1-088a-3562-a9f1-70e9552ce8b6  ethernet  eth0
...

若已存在关于网络接口eth0的连接,需先删除:

nmcli connection delete '有线连接 1'

添加名为my_static_eth0的静态IP连接:

nmcli connection add con-name my_static_eth0 ifname eth0 type ethernet ip4 10.168.1.157/24 gw4 10.168.1.1

设置DNS:

nmcli connection modify my_static_eth0 ipv4.dns "10.168.1.1 119.29.29.29"

设置动态IP示例

查看已创建的连接:

nmcli connection show
...
有线连接 1  36ff5fe1-088a-3562-a9f1-70e9552ce8b6  ethernet  eth0
...

若已存在关于网络接口eth0的连接,需先删除:

nmcli connection delete '有线连接 1'

添加名为my_dynamic_eth0的动态IP连接:

nmcli connection add con-name my_dynamic_eth0 ifname eth0 type ethernet

连接WIFI示例

查看WIFI网络列表:

nmcli device wifi list
...
IN-USE  SSID             MODE  CHAN  RATE        SIGNAL  BARS  SECURITY  
        OrayBox-3D28     红外  9     130 Mbit/s  65      ▂▄▆_  WPA2      
        NORCO-5G         红外  1     130 Mbit/s  59      ▂▄▆_  WPA2      
...

连接名为OrayBox-3D28密码为norco85258506的WIFI:

nmcli device wifi connect OrayBox-3D28 password norco85258506

命令用法举例

查看网络接口状态:

nmcli device status

查看网络接口网络信息:

nmcli device show eth0

使用连接:

nmcli connection up my_static_eth0

不使用连接:

nmcli connection down my_static_eth0

查看连接详细信息:

nmcli connection show my_static_eth0

关闭WIFI:

nmcli radio wifi off

打开WIFI:

nmcli radio wifi on

连接WIFI并设置静态IP:

nmcli con add con-name "my_wifi" type wifi ifname wlan0 ssid "OrayBox-3D28" -- wifi-sec.key-mgmt wpa-psk wifi-sec.psk "norco85258506" ipv4.method manual ipv4.address 10.168.1.158/24 ipv4.dns 119.29.29.29 ipv4.gateway 10.168.1.1

创建名为my_hotspot的WIFI热点:

nmcli dev wifi hotspot ifname wlan0 ssid "my_hotspot" password "88888888"

图形多媒体

Gstreamer

使用Gstreamer播放视频:

gst-play-1.0 /usr/local/test.mp4

277317066.jpg

Gstreamer命令举例:

gst-launch-1.0 playbin uri=file:///usr/local/test.mp4
gst-launch-1.0 uridecodebin uri=file:///usr/local/test.mp4 ! kmssink
gst-launch-1.0 filesrc location=/usr/local/test.mp4 ! queue ! qtdemux  name=dmux dmux.video_0 ! queue ! h264parse ! mppvideodec ! kmssink dmux.audio_0 ! queue ! aacparse ! faad ! autoaudiosink
gst-inspect-1.0 kmssink
gst-discoverer-1.0 /usr/local/test.mp4

OpenCL

查看OpenCL相关信息:

apt install clinfo
clinfo
...
Number of platforms                               1
  Platform Name                                   ARM Platform
  Platform Vendor                                 ARM
  Platform Version                                OpenCL 1.2 v1.r14p0-01rel0-git(a79caef).8ddfd7584149d9238dced4e406610de7
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addy
  Platform Extensions function suffix             ARM

  Platform Name                                   ARM Platform
Number of devices                                 1
  Device Name                                     Mali-T860
  Device Vendor                                   ARM
  Device Vendor ID                                0x8602000
  Device Version                                  OpenCL 1.2 v1.r14p0-01rel0-git(a79caef).8ddfd7584149d9238dced4e406610de7
  Driver Version                                  1.2
  Device OpenCL C Version                         OpenCL C 1.2 v1.r14p0-01rel0-git(a79caef).8ddfd7584149d9238dced4e406610de7
  Device Type                                     GPU
  Device Profile                                  FULL_PROFILE
  Max compute units                               4
  Max clock frequency                             800MHz
  Device Partition                                (core)
    Max number of sub-devices                     0
    Supported partition types                     None
  Max work item dimensions                        3
  Max work item sizes                             256x256x256
  Max work group size                             256
...

固件打包烧录

导出主板上的根文件系统分区镜像rootfs.img

1. 将U盘的第一个分区格式化成ext4格式

2. 在U盘的第一个分区根目录下创建export_rootfs文件

3. 将U盘插到主板上,重新给主板上电

4. 等待rootfs.img自动导出,此时系统会进入recovery模式,不会进入正常系统界面。导出完成后,系统会自动重启进入正常系统界面

5. U盘中的rootfs.img即为根文件系统分区镜像

在Windows电脑主机上制作完整固件

1. 解包完整固件update.img

  • 将下载的烧录包解压到当前文件夹,进入tools目录,将烧录工具windows.zip解压到当前文件夹,进入windows\RKDevTool\rockdev目录,双击执行nc-unpack.bat解包脚本,等待解包完成后各分区镜像保存在Output\Image目录中

Screenshot from 2023-02-01 13-45-54.png

2. 替换根文件系统分区镜像rootfs.img

  • 将导出的根文件系统分区镜像rootfs.img拷贝替换到Output\Image目录中

Screenshot from 2023-02-01 13-50-33.png

3. 打包完整固件update.img

  • 双击执行nc-pack.bat打包脚本,等待打包完成后完整固件update.img保存在Output目录中

Screenshot from 2023-02-01 13-56-02.png

在Windows电脑主机上烧录固件

安装驱动

将下载的烧录包解压到当前文件夹,进入tools目录,将烧录工具windows.zip解压到当前文件夹,进入windows目录,将驱动DriverAssitant_v*.zip解压到当前文件夹,进入DriverAssitant_v*目录,双击DriverInstall.exe安装驱动。 Screenshot from 2023-02-13 15-09-00.png

运行烧录工具

进入tools\windows\RKDevTool\RKDevTool_Release目录,双击RKDevTool.exe运行烧录工具。

连接烧录线

将主板和Windows电脑通过一根USB烧录线进行连接。

让主板进入烧录模式

在主板系统终端下执行命令:

reboot loader

主板会被烧录工具识别成一个LOADER设备或MASKROM设备。
Screenshot from 2023-02-13 16-37-25.png

烧录完整固件update.img

点击“升级固件” --> 点击“固件”并选中完整固件update.img --> 点击“升级”
Screenshot from 2023-02-13 16-46-50.png
烧录完成后,设备自动重启进入正常工作模式。

单独烧录内核分区镜像boot.img

在设备处于LOADER模式下,可以单独烧录boot分区镜像或rootfs等其他分区镜像,点击“设备分区表”可以看到设备的分区信息。
Screenshot from 2023-02-13 17-11-25.png

只勾选boot一栏 --> 确认地址与设备分区地址一致 --> 选中boot.img所在路径 --> 点击“执行”
Screenshot from 2023-02-13 17-13-03.png

烧录完成后,设备会自动重启或需手动断电重启,进入正常工作模式。

在Linux下打包完整固件

unpack.sh用于将完整固件解包成各个分区镜像;打包工具脚本mkupdate.sh用于将各分区镜像打包成一个完整的固件。

  • 将烧录、解包、打包工具linux.tar.gz解压到当前目录
tar xvf linux.tar.gz
  • 解包update.img
cd linux/Linux_Pack_Firmware/rockdev
ln -sfr ../../../../update.img update.img
./unpack.sh

完成后输出文件output/保存在当前目录下。
Screenshot from 2020-12-31 11-27-13.png

  • 根据需要替换指定分区镜像,比如替换根文件系统分区镜像output/Image/rootfs.img
  • 进行必要的移动拷贝,使用初始固件的分区参数、各分区镜像、打包配置文件
mv output/parameter.txt output/Image/
mv output/MiniLoaderAll.bin output/Image/
mv output/package-file .
ln -sfr output/Image/ Image
  • 根据芯片平台执行对应的打包脚本,完成后完整固件update.img保存在当前目录
./rk3399-mkupdate.sh

Screenshot from 2020-12-31 11-48-11.png

在Linux下烧录固件

烧录工具upgrade_tool可用于升级固件。

  • 连接好USB烧录线连接后,在主板的系统终端下执行如下命令,让主板进入烧录模式
reboot loader
  • 将烧录、解包、打包工具linux.tar.gz解压到当前目录,并进行简单设置
tar xvf linux.tar.gz
cd linux/Linux_Upgrade_Tool/Linux_Upgrade_Tool && chmod a+x upgrade_tool && sudo cp upgrade_tool /usr/local/bin
mkdir ~/.config/upgrade_tool/
cp config.ini ~/.config/upgrade_tool/
  • 烧录完整固件及各分区镜像的命令
sudo upgrade_tool uf update.img
  # 烧录完整固件
sudo upgrade_tool di -p parameter.txt
  # 烧录分区参数
sudo upgrade_tool di -uboot uboot.img
  # 烧录uboot分区镜像
sudo upgrade_tool di -b boot.img
  # 烧录内核分区镜像
sudo upgrade_tool di -rootfs rootfs.img
  # 烧录根文件系统分区镜像rootfs.img
sudo upgrade_tool di -r recovery.img
  # 烧录recovery镜像
sudo upgrade_tool di -userdata userdata.img
  # 烧录userdata分区镜像

开发环境

Ubuntu主机开发环境搭建

x86电脑主机或虚拟机的系统可使用Ubuntu 16.04、Ubuntu 18.04或Ubuntu 20.04进行开发。

Ubuntu 16.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

Ubuntu 18.04建议安装:

sudo apt install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm rsync curl 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 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 screen git-lfs npm default-jre default-jdk ccache

Ubuntu 20.04建议安装:

sudo apt install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm rsync curl 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 libsigsegv2 libudev-dev libusb-1.0-0-dev live-build m4 make mercurial mtools ncurses-dev openssh-client parted patch patchelf perl python qemu-user-static rsync sed ssh subversion tar texinfo u-boot-tools unzip w3m wget libdb1-compat python3-pyelftools screen git-lfs npm default-jre default-jdk ccache

QT开发

qt程序测试脚本

系统中添加了qt_test.sh和qt_test_touchscreen.sh测试脚本,在系统终端下直接运行:

qt_test.sh

1365219484.jpg

基于libinput、tslib或evdev适配触摸屏运行qt程序:

qt_test_touchscreen.sh libinput
qt_test_touchscreen.sh tslib
qt_test_touchscreen.sh evdev

285324002.jpg

搭建qt开发环境

主机PC端环境为Ubuntu20.04,目标板系统为debian base系统,默认使用root用户自动登录,并支持root用户ssh远程登录,系统中移植了qt,支持linuxfb显示插件。 SDK与系统镜像一同发布,从相应的烧录包中获取SDK。SDK中包含交叉编译工具链、qmake、与目标板系统qt环境。解压SDK到任意目录$TOP_DIR(示例中以路径~/trash为例),并运行开发环境配置脚本

export TOP_DIR=~/trash
mkdir -p ~/trash
tar xpf 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/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/qt/examples/widgets/widgets/calculator
qmake
make

生成calculator程序,可通过scp拷贝到目标板中,并配置qt运行环境变量后运行:

scp calculator root@10.168.1.157:
ssh root@10.168.1.157
export LD_LIBRARY_PATH=/opt/data/target/usr/lib
export QT_QPA_PLATFORM_PLUGIN_PATH=/opt/data/target/usr/lib/qt/plugins

指定linuxfb显示插件运行程序:

./calculator -platform linuxfb

481762326.jpg

使用qtcreator开发调试qt程序

qtcreator集成编辑、编译、运行、调试环境于一体,提升开发效率。

安装qtcreator

sudo apt install qtcreator qtbase5-dev qt5-default qtbase5-examples

添加Qt Versions
Tools --> Options --> Kits --> Qt Versions --> Add --> 选中qmake路径 --> Apply
Screenshot from 2023-02-09 19-26-12.png

添加Compilers
Tools --> Options --> Kits --> Compilers --> Add --> GCC --> C++ --> 选中g++路径 --> Apply
Screenshot from 2023-02-09 19-35-47.png

添加Debuggers
Tools --> Options --> Kits --> Debuggers --> Add --> 选中gdb路径 --> Apply
Screenshot from 2023-02-09 19-41-35.png

添加Devices
Tools --> Options --> Devices --> Add --> General Linux Device --> start Wizard --> 输入设备IP和用户名 --> Next --> Next --> Finish --> 输入root用户密码进行测试 --> Close Screenshot from 2023-02-09 20-21-38.png

Screenshot from 2023-02-09 20-23-35.png

Screenshot from 2023-02-09 20-23-39.png

添加Kits
Tools --> Options --> Kits --> Add --> 如图示添加各项配置 --> Apply
Screenshot from 2023-02-09 20-29-36.png

打开calculator工程并选择Kits
Welcome --> Projects --> Open --> 选择工程路径 /home/lin/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/qt/examples/widgets/widgets/calculator/calculator.pro --> Configure Project
Screenshot from 2023-02-09 19-58-43.png

配置设备运行环境变量
Projects --> Active Project --> calculator --> Build & Run --> Unnamed --> Run --> Run Environment --> Details --> Batch Edit --> 添加QT程序运行环境变量 --> OK

LD_LIBRARY_PATH=/opt/data/target/usr/lib
QT_QPA_PLATFORM_PLUGIN_PATH=/opt/data/target/usr/lib/qt/plugins
QT_QPA_PLATFORM=linuxfb
PATH=/opt/data/target/usr/bin

Screenshot from 2023-02-09 21-48-17.png

编译运行calculator
Projects --> Run --> 输入root用户密码 --> 程序构建后会部署到设备上并运行
Screenshot from 2023-02-09 20-57-10.png

Screenshot from 2023-02-09 20-57-15.png

配置debug模式
Projects --> Active Project --> calculator --> Build & Run --> Unnamed --> Build --> Build Steps --> qmake --> Details --> qmake build configuration --> 选中Debug --> Additional arguments --> 添加 QMAKE_CXXFLAGS+=-g
Screenshot from 2023-02-09 21-30-06.png

重新编译并调试运行
Build --> Clean Project "calculator"
Debug --> Start Debugging --> Start Debugging of startup project
Screenshot from 2023-02-09 21-38-28.png