RV1126&RV1109 buildroot 增加QT程序

1、先看效果

2、上代码补丁

From 08f234148d543a546e6f64ebbba31e379424322a Mon Sep 17 00:00:00 2001
From: rockemd <rockemd2020@163.com>
Date: Wed, 18 Nov 2020 18:19:02 +0800
Subject: [PATCH] qhellotest

---
 app/qhellotest/main.cpp                            | 11 ++++++
 app/qhellotest/mainwindow.cpp                      | 15 ++++++++
 app/qhellotest/mainwindow.h                        | 21 ++++++++++
 app/qhellotest/mainwindow.ui                       | 45 ++++++++++++++++++++++
 app/qhellotest/qhellotest.pro                      | 28 ++++++++++++++
 .../rockchip_rv1126_rv1109_facial_gate_defconfig   |  1 +
 buildroot/package/rockchip/Config.in               |  1 +
 buildroot/package/rockchip/qhellotest/Config.in    |  4 ++
 .../package/rockchip/qhellotest/qhellotest.mk      | 23 +++++++++++
 9 files changed, 149 insertions(+)
 create mode 100755 app/qhellotest/main.cpp
 create mode 100755 app/qhellotest/mainwindow.cpp
 create mode 100755 app/qhellotest/mainwindow.h
 create mode 100755 app/qhellotest/mainwindow.ui
 create mode 100755 app/qhellotest/qhellotest.pro
 mode change 100644 => 100755 buildroot/configs/rockchip_rv1126_rv1109_facial_gate_defconfig
 mode change 100644 => 100755 buildroot/package/rockchip/Config.in
 create mode 100755 buildroot/package/rockchip/qhellotest/Config.in
 create mode 100755 buildroot/package/rockchip/qhellotest/qhellotest.mk

diff --git a/app/qhellotest/main.cpp b/app/qhellotest/main.cpp
new file mode 100755
index 0000000..aff48df
--- /dev/null
+++ b/app/qhellotest/main.cpp
@@ -0,0 +1,11 @@
+#include "mainwindow.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+    MainWindow w;
+    w.show();
+    return a.exec();
+}
diff --git a/app/qhellotest/mainwindow.cpp b/app/qhellotest/mainwindow.cpp
new file mode 100755
index 0000000..79c64b9
--- /dev/null
+++ b/app/qhellotest/mainwindow.cpp
@@ -0,0 +1,15 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent)
+    : QMainWindow(parent)
+    , ui(new Ui::MainWindow)
+{
+    ui->setupUi(this);
+}
+
+MainWindow::~MainWindow()
+{
+    delete ui;
+}
+
diff --git a/app/qhellotest/mainwindow.h b/app/qhellotest/mainwindow.h
new file mode 100755
index 0000000..934b0f3
--- /dev/null
+++ b/app/qhellotest/mainwindow.h
@@ -0,0 +1,21 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+QT_BEGIN_NAMESPACE
+namespace Ui { class MainWindow; }
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    MainWindow(QWidget *parent = nullptr);
+    ~MainWindow();
+
+private:
+    Ui::MainWindow *ui;
+};
+#endif // MAINWINDOW_H
diff --git a/app/qhellotest/mainwindow.ui b/app/qhellotest/mainwindow.ui
new file mode 100755
index 0000000..0b7ae14
--- /dev/null
+++ b/app/qhellotest/mainwindow.ui
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>364</width>
+    <height>293</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <widget class="QLabel" name="label">
+    <property name="geometry">
+     <rect>
+      <x>0</x>
+      <y>100</y>
+      <width>361</width>
+      <height>131</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>rockemd QT!</string>
+    </property>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>364</width>
+     <height>23</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/app/qhellotest/qhellotest.pro b/app/qhellotest/qhellotest.pro
new file mode 100755
index 0000000..4ec32ea
--- /dev/null
+++ b/app/qhellotest/qhellotest.pro
@@ -0,0 +1,28 @@
+QT += widgets
+
+CONFIG += c++11 console
+
+TARGET = qhellotest
+TEMPLATE = app
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which as been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+#DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+    main.cpp \
+    mainwindow.cpp
+
+HEADERS += \
+    mainwindow.h
+
+FORMS += \
+    mainwindow.ui
+
diff --git a/buildroot/configs/rockchip_rv1126_rv1109_facial_gate_defconfig b/buildroot/configs/rockchip_rv1126_rv1109_facial_gate_defconfig
old mode 100644
new mode 100755
index 71e9632..e325a85
--- a/buildroot/configs/rockchip_rv1126_rv1109_facial_gate_defconfig
+++ b/buildroot/configs/rockchip_rv1126_rv1109_facial_gate_defconfig
@@ -24,6 +24,7 @@ BR2_PACKAGE_RKMEDIA_ANR=y
 BR2_PACKAGE_RKMEDIA_AEC=y
 BR2_PACKAGE_RKMEDIA_EXAMPLES=y
 BR2_PACKAGE_QFACIALGATE=y
+BR2_PACKAGE_QHELLOTEST=y
 # BR2_PACKAGE_MINIGUI_SOFTWARE_SCALE is not set
 BR2_PACKAGE_RKNPU_USE_MINI_DRIVER=y
 BR2_PACKAGE_RKFACIAL_USE_WEB_SERVER=y
diff --git a/buildroot/package/rockchip/Config.in b/buildroot/package/rockchip/Config.in
old mode 100644
new mode 100755
index 6735cdc..8cb643b
--- a/buildroot/package/rockchip/Config.in
+++ b/buildroot/package/rockchip/Config.in
@@ -180,6 +180,7 @@ source "package/rockchip/carmachine/Config.in"
 source "package/rockchip/gallery/Config.in"
 source "package/rockchip/QLauncher/Config.in"
 source "package/rockchip/QFacialGate/Config.in"
+source "package/rockchip/qhellotest/Config.in"
 source "package/rockchip/settings/Config.in"
 source "package/rockchip/qcamera/Config.in"
 source "package/rockchip/qfm/Config.in"
diff --git a/buildroot/package/rockchip/qhellotest/Config.in b/buildroot/package/rockchip/qhellotest/Config.in
new file mode 100755
index 0000000..7b18811
--- /dev/null
+++ b/buildroot/package/rockchip/qhellotest/Config.in
@@ -0,0 +1,4 @@
+config BR2_PACKAGE_QHELLOTEST
+	bool "qhellotest"
+	help
+		rockemd qt test
\ No newline at end of file
diff --git a/buildroot/package/rockchip/qhellotest/qhellotest.mk b/buildroot/package/rockchip/qhellotest/qhellotest.mk
new file mode 100755
index 0000000..8a9dbc4
--- /dev/null
+++ b/buildroot/package/rockchip/qhellotest/qhellotest.mk
@@ -0,0 +1,23 @@
+################################################################################
+#
+# qhellotest
+#
+################################################################################
+
+QHELLOTEST_VERSION = 1.0
+QHELLOTEST_SITE = $(TOPDIR)/../app/qhellotest
+QHELLOTEST_SITE_METHOD = local
+
+QHELLOTEST_LICENSE = Apache V2.0
+QHELLOTEST_LICENSE_FILES = NOTICE
+define QHELLOTEST_CONFIGURE_CMDS
+cd $(@D); $(TARGET_MAKE_ENV) $(HOST_DIR)/bin/qmake 
+endef
+define QHELLOTEST_BUILD_CMDS
+$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) 
+endef
+
+define QHELLOTEST_INSTALL_TARGET_CMDS
+$(INSTALL) -D -m 0755 $(@D)/qhellotest $(TARGET_DIR)/usr/bin/qhellotest
+endef
+$(eval $(generic-package))
-- 
2.7.4

 

3、开发调试步骤

3.1、在PC机上安装QT开发环境,新建工程(这里不详细介绍),可参考rockchip官方文档 《docs\Linux\ApplicationNote\Rockchip_Developer_Guide_Linux_Qt_CN.pdf》

3.2、移植QT工程(见补丁)

3.3、编译调试如下:

source build/envsetup.sh

72. rockchip_rv1126_rv1109
73. rockchip_rv1126_rv1109_facial_gate
74. rockchip_rv1126_rv1109_libs
75. rockchip_rv1126_rv1109_ramboot_uvcc
76. rockchip_rv1126_rv1109_recovery
77. rockchip_rv1126_rv1109_sl
78. rockchip_rv1126_rv1109_spi_nand
79. rockchip_rv1126_rv1109_systemd
80. rockchip_rv1126_rv1109_toolchain
81. rockchip_rv1126_rv1109_uvcc
82. rockchip_rv1126_rv1109_uvcc_spi_nand
Which would you like? [0]: 73   <--------------------------------------

make qhellotest-rebuild

编译成功生成可执行程序目录:rv1126_rv1109/buildroot/output/rockchip_rv1126_rv1109_facial_gate/target/usr/bin/qhellotest


adb push Z:\rv1126_rv1109\buildroot\output\rockchip_rv1126_rv1109_facial_gate\target\usr\bin\qhellotest \usr\bin\

adb shell
[root@ROCKEMD:/]#  chmod 777 /usr/bin/qhellotest
[root@ROCKEMD:/]#  export QT_QPA_FB_DRM=1
[root@ROCKEMD:/]#  export QT_QPA_PLATFORM=linuxfb:rotation=0
[root@ROCKEMD:/]#  qhellotest &

技术交流群: 微信号
===========================================

<think>嗯,用户的问题是关于在RV1126平台上使用Buildroot安装Mosquitto MQTT Broker。我需要先理解用户的需求。RV1126是一个处理器平台,Buildroot是用于构建嵌入式Linux系统的工具。Mosquitto是一个开源的MQTT代理,用户可能想在这个平台上部署物联网相关的应用,比如连接到阿里云或者微信小程序。 首先,我得回忆一下Buildroot的基本流程。Buildroot通过配置包来选择需要编译的软件,然后生成根文件系统。所以用户需要在Buildroot的配置中启用Mosquitto包。可能需要检查Buildroot的版本是否支持Mosquitto,或者是否需要额外的配置。 接下来,我需要查看用户提供的引用内容。引用[3]提到了在RV1126Buildroot构建过程中遇到的一些包的错误,比如libgpg-error和python-crc32c。这可能意味着在编译某些依赖时会有问题。而引用[2]和[1]提到在IMX6Q和STM32+Air724上使用Mosquitto,说明Mosquitto在嵌入式系统上的应用是可行的,但不同平台可能需要不同的配置。 用户的问题可能涉及到几个步骤:首先确保Buildroot配置中包含Mosquitto,然后处理可能的依赖问题,最后进行编译和测试。还需要考虑生成配置文件,如mosquitto.conf,以及启动服务的脚本。另外,引用[5]提到RV1126启动时的问题,修改inittab文件可能需要处理,但用户的问题可能不需要这个步骤,除非Mosquitto服务启动有类似问题。 可能的陷阱包括依赖库缺失,比如OpenSSL的支持,或者在交叉编译过程中某些选项未正确配置。用户可能需要手动启用Mosquitto的配置选项,比如TLS支持,或者调整编译参数。此外,生成后的根文件系统中,Mosquitto的配置文件路径是否正确,服务如何自动启动也是需要考虑的。 另外,用户可能希望Mosquitto在启动时自动运行,这可能需要修改初始化脚本,比如在/etc/init.d中添加启动项,或者使用systemd配置。不过Buildroot通常使用传统的init系统,所以可能需要检查/etc/rc.local或者类似的启动文件。 总结步骤应该是:1. 进入Buildroot配置,启用Mosquitto包;2. 处理依赖项,如OpenSSL;3. 编译并生成固件;4. 在目标平台上配置Mosquitto,如修改配置文件;5. 测试服务是否正常运行。同时需要注意可能的编译错误,参考引用中的解决方法,比如处理libgpg-error的问题可能需要更新或打补丁。 最后,用户可能需要验证Mosquitto是否正确安装,使用mosquitto_sub和mosquitto_pub命令测试MQTT通信,或者检查端口1883是否监听。如果有问题,查看日志文件或启用调试模式。</think>### RV1126平台使用Buildroot安装Mosquitto的步骤 #### 一、配置Buildroot环境 1. **进入SDK目录** ```bash cd buildroot/ source build/envsetup.sh # 初始化编译环境[^4] ``` 2. **启动Buildroot配置界面** ```bash make menuconfig ``` 3. **启用Mosquitto包** - 导航至路径:`Target Packages` → `Networking applications` → `mosquitto` - 勾选以下选项: - `Enable MQTT broker`(启用MQTT服务端) - `Enable TLS support`(如需加密通信) - `Enable command-line clients`(包含mosquitto_pub/sub工具)[^2] #### 二、处理依赖项 1. **确保OpenSSL已启用** - 在`Target Packages` → `Cryptographic libraries`中勾选`openssl` - 若遇到类似`libgpg-error`的编译错误,需检查交叉编译工具链的兼容性[^3] 2. **执行增量编译** ```bash make mosquitto-rebuild # 仅重新编译Mosquitto及其依赖 ``` #### 三、生成固件并部署 1. **编译完整系统镜像** ```bash make ``` 2. **烧录固件到RV1126** - 使用工具如`upgrade_tool`将生成的`rootfs.img`写入开发板 #### 四、配置Mosquitto服务 1. **修改配置文件** ```bash vi /etc/mosquitto/mosquitto.conf ``` 添加基础配置: ```conf listener 1883 allow_anonymous true # 测试阶段允许匿名连接[^2] ``` 2. **设置开机自启动** - 在`/etc/init.d/S50mosquitto`添加: ```bash mosquitto -d -c /etc/mosquitto/mosquitto.conf ``` 3. **解决终端抢占问题** 若出现串口被占用,按引用[^5]方法修改`/etc/inittab`: ```bash cp /etc/inittab.source /etc/inittab # 恢复原始配置 ``` #### 五、功能验证 1. **启动服务** ```bash mosquitto -d -c /etc/mosquitto/mosquitto.conf ``` 2. **测试MQTT通信** ```bash mosquitto_sub -t "test" # 订阅主题 mosquitto_pub -t "test" -m "Hello RV1126" # 发布消息 ```
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值