Difference between revisions of "APITestPage"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
 
(244 intermediate revisions by the same user not shown)
Line 1: Line 1:
===开发Qt程序===
 
  
FriendlyELEC为RK3399平台移植的 Qt 5.10.0 支持以下显示设备插件:KMS、EGLFS和XCB,这三种插件均支持GPU硬件加速的OpenGL ES 2.0,只是调用方式不同,描述如下:<br>
+
{{RockchipUnbrick|NanoPC-T4}}
* KMS – 使用Linux内核的DRM显示接口来渲染界面<br>
+
* EGLFS – 使用OpenGL ES接口来渲染界面<br>
+
* XCB – 在X11服务器上运行,并集成到X11窗口环境<br>
+
<br>
+
三种插件所支持的Qt特性会有所不同,请根据你的需求来选择: <br>
+
::{| class="wikitable"
+
|-
+
  | 插件名称
+
  | OpenGL ES
+
  | QtWebEngine
+
  | QtMultimedia
+
  | 视频硬解播放
+
  | 双屏异显
+
|-
+
  | KMS
+
  | <b>Yes</b>
+
  | No
+
  | <b>Yes</b>
+
  | No
+
  | <b>Yes</b>
+
|-
+
  | EGLFS
+
  | <b>Yes</b>
+
  | No
+
  | <b>Yes</b>
+
  | No
+
  | No
+
|-
+
  | XCB
+
  | <b>Yes</b>
+
  | <b>Yes</b>
+
  | <b>Yes</b>
+
  | <b>Yes</b>
+
  | <b>Yes</b>
+
|}
+
建议使用 KMS或XCB 插件。<br><br>
+
为了方便用户测试,FriendlyCore平台提供了4个脚本文件用于设置Qt环境变量,分别为:
+
::{| class="wikitable"
+
|-
+
|脚本文件名||作用
+
|-
+
|/usr/bin/setqt5env-kms||设置kms插件所需要的环境变量
+
|-
+
|/usr/bin/setqt5env-eglfs||设置eglfs插件所需要的环境变量 
+
|-
+
|/usr/bin/setqt5env-xcb||设置xcb插件所需要的环境变量
+
|-
+
|/usr/bin/setqt5env-nogui||仅供无界面的Qt程序使用
+
|}
+
setqt5env-* 脚本的用法,例如设置KMS:
+
<syntaxhighlight lang="bash">
+
. setqt5env-kms
+
./apps
+
</syntaxhighlight>
+
(注: .与字母s之间有个空格)
+
 
+
====Qt开发环境搭建====
+
FriendlyELEC为RK3399平台提供了两种交叉编译Qt程序的方法:
+
* 方法1:使用Docker容器,详细可参考github页面:http://github.com/friendlyarm/friendlyelec-ubuntu18-docker
+
* 方法2: 搭建本地交叉编译环境,本地需要安装 Ubuntu 18.04 64位系统,其环境搭建方法请参考:[[How to Build and Install Qt Application for FriendlyELEC Boards/zh]]
+
 
+
====Qt示例====
+
FriendlyCore系统内置了几个很有特色的Qt演示程序,方便测试Qt5的特性,如下所示:
+
* <b>Qt QML示例:CinematicExperience</b>
+
CinematicExperience是一个用Qt QML实现的专辑列表界面。<br />
+
例子演示了Qt QML中的界面动态转换、粒子模拟和着色器特效,所以这个示例非常能体现硬件性能与软件优化的差异,在RK3399平台上非常流畅。<br />
+
CinematicExperience的运行命令:<br />
+
<syntaxhighlight lang="bash">
+
cd /opt/Qt5_CinematicExperience
+
./run.sh
+
</syntaxhighlight>
+
 
+
运行截图:<br />
+
[[File:Cinematicsexperience.jpg|frameless|480px]]<br />
+
 
+
* <b>QQt WebEngine示例:网页浏览器</b>
+
Qt WebEngine使用了Chromium作为渲染引挚,对HTML5支持完美。<br />
+
这里示例展示的网页浏览器是 Qt5 自带的Demo,示例运行命令:<br />
+
<syntaxhighlight lang="bash">
+
cd /opt/qt5-brower
+
./run.sh
+
</syntaxhighlight>
+
 
+
运行截图:<br />
+
[[File:qt5-brower.jpg|frameless|480px]]<br />
+
 
+
注:Qt WebEngine在FriendlyCore平台上需要使用Xcb插件来运行。
+
 
+
* <b>Qt 双屏异显示例</b>
+
这是一个比较简单的DEMO,演示了在同时连接HDMI和eDP LCD屏的情况下,用Qt实现两个屏幕显示不同的内容:
+
<syntaxhighlight lang="bash">
+
cd /opt/qt5-multi-screen-demo
+
./run.sh
+
</syntaxhighlight>
+
运行截图:<br />
+
[[File:qt5-multi-screen.jpg|frameless|480px]]<br />
+
 
+
* <b>Qt Multimedia: 硬解播放器qt5-player</b>
+
qt5-player播放器已经适配Rockchip的gstreamer插件rkximagesink,支持4K视频的硬解播放,由于rkximagesink插件只支持输出图像到X11窗口,因此 Qt 播放器程序需要使用 XCB 的显示插件来运行。<br />
+
示例运行命令:<br />
+
先在开发板上执行命令
+
<syntaxhighlight lang="bash">
+
cd /opt/qt5-player
+
./run.sh
+
</syntaxhighlight>
+
运行截图:<br />
+
[[File:qt5-player.gif|frameless|480px]]<br />
+
 
+
* <b>QQt WebGL示例: nmapper</b>
+
Qt WebGL允许你将一个QML应用显示在其他设备的网页游览器上,这个特性让你做一些远程控制的应用变得很简单。<br />
+
开发板需要连接网络,在开发版本执行以下命令,即可以WebGL的方式运行Qt程序:<br />
+
<syntaxhighlight lang="bash">
+
cd /opt/qt5-nmapper
+
./run-with-webgl.sh
+
</syntaxhighlight>
+
然后在电脑或者手机上打开网页游览器,敲入开发板的IP地址,应该就能看到Qt界面了,如下图所示:<br />
+
[[File:qtwebgl.gif|frameless|480px]]<br />
+
 
+
* <b>Qt VNC示例: 智能家居控制界面</b>
+
Qt VNC允许你将一个应用程序以VNC Server的形式运行,在其他设备上可以使用VNC Client来连接和使用你的Qt程序,支持QtWidgets和QML应用。<br />
+
先在开发版本执行以下命令,以webgl的方式运行应用Qt应用:<br />
+
<syntaxhighlight lang="bash">
+
cd /opt/qt5-smarthome
+
./run-with-vnc.sh
+
</syntaxhighlight>
+
然后在电脑或者手机打开VNC viewer软件,输入开发板的IP地址加端口号5900,例如开发板的地址是192.168.1.100,就输入192.168.1.100:5900,连接后应该就能看到智能家居控制界面了,如下图所示:<br />
+
[[File:qt5smarthomevnc.png|frameless|480px]]<br />
+

Latest revision as of 09:23, 4 June 2024

1 Unbricking Method

If the ROM is not installed correctly, causing the development board to become bricked, and you might not have the opportunity to reinstall the ROM via an SD card, you need to enter Maskrom mode to unbrick it by erasing the storage device.

1.1 Windows Users

1.1.1 Download Required Files

  • Get the necessary tools: Visit here, find RKDevTool_v3.19_for_window.zip and DriverAssitant_v5.12.zip in the 05_Tools directory, and download them to your local machine.
  • Install Rockchip USB driver and RKDevTool: Extract DriverAssitant_v5.12.zip to install the Rockchip USB driver, and extract RKDevTool_v3.19_for_window.zip to obtain the Rockchip flashing tool RKDevTool.
  • Get the loader: Visit here, enter the tools directory corresponding to your CPU model, and download MiniLoaderAll.bin.

1.1.2 Enter Maskrom Mode to Erase the Storage Device

  • Connect NanoPC-T4 to your computer using a USB data cable.
  • Start RKDevTool on your computer.
  • Disconnect the power from NanoPC-T4, hold down the MASK button, connect the power, and release the button when you see Found One MASKROM Device displayed at the bottom of the interface, as shown below:

Rkdevtool found one maskrom device.png

  • Click the Advanced Function tab in the RKDevTool interface.
  • In the Boot text box, select MiniLoaderAll.bin, then click the Download button.
  • Select EMMC, click Switch Storage, then click the EraseAll button to erase the eMMC.

Rkdevtool erase emmc.png

  • At this point, NanoPC-T4 is restored to its initial state and can be normally booted via SD card or eMMC.

1.2 Linux/Mac Users

1.2.1 Download the Required Files

  • Get the necessary tools: Visit here and find upgrade_tool_v2.30_for_linux.tgz (or for Mac users, select upgrade_tool_v2.25_for_mac.tgz) in the 05_Tools directory and download it locally.
  • Get the loader: Visit here, enter the tools directory corresponding to your CPU model, and download MiniLoaderAll.bin.

1.2.2 Installation for upgrade_tool

The following commands are for Linux, with only slight differences in file and directory names for Mac users:

tar xzf upgrade_tool_v2.30_for_linux.tgz
cd upgrade_tool_v2.30_for_linux
sudo cp upgrade_tool /usr/local/sbin/
sudo chmod 755 /usr/local/sbin/upgrade_tool

1.2.3 Enter Maskrom Mode to Erase the Storage Device

  • Connect NanoPC-T4 to the computer using a USB data cable.
  • Disconnect the power from NanoPC-T4, hold down the MASK button, connect the power, and release the button after 4 seconds.
  • Check the connection with the following command:
upgrade_tool LD

A result similar to "DevNo=1 Vid=0x2207,Pid=0x350b,LocationID=13 Mode=Maskrom SerialNo=" indicates that the device has been detected.

  • Erase the eMMC with the following command:
upgrade_tool EF MiniLoaderAll.bin
  • At this point, NanoPC-T4 has been restored to its initial state and can boot the system normally via SD card or eMMC.