1 Introduction

Overview

Front

Back

The NanoPi 2 Fire is a high performance ARM Board developed by FriendlyARM for Hobbyists, Makers and Hackers for IOT projects. It features Samsung's Cortex-A9 Quad Core S5P4418@1.4GHz SoC and 1G 32bit DDR3 RAM. It has a Gbps Ethernet port. It boots Android and Debian from a TF card. It integrates an HDMI and LCD interface. Its adoption of the Raspberry Pi's GPIO pin header makes it compatible with both Raspberry Pi's external GPIO modules and Arduino's shield boards. Its PCB dimension is 75 x 40 mm.

occupied by FriendlyARM one wire technology to recognize LCD models and control backlight and implement resistive touch, not applicable for users

32

XnRSTOUT Form CPU

low when system is reset

33

VDEN

signal the external LCD that data is valid on the data bus

34

VSYNC

vertical synchronization

35

HSYNC

horizontal synchronization

36

LCDCLK

LCD clock, Pixel frequency

41

I2C2_SCL

I2C2 clock signal, for capacitive touch's data transmission

42

I2C2_SDA

I2C2 data signal, for capacitive touch's data transmission

43

GPIOC16

interrupt pin for capacitive touch, used with I2C2

44

NC

not connected

Note

SYS_3.3V: 3.3V power output

VDD_5V: 5V power input/output. When the external device’s power is greater than the MicroUSB’s the external device is charging the board otherwise the board powers the external device. The input range is 4.7V ~ 5.6V

(Note: you need to replace "/dev/sdx" with the device name in your system)

4.3 LCD/HDMI Resolution

When the system boots our uboot will check whether it is connected to an LCD or to an HDMI monitor. If it recognizes an LCD it will configure its resolution. Our uboot defaults to the HDMI 720P configuration.
If you want to modify the LCD resolution you can modify file "arch/arm/plat-s5p4418/nanopi2/lcds.c" in the kernel and recompile it.
If your NanoPi2-Fire is connected to an HDMI monitor and it runs Android it will automatically set the resolution to an appropriate HDMI mode by checking the "EDID". If your NanoPi2-Fire is connected to an HDMI monitor and it runs Debian by default it will set the resolution to the HDMI 720P configuration. If you want to modify the HDMI resolution to 1080P modify your kernel's configuration as explained above.

4.4 Update SD Card's boot parameters From PC Host

Insert your SD card into a host PC running Linux, if you want to change your kernel command line parameters you can do it via the fw_setevn utility.
Check the current Command Line:

5.2 FriendlyCore's User Accounts

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：
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-M1：

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

$ sudoapt-get update

5.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.

5.5 Setup Program to AutoRun

5.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

5.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：

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：

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：

5.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

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.

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.

5.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。

5.10 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:

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。

5.11 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.12 Run Qt 5.10.0 Demo with GPU acceleration

Run the following command

$ sudo qt5demo

5.13 Run Qt 5.10.0 Demo with OpenGL

Run the following command

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

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

5.14 Play HD Video with Hardware-decoding

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

5.16 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.):

$ sudoecho100>/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:

$ sudoecho0>/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”.

$ sudocat/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.

6 Work with Android

6.1 Work with 4G Module EC20 under Android5

6.1.1 Hardware Setup

Connect an EC20 module to a USB to miniPCIe board and connect the board to an ARM board's USB Host. Here is a hardware setup:
Power on the board and you will be able to surf the internet with the 4G module like using an Android phone.

7.2 Compile Linux kernel 4.4.y

7.2.1 Compile Kernel

The NanoPi2-Fire's kernel source code is in the "nanopi2-v4.4.y" branch.You need to switch to this branch.

Compile Ubuntu Kernel

touch .scmversion
makeARCH=arm nanopi2_linux_defconfig
makeARCH=arm

After your compilation succeeds an "arch/arm/boot/zImage" will be generated and a DTB file(s5p4418-nanopi2-rev*.dtb) will be generated in the "arch/arm/boot/dts/" directory. You can use them to replace the existing zImage and DTB files in the boot partition of your bootable SD card.

7.2.2 Use Your Generated Kernel

Update kernel in SD card

If you use an SD card to boot Ubuntu you can copy your generated zImage and DTB files to your SD card's boot partition(e.g. partition 1 /dev/sdX1).

Update kernel in eMMC

If you boot your board from eMMC you can update your kernel file by following the steps below:
1) Usually after OS is loaded eMMC's boot partition (in our example eMMC's device name was /dev/mmcblk0p1) will be automatically mounted and you can verify that by running "mount"
2) Connect your board to a host PC running Ubuntu and copy the zImage and DTB files to eMMC's boot partition
3) Or you can copy your generated kernel file to an external storage card(e.g. an SD card or a USB drive), connect the storage card to your board the move the file from the card to eMMC's boot partition
4) After update is done type "reboot" to reboot your board. Note: don't just directly disconnect your board from its power source or press the reset button to reboot the board. These actions will damage your kernel file

Generate Your boot.img

If you want to generate an image file that can be flashed to eMMC you need to generate a boot.img file and then copy it to your installation SD card
For Ubuntu follow the steps below to generate a boot.img file:
1) Download debian_nanopi2

git clone https://github.com/friendlyarm/debian_nanopi2.git

2) Copy the zImage and DTB files to replace the corresponding files under the "debian_nanopi2/boot/" directory
3) Generate boot.img

cd debian_nanopi2
mkdir rootfs
./build.sh

A newly generated boot.img will be under the "debian_nanopi2/sd-fuse_nanopi2/debian" directory.
The "mkdir rootfs" command creates a working directory for the build.sh script to run. It also creates some files such as "rootfs.img" but these files are useless.

7.2.3 Compile U-Boot

Download the U-Boot source code and compile it. Note that the github's branch is nanopi2-v2016.01:

After your compilation succeeds a bootloader.img will be generated. If you want to test it flash it to your installation SD card to replace an existing U-Boot v2016.01 file via fastboot, sd-fuse_nanopi2 or eflasher ROM.
Note: you cannot use mixed U-Boot files. For example you cannot use fastboot to update an existing U-Boot V2014.07 and you cannot use bootloader.img to replace an existing u-boot.bin

7.3 Compile Linux kernel 3.4.y

7.3.1 Prepare mkimage

You need the mkimage utility to compile a U-Boot source code package. Make sure this utility works well on your host before you start compiling a uImage.
You can install this utility by either commanding "sudo apt-get install u-boot-tools" or following the commands below:

7.3.2 Compile Linux Kernel

The NanoPi2-Fire's kernel source code lies in the "nanopi2-lollipop-mr1" branch.

Compile Android Kernel

make nanopi2_android_defconfig
touch .scmversion
make uImage

Compile Debian Kernel

make nanopi2_linux_defconfig
touch .scmversion
make uImage

After your compilation succeeds a uImage will be generated in the "arch/arm/boot/" directory. This kernel is for LCD output. You can use it to replace the existing uImage.
If you want to generate a kernel for HDMI output you need to run nanopi2_linux_hdmi_defconfig and do it this way:

make nanopi2_linux_hdmi_defconfig
touch .scmversion
make uImage

After your compilation succeeds a uImage.hdmi will be generated for HDMI 720P. If you want a uImage.hdmi for 1080P you can do it this way:

After your compilation succeeds a uImage.hdmi will be generated for HDMI 1080P. You can use it to replace the existing uImage.hdmi.

7.3.3 Use Your Generated Kernel

Update the kernel file in SD card

If you use an SD card to boot Android you can copy your generated uImage file to your SD card's boot partition(e.g. partition 1 /dev/sdX1).
If you use an SD card to Debian and you generated a uImage for an HDMI monitor you can use that uImage to replace the uImage.hdmi file in the SD card's boot partition. If you use an SD card to Debian and you generated a uImage for an LCD you can use that uImage to replace the uImage file in the SD card's boot partition.

Update Android kernel file in eMMC

If you want to update the kernel file in eMMC you need firstly boot your board, then mount eMMC's boot partition, replace the boot partition's kernel file with your generated one and reboot your board.
If you boot your board from eMMC you can update your kernel file by following the steps below:
1) After Android is loaded mount eMMC's boot partition (in our example eMMC's device name was /dev/mmcblk0p1) by using the following commands:

sumount-t ext4 /dev/block/mmcblk0p1 /mnt/media_rw/sdcard1/

2) Connect your board to a host PC running Ubuntu with a MicroUSB cable and copy the uImage file to eMMC's boot partition by running the following commands

adb push uImage /mnt/media_rw/sdcard1/

3) Or you can copy your generated kernel file to an external storage card(e.g. an SD card or a USB drive), connect the storage card to your board the move the file from the card to eMMC's boot partition
4) After update is done type "reboot" and enter to reboot your board. Note: don't just directly disconnect your board from its power source or press the reset button to reboot the board. These actions will damage your kernel file

Update Debian kernel file in eMMC

If you boot your board from eMMC you can update your kernel file by following the steps below:
1) When Debian is being loaded eMMC's boot partition will be automatically mounted(in our example eMMC's device name was /dev/mmcblk0p1). You can use "mount" to verify that
2) Connect your board to a host PC via Ethernet and copy your generated uImage file via scp/ftp to eMMC's boot partition and replace the existing file. If your file is for LCD output use your uImage file to replace the existing uImage. If your file is for HDMI output use your uImage.hdmi file to replace the existing uImage.hdmi file
3) Or you can copy your generated kernel file to an external storage card(e.g. an SD card or a USB drive), connect the storage card to your board the move the file from the card to eMMC's boot partition
4) After update is done type in "reboot" to reboot your board. Note: don't just directly disconnect your board from its power source or press the reset button to reboot the board. These actions will damage your kernel file

Generate Your boot.img

If you want to generate an image file that can be flashed to eMMC you need to generate a boot.img file and copy it to your installation SD card
For Android copy the uImage file to Android source code's "device/friendly-arm/nanopi2/boot/" directory and compile this whole Android source code. After your compilation is successful you will get a boot.img file.
For Debian follow the steps below to generate a boot.img file
1) Download debian_nanopi2

git clone https://github.com/friendlyarm/debian_nanopi2.git

2) Copy the image file for an HDMI monitor and use it to replace the "debian_nanopi2/boot/uImage.hdmi" file and copy the image file for an LCD and use it to replace the "debian_nanopi2/boot/uImage" file
3) Generate Debian's boot.img

cd debian_nanopi2
mkdir rootfs
./build.sh

A newly generated boot.img will be under the "debian_nanopi2/sd-fuse_nanopi2/debian" directory.
The "mkdir rootfs" command creates a working directory for the build.sh script to run. It also creates some files such as "rootfs.img" but these files are useless.

7.3.4 Compile Kernel Modules

Android contains kernel modules which are in the "/lib/modules" directory in the system partition. If you want to add your own modules to the kernel or you changed your kernel configurations you need to recompile these new modules.
Compile Original Kernel Modules:

cd linux-3.4.y
makeCROSS_COMPILE=arm-linux- modules

Here we have two new modules and we can compile them by running the commands below:

The "/opt/FriendlyARM/s5p4418/android" directory points to the top directory of Android source code. You can get more details by specifying option "-h".
After your compilation succeeds new modules will be generated

7.3.5 Compile U-Boot

Download the U-Boot v2014.07 source code and compile it. Note that the github's branch is nanopi2-lollipop-mr1:

After compilation is done a u-boot.bin will be generated and you can update your NanoPi2-Fire's u-boot with fastboot by running the following commands:
1) On your host PC run "sudo apt-get install android-tools-fastboot" to installl the fastboot utility;
2) Connect your NanoPi2-Fire to your host PC, boot your NanoPi2-Fire and press "Enter" within two seconds right after your board is powered on and you will enter the u-boot commandline:
3) In the commandline window type "fastboot" and then press "Enter" to enter the fastboot mode:
4) Connect your NanoPi2-Fire to a host PC with a MicroUSB cable and run the following commands in the commandline window to flash u-boot.bin to your NanoPi2-Fire:

fastboot flash bootloader u-boot.bin

Note:you cannot use "dd" to update your SD card in this situation.

7.4 Compile Android

We provide two Android versions: Android 4.4 and Android 5.1. Both of them are compiled the same way.

7.4.2 Download Android5.1 source code

There are two ways to download the source code:

repo archive file on netdisk

Netdisk URL: Click here
File location on netdisk：sources/s5pxx18-android5.git-YYYYMMDD.tgz (YYYYMMDD表示打包的日期)
After extracting the repo package from the network disk, you need to execute the sync.sh script, which will pull the latest code from gitlab:

7.4.3 Compile Android

After your compilation succeeds the following files will be generated in the "out/target/product/nanopi2/" directory.

filename

partition

Description

boot.img

boot

-

cache.img

cache

-

userdata.img

userdata

-

system.img

system

-

partmap.txt

-

partition description file

7.4.4 Flash Image to SD Card

If you boot your board from an SD card you can copy your new image file to the sd-fuse_nanopi2/android/ directory and flash this image to your SD card with an installation script. For more details refer to https://github.com/friendlyarm/sd-fuse_nanopi2。

7.4.5 Flash Image to eMMC

After compiling Android successfully you can flash it to eMMC with either of the following methods
1) fastboot: right after the NanoPi2-Fire is booted from eMMC press any key to enter the uboot commandline mode and type in "fastboot"
Connect your board to a host PC running Ubuntu with a USB cable and run the following commands in the PC's terminal:

2) Use an SD Card
Copy these files: boot.img, cache.img, userdata.img, system.img, partmap.txt from the out/target/product/nanopi2 directory to your installation SD card's images/android directory and you can use this SD card to flash Android to eMMC

7.4.6 Download Android4 source code

If you want to try Android4.4's source code you can run the following commands:

8 Connect NanoPi2-Fire to External Modules

8.1 Connect NanoPi2-Fire to USB Camera(FA-CAM202)

In this use case the NanoPi2-Fire runs Debian. If you connect your NanoPi2-Fire to our LCD or an HDMI monitor after Debain is fully loaded click on "other"-->"xawtv" on the left bottom of the GUI and the USB Camera application will be started. After enter "welcome to xawtv！" click on "OK" to start exploring.

8.2 Connect NanoPi2-Fire to CMOS 5M-Pixel Camera

If your NanoPi2-Fire runs Android5.1 and it is connected to our LCD or an HDMI monitor after Android is fully loaded click on the "Camera" icon and the application will be started. You can take pictures or record videos

Under Debian a camera utility "nanocams" is available for previewing 40 frames and picture taking. You can try it by following the commands below

sudo nanocams -p1-n40-c4-o IMG001.jpg

For more details about the usage of the nanocams run "nanocams -h".
You can get its source code from our git hub:

git clone https://github.com/friendlyarm/nexell_linux_platform.git

Under FriendlyCore (kernel 4.4), You can try it by following the commands below:

8.3 Use OpenCV to Access USB Camera

The full name of "OpenCV" is Open Source Computer Vision Library and it is a cross platform vision library.

When the NanoPi2-Fire runs Debian users can use OpenCV APIs to access a USB Camera device.

1. Here is a guideline on how to use OpenCV with C++ on the NanoPi2-Fire:

Firstly you need to make sure your NanoPi2-Fire is connected to the internet.Login to your NanoPi2-Fire via a serial terminal or SSH. After login type in your username(root) and password(fa):

Run the following commands:

apt-get updateapt-get install libcv-dev libopencv-dev

2. Make sure your USB camera works with the NanoPi2-Fire. You can test your camera with NanoPi2-Fire's camera utility.

3. Check your camera device:

ls/dev/video*

Note:in our test case video0 was the device name.

4. OpenCV's code sample(official code in C++) is under /home/fa/Documents/opencv-demo. Compile the code sample with the following commands:

cd/home/fa/Documents/opencv-demo
make

After it is compiled successfully a "demo" executable will be generated

5. Connect NanoPi2-Fire to USB Keyboard & Run the Following Command:

./demo

opencv is successfully started

8.4 Connect NanoPi2-Fire to Matrix GPS Module

The Matrix-GPS module is a small GPS module with high performance. It can be used in navigation devices, four-axle drones and etc.

The Matrix-GPS module uses serial communication. When the NanoPi2-Fire is connected to the Matrix GPS module, after the NanoPi2-Fire is powered up type in the following command in a terminal or click on the xgps icon it will be started.

$su - fa -c"DISPLAY=:0 xgps 127.0.0.1:9999"

Or on the Debian GUI start the LXTerminal, type in "xgps" and enter it will be started too.

For more details about this GPS module refer to Click to check
Refer to the following diagram to connect the NanoPi2-Fire to the Matrix-GPS:

Connection Details:

Matrix-GPS

NanoPi2-Fire

RXD

Pin11

TXD

Pin12

5V

Pin29

GND

Pin30

9 Access Hardware under Android

FriendlyElec developed a library called “libfriendlyarm-things.so”, for android developer to access the hardware resources on the development board in their android apps, the library is based on Android NDK.
Accessible Modules:

10 Connect NanoPi2-Fire to FriendlyARM LCD Modules

Android

Here are the LCDs that are supported under Android:S430, S700/S701, S702, HD700, HD702, HD101 and X710 all of which are LCDs with capacitive touch.

FriendlyCore & Lubuntu Desktop

Here are the LCDs that are supported under FriendlyCore and Lubuntu Desktop:S430, S700/S701, S702, HD700, HD702, HD101 and X710 all of which are LCDs with capacitive touch;
W35B, H43, P43, S70D and Matrix 2.8" SPI Key TFT LCD all of which are LCDs with resistive touch
All these LCD's tech details can be obtained on our wiki site:LCDModules

12 Source Code and Image Files Download Links

13 Tech Support

If you have any further questions please visit our forum http://www.friendlyarm.com/Forum/ and post a message or email us at techsupport@friendlyarm.com. We will endeavor to get back to you as soon as possible.

14 Update Log

14.1 2019-01-24

14.2 2018-12-17

Android5 updated as follows:

1) Add support for 4G network, support module: Quectel EC20
2) Add audio setting UI, you can set the default output to headphones or HDMI
3) Synchronously turn off the backlight of the one-line touch screen when the system Shutdown