Difference between revisions of "FriendlyCore (based on ubuntu-core with Qt)"

From FriendlyELEC WiKi
Jump to: navigation, search
(Ethernet Connection)
(updated by API)
 
(64 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Ubuntu Core with Qt-Embedded/zh|查看中文]]
+
[[FriendlyCore (based on ubuntu-core with Qt)/zh|查看中文]]
 
+
==Introduction==
+
Ubuntu Core with Qt-Embedded is a light Linux system without X-windows. It uses the Qt-Embedded's GUI and is popular in industrial and enterprise applications.
+
 
+
Besides the regular Ubuntu core's features our Ubuntu-Core has the following additional features:
+
* it supports our LCDs with both capacitive touch and resistive touch(S700, X710, S70)
+
* it supports WiFi
+
* it supports Ethernet
+
* it supports Bluetooth and has been installed with bluez utilities
+
* it supports audio playing
+
  
 
==Download Image Files==
 
==Download Image Files==
Visit the product page of one of the following products and download the firmware nanopi2-ubuntucore-with-qt-embedded-sd4g.img.zip: 
+
You can click this [http://download.friendlyelec.com url] to download an image file for a board on the board's download page.
* NanoPi2, NanoPi M2, NanoPi T2: [https://www.mediafire.com/folder/ilkcy37otd7il/NanoPi2Board Download]
+
  
* Uncompress the file and flash the image to an SD card with either dd under Linux or win32diskimager under Windows.
+
{{FriendlyCoreGeneral}}
 +
==Only Support S5P4418/S5P6818 Platform==
 +
{{FriendlyCoreS5Pxx18}}
 +
{{UbuntuXenial-Arm64-Install-Docker}}
 +
{{UbuntuXenial-Armhf-Install-Docker}}
 +
==Only Support RK3399/S5P4418/S5P6818 Platform==
 +
{{FriendlyCoreRunX11Application}}
 +
==Only Support H3 Platform==
 +
{{FriendlyCoreAllwinnerH3}}
 +
==Only Support H5 Platform==
 +
{{FriendlyCoreAllwinnerH5}}
 +
==Only Support S905 Platform==
 +
{{FriendlyCoreS905}}
 +
==Only Support H2 Platform==
 +
{{FriendlyCoreAllwinnerH2}}
  
==Applications under UbuntuCore==
+
==Work with LCD==
By default our UbuntuCore system brings up a Qt demo application whose GUI is as follows:<br/>
+
If you connect your board to an LCD with capacitive touch panel in general that LCD's calibration is not required. However if your LCD is one with resistive touch panel you will have to do calibration which is triggered by running "/usr/bin/setqt4env" on your first system booting.
[[File:Fluidlauncher-demo.png|frameless|300px|Qt-Embedded demo]]
+
  
 
+
If you want to re-calibrate your LCD with resistive touch panel you need to delete the calibration file by using the following command:
===WiFi===
+
Open the following file in the command line utility from a serial terminal:
+
<syntaxhighlight lang="bash">
+
vi /etc/wpa_supplicant/wpa_supplicant.conf
+
</syntaxhighlight>
+
 
+
Append the following lines. Replace "ESSID" and "PASSWORD" with your actual ID and password:
+
<syntaxhighlight lang="bash">
+
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
+
update_config=1
+
country=CN
+
network={
+
        ssid="ESSID"
+
        psk="PASSWORD"
+
        key_mgmt=WPA-PSK
+
}
+
</syntaxhighlight>
+
 
+
If your WiFi router doesn't have a password you can set "key_mgmt"  to "NONE" and delete the whole line with "psk=".
+
 
+
Save, exit and run the following commands to restart WiFi connections:
+
<syntaxhighlight lang="bash">
+
ifdown wlan0
+
ifup wlan0
+
</syntaxhighlight>
+
 
+
===Ethernet Connection===
+
If a board is connected to a network via Ethernet before it is powered on it will automatically obtain an IP with DHCP activated after it is powered up. You can change this behavior by changing the configurations in the following file:
+
<syntaxhighlight lang="bash">
+
vi /etc/network/interfaces
+
</syntaxhighlight>
+
 
+
===使用蓝牙===
+
 
+
如果你的开发板板载有蓝牙模块,可输入以下命令搜索周边的蓝牙设备:<br />
+
<syntaxhighlight lang="bash">
+
hcitool scan
+
</syntaxhighlight>
+
 
+
使用hciconfig命令来了解接口的状态。
+
 
+
 
+
===播放音频===
+
 
+
在串口终端执行以下aplay命令播放一段音频:
+
<syntaxhighlight lang="bash">
+
aplay -t raw -c 2 -f S16_LE -r 44100 /root/test.pcm
+
</syntaxhighlight>
+
 
+
===使用触摸屏===
+
 
+
电容屏一般无需设置即可使用,电阻屏则需要校准,校准的行为在 /usr/bin/setqt4env 这个脚本中触发的,这个脚本非常有用,它会设置Qt相关的环境变量,会在使用电阻屏时,根据条件判断是否需要运行校准程序。
+
 
+
如果你需要重新校准电阻触摸屏,可以删除以下文件来实现,命令如下:
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
rm /etc/pointercal
 
rm /etc/pointercal
 
</syntaxhighlight>
 
</syntaxhighlight>
  
删除之后重新启动系统即可。
+
After you reboot your system you will enter the calibration process.
 
+
==开发自已的Qt应用==
+
===PC上安装Qt-Embedded===
+
 
+
进入产品的下载页面,下载名为 target-ate-4.8.6-to-hostpc.tgz 的压缩包:
+
* NanoPi2, NanoPi M2, NanoPi T2: [http://wiki.friendlyarm.com/nanopi2/download/ 下载]
+
 
+
然后在电脑上,cd到根目录进行解压:
+
<syntaxhighlight lang="bash">
+
cd /
+
tar xvzf  ~/target-ate-4.8.6-to-hostpc.tgz
+
</syntaxhighlight>
+
 
+
解压完成后,执行 qmake 验证一下安装:
+
<syntaxhighlight lang="bash">
+
/usr/local/Trolltech/QtEmbedded-4.8.6-arm/bin/qmake -v
+
</syntaxhighlight>
+
 
+
应该会得到如下输出信息:<br />
+
QMake version 2.01a <br />
+
Using Qt version 4.8.6 in /usr/local/Trolltech/QtEmbedded-4.8.6-arm/lib <br />
+
 
+
===PC上安装交叉编译器(arm-linux-gcc 4.9.3)===
+
首先下载并解压编译器:
+
<syntaxhighlight lang="bash">
+
git clone https://github.com/friendlyarm/prebuilts.git
+
sudo mkdir -p /opt/FriendlyARM/toolchain
+
sudo tar xf prebuilts/gcc-x64/arm-cortexa9-linux-gnueabihf-4.9.3.tar.xz -C /opt/FriendlyARM/toolchain/
+
</syntaxhighlight>
+
 
+
然后将编译器的路径加入到PATH中,用vi编辑vi ~/.bashrc,在末尾加入以下内容:
+
<syntaxhighlight lang="bash">
+
export PATH=/opt/FriendlyARM/toolchain/4.9.3/bin:$PATH
+
export GCC_COLORS=auto
+
</syntaxhighlight>
+
 
+
执行一下~/.bashrc脚本让设置立即在当前shell窗口中生效,注意"."后面有个空格:
+
<syntaxhighlight lang="bash">
+
. ~/.bashrc
+
</syntaxhighlight>
+
 
+
这个编译器是64位的,不能在32位的Linux系统上运行,安装完成后,你可以快速的验证是否安装成功:
+
<syntaxhighlight lang="bash">
+
arm-linux-gcc -v
+
Using built-in specs.
+
COLLECT_GCC=arm-linux-gcc
+
COLLECT_LTO_WRAPPER=/opt/FriendlyARM/toolchain/4.9.3/libexec/gcc/arm-cortexa9-linux-gnueabihf/4.9.3/lto-wrapper
+
Target: arm-cortexa9-linux-gnueabihf
+
Configured with: /work/toolchain/build/src/gcc-4.9.3/configure --build=x86_64-build_pc-linux-gnu
+
--host=x86_64-build_pc-linux-gnu --target=arm-cortexa9-linux-gnueabihf --prefix=/opt/FriendlyARM/toolchain/4.9.3
+
--with-sysroot=/opt/FriendlyARM/toolchain/4.9.3/arm-cortexa9-linux-gnueabihf/sys-root --enable-languages=c,c++
+
--with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=vfpv3 --with-float=hard
+
...
+
Thread model: posix
+
gcc version 4.9.3 (ctng-1.21.0-229g-FA)
+
</syntaxhighlight>
+
 
+
 
+
===编写并运行Qt版本的Hello world===
+
 
+
在PC上建立个helloqt目录并新建一个main.cpp的源文件:
+
<syntaxhighlight lang="bash">
+
cd ~
+
mkdir helloqt
+
vi main.cpp
+
</syntaxhighlight>
+
 
+
main.cpp的代码如下:
+
<syntaxhighlight lang="c">
+
#include <QApplication>
+
#include <QPushButton>
+
int main(int argc, char **argv)
+
{
+
        QApplication app (argc, argv);
+
        QPushButton button ("Hello world !");
+
        button.show();
+
        return app.exec();
+
}
+
</syntaxhighlight>
+
 
+
退出vi后,执行以下命令编译:
+
<syntaxhighlight lang="bash">
+
cd ~/helloqt
+
/usr/local/Trolltech/QtEmbedded-4.8.6-arm/bin/qmake -project
+
/usr/local/Trolltech/QtEmbedded-4.8.6-arm/bin/qmake
+
make
+
</syntaxhighlight>
+
 
+
编译成功后,会得到了 helloqt 的二进制文件,将它上传到开发板后,在串口终端用以下命令运行:
+
<syntaxhighlight lang="bash">
+
. setqt4env
+
helloqt -qws&
+
</syntaxhighlight>
+
 
+
===开机自动运行Qt程序===
+
 
+
以运行上一章节中的 helloqt4 程序为例,假设它放在 /root 目录,则你可以编辑 /etc/rc.local 文件,先删除以下这两行:
+
<syntaxhighlight lang="bash">
+
cd /usr/local/Trolltech/QtEmbedded-4.8.6-arm/demos/embedded/fluidlauncher
+
./fluidlauncher -qws&
+
</syntaxhighlight>
+
  
注意需要保留 . /usr/bin/setqt4env 这一行内容,并在这一行的后面加上 /root/helloqt -qws & 即可。
+
==Q & A==
 +
* When I compile my Qt program I get a message complaining that linking to libraries such as libts and libz failed
 +
Your arm-linux-gcc 4.9.3 may not include these library files. You need to try downloading the compiler again.
  
===开源的Qt程序===
+
* Where should I get FriendlyCore's source code
开机后显示的界面由Qt Demo换成了一个由友善之臂开发的,开源的Qt程序 (源代码位于/opt目录),该程序启动时显示系统状态信息,例如CPU和内存信息,工作温度和负载等信息,系统同时集成了 qmake,uic 等Qt工具的arm版本,这样你就可以在开发板上直接生成和编译Qt源代码。
+
We used the bin file released by UbuntuCore's official site. You can get its source code from http://packages.ubuntu.com/.
  
==常见问题==
+
==Update Log==
 +
===July-20-2016===
 +
* Released English version
  
* 编译Qt程序时出现无法链接到 libts, libz等库
+
===July-20-2017===
原因是你的 arm-linux-gcc 4.9.3 编译器没有集成这些库,到产品的下载页面重新下载一次编译器,重新安装后即可解决。
+
* Added sections 6.1, 6.2 and 6.3
  
* UbuntuCore源码下载
+
===August-23-2017===
我们是直接官方使用二进制的文件,UbuntuCore源码可到此链接下下载:http://packages.ubuntu.com/。
+
* Updated section 4

Latest revision as of 07:17, 21 February 2022

查看中文

Contents

1 Download Image Files

You can click this url to download an image file for a board on the board's download page.

2 Work with FriendlyCore

2.1 Introduction

FriendlyCore is a light Linux system without X-windows, based on ubuntu core, It uses the Qt-Embedded's GUI and is popular in industrial and enterprise applications.

Besides the regular Ubuntu core's features our FriendlyCore has the following additional features:

  • it supports our LCDs with both capacitive touch and resistive touch(S700, X710, HD702, S430, HD101 and S70)
  • it supports WiFi
  • it supports Ethernet
  • it supports Bluetooth and has been installed with bluez utilities
  • it supports audio playing
  • it supports Qt 5.10.0 EGLES and OpenGL ES1.1/2.0 (Only for S5P4418/S5P6818)

2.2 System Login

  • If your board is connected to an HDMI monitor you need to use a USB mouse and keyboard.
  • If you want to do kernel development you need to use a serial communication board, ie a PSU-ONECOM board, which will

For example, NanoPi-M1:
PSU-ONECOM-M1.jpg
You can use a USB to Serial conversion board too.
Make sure you use a 5V/2A power to power your board from its MicroUSB port:
For example, NanoPi-NEO2:
USB2UART-NEO2.jpg

  • FriendlyCore User Accounts:

Non-root User:

   User Name: pi
   Password: pi

Root:

   User Name: root
   Password: fa

The system is automatically logged in as "pi". You can do "sudo npi-config" to disable auto login.

  • Update packages
$ sudo apt-get update

2.3 Configure System with npi-config

The npi-config is a commandline utility which can be used to initialize system configurations such as user password, system language, time zone, Hostname, SSH switch , Auto login and etc. Type the following command to run this utility.

$ sudo npi-config

Here is how npi-config's GUI looks like:
npi-config

2.4 Develop Qt Application

Please refer to: How to Build and Install Qt Application for FriendlyELEC Boards

2.5 Setup Program to AutoRun

You can setup a program to autorun on system boot with npi-config:

sudo npi-config

Go to Boot Options -> Autologin -> Qt/Embedded, select Enable and reboot.

2.6 Extend TF Card's Section

When FriendlyCore is loaded the TF card's section will be automatically extended.You can check the section's size by running the following command:

$ df -h

2.7 Transfer files using Bluetooth

Take the example of transferring files to the mobile phone. First, set your mobile phone Bluetooth to detectable status, then execute the following command to start Bluetooth search.:

hcitool scan


Search results look like:

Scanning ...
    2C:8A:72:1D:46:02   HTC6525LVW

This means that a mobile phone named HTC6525LVW is searched. We write down the MAC address in front of the phone name, and then use the sdptool command to view the Bluetooth service supported by the phone:

sdptool browser 2C:8A:72:1D:46:02

Note: Please replace the MAC address in the above command with the actual Bluetooth MAC address of the mobile phone.
This command will detail the protocols supported by Bluetooth for mobile phones. What we need to care about is a file transfer service called OBEX Object Push. Take the HTC6525LVW mobile phone as an example. The results are as follows:

Service Name: OBEX Object Push
Service RecHandle: 0x1000b
Service Class ID List:
  "OBEX Object Push" (0x1105)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 12
  "OBEX" (0x0008)
Profile Descriptor List:
  "OBEX Object Push" (0x1105)
    Version: 0x0100

As can be seen from the above information, the channel used by the OBEX Object Push service of this mobile phone is 12, we need to pass it to the obexftp command, and finally the command to initiate the file transfer request is as follows:

obexftp --nopath --noconn --uuid none --bluetooth -b 2C:8A:72:1D:46:02 -B 12 -put example.jpg

Note: Please replace the MAC address, channel and file name in the above command with the actual one.

After executing the above commands, please pay attention to the screen of the mobile phone. The mobile phone will pop up a prompt for pairing and receiving files. After confirming, the file transfer will start.

Bluetooth FAQ:
1) Bluetooth device not found on the development board, try to open Bluetooth with the following command:

rfkill unblock 0

2) Prompt can not find the relevant command, you can try to install related software with the following command:

apt-get install bluetooth bluez obexftp openobex-apps python-gobject ussp-push

2.8 WiFi

For either an SD WiFi or a USB WiFi you can connect it to your board in the same way. The APXX series WiFi chips are SD WiFi chips. By default FriendlyElec's system supports most popular USB WiFi modules. Here is a list of the USB WiFi modules we tested:

Index Model
1 RTL8188CUS/8188EU 802.11n WLAN Adapter
2 RT2070 Wireless Adapter
3 RT2870/RT3070 Wireless Adapter
4 RTL8192CU Wireless Adapter
5 mi WiFi mt7601
6 5G USB WiFi RTL8821CU
7 5G USB WiFi RTL8812AU

You can use the NetworkManager utility to manage network. You can run "nmcli" in the commandline utility to start it. Here are the commands to start a WiFi connection:

  • Change to root
$ su root
  • Check device list
$ nmcli dev

Note: if the status of a device is "unmanaged" it means that device cannot be accessed by NetworkManager. To make it accessed you need to clear the settings under "/etc/network/interfaces" and reboot your system.

  • Start WiFi
$ nmcli r wifi on
  • Scan Surrounding WiFi Sources
$ nmcli dev wifi
  • Connect to a WiFi Source
$ nmcli dev wifi connect "SSID" password "PASSWORD" ifname wlan0

The "SSID" and "PASSWORD" need to be replaced with your actual SSID and password.If you have multiple WiFi devices you need to specify the one you want to connect to a WiFi source with iface
If a connection succeeds it will be automatically setup on next system reboot.

For more details about NetworkManager refer to this link: Use NetworkManager to configure network settings

If your USB WiFi module doesn't work most likely your system doesn't have its driver. For a Debian system you can get a driver from Debian-WiFi and install it on your system. For a Ubuntu system you can install a driver by running the following commands:

$ apt-get install linux-firmware

In general all WiFi drivers are located at the "/lib/firmware" directory.


2.9 Ethernet Connection

If a board is connected to a network via Ethernet before it is powered on it will automatically obtain an IP with DHCP activated after it is powered up. If you want to set up a static IP refer to: Use NetworkManager to configure network settings


2.10 Custom welcome message

The welcome message is printed from the script in this directory:

/etc/update-motd.d/

For example, to change the FriendlyELEC LOGO, you can change the file /etc/update-motd.d/10-header. For example, to change the LOGO to HELLO, you can change the following line:

TERM=linux toilet -f standard -F metal $BOARD_VENDOR

To:

TERM=linux toilet -f standard -F metal HELLO

2.11 Modify timezone

For exampe, change to Shanghai timezone:

sudo rm /etc/localtime
sudo ln -ls /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

2.12 Set Audio Device

If your system has multiple audio devices such as HDMI-Audio, 3.5mm audio jack and I2S-Codec you can set system's default audio device by running the following commands.

  • After your board is booted run the following commands to install alsa packages:
$ apt-get update
$ apt-get install libasound2
$ apt-get install alsa-base
$ apt-get install alsa-utils
  • After installation is done you can list all the audio devices by running the following command. Here is a similar list you may see after you run the command:
$ aplay -l
card 0: HDMI
card 1: 3.5mm codec
card 2: I2S codec

"card 0" is HDMI-Audio, "card 1" is 3.5mm audio jack and "card 2" is I2S-Codec. You can set default audio device to HDMI-Audio by changing the "/etc/asound.conf" file as follows:

pcm.!default {
    type hw
    card 0
    device 0
}
 
ctl.!default {
    type hw
    card 0
}

If you change "card 0" to "card 1" the 3.5mm audio jack will be set to the default device.
Copy a .wav file to your board and test it by running the following command:

$ aplay /root/Music/test.wav

You will hear sounds from system's default audio device.
If you are using H3/H5/H2+ series board with mainline kernel, the easier way is using npi-config


3 Only Support S5P4418/S5P6818 Platform

3.1 Run Qt 5.10.0 Demo with GPU acceleration

Run the following command

$ sudo qt5demo

S5pxx18-QtE

3.2 Run Qt 5.10.0 Demo with OpenGL

Run the following command

. setqt5env
cd $QTDIR
cd /examples/opengl/qopenglwidget
./qopenglwidget

For more Qt 5.10.0 examples, please go to:
cd $QTDIR/examples/

3.3 Play HD Video with Hardware-decoding

gst-player is console player, it base on GStreamer, support VPU with Hardware-decoding:

sudo gst-player /home/pi/demo.mp4

The equivalent gsteamer command is as follows:

sudo gst-launch-1.0 filesrc location=/home/pi/demo.mp4 ! qtdemux name=demux demux. ! queue ! faad ! audioconvert ! audioresample ! alsasink device="hw:0,DEV=1" demux. ! queue ! h264parse ! nxvideodec ! nxvideosink dst-x=0 dst-y=93 dst-w=1280 dst-h=533

3.4 Connect to DVP Camera CAM500B

The CAM500B camera module is a 5M-pixel camera with DVP interface. For more tech details about it you can refer to Matrix - CAM500B.
Enter the following command to preview the video:

gst-launch-1.0 -e v4l2src device=/dev/video6 ! video/x-raw,format=I420,framerate=30/1,width=1280,height=720 ! nxvideosink

Enter the following command to start recording (VPU hardware encoding):

gst-launch-1.0 -e v4l2src device=/dev/video6 ! video/x-raw,format=I420,framerate=30/1,width=1280,height=720 ! tee name=t t. \
 ! queue ! nxvideosink t. ! queue ! nxvideoenc bitrate=12000000 ! mp4mux ! \
 filesink location=result_720.mp4

3.5 Power Off and Schedule Power On

“PMU Power Management” feature helps us to auto power on the board at a specific time, it is implemented by an MCU, support software power-off, and RTC alarm power-up functions.

Here’s a simple guide:
Turn on automatically after 100 seconds. (Time must be greater than 60 seconds.):

$ sudo echo 100 > /sys/class/i2c-dev/i2c-3/device/3-002d/wakealarm

After setting up the automatic boot, turn off board with the 'poweroff’ command:

$ sudo poweroff

Cancel automatic boot:

$ sudo echo 0 > /sys/class/i2c-dev/i2c-3/device/3-002d/wakealarm

Query the current settings, in the front is current time, followed by the time of automatic booting: If no automatic boot is set, it will display "disabled”.

$ sudo cat /sys/class/i2c-dev/i2c-3/device/3-002d/wakealarm


Note that some older versions of hardware may not support this feature, if you don't see this file node in your system:
/sys/class/i2c-dev/i2c-3/device/3-002d/wakealarm
your board may be it does not support this feature.

3.6 Installing and Using OpenCV 4.1.2

OpenCV has been pre-installed in FriendlyCore (Version after 20191126) and does not require manual installation.
Please refre this link: https://github.com/friendlyarm/install-opencv-on-friendlycore/blob/s5pxx18/README.md
Quick test:

. /usr/bin/cv-env.sh
. /usr/bin/setqt5env-eglfs
cd /usr/local/share/opencv4/samples/python
python3 turing.py

3.7 Installing and Using Caffe

git clone https://github.com/friendlyarm/install-caffe-on-friendlycore
cd install-caffe-on-friendlycore
sudo ./install-caffe.sh

3.8 How to install and use docker (for aarch64 system)

3.8.1 How to Install Docker

Run the following commands:

wget https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/arm64/containerd.io_1.2.6-3_arm64.deb
wget https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/arm64/docker-ce-cli_19.03.2~3-0~ubuntu-xenial_arm64.deb
wget https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/arm64/docker-ce_19.03.2~3-0~ubuntu-xenial_arm64.deb
sudo dpkg -i containerd.io_1.2.6-3_arm64.deb
sudo dpkg -i docker-ce-cli_19.03.2~3-0~ubuntu-xenial_arm64.deb
sudo dpkg -i docker-ce_19.03.2~3-0~ubuntu-xenial_arm64.deb

3.8.2 Test Docker installation

Test that your installation works by running the simple docker image:

git clone https://github.com/friendlyarm/debian-jessie-arm-docker
cd debian-jessie-arm-docker
./rebuild-image.sh
./run.sh

3.9 How to install and use docker (for armhf system)

3.9.1 How to Install Docker

Run the following commands:

sudo apt-get update
sudo apt-get install docker.io

3.9.2 Test Docker installation

Test that your installation works by running the simple docker image:

git clone https://github.com/friendlyarm/debian-jessie-arm-docker
cd debian-jessie-arm-docker
./rebuild-image.sh
./run.sh

4 Only Support RK3399/S5P4418/S5P6818 Platform

4.1 Run the X11 application

FriendlyCore system built-in lightweight Xorg,although there is no window manager, you can still run a single X-Windows application,For example, the program to run is ~/YourX11App,use the following command:

. /usr/bin/setqt5env-xcb
startx ~/YourX11App -geometry 1280x800

Note that there is a space between "." and /usr/bin/setqt5env-xcb. In addition, the resolution after -geometry should be changed to the actual resolution of your screen.

5 Only Support H3 Platform

5.1 Connect to USB Camera(FA-CAM202)

The FA-CAM202 is a 200M USB camera. Connect your board to camera module. Then boot OS, connect your board to a network, log into the board as root and run "mjpg-streamer":

$ cd /root/C/mjpg-streamer
$ make
$ ./start.sh

You need to change the start.sh script and make sure it uses a correct /dev/videoX node. You can check your camera's node by running the following commands:

$ apt-get install v4l-utils
$ v4l2-ctl -d /dev/video0 -D
Driver Info (not using libv4l2):
        Driver name   : uvcvideo
        Card type     : HC 3358+2100: HC 3358+2100  / USB 2.0 Camera: USB 2.0 Camera
        Bus info      : usb-1c1b000.usb-1
	...

The above messages indicate that "/dev/video0" is camera's device node.The mjpg-streamer application is an open source video steam server. After it is successfully started the following messages will be popped up:

 
$ ./start.sh
 i: Using V4L2 device.: /dev/video0
 i: Desired Resolution: 1280 x 720
 i: Frames Per Second.: 30
 i: Format............: YUV
 i: JPEG Quality......: 90
 o: www-folder-path...: ./www/
 o: HTTP TCP port.....: 8080
 o: username:password.: disabled
 o: commands..........: enabled

start.sh runs the following two commands:

export LD_LIBRARY_PATH="$(pwd)"
./mjpg_streamer -i "./input_uvc.so -d /dev/video0 -y 1 -r 1280x720 -f 30 -q 90 -n -fb 0" -o "./output_http.so -w ./www"

Here are some details for mjpg_streamer's major options:
-i: input device. For example "input_uvc.so" means it takes input from a camera;
-o: output device. For example "output_http.so" means the it transmits data via http;
-d: input device's subparameter. It defines a camera's device node;
-y: input device's subparameter. It defines a camera's data format: 1:yuyv, 2:yvyu, 3:uyvy 4:vyuy. If this option isn't defined MJPEG will be set as the data format;
-r: input device's subparameter. It defines a camera's resolution;
-f: input device's subparameter. It defines a camera's fps. But whether this fps is supported depends on its driver;
-q: input device's subparameter. It defines the quality of an image generated by libjpeg soft-encoding;
-n: input device's subparameter. It disables the dynctrls function;
-fb: input device's subparameter. It specifies whether an input image is displayed at "/dev/fbX";
-w: output device's subparameter. It defines a directory to hold web pages;

In our case the board's IP address was 192.168.1.230. We typed 192.168.1.230:8080 in a browser and were able to view the images taken from the camera's. Here is what you would expect to observe:
mjpg-streamer-cam500a

5.2 Check CPU's Working Temperature

You can get CPU's working temperature by running the following command:

$ cpu_freq 
Aavailable frequency(KHz):
        480000 624000 816000 1008000
Current frequency(KHz):
        CPU0 online=1 temp=26548C governor=ondemand freq=624000KHz
        CPU1 online=1 temp=26548C governor=ondemand freq=624000KHz
        CPU2 online=1 temp=26548C governor=ondemand freq=624000KHz
        CPU3 online=1 temp=26548C governor=ondemand freq=624000KHz

This message means there are currently four CPUs working. All of their working temperature is 26.5 degree in Celsius and each one's clock is 624MHz.
Set CPU frequency:

$ cpu_freq -s 1008000
Aavailable frequency(KHz):
        480000 624000 816000 1008000
Current frequency(KHz):
        CPU0 online=1 temp=36702C governor=userspace freq=1008000KHz
        CPU1 online=1 temp=36702C governor=userspace freq=1008000KHz
        CPU2 online=1 temp=36702C governor=userspace freq=1008000KHz
        CPU3 online=1 temp=36702C governor=userspace freq=1008000KHz


5.3 Test Infrared Receiver

Note: Please Check your board if IR receiver exist.
By default the infrared function is disabled you can enable it by using the npi-config utility:

$ npi-config
    6 Advanced Options     Configure advanced settings
        A8 IR              Enable/Disable IR
            ir Enable/Disable ir[enabled]

Reboot your system and test its infrared function by running the following commands:

$ apt-get install ir-keytable
$ echo "+rc-5 +nec +rc-6 +jvc +sony +rc-5-sz +sanyo +sharp +mce_kbd +xmp" > /sys/class/rc/rc0/protocols   # Enable infrared
$ ir-keytable -t
Testing events. Please, press CTRL-C to abort.

"ir-keytable -t" is used to check whether the receiver receives infrared signals. You can use a remote control to send infrared signals to the receiver. If it works you will see similar messages as follows:

1522404275.767215: event type EV_MSC(0x04): scancode = 0xe0e43
1522404275.767215: event type EV_SYN(0x00).
1522404278.911267: event type EV_MSC(0x04): scancode = 0xe0e42
1522404278.911267: event type EV_SYN(0x00).

5.4 Run Qt Demo

Run the following command

$ sudo /opt/QtE-Demo/run.sh

Here is what you expect to observe. This is an open source Qt Demo:
K2-QtE

5.5 How to install and use docker (for armhf system)

5.5.1 How to Install Docker

Run the following commands:

sudo apt-get update
sudo apt-get install docker.io

5.5.2 Test Docker installation

Test that your installation works by running the simple docker image:

git clone https://github.com/friendlyarm/debian-jessie-arm-docker
cd debian-jessie-arm-docker
./rebuild-image.sh
./run.sh

6 Only Support H5 Platform

6.1 Connect to USB Camera(FA-CAM202)

The FA-CAM202 is a 200M USB camera. You can refer to <Connect DVP Camera (CAM500B) to Board> on how to connect a USB camera to a board.
You need to change the start.sh script and make sure it uses a correct /dev/videoX node. You can check your FA-CAM202's node by running the following commands:

$ apt-get install v4l-utils
$ v4l2-ctl -d /dev/video1 -D
Driver Info (not using libv4l2):
        Driver name   : uvcvideo
        Card type     : HC 3358+2100: HC 3358+2100
        Bus info      : usb-1c1b000.usb-1
	...

Information above indicates that /dev/video1 is the device node of the FA-CAM 202.

6.2 Check CPU's Working Temperature

You can get CPU's working temperature by running the following command:

$ cpu_freq
CPU0 online=1 temp=26581 governor=ondemand cur_freq=480000
CPU1 online=1 temp=26581 governor=ondemand cur_freq=480000
CPU2 online=1 temp=26581 governor=ondemand cur_freq=480000
CPU3 online=1 temp=26581 governor=ondemand cur_freq=480000

This message means there are currently four CPUs working. All of their working temperature is 26.5 degree in Celsius and each one's clock is 480MHz.

6.3 Test Watchdog

You can test watchdog by running the following commands:

$ cd /root/demo/watchdog/
$ gcc watchdog_demo.c -o watchdog_demo
$ ./watchdog_demo /dev/watchdog0 10
Set timeout: 10 seconds
Get timeout: 10 seconds
System will reboot in 10 second

System will reboot in 10 seconds.

6.4 Test Infrared Receiver

Note: Please Check your board if IR receiver exist.
By default the infrared function is disabled you can enable it by using the npi-config utility:

$ npi-config
    6 Advanced Options     Configure advanced settings
        A8 IR              Enable/Disable IR
            ir Enable/Disable ir[enabled]

Reboot your system and test its infrared function by running the following commands:

$ apt-get install ir-keytable
$ echo "+rc-5 +nec +rc-6 +jvc +sony +rc-5-sz +sanyo +sharp +mce_kbd +xmp" > /sys/class/rc/rc0/protocols   # Enable infrared
$ ir-keytable -t
Testing events. Please, press CTRL-C to abort.

"ir-keytable -t" is used to check whether the receiver receives infrared signals. You can use a remote control to send infrared signals to the receiver. If it works you will see similar messages as follows:

1522404275.767215: event type EV_MSC(0x04): scancode = 0xe0e43
1522404275.767215: event type EV_SYN(0x00).
1522404278.911267: event type EV_MSC(0x04): scancode = 0xe0e42
1522404278.911267: event type EV_SYN(0x00).

6.5 Read CHIP ID

As for Allwinner H2+/H3/H5/ SoCs each of these CPUs has an internal 16-btye CHIP ID which can be read by running the following commands in the Linux-4.14 kernel:

$ apt-get install bsdmainutils
$ hexdump /sys/bus/nvmem/devices/sunxi-sid0/nvmem 
0000000 8082 0447 0064 04c3 3650 ce0a 1e28 2202
0000010 0002 0000 0000 0000 0000 0000 0000 0000
0000020 0000 0000 0000 0000 0000 0000 0000 0000
0000030 0000 0008 0508 0000 0000 0000 0000 0000
0000040 0000 0000 0000 0000 0000 0000 0000 0000

"8082 0447 0064 04c3 3650 ce0a 1e28 2202" is the 16-byte CHIP ID.

6.6 Access GPIO Pins/Wirings with WiringNP

The wiringPi library was initially developed by Gordon Henderson in C. It contains libraries to access GPIO, I2C, SPI, UART, PWM and etc. The wiringPi library contains various libraries, header files and a commandline utility:gpio. The gpio utility can be used to read and write GPIO pins.
FriendlyElec integrated this utility in FriendlyCore system allowing users to easily access GPIO pins. For more details refer to WiringNP WiringNP

6.7 Run Qt Demo

Run the following command

$ sudo /opt/QtE-Demo/run.sh

Here is what you expect to observe. This is an open source Qt Demo:
K2-QtE

6.8 How to install and use docker (for arm64 system)

6.8.1 How to Install Docker

Run the following commands:

sudo apt-get update
sudo apt-get install docker.io

6.8.2 Test Docker installation

Test that your installation works by running the simple docker image:

git clone https://github.com/friendlyarm/debian-jessie-arm-docker
cd debian-jessie-arm-docker
./rebuild-image.sh
./run.sh

7 Only Support S905 Platform

7.1 Run Qt Demo

Run the following command

$ sudo /opt/QtE-Demo/run.sh

Here is what you expect to observe. This is an open source Qt Demo:
K2-QtE

8 Only Support H2 Platform

8.1 Read CHIP ID

As for Allwinner H2+/H3/H5/ SoCs each of these CPUs has an internal 16-btye CHIP ID which can be read by running the following commands in the Linux-4.14 kernel:

$ apt-get install bsdmainutils
$ hexdump /sys/bus/nvmem/devices/sunxi-sid0/nvmem 
0000000 8082 0447 0064 04c3 3650 ce0a 1e28 2202
0000010 0002 0000 0000 0000 0000 0000 0000 0000
0000020 0000 0000 0000 0000 0000 0000 0000 0000
0000030 0000 0008 0508 0000 0000 0000 0000 0000
0000040 0000 0000 0000 0000 0000 0000 0000 0000

"8082 0447 0064 04c3 3650 ce0a 1e28 2202" is the 16-byte CHIP ID.

8.2 Boot System from SSD

A NanoPi-Duo can be booted from the SSD on a Mini Shield for NanoPi Duo. Booting OS from an SSD has the following benefits:
1) faster read/write;
2) much longer life time than a TF card;
3) more reliable than booting from a TF card;

You can install an OS to SSD by using the npi-config utility. Here are the steps to follow:

sudo npi-config

Enter the "Boot Options" menu, go to "Boot device" and you will see two options:
1) D1 Hard drive
2) D2 TF card
Select "D1 Hard drive" and proceed with its prompts.
Select "D2 TF card" to boot OS from a TF card.

If your npi-config doesn't have a "Boot device" menu it might be that your npi-config is out of date and you can update it by selecting "Update" in the menu.

8.3 How to install and use docker (for armhf system)

8.3.1 How to Install Docker

Run the following commands:

sudo apt-get update
sudo apt-get install docker.io

8.3.2 Test Docker installation

Test that your installation works by running the simple docker image:

git clone https://github.com/friendlyarm/debian-jessie-arm-docker
cd debian-jessie-arm-docker
./rebuild-image.sh
./run.sh

9 Work with LCD

If you connect your board to an LCD with capacitive touch panel in general that LCD's calibration is not required. However if your LCD is one with resistive touch panel you will have to do calibration which is triggered by running "/usr/bin/setqt4env" on your first system booting.

If you want to re-calibrate your LCD with resistive touch panel you need to delete the calibration file by using the following command:

rm /etc/pointercal

After you reboot your system you will enter the calibration process.

10 Q & A

  • When I compile my Qt program I get a message complaining that linking to libraries such as libts and libz failed

Your arm-linux-gcc 4.9.3 may not include these library files. You need to try downloading the compiler again.

  • Where should I get FriendlyCore's source code

We used the bin file released by UbuntuCore's official site. You can get its source code from http://packages.ubuntu.com/.

11 Update Log

11.1 July-20-2016

  • Released English version

11.2 July-20-2017

  • Added sections 6.1, 6.2 and 6.3

11.3 August-23-2017

  • Updated section 4