Difference between revisions of "NanoPi 2"
(→Features) |
(→Login Debian via VNC or SSH) |
||
Line 283: | Line 283: | ||
<br /> | <br /> | ||
You can login via "SSH -l root 192.168.8.1" too and the default password for "root" is "fa". | You can login via "SSH -l root 192.168.8.1" too and the default password for "root" is "fa". | ||
+ | <br /> | ||
+ | To make SSH login fluent and fast please turn off the WiFi's power saving mode by running the following command: | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | iwconfig wlan0 power off | ||
+ | </syntaxhighlight> | ||
==Play with Debian== | ==Play with Debian== |
Revision as of 06:12, 25 November 2015
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
4.2.1 Under Windows
Please get the following files from here: download link:
For LCD output please use the following files: nanopi2-debian-sd4g-lcd.img.zip Debian image file (LCD output, default image supports S700/S701 LCD with capacitive touch panel) nanopi2-android-sd4g-lcd.img.zip Android image file (LCD output, default image supports S700/S701 LCD with capacitive touch panel) For HDMI output please use the following files: nanopi2-debian-sd4g-hdmi.img.zip Debian image file (HDMI output) nanopi2-android-sd4g-hdmi.img.zip Android image file (HDMI output) No display device connected, please use the following files: nanopi2-debian-sd4g-wifiap.img.zip Debian image file (By default WIFI AP is started and users can login via VNC or SSH) Flash Utility: win32diskimager.rar Windows utility. Under Linux users can use "dd"
Please uncompress these files. Insert an SD card(at least 4G) to a Windows PC, run the win32diskimager utility as administrator,On the utility's main window select your SD card's drive and the image files and click on "write" to start flashing the SD card.
4.2.2 Under Linux Desktop
- 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.
3) Connect to LCD S700
If you want to connect your NanoPi2 to our S700 LCD with capacitive touch panel you need to make changes in the "kernel command line" as follows:
./fw_setenv /dev/sdc bootargs XXX lcd=S70,128dpi
Parameter ",128dpi" sets the Android's "ro.sf.lcd_density" property,By default it is 160.
When you set this parameter to a new value please make sure the new value is a workable one otherwise it will cause problems in display.
Here are some values we tested:
LCD# Parameter S700 lcd=S70,128dpi HD101 lcd=HD101 HD700 lcd=HD700,213dpi
4) If you want to use your own kernel you can replace the uImage file with your image file.
4.4 Run Android or Debian
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. Under Debian the password for "root" is "fa".
4.5 Login Debian via VNC or SSH
If your NanoPi 2 is not connected to a display device and it runs the "-wifiap.img" image file you can login your NanoPi2 at "nanopi2-wifiap" from another device via WIFI. The password for that AP is "123456789". After you successfully connect to your NanoPi2 you can go to this link here to download and install a "VNC Viewer". To login the NanoPi2 via VNC you need to set the IP address and port to 192.168.8.1:5901 and its default password is "fa123456". Here is a screenshot which shows how it looks like when users login the NanoPi2 from an iPhone via VNC:
You can login via "SSH -l root 192.168.8.1" too and the default password for "root" is "fa".
To make SSH login fluent and fast please turn off the WiFi's power saving mode by running the following command:
iwconfig wlan0 power off
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.
The following section only applies to the NanoPi2 which runs the "-wifiap.img" file:
By default the system's WIFI AP mode is on therefore it cannot search and connect to a wireless router. You need to turn off the WiFi AP mode by following the instructions below:
Step 1: please set up the WIFI rounter you expect to connect to:
Log in the NanoPi2 via SSH. Check the WIFI device by running the following commands. Those starting with "wlan" are WiFi devices:
ifconfig -a
By default "wlan0" is the Wifi device. You need to create a configuration file with the same name under "/etc/network/interfaces.d/". For instance you can create a "wlan0" file:
vi /etc/network/interfaces.d/wlan0
Here is the wlan0's content:
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
The "YourWiFiESSID" and "YourWiFiPassword" need to be replaced with your actual ESSID and password.
Step 2: turn off the AP mode. You need to do this as root. Please run the following commands and your system will be rebooted. After your system rebooted it will automatically connect to the WiFi router you set up in step 1:
su
turn-wifi-into-apmode no
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 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
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 [1]. You need to select the one with "armhf".
6 Make Your Own OS Image
6.1 Setup Development Environment
6.2 Install Cross Compiler
Please download the compiler package:
git clone https://github.com/friendlyarm/prebuilts.git sudo mkdir -p /opt/FriendlyARM/toolchain sudo tar xf prebuilts/gcc-x64/arm-cortexa9-linux-gnueabihf-4.9.3.tar.xz -C /opt/FriendlyARM/toolchain/
Then add the compiler's directory to "PATH" by appending the following lines in "~/.bashrc":
export PATH=/opt/FriendlyARM/toolchain/4.9.3/bin:$PATH export GCC_COLORS=auto
Execute "~/.bashrc" to make the changes into effect. Please note that there is a space after ".":
. ~/.bashrc
This compiler is a 64-bit one therefore it cannot be run on a 32-bit LINUX. After the compiler is installed you can verify it by running the following commands:
arm-linux-gcc -v Using built-in specs. COLLECT_GCC=arm-linux-gcc COLLECT_LTO_WRAPPER=/opt/FriendlyARM/toolchain/4.9.3/libexec/gcc/arm-cortexa9-linux-gnueabihf/4.9.3/lto-wrapper Target: arm-cortexa9-linux-gnueabihf Configured with: /work/toolchain/build/src/gcc-4.9.3/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=arm-cortexa9-linux-gnueabihf --prefix=/opt/FriendlyARM/toolchain/4.9.3 --with-sysroot=/opt/FriendlyARM/toolchain/4.9.3/arm-cortexa9-linux-gnueabihf/sys-root --enable-languages=c,c++ --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=vfpv3 --with-float=hard ... Thread model: posix gcc version 4.9.3 (ctng-1.21.0-229g-FA)
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 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 https://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 )