Difference between revisions of "NanoPi"

From FriendlyELEC WiKi
Jump to: navigation, search
(制作microSD卡)
(Install Debian Packages)
 
(129 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
[[NanoPi/zh|查看中文]]
 
[[NanoPi/zh|查看中文]]
==介绍==
+
==Introduction==
[[File:NanoPi-01B.jpg|thumb|NanoPi]]
+
[[File:NanoPi-01B.jpg|thumb|Overview]]
NanoPi是友善之臂专门为嵌入式Linux爱好者、创客、玩家设计的一款低功耗ARM主控板,它的尺寸只有Raspberry Pi(RPi)的一半大小,并且兼容RPi的GPIO接口,NanoPi集成无线WiFi和蓝牙4.0模块,并带有并行摄像头接口,和全彩LCD接口,可从TF卡运行Linux/Debian系统,非常适合物联网、无线智能小车、机器人、图像识别、人机界面等应用开发。
+
[[File:NanoPi-A01.png|thumb|Front]]
 +
[[File:NanoPi-B01.png|thumb|Back]]
 +
The NanoPi is a low power consumption, Samsung S3C2451 based ARM SOC that FriendlyARM developed for Linux hackers, makers and hobbyists. Its size is only half of the Raspberry Pi(RPi) and its GPIO pin is compatible with the RPi’s. The NanoPi integrates both the WiFi and Bluetooth 4.0. It has a DVP camera interface and full color LCD interface. It boots Linux/Debian quickly from a TF card. These features make it a good platform for applications in IOT, unmanned vehicles, robotics, image processing and human machine interaction.
  
==资源特性==
+
==Hardware Features==
* CPU: Samsung S3C2451, 运行主频400Mhz
+
* CPU: Samsung S3C2451, 400Mhz
 
* RAM: 64M DDR2
 
* RAM: 64M DDR2
* 集成SDIO WiFi蓝牙模块
+
* Integrated SDIO WiFi and Bluetooth
 
* USB Type A x1
 
* USB Type A x1
* 调试串口 x1
+
* Debugging Serial Port x1
 
* microSD Slot x1
 
* microSD Slot x1
* microUSB x1: 支持供电和数据传输,可模拟为串口和以太网
+
* microUSB x1: for power and data transmission. It can be configured as a serial port or Ethernet
* LCD接口: 0.5mm间距贴片FPC座,支持全彩LCD (RGB:8-8-8)
+
* LCD Interface: 0.5 mm pitch SMT FPC seat, for full-color LCD (RGB: 8-8-8)
* DVP Camera接口:0.5mm间距竖直贴片FPC座,包含ITU-R BT 601/656 8-bit,I2C和IO
+
* DVP Camera interface:0.5mm spacing FPC socket. It includes ITU-R BT 601/656 8-bit, I2C and IO
* GPIO1: 2.54mm间距,40pin, 兼容RPi的GPIO,含UART, SPI, I2C, IO等管脚资源
+
* GPIO1: 2.54mm spacing 40pin, compatible with Raspberry Pi's GPIO. It includes UART, SPI, I2C, IO etc
* GPIO2: 2.54mm间距, 12pin, 含I2S, I2C, UART等管脚资源
+
* GPIO2: 2.54mm spacing 12pin. It includes I2S, I2C, UART etc.
* PCB 尺寸: 75 x 30 mm
+
* PCB dimension: 75 x 30 mm
* 供电: DC 5V
+
* Power: DC 5V
* 软件支持: u-boot, Linux-4.1+Qt-4.8.5, Debian
+
* Bootloader and OS: u-boot, Linux-4.1, Debian8 jessie, Rabbit linux
  
==接口布局和尺寸==
+
==Diagram, Layout and Dimension==
===接口布局===
+
===Layout===
[[File:NanoPi-1506-IF.png |thumb|400px|NanoPi接口布局]]
+
[[File:NanoPi-1506-IF.png |thumb|300px|NanoPi Layout]]
* GPIO1 管脚定义
+
* GPIO1 Pin Spec
 
::[[File:NanoPiGPIOHeader.png | frameless|400px|NanoPi GPIO Header ]]
 
::[[File:NanoPiGPIOHeader.png | frameless|400px|NanoPi GPIO Header ]]
  
* GPIO2 管脚定义
+
* GPIO2 Pin Spec
 
::{| class="wikitable"
 
::{| class="wikitable"
 
|-
 
|-
Line 56: Line 58:
 
|4    || RXD0  
 
|4    || RXD0  
 
|}
 
|}
* DVP Camera IF 管脚定义
+
* DVP Camera IF Pin Spec
 
::{| class="wikitable"
 
::{| class="wikitable"
 
|-
 
|-
Line 85: Line 87:
 
|16-23 || Data bit7-0
 
|16-23 || Data bit7-0
 
|}
 
|}
* RGB LCD IF 管脚定义
+
* RGB LCD IF Pin Spec
 
::{| class="wikitable"
 
::{| class="wikitable"
 
|-
 
|-
Line 116: Line 118:
 
|37,38,39,40 || XM,XP,YM,YP
 
|37,38,39,40 || XM,XP,YM,YP
 
|}
 
|}
:说明
+
:Note:
::#VDD_SYS_3.3V: 3.3V电源输出
+
::#VDD_SYS_3.3V: 3.3V power output
::#VDD_5V: 5V电源输入/输出。当电压大于MicroUSB时,向板子供电,否则板子从MicroUSB取电。输入范围:4.7~5.6V。
+
::#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
::#更详细的信息请查看原理图:[[:File:NanoPi-1507-Schematic.pdf|NanoPi-1507-Schematic.pdf]]
+
::#3. For more details please refer to the document:[http://wiki.friendlyarm.com/wiki/images/f/f0/NanoPi-1507-Schematic.pdf NanoPi-1507-Schematic.pdf]
  
===机械尺寸===
+
===Board Dimension===
[[File:NanoPi-1507-dimensions.png|frameless|600px|NanoPi 机械尺寸]]
+
[[File:NanoPi-1507-dimensions.png|frameless|500px|NanoPi 机械尺寸]]
  
::需要更详细的尺寸请下载:[[:File:NanoPi-1507-Dimesions(dxf).zip | NanoPi-1507-Dimesions(dxf).zip ]]
+
:: For more details please refer to the document:[http://wiki.friendlyarm.com/wiki/images/3/37/NanoPi-1507-Dimesions%28dxf%29.zip NanoPi-1507-Dimesions(dxf).zip ]
  
==快速入门==
+
==Get Started==
===准备工作===
+
===Essentials You Need===
要开启你的NanoPi新玩具,请先准备好以下硬件
+
Before play with your NanoPi please get the following items ready
* NanoPi主板
+
* NanoPi
* microSD卡/TF卡: 最小系统需要64 MB
+
* Class 8, microSD card/TF card: >= 4GB
* microUSB线
+
* microUSB cable
* 一台运行Linux的电脑
+
* a Host running Ubuntu and connected to the internet
  
===制作microSD卡===
+
===Make an Installation MicroSD Card===
准备好后,可使用已经编译好的文件快速的制作能启动NanoPi的microSD卡,具体请点击查看 #REDIRECT [[制作可启动的microSD卡]]
+
* 1) Insert your microSD card to your host running Ubuntu and check your SD card's device name
 +
<syntaxhighlight lang="bash">
 +
dmesg | tail
 +
</syntaxhighlight>
 +
Search the messages output by "dmesg" for similar words like "sdc: sdc1 sdc2". If you can find them it means your SD card is recognized as "/dev/sdc". Or you can check that by commanding "cat /proc/partitions".
  
===运行系统===
+
*2) Flash Firmware to MicroSD Card
::把制作好的microSD卡插入NanoPi,使用microUSB线连上电源,稍等片刻,看到板上的蓝色LED开始闪烁,这说明系统已经开始正常运行了
+
<syntaxhighlight lang="bash">
 +
git clone https://github.com/friendlyarm/sd-fuse_nanopi.git
 +
cd sd-fuse_nanopi
 +
su
 +
./fusing.sh /dev/sdx
 +
</syntaxhighlight>
 +
(Note: you need to replace "/dev/sdx" with the device name in your system)
 +
<br/><br/>
 +
If you cannot get these files from github you can get them from our source: [http://wiki.friendlyarm.com/NanoPi/download/sd-fuse_nanopi.tgz].<br/>
 +
If you have problems with using the "fusing.sh" script you can download our "NanoPi-fuser-win32.zip" and use it to make your SD card in Windows. Here is the download:[http://wiki.friendlyarm.com/NanoPi/download/NanoPi-fuser-win32.zip].<br/>
  
===通过microUSB登陆NanoPi===
+
===Run System===
===配置使用Wi-Fi===
+
Insert this MicroSD card to your NanoPi, connect it to a PC via a MicroUSB cable the NanoPi will be automatically powered on. If you can see the blue LED flashing it means your board is running now. By default we install Debian. It would be better if you connect your NanoPi to an LCD since this helps you set up your NanoPi more easily and conveniently.
使用新制作的SD卡启动NanoPi 后,系统不会自动连接您的Wi-Fi网络,必须先通过microUSB或串口登陆NanoPi,然后手动进行配置Wi-Fi。<br />
+
以下操作,如无特别说明,均是指在NanoPi 上进行的操作。
+
  
====启动wpa_supplicant====
+
[[File:DebianJessie.png|frameless|400px|Debian8 Jessie]]
NanoPi的Rootfs集成了wpa_supplicant 2.4,同时支持nl80211和wext,运行以下命令即可启动它。
+
 
 +
===Log on NanoPi via MicroUSB===
 +
After connecting your NanoPi to you PC host (running Ubuntu) please type "dmesg" in your PC's command line. If you can find the following messages it means your NanoPi is correctly connected to your host and runs well:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
wpa_supplicant -Dnl80211 -iwlan0 -C/var/run/wpa_supplicant -c/etc/wpa.conf -B
+
[12601.100339] usb 2-1.7: Product: FriendlyARM Gadget v2.4
 +
[12601.100343] usb 2-1.7: Manufacturer: Linux 4.1.2-FriendlyARM with s3c-hsudc
 +
[12601.103192] cdc_acm 2-1.7:2.0: This device cannot do calls on its own. It is not a modem.
 +
[12601.103368] cdc_acm 2-1.7:2.0: ttyACM0: USB ACM device
 +
[12601.105300] cdc_ether 2-1.7:2.2 usb0: register 'cdc_ether' at usb-0000:00:1d.0-1.7, CDC Ethernet Device, 46:a1:e7:6d:5c:32
 
</syntaxhighlight>
 
</syntaxhighlight>
  
====运行wpa_cli====
+
If you command "ifconfig" and find a "usb0" device you can SSH to 192.168.100.1 to log on your NanoPi:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
wpa_cli -iwlan0
+
ssh root@192.168.100.1
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
After it prompts you to input your password you can try "fa"
 +
 +
===Setup Wi-Fi===
  
====使用wpa_cli扫描无线AP====
+
After SSH to your NanoPi please check the WiFi interface first. The "wlan" device is WiFi.
启动wpa_cli后,自动进入其Interactive mode,输入以下命令即可扫描AP并获得扫描结果。
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
scan
+
ifconfig -a
scan_results
+
 
</syntaxhighlight>
 
</syntaxhighlight>
  
====使用wpa_cli配置并连接WLAN====
+
By default the WiFi device is "wlan0". You need to create a configuration file under "/etc/network/interfaces.d/" for WiFi:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
add_network
+
vi /etc/network/interfaces.d/wlan0
set_network 0 ssid "WLAN-Network"
+
set_network 0 psk "YourSecretPassphrase"
+
enable_network 0
+
 
</syntaxhighlight>
 
</syntaxhighlight>
其中"WLAN-Network"和"YourSecretPassphrase"请使用您的WLAN配置信息,"YourSecretPassphrase"可以是明文的,也可以在启动wpa_cli前先使用wpa_passphrase来生成加密后的psk。
+
Here is a sample wlan0 file:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
wpa_passphrase "WLAN-Network" "YourSecretPassphrase"
+
auto lo
 +
iface lo inet loopback
 +
auto wlan0
 +
iface wlan0 inet dhcp
 +
wpa-driver wext
 +
wpa-ssid YourWiFiESSID
 +
wpa-ap-scan 1
 +
wpa-proto RSN
 +
wpa-pairwise CCMP
 +
wpa-group CCMP
 +
wpa-key-mgmt WPA-PSK
 +
wpa-psk YourWiFiPassword
 
</syntaxhighlight>
 
</syntaxhighlight>
如果配置正确,系统将成功连接到指定的无线AP。
+
Please replace "YourWiFiESSID" and "YourWiFiPassword" with your WiFiESSID and password. After save and close the file you can connect to your WiFi source by running the following command:
 +
<syntaxhighlight lang="bash">
 +
/etc/init.d/networking restart
 +
</syntaxhighlight>
 +
After you power on your board it will automatically connect to your WiFi source.<br />
 +
Please note that if you use one TF card to boot multiple boards the WiFi device name will likely be named to "wlan1", "wlan2" and etc. You can reset it to "wlan0" by deleting the contents of the following file and reboot your board:
 +
/etc/udev/rules.d/70-persistent-net.rules
 +
 
 +
[[File:nanopi-ssh-via-wifi.png|frameless|400px|SSH connected to NanoPi over WiFi]]
 +
 
 +
===Setup Wi-Fi AP===
  
====使用wpa_cli保存配置及退出====
+
By default a NanoPi is set to a WiFi AP. The default AP name is "nanopi-wifiap" and the password is "123456789".<br />
 +
<br />
 +
The WiFi's working mode can be checked by running the following command:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
save_config
+
cat /sys/module/bcmdhd/parameters/op_mode
quit
+
 
</syntaxhighlight>
 
</syntaxhighlight>
您所进行的Wi-Fi配置将保存到/etc/wpa.conf,可查看此文件来确定是否正确保存。
+
If the result is "2" it means it is currently working as a WiFi AP.<br />
 +
<br />
 +
If the board is not working as a WiFi AP you can set it by running the following commands:<br />
 +
<syntaxhighlight lang="bash">
 +
turn-wifi-into-apmode yes
 +
</syntaxhighlight>
 +
<br />
 +
The WiFi AP's name and password can be configured by editing the file "/etc/hostapd/hostapd.conf".
  
====配置Wi-Fi的IP地址====
+
<!-- comments
成功连接到无线AP后,便可以dhcp来获得IP地址,命令如下:
+
The steps above are for Debian. For Rabbit you can run the following commands:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
udhcpc -i wlan0
+
wpa_passphrase YourWiFiESSID 'YourWiFiPassword' >> /etc/wpa.conf
 +
wpa_cli -iwlan0 reconfigure
 
</syntaxhighlight>
 
</syntaxhighlight>
另外,您也可以使用ifconfig 来手动配置IP地址,具体的IP地址与您的网络配置有关。
 
  
====自动连接Wi-Fi====
+
 
在正确配置好Wi-Fi后,如果你保存了配置,则可以使用命令vi 来修改启动脚本 /etc/init.d/rcS ,在末尾增加以下内容:
+
====Scan Wireless AP====
 +
You can scan your surrounding wireless APs by running the following commands:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
wpa_supplicant -Dnl80211 -iwlan0 -C/var/run/wpa_supplicant -c/etc/wpa.conf -B
+
wpa_cli -iwlan0 scan
sleep 3
+
wpa_cli -iwlan0 scan_result
udhcpc -i wlan0
+
 
</syntaxhighlight>
 
</syntaxhighlight>
保存后可使用命令 reboot 来重启NanoPi ,然后登陆NanoPi来进一步检查是否成功连接。
 
  
===配置使用蓝牙===
+
-->
  
==如何编译及制作自己的microSD卡==
+
<!-- comments
 +
===Setup Bluetooth===
 +
-->
  
===编译U-Boot===
+
===Bluetooth===
====下载源代码====
+
In our Debian Jessie we include bluetooth packages: bluetooth, bluez, obexftp and etc<br />
 +
We will show how to transfer files between a NanoPi and a cellphone<br /><br />
 +
In this example we used an MX4 cellphone, enabled its bluetooth and made it searchable by other devices. Firstly we typed the following commands in the NanoPi to search its nearby bluetooth devices:<br />
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
git clone https://github.com/friendlyarm/uboot_nanopi.git
+
hcitool scan
 
</syntaxhighlight>
 
</syntaxhighlight>
下载完成后,u-boot的缺省分支是nanopi,在开始编译前,请检查当前分支是否为nanopi,如果不是则需要先checkout。
+
<br />
 +
Scanning ...<br />
 +
8C:BE:BE:C5:2C:C7            MX4<br />
 +
<br />
 +
The listed search result above indicated that our MX4 phone was found and its MAC was 8C:BE:BE:C5:2C:C7. We ran "sdptool" to list all the protocols it supported:<br />
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
cd uboot_nanopi
+
sdptool browse 8C:BE:BE:C5:2C:C7
git checkout nanopi
+
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
What we would like to test was its file transfer function therefore we must find out whether "OBEX File Transfer" was supported:<br />
 +
::Service Name: OBEX File Transfer<br />
 +
::Service RecHandle: 0x1000c<br />
 +
::Service Class ID List:<br />
 +
::  "OBEX File Transfer" (0x1106)<br />
 +
::Protocol Descriptor List:<br />
 +
::  "L2CAP" (0x0100)<br />
 +
::  "RFCOMM" (0x0003)<br />
 +
::    Channel: 11<br />
 +
::  "OBEX" (0x0008)<br />
 +
::Language Base Attr List:<br />
 +
::  code_ISO639: 0x454e<br />
 +
::  encoding: 0x6a<br />
 +
::  base_offset: 0x100<br />
 +
::Profile Descriptor List:<br />
 +
::  "OBEX File Transfer" (0x1106)<br />
 +
::    Version: 0x0100<br />
 +
Here we found out that "OBEX File Transfer" was supported and we could use "obexftp" to start our file transfers. The following commands listed all the files under the root directory of the phone:<br />
 +
<syntaxhighlight lang="bash">
 +
obexftp -b 8C:BE:BE:C5:2C:C7 -c / -l   
 +
</syntaxhighlight>
 +
The following commands downloaded "/Adnroid/djaof.dll" from the phone to the NanoPi:<br />
 +
<syntaxhighlight lang="bash">
 +
obexftp -b 8C:BE:BE:C5:2C:C7 -c /Android -g djaof.dll
 +
</syntaxhighlight>
 +
The following commands uploaded "hello.txt" from the NanoPi to the "/Android" directory of the phone<br />
 +
<syntaxhighlight lang="bash">
 +
obexftp -b 8C:BE:BE:C5:2C:C7 -c /Android -p hello.txt
 +
</syntaxhighlight>
 +
<br />
  
====配置并编译u-boot====
+
===Setup iBeacon Transmitter===
 +
The iBeacon technology enables smartphones, tablets and other devices to perform actions when in close proximity to an iBeacon transmitter. Please run the following commands to setup a NanoPi to an iBeacon transmitter:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 +
hciconfig hci0 up
 +
hciconfig hci0 leadv 3
 +
hciconfig hci0 noscan
 +
hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 63 6F 3F 8F 64 91 4B EE 95 F7 D8 CC 64 A8 63 B5 00 00 00 00 C8
 +
</syntaxhighlight>
 +
If this is setup correctly on a NanoPi it will broadcast its presence to nearby portable electronic devices. If a nearby Android device or iPhone has the "locate Beacon" application installed it will be able to measure the distance between itself to the NanoPi. If you want enable the indoor positioning function you will need to setup multiple iBeacon transmitters.
 +
 +
===Communicate with Cellphone via Bluetooth BLE===
 +
The function requires a BLE service be started on the NanoPi. <br />
 +
The BLE service's code is open source. Please follow the steps below to get it:<br />
 +
<syntaxhighlight lang="bash">
 +
git clone https://github.com/friendlyarm/ble-peripheral-service-demo.git
 +
</syntaxhighlight>
 +
Please run the following build.sh script which will generate a "nanopi_ble_server" executable if it is successful:
 +
<syntaxhighlight lang="bash">
 +
./build.sh
 +
</syntaxhighlight>
 +
We assume your cross compiler is installed at "/opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-gcc". If it is not installed under this directory you need to make changes in the script accordingly.<br />
 +
After a "nanopi_ble_server" is generated please copy it to the NanoPi and execute the following commands:
 +
<syntaxhighlight lang="bash">
 +
hciconfig hci0 down
 +
service bluetooth stop
 +
chmod 755 nanopi_ble_server
 +
./nanopi_ble_server
 +
</syntaxhighlight>
 +
Now please install a BLE Scanner application on an Android phone or a Lightblue application on an iPhone which will be used to test the function.<br />
 +
We have an open source Android Demo on GitHub too,It is under "android/BLETest". This demo shows how a cellphone communicates(transmits data to/receives data from) with the NanoPi via BLE.<br />
 +
[[File:NanoBLEAndroidDemo.jpg|frameless|250px|NanoBLEAndroidDemo]]<br /><br />
 +
NanoPi's output messages are as follows:<br />
 +
[[File:NanoPiBLEServer.png|frameless|500px|NanoPiBLEServer]]
 +
<br />
 +
<br />
 +
 +
===Install Debian Packages===
 +
We provide a Debian Jessie image. You can install Jessie's packages by commanding "apt-get". If this is your first installation you need to update the package list by running the following command:
 +
<syntaxhighlight lang="bash">
 +
apt-get update
 +
</syntaxhighlight>
 +
Or you can try a complete command set
 +
<syntaxhighlight lang="bash">
 +
apt-get update
 +
apt-get dist-upgrade
 +
apt-get autoremove
 +
</syntaxhighlight>
 +
You can install your preferred packages. For example if you want to install an FTP server you can do this:
 +
<syntaxhighlight lang="bash">
 +
apt-get install vsftpd
 +
</syntaxhighlight>
 +
Note: you can change your download server by editting "/etc/apt/sources.list". You can get a complete server list from [http://www.debian.org/mirror/list]. You need to select the one with "armel".
 +
 +
==Make OS Image==
 +
 +
===Install Cross Compiler===
 +
Download and untar cross compiler file:
 +
<syntaxhighlight lang="bash">
 +
git clone https://github.com/friendlyarm/prebuilts.git
 +
tar xvzf prebuilts/gcc/arm-linux-gcc-4.4.3.tar.gz -C /
 +
</syntaxhighlight>
 +
 +
It will ease your future development work if you add compiler's path to "PATH". You can do it by first opening "~/.bashrc" and then appending the following lines:
 +
<syntaxhighlight lang="bash">
 +
export PATH=/opt/FriendlyARM/toolschain/4.4.3/bin/:$PATH
 +
</syntaxhighlight>
 +
 +
Run "~/.bashrc" to make your changes in effect right away:
 +
<syntaxhighlight lang="bash">
 +
. ~/.bashrc
 +
</syntaxhighlight>
 +
 +
We assume you would use a 32-bit compiler. However if your host runs a 64-bit Linux you need to install some extra packages. For example if your host runs a Debian 8 Jessie desktop 64 bit system you will need to install the following packages:
 +
<syntaxhighlight lang="bash">
 +
dpkg --add-architecture i386
 +
apt-get update
 +
apt-get install build-essential gcc-multilib rpm libstdc++6:i386 libgcc1:i386 zlib1g:i386 libncurses5:i386
 +
</syntaxhighlight>
 +
 +
===Compile U-Boot===
 +
 +
Download U-Boot source code and compile it. Please note it is in the branch "nanopi":
 +
<syntaxhighlight lang="bash">
 +
git clone https://github.com/friendlyarm/uboot_nanopi.git
 
cd uboot_nanopi
 
cd uboot_nanopi
 +
git checkout nanopi
 
make nanopi_config
 
make nanopi_config
 
make
 
make
 
</syntaxhighlight>
 
</syntaxhighlight>
  
====烧写u-boot 到SD卡====
+
After your compilation succeeds a u-boot.bin will be generated. If you want to test it please flash it to your MicroSD card by running the "fusing.sh" script.<br />
编译成功结束后您将获得u-boot.bin, 如果想马上就测试u-boot,可使用脚本fusing.sh 烧写新的u-boot 到SD 卡。<br />
+
If your SD card's device name is "/dev/sdd" please run the following command as "root":
假设您的 SD 卡对应设备名是/dev/sdd,以root运行以下命令:
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 +
su
 
./fusing.sh /dev/sdd
 
./fusing.sh /dev/sdd
 
</syntaxhighlight>
 
</syntaxhighlight>
注意:以上操作会破坏SD卡的数据,请先进行备份。
+
Note: this operation will remove all the data in the SD card.
  
===编译Linux kernel===
+
===Compile Linux kernel===
====下载内核源代码====
+
====Compile Kernel====
 +
Please download kernel source code and compile it
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
git clone https://github.com/friendlyarm/linux-4.x.y.git
 
git clone https://github.com/friendlyarm/linux-4.x.y.git
</syntaxhighlight>
 
适应于NanoPi的分支是nanopi-v4.1.y,在开始编译前,请检查当前分支是否正确,如果不是则需要先checkout。
 
<syntaxhighlight lang="bash">
 
 
cd linux-4.x.y
 
cd linux-4.x.y
 
git checkout nanopi-v4.1.y
 
git checkout nanopi-v4.1.y
</syntaxhighlight>
 
 
====配置并编译内核====
 
<syntaxhighlight lang="bash">
 
cd linux-4.x.y
 
 
make nanopi_defconfig
 
make nanopi_defconfig
 
touch .scmversion
 
touch .scmversion
 
make
 
make
 
</syntaxhighlight>
 
</syntaxhighlight>
如果您的PC是多核的CPU,可以make的参数"-j, --jobs" 来加快编译,例如:
+
The kernel that the NanoPi uses is "nanopi-v4.1.y". Please make sure you get the correct branch. After your compilation succeeds a new file "arch/arm/boot/zImage" will be generated
<syntaxhighlight lang="bash">
+
make -j8
+
</syntaxhighlight>
+
编译成功结束后,新生成内核烧写文件为 arch/arm/boot/zImage
+
  
====编译内核模块====
+
====Compile Kernel Modules====
目前的内核配置会编译生成内核模块,如ipv6、netfilter,通常在编译内核时,内核模块(.ko)已经编译,如果您有新的内核模块或者内核配置有变化,则需要编译安装内核模块并打包成 kernel-modules.tgz,然后替换Rootfs下的 basefs/kernel-modules.tgz。<br />
+
In general kernel compilation generates kernel modules such as ipv6, netfilter and etc. If you want to add your own  modules to the kernel or you changed your kernel configurations you need to recompile these new modules and pack them as a new "kernel-modules.tgz" to replace the corresponding file "basefs/kernel-modules.tgz" in "Rootfs"<br />
以root用户运行以下命令安装.ko到/tmp/nanopi-modules
+
please run the following commands as root to install ".ko" to /tmp/nanopi-modules:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
make INSTALL_MOD_PATH=/tmp/nanopi-modules modules_install
 
make INSTALL_MOD_PATH=/tmp/nanopi-modules modules_install
 
</syntaxhighlight>
 
</syntaxhighlight>
接下来可对内核模块进行strip,然后创建压缩包。
+
Please strip your kernel modules and create a new package
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
cd /tmp/nanopi-modules/lib/
 
cd /tmp/nanopi-modules/lib/
Line 265: Line 419:
 
tar czvf kernel-modules.tgz modules/
 
tar czvf kernel-modules.tgz modules/
 
</syntaxhighlight>
 
</syntaxhighlight>
如果想测试新编译的内核模块,也可以解压压缩包或复制modules 到已制作好的能启动NanoPi的SD卡的rootfs下的/lib 目录。
+
If you want to test your newly generated kernel modules you can copy them to your MicroSD card's "rootfs/lib":
假设SD卡的rootfs已经mount到 /media/fa/NANOPI,以root 运行以下命令:
+
We assume your MicroSD card was already mounted to "/media/fa/NANOPI" please run the following commands as root:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
rm -rf /media/fa/NANOPI/lib/modules/
 
rm -rf /media/fa/NANOPI/lib/modules/
Line 272: Line 426:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
===编译制作Rootfs===
+
===Make File System===
====下载源文件====
+
====File System for Debian====
 +
By default we install a Debian system to the NanoPi, which can be obtained from the following repository:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
git clone https://github.com/friendlyarm/rootfs_nanopi.git
+
git clone https://github.com/friendlyarm/sd-fuse_nanopi.git
 +
cd sd-fuse_nanopi/prebuilt/
 +
ls -l rootfs.tgz
 
</syntaxhighlight>
 
</syntaxhighlight>
适应于NanoPi的分支是nanopi,在开始编译前,请检查当前分支是否正确,如果不是则需要先checkout。
+
If you want to customize it you can uncompress "rootfs.tgz", edit its components and tar it. Here is an example showing how you can do it:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
cd rootfs_nanopi
+
tar xzf rootfs.tgz
git checkout nanopi
+
dpkg -i --force-all --root=./rootfs /tmp/qtembedded-4.8.5_armel.deb
 +
tar czf rootfs.tgz rootfs
 
</syntaxhighlight>
 
</syntaxhighlight>
  
====编译Rootfs====
+
====File System for Rabbit Linux====
下载Rootfs的源文件后,只需要只以root用户运行以下命令即可。
+
Another Linux system we provide is Rabbit Linux which is open source. You can work on it as "root" by following the steps below:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 +
git clone https://github.com/friendlyarm/rootfs_nanopi.git
 
cd rootfs_nanopi
 
cd rootfs_nanopi
make && make install
+
git checkout nanopi
 +
su
 +
make && make install && make strip
 
</syntaxhighlight>
 
</syntaxhighlight>
如果您的PC是多核的CPU,可以make的参数"-j, --jobs" 来加快编译,也可以先定义alias,例如:
+
 
<syntaxhighlight lang="bash">
+
If the compilation is successful you will observe the following messages:
make -j8 && make -j8 install
+
alias make='make -j8'
+
</syntaxhighlight>
+
编译成功结束后,将看到以下信息,重点是编译好的rootfs 存放位置。
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
RootFS (core) successfully installed to:
 
RootFS (core) successfully installed to:
Line 300: Line 457:
  
 
Copyright 2015 FriendlyARM (http://www.arm9.net/)
 
Copyright 2015 FriendlyARM (http://www.arm9.net/)
</syntaxhighlight>
 
如果没有看到以上信息,则说明编译失败了,请检查编译时显示的信息以定位是编译哪部分时出错了,同时还请检查PC的开发环境。<br />
 
编译生成的rootfs中的可执行程序和库是包含调试用的符号信息,可去除这些符号信息来减小rootfs的体积。
 
<syntaxhighlight lang="bash">
 
make strip
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
====创建压缩包====
+
The information above indicates that the generated file system is located under "/tmp/FriendlyARM/nanopi/rootfs". We will make it a package by running the following commands:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
cd /tmp/FriendlyARM/nanopi
 
cd /tmp/FriendlyARM/nanopi
Line 313: Line 465:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
===制作可启动的microSD卡===
+
<div id="BuildMicroSDCard"></div>
====下载源代码====
+
 
 +
===Make an Installation MicroSD Card with Your Own Files===
 +
====Make Your Own System====
 +
Please download the SD card fuse utility and switch to the correct "master" branch:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
git clone https://github.com/friendlyarm/sd-fuse_nanopi.git
 
git clone https://github.com/friendlyarm/sd-fuse_nanopi.git
</syntaxhighlight>
 
适应于NanoPi的分支是master,在开始编译前,请检查当前分支是否正确,如果不是则需要先checkout。
 
<syntaxhighlight lang="bash">
 
 
cd sd-fuse_nanopi
 
cd sd-fuse_nanopi
 
git checkout master
 
git checkout master
 
</syntaxhighlight>
 
</syntaxhighlight>
  
====烧写U-Boot和Linux kernel到SD卡====
+
Under "sd-fuse_nanopi" there is a "prebuilt" which contains the files that a system needs: <br />
prebuilt目录下已包含编译好的u-boot.bin 和 zImage,使用脚本fusing.sh 即可快速的创建SD卡的分区,同时再将它们烧写到卡上。<br />
+
Bootloader: u-boot.bin <br />
以下操作将破坏您卡上已有的数据,请先进行备份。<br />
+
Kernel Command Parameters: sdenv.raw <br />
准备好后,假设SD卡的设备名是 /dev/sdd,以root用户运行以下命令即可。
+
Linux Kernel: zImage  <br />
 +
File System Package: rootfs.tgz <br />
 +
 
 +
You can replace one or multiple of these files with the ones you generated on your own in the previous steps and then run the following command to flash them to your MicroSD card. Please note that you need to run these commands under the "sd-fuse_nanopi" directory.
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
cd sd-fuse_nanopi
+
su
./fusing.sh /dev/sdd
+
./fusing.sh /dev/sdx
 
</syntaxhighlight>
 
</syntaxhighlight>
由于修改了SD卡的分区表,在烧写rootfs 前需要使新的分区表生效,可以重新插拨一次卡,也可以使用以下命令:
+
(Note: please replace /dev/sdx with your SD card's device name)
 +
 
 +
After it is done you can play with your new OS with this card.
 +
 
 +
====Change U-Boot Environment Variables====
 +
After you boot your NanoPi you can check the U-Boot environment variables by running the following command:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
partx -u /dev/sdd
+
fw_printenv bootargs
 
</syntaxhighlight>
 
</syntaxhighlight>
然后,您可以查看 /proc/partitions 是否包含 2 个分区,其中较大的分区 sdd2 将用于存放 rootfs。
+
If you want to change variables (e.g. adding an LCD variable) you can do it this way:
 
+
====烧写Rootfs====
+
prebuilt目录下已包含编译好的rootfs.tgz, 检查分区正确后,可使用脚本 mkrootfs.sh 来格式化SD卡分区并烧写rootfs,请以root用户运行以下命令。
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
./mkrootfs.sh /dev/sdd
+
fw_setenv bootargs root=/dev/mmcblk0p2 rootfstype=ext4 init=/sbin/init console=ttySAC0,115200 lcd=S70
 
</syntaxhighlight>
 
</syntaxhighlight>
烧写成功完成后,这张SD卡即可用于启动NanoPi。
 
  
====使用自己编译的文件====
+
If you want to port an existing SD card's all environment variables you can to insert it to a host and export its environment variables to a new sdenv.raw by running the following commands and then replace the "prebuilt/sdenv.raw" with this new file:
在成功编译U-Boot、Linux kernel和Rootfs后,只需要把生成的文件即u-boot.bin、zImage、rootfs.tgz复制到prebuilt 目录,替换原文件,再重新全部烧写一次即可。
+
 
+
====更新U-Boot环境变量====
+
制作好的SD启动NanoPi 后,如果通过串口在U-Boot命令模式下修改了环境变量,如bootargs,现在想要把这个修改后的环境用于制作其它新的SD卡,则需要把保存在卡的U-Boot环境变量数据读出来,替换掉prebuilt 下的 sdenv.raw,然后烧写新的SD卡即可。
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 +
cd sd-fuse_nanopi
 
./readenv.sh /dev/sdd
 
./readenv.sh /dev/sdd
 
cp sdenv.raw prebuilt/
 
cp sdenv.raw prebuilt/
 
</syntaxhighlight>
 
</syntaxhighlight>
  
====关于SD卡RAW文件====
+
====Comments on SD Card's "RAW" File====
由于CPU S3C2451的iROM 是从SD卡的尾部来读取Bootloader,且普通SD卡和SDHC卡的位置不同,而不同品牌或是不同容量的SD卡的大小又是不同的,因此没办法创建适应不同卡的RAW文件。<br />
+
There is a known issue with the S3C2451: when iROM boots with SDHC card, calculated card size is smaller than original card size, exactly 1024 blocks so SDHC card has additional reserved blocks(512Kbyte). The S3C2451's iROM reads a bootloader from the end of an SD card. The results in an issue that when the iROM reads a regular SD card and an SDHC card of the same size it will get different positions. In addition different SD cards have different sizes. Therefore it is impossible to create a universal RAW file for all SD cards.<br />
如果您有一批大小完全一致的SD卡,可使用工具如linux下的dd 读取已经制作好的SD 卡的全部数据,保存为RAW文件,然后将此文件写入其它大小相同的SD卡。<br />
+
If you have multiple SD cards of the same size and one of them is flashed with a complete system you can use "dd" under Linux to read its data and save it as a RAW file and then dump it to all the other SD cards.<br />
另外,由于现在的SD卡容量通常都比较大,对于8 GB的SD卡,写一个RAW文件将需要较长时间,而目前的rootfs实际只有 ~23 MB,因此直接使用脚本制作SD卡将更快。
+
For an SD card whose size is greater than 8 GB it takes much longer time to write a RAW file to it. On general our rootfs is only about 23 MB it will be much faster to run a script file making an SD card.
 +
 
 +
==Related Links==
 +
===Connect Camera===
 +
===Connect TFT LCD===
 +
[[File:NanoWithP43.png|frameless|400px|P43 LCD]]<br />
 +
The NanoPi can work with FriendlyARM's LCDs: H43,S70,A70,W50,A97,L80,G10,A56,W101,W35,P43,P35,TD35.<br />
 +
<br />
 +
Please follow the steps below:<br />
 +
1) If you connect your NanoPi to a PC host via a mini USB cable its power may not be enough and you will need to connect an additional 5V 2A power to the board's GPIO's VDD_5V and DGND;<br />
 +
2) You need to add an LCD variable in U-boot. For example if you want to connect your NanoPi to an S70 LCD you can do it this way:<br />
 +
<br />
 +
Firstly list the current environment variables:
 +
<syntaxhighlight lang="bash">
 +
fw_printenv bootargs
 +
</syntaxhighlight>
 +
<br />
 +
Here is the list<br />
 +
bootargs=root=/dev/mmcblk0p2 rootfstype=ext4 init=/sbin/init console=ttySAC0,115200<br /><br />
 +
Append "lcd=S70" to "bootargs=" and reset the list with "fw_setenv"
 +
<syntaxhighlight lang="bash">
 +
fw_setenv bootargs root=/dev/mmcblk0p2 rootfstype=ext4 init=/sbin/init console=ttySAC0,115200 lcd=S70
 +
</syntaxhighlight>
 +
<br />
 +
Reboot your board you will see Debian on the LCD.<br> <br>
 +
 
 +
Download Qt and tslib Packages:
 +
<syntaxhighlight lang="bash">
 +
apt-get update
 +
apt-get install qtembedded
 +
apt-get install friendlyarm-tslib
 +
</syntaxhighlight>
 +
The qtemebdded is the library Qt4 relies on. The friendlyarm-tslib is the library touch functions and screen calibration rely on. <br> <br>
 +
 
 +
Run Qt Sample Application:
 +
<syntaxhighlight lang="bash">
 +
. /usr/bin/setqt4env
 +
/usr/local/Trolltech/QtEmbedded-4.8.5-arm/examples/tetrix -qws
 +
</syntaxhighlight>
 +
The setqt4env script sets the environmental variables which Qt and tslib rely on. If it is run on a platform for the first time a screen calibration GUI will be launched. Users need to go through a five-point calibration process to calibrate the screen.<br>
 +
The tetrix application is a game developed in Qt4 and it runs as follows.<br>
 +
[[File:nanopi_with_s70.jpg|frameless|400px|]]
 +
 
 +
===Connect Matrix DIY Modules===
 +
[[Matrix - Buzzer#NanoPi|Matrix - Buzzer]]
  
==扩展连接==
 
===连接使用摄像头模块===
 
===连接使用TFT LCD===
 
===连接使用Matrix入门DIY套件===
 
  
==玩转NanoPi==
+
==NanoPi Applications==
===制作一台4.3英寸小电脑===
+
===4.3" Mini Computer===
===制作无线智能小车===
+
===Wireless Intelligent Vehicle===
  
==资源链接==
+
==Resources==
* GitHub:
+
* [Schematic]( [http://wiki.friendlyarm.com/wiki/images/f/f0/NanoPi-1507-Schematic.pdf NanoPi-1507-Schematic.pdf])
* Schematic: [[:File:NanoPi-1507-Schematic.pdf | NanoPi-1507-Schematic.pdf ]]
+
* [Dimensions]( [http://wiki.friendlyarm.com/wiki/images/3/37/NanoPi-1507-Dimesions%28dxf%29.zip NanoPi-1507-Dimesions(dxf).zip ])
* Dimensions: [[:File:NanoPi-1507-Dimesions(dxf).zip | NanoPi-1507-Dimesions(dxf).zip ]]
+
* [S3C2451 Datasheet]([http://wiki.friendlyarm.com/wiki/images/b/b9/S3C2451_UM_REV1.1.pdf S3C2451_UM_REV1.1.pdf])
 +
* [RT8059 Datasheet]( [http://www.richtek.com/assets/product_file/RT8059/DS8059-05.pdf RT8059.pdf])
 +
* [XC6209 Datasheet]( [http://www.torex.co.jp/english/products/discon/item/53-XC6209_12.pdf XC6209.pdf])
 +
* [DDR2 RAM Datasheet]( [http://www.samsung.com/global/business/semiconductor/file/2011/product/2011/7/18/148752ds_k4t51xx3qi_rev11.pdf K4T51163QI_rev1.1.pdf])
 +
* [AP6210 Datasheet]( [http://wiki.friendlyarm.com/wiki/images/7/77/AP6210_V1.2_12262012.pdf AP6210_V1.2_12262012.pdf])

Latest revision as of 06:48, 21 January 2016

查看中文

1 Introduction

Overview
Front
Back

The NanoPi is a low power consumption, Samsung S3C2451 based ARM SOC that FriendlyARM developed for Linux hackers, makers and hobbyists. Its size is only half of the Raspberry Pi(RPi) and its GPIO pin is compatible with the RPi’s. The NanoPi integrates both the WiFi and Bluetooth 4.0. It has a DVP camera interface and full color LCD interface. It boots Linux/Debian quickly from a TF card. These features make it a good platform for applications in IOT, unmanned vehicles, robotics, image processing and human machine interaction.

2 Hardware Features

  • CPU: Samsung S3C2451, 400Mhz
  • RAM: 64M DDR2
  • Integrated SDIO WiFi and Bluetooth
  • USB Type A x1
  • Debugging Serial Port x1
  • microSD Slot x1
  • microUSB x1: for power and data transmission. It can be configured as a serial port or Ethernet
  • LCD Interface: 0.5 mm pitch SMT FPC seat, for full-color LCD (RGB: 8-8-8)
  • DVP Camera interface:0.5mm spacing FPC socket. It includes ITU-R BT 601/656 8-bit, I2C and IO
  • GPIO1: 2.54mm spacing 40pin, compatible with Raspberry Pi's GPIO. It includes UART, SPI, I2C, IO etc
  • GPIO2: 2.54mm spacing 12pin. It includes I2S, I2C, UART etc.
  • PCB dimension: 75 x 30 mm
  • Power: DC 5V
  • Bootloader and OS: u-boot, Linux-4.1, Debian8 jessie, Rabbit linux

3 Diagram, Layout and Dimension

3.1 Layout

NanoPi Layout
  • GPIO1 Pin Spec
NanoPi GPIO Header
  • GPIO2 Pin Spec
Pin# Name Pin# Name
1 VDD_5V 2 VDD_SYS_3.3V
3 TXD2 4 RXD2
5 SDA0 6 SCL0
7 IISSDO0 8 IISSDI0
9 IISSCLK0 10 IISLRCK0
11 IISCDCLK0 12 DGND
  • Debug Port CON1(UART0)
Pin# Name
1 DGND
2 VDD_5V
3 TXD0
4 RXD0
  • DVP Camera IF Pin Spec
Pin# Name
1, 2 VDD_SYS_3.3V
7,9,13,15,24 DGND
3 SCL0
4 SDA0
5 GPH13
6 GPJ12
8 XCLK
10 NC
11 VSYNC
12 HREF
14 PCLK
16-23 Data bit7-0
  • RGB LCD IF Pin Spec
Pin# Name
1, 2 VDD_5V
11,20,29 DGND
3-10 Blue LSB to MSB
12-19 Green LSB to MSB
21-28 Red LSB to MSB
30 GPG12
31 GPG2
32 XnRSTOUT Form CPU
33 VDEN
34 VSYNC
35 HSYNC
36 LCDCLK
37,38,39,40 XM,XP,YM,YP
Note:
  1. VDD_SYS_3.3V: 3.3V power output
  2. 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
  3. 3. For more details please refer to the document:NanoPi-1507-Schematic.pdf

3.2 Board Dimension

NanoPi 机械尺寸

For more details please refer to the document:NanoPi-1507-Dimesions(dxf).zip

4 Get Started

4.1 Essentials You Need

Before play with your NanoPi please get the following items ready

  • NanoPi
  • Class 8, microSD card/TF card: >= 4GB
  • microUSB cable
  • a Host running Ubuntu and connected to the internet

4.2 Make an Installation MicroSD Card

  • 1) Insert your microSD card to your host running Ubuntu and check your SD card's device name
dmesg | tail

Search the messages output by "dmesg" for similar words like "sdc: sdc1 sdc2". If you can find them it means your SD card is recognized as "/dev/sdc". Or you can check that by commanding "cat /proc/partitions".

  • 2) Flash Firmware to MicroSD Card
git clone https://github.com/friendlyarm/sd-fuse_nanopi.git
cd sd-fuse_nanopi
su
./fusing.sh /dev/sdx

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

If you cannot get these files from github you can get them from our source: [1].
If you have problems with using the "fusing.sh" script you can download our "NanoPi-fuser-win32.zip" and use it to make your SD card in Windows. Here is the download:[2].

4.3 Run System

Insert this MicroSD card to your NanoPi, connect it to a PC via a MicroUSB cable the NanoPi will be automatically powered on. If you can see the blue LED flashing it means your board is running now. By default we install Debian. It would be better if you connect your NanoPi to an LCD since this helps you set up your NanoPi more easily and conveniently.

Debian8 Jessie

4.4 Log on NanoPi via MicroUSB

After connecting your NanoPi to you PC host (running Ubuntu) please type "dmesg" in your PC's command line. If you can find the following messages it means your NanoPi is correctly connected to your host and runs well:

[12601.100339] usb 2-1.7: Product: FriendlyARM Gadget v2.4
[12601.100343] usb 2-1.7: Manufacturer: Linux 4.1.2-FriendlyARM with s3c-hsudc
[12601.103192] cdc_acm 2-1.7:2.0: This device cannot do calls on its own. It is not a modem.
[12601.103368] cdc_acm 2-1.7:2.0: ttyACM0: USB ACM device
[12601.105300] cdc_ether 2-1.7:2.2 usb0: register 'cdc_ether' at usb-0000:00:1d.0-1.7, CDC Ethernet Device, 46:a1:e7:6d:5c:32

If you command "ifconfig" and find a "usb0" device you can SSH to 192.168.100.1 to log on your NanoPi:

ssh root@192.168.100.1

After it prompts you to input your password you can try "fa"

4.5 Setup Wi-Fi

After SSH to your NanoPi please check the WiFi interface first. The "wlan" device is WiFi.

ifconfig -a

By default the WiFi device is "wlan0". You need to create a configuration file under "/etc/network/interfaces.d/" for WiFi:

vi /etc/network/interfaces.d/wlan0

Here is a sample wlan0 file:

auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet dhcp
wpa-driver wext
wpa-ssid YourWiFiESSID
wpa-ap-scan 1
wpa-proto RSN
wpa-pairwise CCMP
wpa-group CCMP
wpa-key-mgmt WPA-PSK
wpa-psk YourWiFiPassword

Please replace "YourWiFiESSID" and "YourWiFiPassword" with your WiFiESSID and password. After save and close the file you can connect to your WiFi source by running the following command:

/etc/init.d/networking restart

After you power on your board it will automatically connect to your WiFi source.
Please note that if you use one TF card to boot multiple boards the WiFi device name will likely be named to "wlan1", "wlan2" and etc. You can reset it to "wlan0" by deleting the contents of the following file and reboot your board: /etc/udev/rules.d/70-persistent-net.rules

SSH connected to NanoPi over WiFi

4.6 Setup Wi-Fi AP

By default a NanoPi is set to a WiFi AP. The default AP name is "nanopi-wifiap" and the password is "123456789".

The WiFi's working mode can be checked by running the following command:

cat /sys/module/bcmdhd/parameters/op_mode

If the result is "2" it means it is currently working as a WiFi AP.

If the board is not working as a WiFi AP you can set it by running the following commands:

turn-wifi-into-apmode yes


The WiFi AP's name and password can be configured by editing the file "/etc/hostapd/hostapd.conf".


4.7 Bluetooth

In our Debian Jessie we include bluetooth packages: bluetooth, bluez, obexftp and etc
We will show how to transfer files between a NanoPi and a cellphone

In this example we used an MX4 cellphone, enabled its bluetooth and made it searchable by other devices. Firstly we typed the following commands in the NanoPi to search its nearby bluetooth devices:

hcitool scan


Scanning ...
8C:BE:BE:C5:2C:C7 MX4

The listed search result above indicated that our MX4 phone was found and its MAC was 8C:BE:BE:C5:2C:C7. We ran "sdptool" to list all the protocols it supported:

sdptool browse 8C:BE:BE:C5:2C:C7

What we would like to test was its file transfer function therefore we must find out whether "OBEX File Transfer" was supported:

Service Name: OBEX File Transfer
Service RecHandle: 0x1000c
Service Class ID List:
"OBEX File Transfer" (0x1106)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 11
"OBEX" (0x0008)
Language Base Attr List:
code_ISO639: 0x454e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"OBEX File Transfer" (0x1106)
Version: 0x0100

Here we found out that "OBEX File Transfer" was supported and we could use "obexftp" to start our file transfers. The following commands listed all the files under the root directory of the phone:

obexftp -b 8C:BE:BE:C5:2C:C7 -c / -l

The following commands downloaded "/Adnroid/djaof.dll" from the phone to the NanoPi:

obexftp -b 8C:BE:BE:C5:2C:C7 -c /Android -g djaof.dll

The following commands uploaded "hello.txt" from the NanoPi to the "/Android" directory of the phone

obexftp -b 8C:BE:BE:C5:2C:C7 -c /Android -p hello.txt


4.8 Setup iBeacon Transmitter

The iBeacon technology enables smartphones, tablets and other devices to perform actions when in close proximity to an iBeacon transmitter. Please run the following commands to setup a NanoPi to an iBeacon transmitter:

hciconfig hci0 up
hciconfig hci0 leadv 3
hciconfig hci0 noscan
hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 63 6F 3F 8F 64 91 4B EE 95 F7 D8 CC 64 A8 63 B5 00 00 00 00 C8

If this is setup correctly on a NanoPi it will broadcast its presence to nearby portable electronic devices. If a nearby Android device or iPhone has the "locate Beacon" application installed it will be able to measure the distance between itself to the NanoPi. If you want enable the indoor positioning function you will need to setup multiple iBeacon transmitters.

4.9 Communicate with Cellphone via Bluetooth BLE

The function requires a BLE service be started on the NanoPi.
The BLE service's code is open source. Please follow the steps below to get it:

git clone https://github.com/friendlyarm/ble-peripheral-service-demo.git

Please run the following build.sh script which will generate a "nanopi_ble_server" executable if it is successful:

./build.sh

We assume your cross compiler is installed at "/opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-gcc". If it is not installed under this directory you need to make changes in the script accordingly.
After a "nanopi_ble_server" is generated please copy it to the NanoPi and execute the following commands:

hciconfig hci0 down
service bluetooth stop
chmod 755 nanopi_ble_server
./nanopi_ble_server

Now please install a BLE Scanner application on an Android phone or a Lightblue application on an iPhone which will be used to test the function.
We have an open source Android Demo on GitHub too,It is under "android/BLETest". This demo shows how a cellphone communicates(transmits data to/receives data from) with the NanoPi via BLE.
NanoBLEAndroidDemo

NanoPi's output messages are as follows:
NanoPiBLEServer

4.10 Install Debian Packages

We provide a Debian Jessie image. You can install Jessie's packages by commanding "apt-get". If this is your first installation you need to update the package list by running the following command:

apt-get update

Or you can try a complete command set

apt-get update
apt-get dist-upgrade
apt-get autoremove

You can install your preferred packages. For example if you want to install an FTP server you can do this:

apt-get install vsftpd

Note: you can change your download server by editting "/etc/apt/sources.list". You can get a complete server list from [3]. You need to select the one with "armel".

5 Make OS Image

5.1 Install Cross Compiler

Download and untar cross compiler file:

git clone https://github.com/friendlyarm/prebuilts.git
tar xvzf prebuilts/gcc/arm-linux-gcc-4.4.3.tar.gz -C /

It will ease your future development work if you add compiler's path to "PATH". You can do it by first opening "~/.bashrc" and then appending the following lines:

export PATH=/opt/FriendlyARM/toolschain/4.4.3/bin/:$PATH

Run "~/.bashrc" to make your changes in effect right away:

. ~/.bashrc

We assume you would use a 32-bit compiler. However if your host runs a 64-bit Linux you need to install some extra packages. For example if your host runs a Debian 8 Jessie desktop 64 bit system you will need to install the following packages:

dpkg --add-architecture i386
apt-get update
apt-get install build-essential gcc-multilib rpm libstdc++6:i386 libgcc1:i386 zlib1g:i386 libncurses5:i386

5.2 Compile U-Boot

Download U-Boot source code and compile it. Please note it is in the branch "nanopi":

git clone https://github.com/friendlyarm/uboot_nanopi.git
cd uboot_nanopi
git checkout nanopi
make nanopi_config
make

After your compilation succeeds a u-boot.bin will be generated. If you want to test it please flash it to your MicroSD card by running the "fusing.sh" script.
If your SD card's device name is "/dev/sdd" please run the following command as "root":

su
./fusing.sh /dev/sdd

Note: this operation will remove all the data in the SD card.

5.3 Compile Linux kernel

5.3.1 Compile Kernel

Please download kernel source code and compile it

git clone https://github.com/friendlyarm/linux-4.x.y.git
cd linux-4.x.y
git checkout nanopi-v4.1.y
make nanopi_defconfig
touch .scmversion
make

The kernel that the NanoPi uses is "nanopi-v4.1.y". Please make sure you get the correct branch. After your compilation succeeds a new file "arch/arm/boot/zImage" will be generated

5.3.2 Compile Kernel Modules

In general kernel compilation generates kernel modules such as ipv6, netfilter and etc. If you want to add your own modules to the kernel or you changed your kernel configurations you need to recompile these new modules and pack them as a new "kernel-modules.tgz" to replace the corresponding file "basefs/kernel-modules.tgz" in "Rootfs"
please run the following commands as root to install ".ko" to /tmp/nanopi-modules:

make INSTALL_MOD_PATH=/tmp/nanopi-modules modules_install

Please strip your kernel modules and create a new package

cd /tmp/nanopi-modules/lib/
find . -name \*.ko | xargs arm-linux-strip --strip-unneeded
tar czvf kernel-modules.tgz modules/

If you want to test your newly generated kernel modules you can copy them to your MicroSD card's "rootfs/lib": We assume your MicroSD card was already mounted to "/media/fa/NANOPI" please run the following commands as root:

rm -rf /media/fa/NANOPI/lib/modules/
tar xzvf kernel-modules.tgz -C /media/fa/NANOPI/lib/

5.4 Make File System

5.4.1 File System for Debian

By default we install a Debian system to the NanoPi, which can be obtained from the following repository:

git clone https://github.com/friendlyarm/sd-fuse_nanopi.git
cd sd-fuse_nanopi/prebuilt/
ls -l rootfs.tgz

If you want to customize it you can uncompress "rootfs.tgz", edit its components and tar it. Here is an example showing how you can do it:

tar xzf rootfs.tgz 
dpkg -i --force-all --root=./rootfs /tmp/qtembedded-4.8.5_armel.deb 
tar czf rootfs.tgz rootfs

5.4.2 File System for Rabbit Linux

Another Linux system we provide is Rabbit Linux which is open source. You can work on it as "root" by following the steps below:

git clone https://github.com/friendlyarm/rootfs_nanopi.git
cd rootfs_nanopi
git checkout nanopi
su
make && make install && make strip

If the compilation is successful you will observe the following messages:

RootFS (core) successfully installed to:
   /tmp/FriendlyARM/nanopi/rootfs
 
Copyright 2015 FriendlyARM (http://www.arm9.net/)

The information above indicates that the generated file system is located under "/tmp/FriendlyARM/nanopi/rootfs". We will make it a package by running the following commands:

cd /tmp/FriendlyARM/nanopi
tar czvf rootfs.tgz rootfs/

5.5 Make an Installation MicroSD Card with Your Own Files

5.5.1 Make Your Own System

Please download the SD card fuse utility and switch to the correct "master" branch:

git clone https://github.com/friendlyarm/sd-fuse_nanopi.git
cd sd-fuse_nanopi
git checkout master

Under "sd-fuse_nanopi" there is a "prebuilt" which contains the files that a system needs:
Bootloader: u-boot.bin
Kernel Command Parameters: sdenv.raw
Linux Kernel: zImage
File System Package: rootfs.tgz

You can replace one or multiple of these files with the ones you generated on your own in the previous steps and then run the following command to flash them to your MicroSD card. Please note that you need to run these commands under the "sd-fuse_nanopi" directory.

su
./fusing.sh /dev/sdx

(Note: please replace /dev/sdx with your SD card's device name)

After it is done you can play with your new OS with this card.

5.5.2 Change U-Boot Environment Variables

After you boot your NanoPi you can check the U-Boot environment variables by running the following command:

fw_printenv bootargs

If you want to change variables (e.g. adding an LCD variable) you can do it this way:

fw_setenv bootargs root=/dev/mmcblk0p2 rootfstype=ext4 init=/sbin/init console=ttySAC0,115200 lcd=S70

If you want to port an existing SD card's all environment variables you can to insert it to a host and export its environment variables to a new sdenv.raw by running the following commands and then replace the "prebuilt/sdenv.raw" with this new file:

cd sd-fuse_nanopi
./readenv.sh /dev/sdd
cp sdenv.raw prebuilt/

5.5.3 Comments on SD Card's "RAW" File

There is a known issue with the S3C2451: when iROM boots with SDHC card, calculated card size is smaller than original card size, exactly 1024 blocks so SDHC card has additional reserved blocks(512Kbyte). The S3C2451's iROM reads a bootloader from the end of an SD card. The results in an issue that when the iROM reads a regular SD card and an SDHC card of the same size it will get different positions. In addition different SD cards have different sizes. Therefore it is impossible to create a universal RAW file for all SD cards.
If you have multiple SD cards of the same size and one of them is flashed with a complete system you can use "dd" under Linux to read its data and save it as a RAW file and then dump it to all the other SD cards.
For an SD card whose size is greater than 8 GB it takes much longer time to write a RAW file to it. On general our rootfs is only about 23 MB it will be much faster to run a script file making an SD card.

6 Related Links

6.1 Connect Camera

6.2 Connect TFT LCD

P43 LCD
The NanoPi can work with FriendlyARM's LCDs: H43,S70,A70,W50,A97,L80,G10,A56,W101,W35,P43,P35,TD35.

Please follow the steps below:
1) If you connect your NanoPi to a PC host via a mini USB cable its power may not be enough and you will need to connect an additional 5V 2A power to the board's GPIO's VDD_5V and DGND;
2) You need to add an LCD variable in U-boot. For example if you want to connect your NanoPi to an S70 LCD you can do it this way:

Firstly list the current environment variables:

fw_printenv bootargs


Here is the list
bootargs=root=/dev/mmcblk0p2 rootfstype=ext4 init=/sbin/init console=ttySAC0,115200

Append "lcd=S70" to "bootargs=" and reset the list with "fw_setenv"

fw_setenv bootargs root=/dev/mmcblk0p2 rootfstype=ext4 init=/sbin/init console=ttySAC0,115200 lcd=S70


Reboot your board you will see Debian on the LCD.

Download Qt and tslib Packages:

apt-get update
apt-get install qtembedded
apt-get install friendlyarm-tslib

The qtemebdded is the library Qt4 relies on. The friendlyarm-tslib is the library touch functions and screen calibration rely on.

Run Qt Sample Application:

. /usr/bin/setqt4env
/usr/local/Trolltech/QtEmbedded-4.8.5-arm/examples/tetrix -qws

The setqt4env script sets the environmental variables which Qt and tslib rely on. If it is run on a platform for the first time a screen calibration GUI will be launched. Users need to go through a five-point calibration process to calibrate the screen.
The tetrix application is a game developed in Qt4 and it runs as follows.
Nanopi with s70.jpg

6.3 Connect Matrix DIY Modules

Matrix - Buzzer


7 NanoPi Applications

7.1 4.3" Mini Computer

7.2 Wireless Intelligent Vehicle

8 Resources