Difference between revisions of "NanoPi 2"

From FriendlyELEC WiKi
Jump to: navigation, search
(Get Started)
(Get Started)
Line 225: Line 225:
 
===Run Android===
 
===Run Android===
 
Insert a MicroSD card with Android image files to your NanoPi2, connect the NanoPi2 to an HDMI monitor and a 5V/2A power source the NanoPi2 will be automatically powered on. If you can see the blue LED flashing it means your board is working and you will see Android loading on the HDMI monitor. If at the same time you connect your NanoPi2 to a PC running Ubuntu and Minicom via a serial cable you will see system messages output to the PC’s minicom terminal.
 
Insert a MicroSD card with Android image files to your NanoPi2, connect the NanoPi2 to an HDMI monitor and a 5V/2A power source the NanoPi2 will be automatically powered on. If you can see the blue LED flashing it means your board is working and you will see Android loading on the HDMI monitor. If at the same time you connect your NanoPi2 to a PC running Ubuntu and Minicom via a serial cable you will see system messages output to the PC’s minicom terminal.
 +
 +
==Debian系统的使用==
 +
===连接无线网络===
 +
在Debian的图形界面上,点击右上角的网络图标,程序会自动搜索到附近的WiFi热点,找到你需要连接的热点,点击旁边的Properties按钮,输入WiFi密码后保存退出,再点击Connect按钮即可。<br />
 +
[[File:nanopi2-wifi.png|frameless|500px|NanoPi 2 WiFi]]
 +
 +
===配置Wi-Fi无线热点===
 +
可以通过以下命令,将Wi-Fi切换至无线热点模式:<br />
 +
<syntaxhighlight lang="bash">
 +
turn-wifi-into-apmode yes
 +
</syntaxhighlight>
 +
按提示重启即可,默认的热点名称为 nanopi2-wifiap,密码为123456789。<br />
 +
<br />
 +
现在,你可以在电脑上搜索并连接nanopi2-wifiap这个无线热点,连接成功后,可以通过ssh到192.168.8.1这个地址来登录NanoPi2:
 +
<syntaxhighlight lang="bash">
 +
ssh root@192.168.8.1
 +
</syntaxhighlight>
 +
在提示输入密码时,输入预设的密码fa,即可登入。<br />
 +
<br />
 +
WiFi工作模式可通过以下命令查询:<br />
 +
<syntaxhighlight lang="bash">
 +
cat /sys/module/bcmdhd/parameters/op_mode
 +
</syntaxhighlight>
 +
输出为数字2则表示当前处于无线热点模式,要切换回普通的Station模式,输入如下命令:<br />
 +
<syntaxhighlight lang="bash">
 +
turn-wifi-into-apmode no
 +
</syntaxhighlight>
 +
 +
 +
===使用蓝牙传输===
 +
点击Xfce4右上角的蓝牙图标,会弹出一个操作菜单,其中,<br />
 +
Make discoverable菜单项是打开NanoPi2蓝牙的可发现属性,这样其他设备(例如手机)就可以搜索到NanoPi2并进行配对了; <br />
 +
Devices... 菜单项可以打开搜索界面,主动搜索周边的蓝牙设备(注:需要这个设备先打开可发现属性);<br />
 +
Send Files to Device...菜单项则可以通过蓝牙发送文件到已配对的指定设备上。<br />
 +
[[File:nanopi2-bluetooth.png|frameless|500px|NanoPi 2 Bluetooth]]
 +
 +
===安装Debian软件包===
 +
我们提供的是标准的Debian jessie系统,你可以使用apt-get等命令来安装软件包,如果板子是首次运行,需要先用以下命令更新软件包列表:
 +
<syntaxhighlight lang="bash">
 +
apt-get update
 +
</syntaxhighlight>
 +
然后就可以安装软件包了,例如要安装ftp服务器,使用以下命令:
 +
<syntaxhighlight lang="bash">
 +
apt-get install vsftpd
 +
</syntaxhighlight>
 +
如果软件包下载速度不理想,你可以编辑 /etc/apt/sources.list 更换一个更快的源服务器,这个网址[http://www.debian.org/mirror/list]有一份完整的源镜像服务器列表,注意要选用一个带armhf架构的。
  
 
==Make Your Own OS Image==
 
==Make Your Own OS Image==

Revision as of 10:36, 5 November 2015

查看中文

1 Introduction

Overview
Front
Back
  • The NanoPi2 is a high performance ARM Board developed by FriendlyARM for Hobbysts, 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 built-in WiFi and Bluetooth which supports 802.11 b/g/n and Bluetooth 4.0. 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.

2 Features

  • CPU: S5P4418, 1.4GHz
  • RAM: 1GB DDR3
  • Built in SDIO WiFi and Bluetooth module
  • USB 2.0 Type A x 1
  • Debug Serial Port/UART0 x 1
  • microSD Slot x 2
  • microUSB x 1: for data transmission and power input
  • LCD Interface: 0.5 mm pitch SMT FPC seat, for full-color LCD (RGB: 8-8-8)
  • HDMI: HDMI 1.4A, Type-A, 1080P60
  • DVP Camera Interface: 0.5mm spacing FPC socket. It includes ITU-R BT 601/656 8-bit, I2C and IO
  • GPIO: 2.54mm spacing 40pin, compatible with Raspberry Pi's GPIO. It includes UART, SPI, I2C, IO etc
  • Button: User Button x 1, Reset Button x 1
  • LED: LED for Power Indication x 1, User LED x 1
  • PCB Dimension: 75 x 40mm
  • Power: DC 5V/2A
  • OS: Android, Debian

3 Diagram, Layout and Dimension

3.1 Layout

NanoPi 2接口布局
NanoPi 2 MicroSD
  • GPIO Pin Spec
Pin# Name Pin# Name
1 VDD_SYS_3.3V 2 VDD_5V
3 I2C0_SDA 4 VDD_5V
5 I2C0_SCL 6 DGND
7 GPIOB28 8 UART3_TXD
9 DGND 10 UART3_RXD
11 GPIOB29 12 GPIOB26
13 GPIOB30 14 DGND
15 GPIOB31 16 PWM2
17 VDD_SYS_3.3V 18 GPIOB27
19 SPI0_MOSI 20 DGND
21 SPI0_MISO 22 PWM0
23 SPI0_CLK 24 SPI0_CS
25 DGND 26 PWM1
27 I2C1_SDA 28 I2C1_SCL
29 GPIOC8 30 DGND
31 SPI2_CLK 32 GPIOC28
33 SPI2_CS 34 DGND
35 SPI2_MOSI 36 GPIOC7
37 SPI2_MISO 38 ALIVEGPIO2
39 DGND 40 ALIVEGPIO3
  • Debug Port CON1(UART0)
Pin# Name
1 DGND
2 VDD_5V
3 TXD0
4 RXD0
  • DVP Camera Interface Pin Spec
Pin# Name
1, 2 VDD_SYS_3.3V
7,9,13,15,24 DGND
3 SCL0
4 SDA0
5 GPIOB14
6 GPIOB16
8,10 NC
11 VSYNC
12 HREF
14 PCLK
16-23 Data bit7-0
  • RGB LCD Interface Pin Spec
Pin# Name
1, 2 VDD_5V
11,20,29, 37,38,39,40, 45 DGND
3-10 Blue LSB to MSB
12-19 Green LSB to MSB
21-28 Red LSB to MSB
30 GPIOB25
31 GPIOC15
32 XnRSTOUT Form CPU
33 VDEN
34 VSYNC
35 HSYNC
36 LCDCLK
41 SCL2
42 SDA2
43 GPIOC16
44 NC
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. For more details please refer to the document:NanoPi-2-1507-Schematic.pdf

3.2 Board Dimension

NanoPi 2 Dimension

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

4 Get Started

4.1 Essentials You Need

Before play with your NanoPi2 please get the following items ready

  • NanoPi 2
  • microSD Card/TFCard: Class 10 or Above, minimum 8GB SDHC
  • microUSB cable
  • A Host running Ubuntu 14.04 64 bit system

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) Download Firmware Package
git clone https://github.com/friendlyarm/sd-fuse_nanopi2.git
cd sd-fuse_nanopi2
  • 3) Flash Android Firmware to MicroSD Card
su
./fusing.sh /dev/sdx

(Note: you need to replace "/dev/sdx" with the device name in your system) When you do “git clone” you have to hit “Y” within 10 seconds after it prompts you to download image files otherwise you will miss the download.

  • 4) Flash Debian Firmware to MicroSD Card
./fusing.sh /dev/sdx debian


4.3 Update Image Files in MicroSD Card From PC Host

If you want to make some changes to the image files in your MicroSD card please follow steps below otherwise you can skip this section.
Please insert your MicroSD card to a PC host running LINUX, mount the boot and rootfs sections of the SD card and follow the steps below:
1) If you want to output your Debian to an LCD you need to change the uImage in the boot section. If the boot section is mounted on "/media/boot" please run these commands:

cd /media/boot
rm uImage
ln -s uImage.lcd uImage

Note: if the image file is for Android you don't need to make these changes because the default output is LCD.

2) If you want to change the Kernel Command Line you can use the "fw_setenv" utility to do it, which is under "sd-fuse_nanopi2/tools". For instance if your LCD is HD101 you can do it this way:
Check the current Command Line:

cd sd-fuse_nanopi2/tools
./fw_printenv /dev/sdc | grep bootargs

Append "lcd=HD101" and then do "fw_setenv" to reset the command line:

./fw_setenv /dev/sdc bootargs XXX lcd=HD101

Attention: The "XXX" should be repalced with original bootargs.


4.4 Run Android

Insert a MicroSD card with Android image files to your NanoPi2, connect the NanoPi2 to an HDMI monitor and a 5V/2A power source the NanoPi2 will be automatically powered on. If you can see the blue LED flashing it means your board is working and you will see Android loading on the HDMI monitor. If at the same time you connect your NanoPi2 to a PC running Ubuntu and Minicom via a serial cable you will see system messages output to the PC’s minicom terminal.

5 Debian系统的使用

5.1 连接无线网络

在Debian的图形界面上,点击右上角的网络图标,程序会自动搜索到附近的WiFi热点,找到你需要连接的热点,点击旁边的Properties按钮,输入WiFi密码后保存退出,再点击Connect按钮即可。
NanoPi 2 WiFi

5.2 配置Wi-Fi无线热点

可以通过以下命令,将Wi-Fi切换至无线热点模式:

turn-wifi-into-apmode yes

按提示重启即可,默认的热点名称为 nanopi2-wifiap,密码为123456789。

现在,你可以在电脑上搜索并连接nanopi2-wifiap这个无线热点,连接成功后,可以通过ssh到192.168.8.1这个地址来登录NanoPi2:

ssh root@192.168.8.1

在提示输入密码时,输入预设的密码fa,即可登入。

WiFi工作模式可通过以下命令查询:

cat /sys/module/bcmdhd/parameters/op_mode

输出为数字2则表示当前处于无线热点模式,要切换回普通的Station模式,输入如下命令:

turn-wifi-into-apmode no


5.3 使用蓝牙传输

点击Xfce4右上角的蓝牙图标,会弹出一个操作菜单,其中,
Make discoverable菜单项是打开NanoPi2蓝牙的可发现属性,这样其他设备(例如手机)就可以搜索到NanoPi2并进行配对了;
Devices... 菜单项可以打开搜索界面,主动搜索周边的蓝牙设备(注:需要这个设备先打开可发现属性);
Send Files to Device...菜单项则可以通过蓝牙发送文件到已配对的指定设备上。
NanoPi 2 Bluetooth

5.4 安装Debian软件包

我们提供的是标准的Debian jessie系统,你可以使用apt-get等命令来安装软件包,如果板子是首次运行,需要先用以下命令更新软件包列表:

apt-get update

然后就可以安装软件包了,例如要安装ftp服务器,使用以下命令:

apt-get install vsftpd

如果软件包下载速度不理想,你可以编辑 /etc/apt/sources.list 更换一个更快的源服务器,这个网址[1]有一份完整的源镜像服务器列表,注意要选用一个带armhf架构的。

6 Make Your Own OS Image

6.1 Setup Development Environment

6.2 Install Cross Compiler

FriendlyARM has an open source Android package which contains a working cross compiler. You can set it up in the "PATH" variable:

export PATH=/opt/FriendlyARM/s5p4418/android/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin:$PATH
arm-eabi-gcc -v

The “/opt/FriendlyARM/s5p4418/android” is where Android source code package is located.
When you use this compiler please specify the option "CROSS_COMPILE=arm-eabi-".

6.3 Compile U-Boot

Download the U-Boot source code and compile it. Please note the github's branch is s5p4418-nanopi2:

git clone https://github.com/friendlyarm/uboot_nanopi2.git
cd uboot_nanopi2
git checkout s5p4418-nanopi2
make s5p4418_nanopi2_config
make CROSS_COMPILE=arm-eabi-

After your compilation succeeds a u-boot.bin will be generated. If you want to test it please flash it to your installation MicroSD card via fastboot.
Warning: you cannot update this MicroSD card by commanding "dd". This command which will cause trouble when booting the NanoPi2.

6.4 Prepare mkimage

You need the mkimage utility to compile a U-Boot source code package. Please 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:

cd uboot_nanopi2
make tools
mkdir -p /usr/local/sbin && cp -v tools/mkimage /usr/local/sbin

6.5 Compile Linux kernel

6.5.1 Compile Kernel

  • Download Kernel Source Code
git clone https://github.com/friendlyarm/linux-3.4.y.git
cd linux-3.4.y
git checkout s5p4418-nanopi2

The NanoPi2's kernel source code lies in the "s5p4418-nanopi2" branch.

  • Compile Android Kernel
make nanopi2_android_defconfig
touch .scmversion
make CROSS_COMPILE=arm-eabi- uImage
  • Compile Debian Kernel
make nanopi2_linux_defconfig
touch .scmversion
make CROSS_COMPILE=arm-eabi- uImage

After your compilation succeeds a uImage will be generated in the "arch/arm/boot/" directory.

6.5.2 Compile Kernel Modules

Android contains kernel modules which are in the "/lib/modules" directory in the system section. 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
make CROSS_COMPILE=arm-eabi- modules

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

cd /opt/FriendlyARM/s5p4418/android
./vendor/friendly-arm/build/common/build-modules.sh

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

6.6 Compile Android

  • Install Cross Compiler

We recommend installing 64 bit Ubuntu 14.04 on your PC host.

sudo apt-get install zlib1g-dev:i386
sudo apt-get install bison g++-multilib git gperf libxml2-utils make python-networkx zip
sudo apt-get install flex libncurses5-dev zlib1g-dev gawk minicom

For more details please refer to https://source.android.com/source/initializing.html

  • Download Source Code

You need to use repo to get the Android source code. Please refer to https://source.android.com/source/downloading.html

mkdir android && cd android
repo init -u git@github.com:friendlyarm/android_manifest.git -b nanopi2-kitkat
repo sync

The "android" directory is the working directory. To initialize repo you can do "HTTPS clone URL".

  • Compile System Package
source build/envsetup.sh
lunch aosp_nanopi2-userdebug
make -j8

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

7 Resources