NanoPi 2
Contents
1 Introduction
- 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
- 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
- VDD_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
- For more details please refer to the document:NanoPi-2-1507-Schematic.pdf
3.2 Board 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 Play with Debian
5.1 Wireless Connection
After Debian is fully loaded please click on the network icon on top right of the GUI it will automatically search for nearby WiFi sources. Select one source from the list, click on its "Properties", type its password, save, close and then "Connect". If everything is fine your NanoPi2 will be able to connect to a WiFi source
5.2 Setup Wi-Fi AP
You can follow the steps below to setup Wi-Fi AP:
turn-wifi-into-apmode yes
Please reboot the system as prompted. By default the AP's name is "nanopi2-wifiap" and the password is 123456789.
Now you are able to find the "nanopi2-wifiap" from a PC host and connect to it. If a connection is a success you will be able to SSH to this NanoPi2 at "192.168.8.1":
ssh root@192.168.8.1
The password for it is "fa".
You can check the WiFi mode via 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 you want to switch back to the Station mode you can do it this way:
turn-wifi-into-apmode no
5.3 Bluetooth
Click on the bluetooth icon on top right of the GUI a menu will pop up:
Make discoverable enables the NanoPi2 to be searched for by other bluetooth devices;
Devices... opens a search window and searches for nearby bluetooth devices(Note: the "Make discoverable" property needs to be enabled on those nearby devices):
Send Files to Device...enables the NanoPi2 to send files to another bluetooth device which is a pair of the NanoPi2.
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
- [Schematic]( NanoPi-2-1507-Schematic.pdf)
- [Dimensions]( NanoPi-2-1507-Dimesions(dxf).zip )
- [S5P4418 User Manual]( S5P4418_Users_Manual_Preliminary_Ver.0.10.pdf )
- [AP6212 Datasheet]( AP6212_V1.1_09022014.pdf )