FriendlyCore (based on ubuntu-core with Qt)
Contents
1 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
2 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:
- NanoPi2, NanoPi M2, NanoPi T2: Download
- Uncompress the file and flash the image to an SD card with either dd under Linux or win32diskimager under Windows.
3 Ubuntu-Core's 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.
4 Update packages
sudo apt-get update
5 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:
6 Applications under UbuntuCore
By default our UbuntuCore system brings up a Qt demo application whose GUI is as follows:
6.1 WiFi
Open the following file in the command line utility from a serial terminal:
vi /etc/wpa_supplicant/wpa_supplicant.conf
Append the following lines. Replace "ESSID" and "PASSWORD" with your actual ID and password:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 country=CN network={ ssid="ESSID" psk="PASSWORD" key_mgmt=WPA-PSK }
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:
ifdown wlan0 ifup wlan0
6.2 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:
vi /etc/network/interfaces
6.3 Bluetooth
If your board has built-in bluetooth module you can run the following command to search for a nearby bluetooth device:
hcitool scan
You can check the status by using command "hciconfig"
6.4 Playing Audio
You can play an audio file by running the following command:
aplay -t raw -c 2 -f S16_LE -r 44100 /root/test.pcm
6.5 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.
7 Develop Qt Application
7.1 Install Qt-Embedded on Host PC
Visit the product page of one of the following products and download the target-ate-4.8.6-to-hostpc.tgz file:
- NanoPi2, NanoPi M2, NanoPi T2: Download
Enter the root directory and uncompress the file:
cd / tar xvzf ~/target-ate-4.8.6-to-hostpc.tgz
After it is done verify it by using the following command:
/usr/local/Trolltech/QtEmbedded-4.8.6-arm/bin/qmake -v
If you install it successfully you will get the following information:
QMake version 2.01a
Using Qt version 4.8.6 in /usr/local/Trolltech/QtEmbedded-4.8.6-arm/lib
7.2 Install Cross Compiler on Host PC (arm-linux-gcc 4.9.3)
Download and uncompress the compiler:
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/
Add the compiler's directory to "PATH" and append the following lines in "~/.bashrc":
export PATH=/opt/FriendlyARM/toolchain/4.9.3/bin:$PATH export GCC_COLORS=auto
Run "~/.bashrc" to make your setting effective. Attention: there is a space after ".":
. ~/.bashrc
This compiler is a 64-bit one therefore it cannot be run on a 32-bit Linux machine. After the compiler is installed you can verify it by running the following commands:
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)
7.3 Your "Hello world"
Create a "helloqt" directory and a main.cpp file on your host PC:
cd ~ mkdir helloqt vi main.cpp
Here is a main.cpp sample:
#include <QApplication> #include <QPushButton> int main(int argc, char **argv) { QApplication app (argc, argv); QPushButton button ("Hello world !"); button.show(); return app.exec(); }
Exit vi and run the following commands to compile the program:
cd ~/helloqt /usr/local/Trolltech/QtEmbedded-4.8.6-arm/bin/qmake -project /usr/local/Trolltech/QtEmbedded-4.8.6-arm/bin/qmake make
If compilation is successful you will get a helloqt bin file. Copy the bin file to your board and run it from a terminal:
. setqt4env
helloqt -qws&
7.4 Set Your Qt Program to Autorun
You can set your Qt program to autorun. Let's take the helloqt4 as an example. We assume it is under "/root". You need to open the "/etc/rc.local" file and delete the following two lines:
cd /usr/local/Trolltech/QtEmbedded-4.8.6-arm/demos/embedded/fluidlauncher ./fluidlauncher -qws&
You need to keep ". /usr/bin/setqt4env" and append "/root/helloqt -qws &".
7.5 Open Source Qt Program
The GUI you will see after you boot our UbuntuCore is developed by FriendlyARM. We replaced its original Qt Demo with this GUI. This GUI is open source and its source code is under "/opt". After this program starts it will list various system information including CPU's temperature, RAM and etc. It also includes some basic Qt utilities: qmake, uic and etc which make it much easier for users to compile and generate Qt executables.
8 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 UbuntuCore'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/.
9 Update Log
9.1 July-20-2016
- Released English version