第一部分:编译rk3328 sdk
0. 环境
- EC-R3328PC(ROC-RK3328-PC)
- ubuntu18(100GB)
1. 安装依赖
sudo apt-get update
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 gcc-arm-linux-gnueabihf libssl-dev liblz4-tool genext2fs lib32stdc++6 \
gcc-aarch64-linux-gnu g+conf 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 fakeroot \
libparse-yapp-perl default-jre patchutils
注意: Ubuntu17.04 或者更高的系统还需要如下依赖包:
sudo apt-get install lib32gcc-7-dev g++-7 libstdc++-7-dev
sudo apt install swig
sudo apt-get install python-dev
sudo apt install expect-dev
2. 解压 Firefly_Linux_SDK 分卷压缩包(晚上测试了网络不通,白天重试可以连上了)
确认无误后,就可以解压:
cat *firefly_split* | tar -xzv
#本SDK文件夹内包含一个 .repo 目录,解压之后,在当前目录下执行以下操作
cd rk3328_linux_release_v2.5.1_20210301/
ls -al
.repo/repo/repo sync -l
.repo/repo/repo sync -c --no-tags
.repo/repo/repo start firefly --all
问题:error: Cannot remove project "distro": uncommitted changes are present
解决办法:rm -rf distro
重新执行 .repo/repo/repo sync -l
3. 编译buildroot
./build.sh roc-rk3328-pc-buildroot.mk #文件路径在 `device/rockchip/rk3328/firefly-rk3328-buildroot.mk`
./build.sh
4. 裁剪内核
cd rk3328_linux_release_v2.5.1_20210301/kernel
make ARCH=arm64 firefly-rk3328_defconfig
make ARCH=arm64 menuconfig
5. 固件打包
5.1 同步更新各部分镜像
./mkfirmware.sh
5.2 打包统一固件
./build.sh updateimg
打包生成的完整固件会保存到 rockdev/pack/ 目录。
6. 配置环境变量
打开文件:
gedit ~/.bashrc
添加内容:
export PATH=/home/xxjianvm/work/rk3328_linux_release_v2.5.1_20210301_split_dir/rk3328_linux_release_v2.5.1_20210301/buildroot/output/rockchip_rk3328/host/bin:$PATH
测试验证:
重新打开命令行控制台
aarch64-linux-gcc -v
注意:
aarch64-linux-gcc 是在sdk里面的,aarch64-linux-gnu-gcc是在 /usr/bin 里面
参考:https://wiki.t-firefly.com/zh_CN/ROC-RK3328-PC/intro.html
第二部分:buildroot添加qt、vnc
0. 环境
- EC-R3328PC(ROC-RK3328-PC)
- ubuntu18(100GB)
- rk3328_linux_release_v2.5.1_20210301(编译好了一遍buildroot)
1. 配置变量
# 进入 SDK 根目录
cd path/to/SDK/
source envsetup.sh rockchip_rk3328
2. 自定义
cd buildroot
make menuconfig
2.1 qt5
Target packages -> Graphic libraries and applications (graphic/text) > Qt5
Target packages -> Graphic libraries and applications (graphic/text) > Qt5 -> gui module
Target packages -> Graphic libraries and applications (graphic/text) > Qt5 -> qt5charts
Target packages —> Graphic libraries and applications (graphic/text) —> Qt5 —> Enable Tslib support
2.2 vnc
Target packages -> Graphic libraries and applications (graphic/text) -> X.org X Window System
Target packages -> Graphic libraries and applications (graphic/text) -> x11vnc
2.3 保存配置
make savedefconfig
3. 编译
全自动编译
./build.sh
打包生成的完整固件会保存到 rockdev/pack/ 目录。
4. 下载新固件后测试
4.1 准备镜像和工具
开发板-LINUX资料、ROC-RK3328-PC
镜像:
ROC-RK3328-PC-UBUNTU-18.04_DESKTOP-GPT-20211230-1007.img
工具:
AndroidTool_Release_v2.71
4.2 进入烧写模式
打开 AndroidTool_Release_v2.71
用USB-TYPE-C线连接笔记本的USB和设备。注意不要用USB-HUB,供电不足,usb-hub外接5v电源也不够。刚开始没有网络,原来一直在重启。
拆下外壳,按下 reboot按键 reset。会提示发现一个LOADER设备。
也可以试试不拆外壳,用牙签按下耳机控位置内的按键,上电。
4.3 选择固件
升级固件 -> 固件-> 选择: ROC-RK3328-PC-UBUNTU-18.04_DESKTOP-GPT-20211230-1007.img
-> 擦除Flash
-> 升级
5. 测试
机子默认开机后有adb的。
参考:
[1]https://wiki.t-firefly.com/zh_CN/Firefly-RK3288/buildroot_develop.html
[2]buildroot配置QT5和tslib,https://blog.csdn.net/u012577474/article/details/103365647
[3]STM32MP157使用buildroot编译QT并且跑通QT demo应用程序,https://blog.csdn.net/qq_24622489/article/details/119881325
第三部分:QT hello world[PC]
0. 环境
vmware: ubuntu18
winscp:
mobaterm:
1. 获取linux-qt
https://download.qt.io/archive/qt/5.14/5.14.2/
下载
qt-opensource-linux-x64-5.12.2.run
这个版本是编译板子buildroot的qt5版本。
2. 安装
sudo chmod 777 qt-opensource-linux-x64-5.12.2.run
./qt-opensource-linux-x64-5.12.2.run
-> Next
-> 输入账号密码登录
-> Next
-> Installation Folder: /home/xxjianvm/Qt5.12.2 -> Next
-> Select Components -> 勾选 Desktop gcc 64-bit,勾选 Qt Charts,勾选 Developer and Designer Tools -> Next
-> License Agreement -> Next
-> Install
3. 界面 helloworld
通过开始界面打开 Qt Creator
3.1 创建工程
Qt Creator -> File -> New File or Project -> Application -> Qt Widgets Application -> choose
Location
-> Name: hello_qt
-> Create in: /home/xxjianvm/work/workspace_qt/
-> Next
Kits -> Next
-> Finish
Build System:
-> Build System: qmake -> Next
Details
-> Class Information: hello_qt -> Next
Translaton -> Next
3.2 修改界面
双击 helloworld_ui/Forms/hello_qt.ui
添加 Push Button ->
-> objectName: Btn_Hello
-> 右键 -> Go to slot... -> clicked() -> OK
修改ep4ce30Adc_LinuxQt.cpp:
#include <QtWidgets/QMessageBox>
void hello_qt::on_Btn_Hello_clicked()
{
QMessageBox msgBox;
msgBox.setText("The document has been modified.");
msgBox.exec();
}
修改 helloworld_ui.pro
把
QT += core gui
修改为:
QT += core gui
QT += widgets
编译
运行
参考:
[1]Linux安装qt完整版教程,https://blog.csdn.net/m0_45463480/article/details/127696388
[2]qt-creator的hello world,https://blog.csdn.net/qq_27158179/article/details/122790006?spm=1001.2014.3001.5501
[3]究极保姆式教你如何在Ubuntu上源码安装Qt5.15.2,https://blog.csdn.net/qq_43459209/article/details/119336675
[4]Qt中QMessageBox的用法---看这一篇就够了,https://blog.csdn.net/qq_42250189/article/details/105178379
[5]QT系统学习系列:1.2 PushButton(常规按钮),https://blog.csdn.net/Fdog_/article/details/113041687
第四部分:QT hello world[arm64]
0. 环境
ROC-RK3328-PC,buildroot镜像
vmware: ubuntu18,编译好了 buildroot,qt creator,
winscp:
mobaterm:
1. 添加Kit
Qt Creator -> Tools -> Options ->
-> Kits -> Compilers -> Manual -> C -> Add -> GCC -> C
-> Name: aarch64-linux-gcc
-> Compiler path: /home/xxjianvm/work/rk3328_linux_release_v2.5.1_20210301_split_dir/rk3328_linux_release_v2.5.1_20210301/buildroot/output/rockchip_rk3328/host/bin/aarch64-linux-gcc
-> Kits -> Compilers -> Manual -> C++ -> Add -> GCC -> C++
-> Name: aarch64-linux-g++
-> Compiler path: /home/xxjianvm/work/rk3328_linux_release_v2.5.1_20210301_split_dir/rk3328_linux_release_v2.5.1_20210301/buildroot/output/rockchip_rk3328/host/bin/aarch64-linux-g++
-> Kits -> Qt Versions -> Manual -> Add -> /home/xxjianvm/work/rk3328_linux_release_v2.5.1_20210301_split_dir/rk3328_linux_release_v2.5.1_20210301/buildroot/output/rockchip_rk3328/host/bin/qmake
-> Kits -> Kits -> Manual -> Add
-> Name: arm64
-> Compiler C: aarch64-linux-gcc
-> Compiler C++: aarch64-linux-g++
-> Qt version: Qt version 5.12.2 for Embedded Linux
2. 界面 helloworld
通过开始界面打开 Qt Creator
2.1 创建工程
Qt Creator -> File -> New File or Project -> Application -> Qt Widgets Application -> choose
Location
-> Name: hello2_qt
-> Create in: /home/xxjianvm/work/workspace_qt/
-> Next
Kits ->
-> 全选 -> Next
Build System:
-> Build System: qmake -> Next
Details
-> Class Information: hello2_qt -> Next
-> Finish
2.2 修改界面
双击 helloworld_ui/Forms/hello_qt.ui
添加 Push Button ->
-> objectName: Btn_Hello
-> 右键 -> Go to slot... -> clicked() -> OK
修改ep4ce30Adc_LinuxQt.cpp:
#include <QtWidgets/QMessageBox>
void hello2_qt::on_Btn_Hello_clicked()
{
QMessageBox msgBox;
msgBox.setText("The document has been modified.");
msgBox.exec();
}
修改 helloworld_ui.pro
把
QT += core gui
修改为:
QT += core gui
QT += widgets
2.3 编译
左下角可以切换 Kit了。
3. 运行
3.1 PC
qt creator直接运行
3.2 DEV
拷贝
build-hello2_qt-arm64-Debug/hello2_qt
到板子上的
/root/hello2_qt
配置QT程序的启动的方式
export QT_QPA_PLATFORM=vnc
方式2:启动程序时指定启动方式
启动参数
./hello2_qt -platform vnc:size=1280x10,port=12345
mobaterm,用VNC打开 192.168.3.237:12345,输入密码 firefly
参考:
[1]记录QTCreator如何更换套件(Kit),切换QT不同版本,https://blog.csdn.net/Wslience/article/details/132159413
[2]Qt-Vnc远程,https://www.cnblogs.com/yaronzz/p/15723128.html