Difference between revisions of "NanoPi K2"

From FriendlyELEC WiKi
Jump to: navigation, search
(介绍)
(updated by API)
 
(49 intermediate revisions by 3 users not shown)
Line 5: Line 5:
 
[[File:NanoPi K2-2.jpg|thumb|300px]]
 
[[File:NanoPi K2-2.jpg|thumb|300px]]
 
[[File:NanoPi K2-3.jpg|thumb|300px]]
 
[[File:NanoPi K2-3.jpg|thumb|300px]]
* FriendlyElec's NanoPi K2 uses Amlogic's 64-bit quad-core A53 S905 SoC. This SoC has internal Mali450 GPU. S905's dynamic frequency scales up to 2G Hz. Its most significant feature is that it supports various video formats and has strong video decoding capability
+
* FriendlyElec's NanoPi K2 uses Amlogic's 64-bit quad-core A53 S905 SoC. This SoC has an internal Mali450 GPU. S905's dynamic frequency scales up to 2G Hz.In FriendlyElec's tests it can scale up to 2G. Its most significant feature is that it supports various video formats and has strong video decoding capability
* The NanoPi K2 has 2GB DDR3 RAM, onboard WiFi & Bluetooth, 1000M Ethernet, USB, HDMI, IR and etc. It has a socket for external eMMC. It boots OS from a TF card. It has the same form factor and layout of interfaces and ports as the RPi 3. An Android image is ready for K2. Later on a Ubuntu image will be ready.
+
* The NanoPi K2 has 2GB DDR3 RAM, onboard WiFi & Bluetooth, 1000M Ethernet, USB, HDMI, IR and more. It has a socket for adding an external eMMC card. It boots an OS from a TF card. It has the same form factor, GPIO interface and port layout as the RPi 3. An Android image is ready for K2. Later on a Ubuntu image will be ready.
 
* A special feature of the NanoPi K2 is that it supports DVFS and can play high-definition video steams stably and smoothly. It is a good platform for applications such as advertisement machines, TV boxes, home entertainment appliances, multi-media devices and etc.
 
* A special feature of the NanoPi K2 is that it supports DVFS and can play high-definition video steams stably and smoothly. It is a good platform for applications such as advertisement machines, TV boxes, home entertainment appliances, multi-media devices and etc.
  
==资源特性==
+
==Hardware Spec==
* CPU: Amlogic S905, Quad-core ARM Cortex-A53@1.5GHz, DVFS
+
* SoC: Amlogic S905, Quad-core ARM Cortex-A53@1.5GHz, DVFS
 
* GPU: Penta-core ARM Mali™-450
 
* GPU: Penta-core ARM Mali™-450
 
* RAM: 2GB DDR3
 
* RAM: 2GB DDR3
* 以太网: 10/100/1000M (RTL8211F)
+
* Network Connectivity: 10/100/1000M (RTL8211F)
 
* Wireless:802.11 b/g/n
 
* Wireless:802.11 b/g/n
 
* Bluetooth:4.0 dual mode
 
* Bluetooth:4.0 dual mode
* 天线: Wi-Fi和蓝牙共用, 板载陶瓷天线, 同时提供IPX接口
+
* Antenna: One onboard porcelain antenna shared by both WiFi and Bluetooth. One individual IPEX connector.
* 红外:板载红外接收模块
+
* IR: Onboard IR receiver
* 音频:Via HDMI/蓝牙
+
* Audio: Via HDMI/Bluetooth
* eMMC: 板载eMMC模块接口
+
* eMMC interface: eMMC socket
* I2S:板载I2S接口, 7Pin, 2.54mm排针
+
* I2S: 7-Pin, 2.54mm pitch pin-header
* SD: microSD卡槽一个
+
* SD: 1 x MicroSD slot
* USB Host: 4 x USB 2.0 Host, 标准A型接口
+
* USB Host: 4 x USB 2.0 Host, standard type A
* Micro USB: 1 x USB 2.0, 有OTG功能, 可作为电源输入和数据传输
+
* Micro USB: 1 x USB 2.0, OTG, power input and data transmission
* HDMI: HDMI 2.0, Type-A型口, 支持4K显示
+
* HDMI: HDMI 2.0, Type-A. It supports 4K video
* GPIO扩展接口: 40 Pin,2.54mm排针, 包含I2C, ADC, GPIO, UART, PWM, SPDIF, CVBS等
+
* GPIO: 40-Pin, 2.54mm pitch pin-header including I2C, ADC, GPIO, UART, PWM, SPDIF and CVBS
* 调试串口:4Pin,2.5mm单排针
+
* Serial debug port: 4-Pin, 2.54mm pitch single-row pin-header
* 按键:电源按键一个
+
* User Key: 1 x power key
* LED:电源指示灯一个, 系统状态指示灯一个
+
* LED: 1 x power LED and 1 x status LED
* 电源接口:DC电源接口, microUSB接口
+
* Power Interface: DC jack, MicroUSB
* PCB Size:56x85mm,6层,沉金工艺
+
* Power Supply: DC 5V/2A
* 供电: DC 5V/2A
+
* PCB dimension: 56 x 85mm,6-layer, ENIG
  
==接口布局和尺寸==
+
==Software Features==
===接口布局===
+
===UbuntuCore===
[[File:NanoPi-K2-IF-001.png |thumb|600px|NanoPi-K2接口布局]]
+
* it supports output to an HDMI monitor
 +
* it supports WiFi
 +
* it supports Ethernet
 +
* it supports Bluetooth
 +
* built-in Qt-Embedded
  
* '''GPIO管脚定义'''
+
===Android===
 +
* Kodi integrated
 +
 
 +
==Diagram, Layout and Dimension==
 +
===Layout===
 +
[[File:NanoPi-K2-IF-001.png |thumb|600px|NanoPi-K2 Layout]]
 +
 
 +
* '''GPIO Pin Description'''
 
::{| class="wikitable"
 
::{| class="wikitable"
 
|-
 
|-
Line 83: Line 94:
 
|}
 
|}
  
* '''eMMC接口管脚定义'''
+
* '''eMMC Interface Pin Description'''
 
::{| class="wikitable"
 
::{| class="wikitable"
 
|-
 
|-
Line 122: Line 133:
 
|4    || UART_RX_AO_A
 
|4    || UART_RX_AO_A
 
|}
 
|}
* '''7Pin I2S接口定义'''
+
* '''7Pin I2S Interface Pin Description'''
 
::{| class="wikitable"
 
::{| class="wikitable"
 
|-
 
|-
Line 142: Line 153:
 
|}
 
|}
  
:'''说明'''
+
:'''Notes'''
::#SYS_3.3V: 3.3V电源输出
+
::#SYS_3.3V: 3.3V power output
::#VDD_5V: 5V电源输入/输出。输入范围:4.7~5.6V
+
::#VDD_5V: 5V power output5V. The input range is 4.7V ~ 5.6V
::#全部信号引脚均为3.3V电平
+
::#All pins are 3.3V
::#更详细的信息请查看原理图:[http://wiki.friendlyarm.com/wiki/images/d/d1/NanoPi-K2-1701-Schematic.pdf NanoPi-K2-1701-Schematic.pdf]
+
::#For more details refer to the document:[http://wiki.friendlyelec.com/wiki/images/d/d1/NanoPi-K2-1701-Schematic.pdf NanoPi-K2-1701-Schematic.pdf]
  
===机械尺寸===
+
===Board Dimension===
 
[[File:NanoPi-K2-1701-Dim.png|frameless|500px|NanoPi K2 Dimensions]]
 
[[File:NanoPi-K2-1701-Dim.png|frameless|500px|NanoPi K2 Dimensions]]
  
::详细尺寸:[http://wiki.friendlyarm.com/wiki/images/2/26/NanoPi-K2-1701-dxf.zip NanoPi-K2-1701-dxf.zip]
+
::For more details refer to the document:[http://wiki.friendlyelec.com/wiki/images/2/26/NanoPi-K2-1701-dxf.zip NanoPi-K2-1701-dxf.zip]
  
==快速入门==
+
==Get Started==
===准备工作===
+
===Essentials You Need===
启动NanoPi K2前,请先准备好以下硬件
+
Before starting to use your NanoPi K2 get the following items ready
* NanoPi K2主板
+
* NanoPi K2
* TF卡: Class10或以上的 8GB SDHC卡
+
* MicroSD Card/TF Card: Class 10 or Above, minimum 8GB SDHC
* 一个DC接口的外接电源,要求输出为5V/2A
+
* A DC 5V/2A power is a must
* 一台支持HDMI输入的显示器或者电视
+
* HDMI monitor
* 一套USB键盘鼠标
+
* USB keyboard and USB mouse
* 一台电脑,需要联网,建议使用Ubuntu 14.04 64位系统
+
* A host computer running Ubuntu 18.04 64 bit system
  
===经测试使用的TF卡===
+
{{TFCardsWeTested}}
制作启动NanoPi K2的TF卡时,建议Class10或以上的 8GB SDHC卡。以下是经友善之臂测试验证过的高速TF卡:
+
*SanDisk闪迪 TF 8G Class10 Micro/SD 高速 TF卡:
+
[[File:SanDisk MicroSD.png|frameless|100px|SanDisk MicroSD 8G]]
+
*SanDisk闪迪 TF128G 至尊高速MicroSDXC TF 128G Class10 48MB/S:
+
[[File:SanDisk MicroSD-01.png|frameless|100px|SanDisk MicroSD 128G]]
+
*川宇 8G手机内存卡 8GTF卡存储卡 C10高速class10 micro SD卡:
+
[[File:SanDisk MicroSD-02.png|frameless|100px|chuanyu MicroSD 8G]]
+
 
+
===制作一张带运行系统的SD卡===
+
====快速从SD卡启动NanoPi K2====
+
首先访问[http://pan.baidu.com/s/1c2MQ1P2 下载地址1]下载需要的固件文件:<br />
+
* 您需要准备一张4G或以上容量的SDHC卡,该卡的已有数据将会被破坏,因此请先对SD卡上的数据进行备份。
+
  
 +
===Make an Installation TF Card/eMMC Module===
 +
====Boot OS from TF Card/eMMC Module====
 +
Get the following files from [http://dl.friendlyelec.com/nanopik2 download link]: <br />
 +
* Download needed image files and utilities
 
::{| class="wikitable"
 
::{| class="wikitable"
 
|-
 
|-
|colspan=2|固件文件列表:
+
|colspan=2|Image File:
 +
|-
 +
|nanopi-k2_android_5.1.1-YYYYMMDD.img.zip    || Android5.1 Image File for flashing a TF card
 +
|-
 +
|nanopi-k2_ubuntu_core_xenial-YYYYMMDD.img.zip    || Ubuntu-Core with Qt-Embedded Image File for flashing a TF card
 +
|-
 +
|nanopi-k2_android_5.1.1-emmc-YYYYMMDD.img.zip    || Android5.1 Image File for flashing an eMMC module
 
|-
 
|-
|s905-android-sd4g-YYYYMMDD.img.zip     || Android5.1系统固件               
+
|nanopi-k2_ubuntu_core_xenial-emmc-YYYYMMDD.img.zip   || Ubuntu-Core with Qt-Embedded Image File for flashing an eMMC module
 
|-
 
|-
|colspan=2|烧写工具:  
+
|colspan=2|Flash Utility:  
 
|-
 
|-
|win32diskimager.rar || Windows平台下的烧写工具,Linux系统可以用dd命令
+
|win32diskimager.rar || Windows utility. Under Linux users can use "dd"
 
|-  
 
|-  
 
|}
 
|}
 +
=====Flash Image to TF Card=====
 +
* Extract an image file and win32diskimager.rar. Insert a TF card(at least 8G) into a Windows PC and run the win32diskimager utility as administrator. On the utility's main window select your TF card's drive, the wanted image file and click on "write" to start flashing the TF card.
 +
* Insert this card into your NanoPi K2's BOOT slot and power on (with a 5V/2A power source). If both the green LED and blue LED are solid on this indicates your NanoPi K2 has successfully booted.<br />
  
*将固件和烧写工具分别解压,在Windows下插入SD卡(限8G及以上的卡),以管理员身份运行 win32diskimager 工具, 在win32diskimager工具的界面上, 选择你的SD卡盘符,选择你要烧写的系统固件,点击 Write 按钮烧写即可。
+
=====Flash Image to eMMC Module=====
*当制作完成 SD 卡后,拔出 SD 卡插入 NanoPi K2 的 BOOT 卡槽,上电启动(注意,这里需要 5V/2A 的供电),你可以看到绿灯以及蓝灯长亮,这时你已经成功启动 NanoPi K2。<br />
+
* Extract an image file and win32diskimager.rar on a Window PC. Connect an eMMC module to a TF card to eMMC adapter, insert this TF card adapter to a TF to USB adapter and insert this USB adapter to the Windows PC. Run the win32diskimager utility as administrator. On the utility's main window select this TF adapter's drive, the wanted image file and click on "write" to start flashing the eMMC module.
 +
[[File:EMMC_module_1.jpg|400px]][[File:EMMC_module_4.jpg|400px]]
 +
* After flashing is done take off the eMMC module of the TF card adapter. Insert the eMMC module to the eMMC slot on a NanoPi K2 and power on (with a 5V/2A power source) the board. If both the green LED and blue LED are solid on this indicates your NanoPi K2 has successfully booted.<br />
 +
[[File:Emmc_k2.jpg|400px]]
 +
* When a K2 board has both a TF card and an eMMC module inserted it will always boot from the eMMC module. If you want to boot your K2 from a TF card just insert a TF card only and leave the eMMC slot empty.
  
====在Linux Desktop下通过脚本制作====
+
====Make Installation Card under Linux Desktop====
* 1) 将microSD插入Ubuntu的电脑,用以下命令查看你的SD卡设备名
+
*1) Insert your TF card/TF adapter with eMMC flash into a host computer running Ubuntu and check your SD card's device name
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
dmesg | tail
 
dmesg | tail
 
</syntaxhighlight>
 
</syntaxhighlight>
当dmesg输出类拟信息 sdc: sdc1 sdc2时,则表示SD卡对应的设备名为 /dev/sdc,也通过用命令cat /proc/partitions来查看。
+
Search the messages output by "dmesg" for similar words like "sdc: sdc1 sdc2". If you can find them it means your SD card has been recognized as "/dev/sdc". Or you can check that by commanding "cat /proc/partitions".
  
*2) 下载Linux下的制作脚本
+
*2) Downlaod Linux script
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
git clone https://github.com/friendlyarm/sd-fuse_amlogic.git
 
git clone https://github.com/friendlyarm/sd-fuse_amlogic.git
Line 205: Line 221:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
*3) 以下是制作启动Android的SD卡的方法
+
*3) Make Android TF Card
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
su
 
su
./fusing.sh /dev/sdx
+
./fusing.sh /dev/sdx android
 
</syntaxhighlight>
 
</syntaxhighlight>
(注:/dev/sdx请替换为实际的SD卡设备文件名) <br />
+
(Note: you need to replace "/dev/sdx" with the device name in your system)<br/>
制作包中未包含Android烧写文件,第一次使用时会提示需要下载,输入Y下载,N或10秒未输入则取消。
+
When you run the script for the first time it will prompt you to download an image you have to hit “Y” within 10 seconds otherwise you will miss the download
  
====NanoPi K2 扩展TF卡分区====
+
*4) Make Android eMMC Module
* Android扩展分区,要在pc上执行下列操作:
+
<syntaxhighlight lang="bash">
 +
su
 +
./fusing.sh /dev/sdx android emmc
 +
</syntaxhighlight>
 +
(Note: you need to replace "/dev/sdx" with the device name in your system)<br/>
 +
When you run the script for the first time it will prompt you to download an image you have to hit “Y” within 10 seconds otherwise you will miss the download
 +
 
 +
====Extend NanoPi K2's TF Card/eMMC Module Section====
 +
* If your board runs Ubuntu you can skip this section since Ubuntu will automatically extend your TF card's section. When Android is loaded you need to run the following commands on your host PC to extend your TF card's section:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
sudo umount /dev/sdx?
 
sudo umount /dev/sdx?
Line 220: Line 244:
 
sudo resize2fs -f /dev/sdx4
 
sudo resize2fs -f /dev/sdx4
 
</syntaxhighlight>
 
</syntaxhighlight>
(注:/dev/sdx请替换为实际的SD卡设备文件名)
+
(Note: you need to replace "/dev/sdx" with the device name in your system)
  
====关于HDMI分辨率====
+
====HDMI Resolution====
对于HDMI的显示模式,Android则是会通过EDID获得HDMI设备如电视机所支持的显示模式,然后自动选择一个合适的分辨率。
+
If your NanoPi K2 is connected to an HDMI monitor and it runs Android it will automatically set the resolution to an appropriate HDMI mode by checking the "EDID".
  
===运行Android===
+
===Run Android===
* 将制作好SD卡插入NanoPi K2,连接HDMI,最后接电源,NanoPi K2会从SD卡启动。你可以看到板上PWR灯以及蓝灯常亮,这说明系统已经开始启动了,同时电视上也将能看到系统启动的画面。<br />
+
* Insert an SD card with Android image into your NanoPi K2, connect the board to an HDMI monitor, power on the board K2 will boot from the SD card. If you can see the PWR LED on and the blue LED are solid on it means your board is working and you will see Android being loaded on the HDMI monitor.
 +
<br />
 
[[File:NanoPi-K2-4.jpg|frameless|NanoPi K2 Android5.1]]
 
[[File:NanoPi-K2-4.jpg|frameless|NanoPi K2 Android5.1]]
* 如同所有PC, 正确的关机对NanoPi K2而言很重要,否则可能会损坏安装在MicroSD卡中的系统文件,导致下次无法顺利启动运行,如要关机,直接按PWR按键即可。
+
* It is recommended to turn off its power by pressing the PWR key otherwise the system data in the TF card will be damaged.
 +
 
 +
====Play Multi-Media Stream with Kodi====
 +
Kodi is pre-installed on Android. It supports hard-decoding. Here is how Kodi looks like:<br />
 +
[[File:Kodi-Homepage.png|frameless|Kodi-Homepage]] <br />
 +
Insert a USB storage card with a video file to K2's USB port and on Kodi's main window select "Videos -> udisk0" to load and play the video file in the storage card:<br />
 +
[[File:Kodi-Playing.png|frameless|Kodi-Playing]] <br />
 +
 
 +
===Run Ubuntu core===
 +
====Introduction to Ubuntu core====
 +
Ubuntu Core with Qt-Embedded is a light Linux system without X-windows. It uses the Qt-Embedded's GUI and is popular in industrial and enterprise applications.
 +
Besides the regular Ubuntu core's features our Ubuntu-Core has the following additional features:<br/>
 +
* it supports output to an HDMI monitor
 +
* it supports WiFi
 +
* it supports Ethernet
 +
* it supports Bluetooth
 +
* built-in Qt-Embedded
 +
Thanks to A53 SoC's powerful performance, 2G RAM and Gbps Ethernet the NanoPi K2 with Ubuntu is well suited for IoT applications and light server applications such as NAS.
 +
 
 +
====Applications under Ubuntu core====
 +
After you insert an SD card pre-installed with Ubuntu to a NanoPi K2 and power up the board you will observe the following GUI:<br />
 +
[[File:K2-ubuntu.png|frameless|500px|K2-ubuntu]]<br />
 +
 
 +
To enable Qt-Embedded GUI you can run the following command:<br />
 +
<syntaxhighlight lang="bash">
 +
$ sudo /opt/QtE-Demo/run.sh
 +
</syntaxhighlight>
 +
Here is a what you expect to observe. This is an open source Qt Demo application:<br />
 +
[[File:K2-QtE.png|frameless|500px|K2-QtE]]<br />
 +
For more details about Ubuntu Core refer to: [http://wiki.friendlyelec.com/wiki/index.php/Ubuntu_Core_with_Qt-Embedded/zh Ubuntu Core with Qt-Embedded]
  
==如何编译系统==
+
==Make Your Own OS Image==
  
===安装交叉编译器===
+
===Install Cross Compiler===
* 安装ARMv7交叉编译器
+
* Install ARMv7 Cross Compiler
编译U-Boot需要ARMv7的交叉编译器,首先下载并解压编译器:
+
Download the compiler package:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
git clone https://github.com/friendlyarm/prebuilts.git
 
git clone https://github.com/friendlyarm/prebuilts.git
Line 241: Line 295:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
然后将编译器的路径加入到PATH中,用vi编辑vi ~/.bashrc,在末尾加入以下内容:
+
Then add the compiler's directory to "PATH" by appending the following lines in "~/.bashrc".:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
export PATH=/opt/FriendlyARM/toolchain/4.9.3/bin:$PATH
 
export PATH=/opt/FriendlyARM/toolchain/4.9.3/bin:$PATH
Line 247: Line 301:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
执行一下~/.bashrc脚本让设置立即在当前shell窗口中生效,注意"."后面有个空格:
+
Execute "~/.bashrc" to make the changes take effect. Note that there is a space after the first ".":
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
. ~/.bashrc
 
. ~/.bashrc
 
</syntaxhighlight>
 
</syntaxhighlight>
  
这个编译器是64位的,不能在32位的Linux系统上运行,安装完成后,你可以快速的验证是否安装成功:
+
This compiler is a 64-bit one therefore it cannot be run on a 32-bit Linux machine. After the compiler is installed you can verify it by running the following commands:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
arm-linux-gcc -v
 
arm-linux-gcc -v
Line 268: Line 322:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
* 安装AArch64交叉编译器
+
* Install AArch64 Cross Compiler
编译U-Boot和Linux需要AArch64的交叉编译器,可使用linaro toolchain:
+
The AArch64 cross compiler is needed to compile U-Boot and Linux. We used linaro toolchain:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
wget http://releases.linaro.org/components/toolchain/binaries/4.9-2017.01/aarch64-linux-gnu/gcc-linaro-4.9.4-2017.01-x86_64_aarch64-linux-gnu.tar.xz
 
wget http://releases.linaro.org/components/toolchain/binaries/4.9-2017.01/aarch64-linux-gnu/gcc-linaro-4.9.4-2017.01-x86_64_aarch64-linux-gnu.tar.xz
Line 275: Line 329:
 
export PATH=~/gcc-linaro-4.9.4-2017.01-x86_64_aarch64-linux-gnu/bin:$PATH
 
export PATH=~/gcc-linaro-4.9.4-2017.01-x86_64_aarch64-linux-gnu/bin:$PATH
 
</syntaxhighlight>
 
</syntaxhighlight>
可以修改 ~/.bashrc 将编译器的路径加入到PATH中。
+
Add the compiler's directory to "PATH".
  
===编译U-Boot===
+
===Compile U-Boot===
下载U-Boot源代码并编译,注意分支是nanopi-k2-v2015.01:
+
Download the U-Boot source code and compile it. Note that the github's branch is nanopi-k2-v2015.01:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
git clone https://github.com/friendlyarm/uboot.git
+
git clone https://github.com/friendlyarm/u-boot.git uboot
 
cd uboot
 
cd uboot
 
git checkout nanopi-k2-v2015.01
 
git checkout nanopi-k2-v2015.01
Line 287: Line 341:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
编译成功结束后您将获得fip/gxb/u-boot.bin,可使用以下命令直接更新SD卡:
+
After your compilation succeeds a u-boot.bin will be generated. If you want to test it flash it to your installation TF card via fastboot. Here is how you can do it:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
sudo ./fusing.sh /dev/sdc
 
sudo ./fusing.sh /dev/sdc
 
</syntaxhighlight>
 
</syntaxhighlight>
  
您也可以通过fastboot来更新正在运行的NanoPi K2板上SD的U-Boot,方法如下:<br />
+
You can type the following command to update both a TF card and an eMMC Flash
1) 在电脑上先用命令 sudo apt-get install android-tools-fastboot 安装 fastboot 工具;<br />
+
<syntaxhighlight lang="bash">
2) 用串口配件连接NanoPi K2和电脑,在上电启动的2秒内,在串口终端上按下回车,进入 u-boot 的命令行模式;<br />
+
sudo ./fusing.sh /dev/sdc emmc
3) 在u-boot 命令行模式下输入命令 fastboot usb 回车,进入 fastboot 模式;<br />
+
</syntaxhighlight>
4) 用microUSB线连接NanoPi K2和电脑,在电脑上输入以下命令烧写u-boot.bin:<br />
+
 
 +
Or you can do it with fastboot:<br />
 +
1) On your host PC run "sudo apt-get install android-tools-fastboot" to install the fastboot utility;<br/>
 +
2) Connect your NanoPi K2 to your host PC via a serial cable (e.g. PSU-ONECOME). Press the enter key within two seconds right after you power on your NanoPi K2 and you will enter uboot's command line mode;<br/>
 +
3) After type in "fastboot" and press "enter" you will enter the fastboot mode;<br/>
 +
4) Connect your NanoPi K2 to this host PC via a microUSB cable and type in the following command to flash u-boot.bin:<br/>
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
fastboot flash bootloader fip/gxb/u-boot.bin
 
fastboot flash bootloader fip/gxb/u-boot.bin
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
We haven't found a way to update the uboot on an eMMC flash with fastboot.
  
===编译Linux kernel===
+
===Compile Linux kernel===
====编译内核====
+
====Compile Kernel====
* 下载内核源代码
+
* Download Kernel Source Code
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
git clone https://github.com/friendlyarm/linux.git
 
git clone https://github.com/friendlyarm/linux.git
Line 309: Line 369:
 
git checkout nanopi-k2-3.14.y
 
git checkout nanopi-k2-3.14.y
 
</syntaxhighlight>
 
</syntaxhighlight>
NanoPi K2内核所属的分支是nanopi-k2-3.14.y,在开始编译前先切换分支。
+
The NanoPi K2's kernel source code lies in the "nanopi-k2-3.14.y" branch.
* 编译Android内核
+
 
 +
* Compile Android Kernel
 +
<syntaxhighlight lang="bash">
 +
touch .scmversion
 +
make ARCH=arm64 nanopi-k2_android_defconfig
 +
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image nanopi-k2.dtb
 +
</syntaxhighlight>
 +
After your compilation succeeds an arch/arm64/boot/dts/amlogic/nanopi-k2.dtb file and an arch/arm64/boot/Image will be generated. You can use them to replace the existing files under your SD card's boot section.
 +
 
 +
* Compile Ubuntu Kernel
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
make ARCH=arm64 nanopi-k2_defconfig
+
touch .scmversion
 +
make ARCH=arm64 nanopi-k2_ubuntu_defconfig
 
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image nanopi-k2.dtb
 
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image nanopi-k2.dtb
 
</syntaxhighlight>
 
</syntaxhighlight>
编译成功结束后,即会生成新的 arch/arm64/boot/dts/amlogic/nanopi-k2.dtb 和 arch/arm64/boot/Image ,用于替换掉SD卡boot分区下对应的文件。
 
  
====如何使用新编译的内核====
+
====User Your Generated Kernel====
* 更新SD卡上的内核
+
* Update the kernel file in SD card
如果您是使用SD卡启动Android,则在PC上复制为Android编译的Image 和nanopi-k2.dtb 到SD卡的boot分区(即分区1,设备是/dev/sdX1)即可。<br />
+
If you use an SD card to boot Android you can copy your generated uImage file and nanopi-k2.dtb file to your SD card's boot section(e.g. section 1 /dev/sdX1).<br/>
  
* 通过adb直接更新
+
* Update kernel with adb
如果想直接更新正在运行中的板子,可通过adb将新的文件push到板子上,然后reboot即可,具体如下:
+
You can update your kernel with adb and here is how you can do it:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
adb shell mount -t ext4 /dev/block/mmcblk0p1 /storage/sdcard1/
 
adb shell mount -t ext4 /dev/block/mmcblk0p1 /storage/sdcard1/
Line 330: Line 399:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
* 更新Android中预先编译的文件
+
* Update Image and nanopi-k2.dtb
如果想要生成新的Android boot.img,则需要使用新生成的文件替换Android源代码目录device/friendly-arm/nanopi-k2-kernel 下对应的文件,然后编译Android即可。
+
If you want to generate a new Android's boot.img you need to use your newly generated image and nanopi-k2.dtb to replace the existing files under "device/friendly-arm/nanopi-k2-kernel" and recompile Android.
  
===编译Android===
+
===Compile Android===
* 搭建编译环境
+
* Install Cross Compiler
搭建编译Android的环境建议使用64位的Ubuntu 14.04,安装需要的包即可。
+
Install a 64-bit Ubuntu 16.04 on your host PC
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
sudo apt-get install bison g++-multilib git gperf libxml2-utils make python-networkx zip
 
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
 
sudo apt-get install flex libncurses5-dev zlib1g-dev gawk minicom
 
</syntaxhighlight>
 
</syntaxhighlight>
更多说明可查看 https://source.android.com/source/initializing.html
+
For more details refer to https://source.android.com/source/initializing.html  
  
* 下载Android5.1源代码
+
* Download Android5.1 Source Code
Android源代码的下载需要使用repo,其安装和使用请查看 https://source.android.com/source/downloading.html
+
You need to use repo to get the Android source code. Refer to https://source.android.com/source/downloading.html .
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
mkdir android && cd android
 
mkdir android && cd android
Line 349: Line 418:
 
repo sync
 
repo sync
 
</syntaxhighlight>
 
</syntaxhighlight>
其中“android”是指工作目录。<br />
+
"android" is the working directory.<br />
  
* 编译系统
+
* Compile System
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
source build/envsetup.sh
 
source build/envsetup.sh
Line 357: Line 426:
 
make -j8
 
make -j8
 
</syntaxhighlight>
 
</syntaxhighlight>
编译成功完成后,目录 out/target/product/nanopi-k2 下包含可用于烧写的image文件。
+
After compilation succeeds an image file will be generated under "out/target/product/nanopi-k2"
 
::{| class="wikitable"
 
::{| class="wikitable"
 
|-
 
|-
Line 372: Line 441:
 
|system.img  || system    || -
 
|system.img  || system    || -
 
|-  
 
|-  
|partmap.txt  || -        || 分区描述文件
+
|partmap.txt  || -        || partition file
 
|-  
 
|-  
 
|}
 
|}
  
* 烧写到SD卡
+
* Flash Image to SD Card
如果是采用SD卡启动Android,可复制编译生成的image文件到sd-fuse_amlogic/android/ 下,使用脚本即可烧到到SD卡,具体请查看[[#在Linux Desktop下通过脚本制作]]
+
If you want to boot your board from an SD card you need to copy your generated image file to the "sd-fuse_amlogic/android/" directory and flash it to your SD card with our script. For more details refer to [[# Make Installation Card under Linux Desktop]].
  
* 使用fastboot更新
+
* Update Image with fastboot
板子启动后通过串口快速按任意键进入uboot命令行模式,输入命令fastboot usb即可更新Android。<br />
+
Right after the NanoPi K2 is booted press any key to enter the uboot commandline mode and type in "fastboot usb"<br />
连接USB线,然后PC端输入以下命令:
+
Connect your K2 to a host PC with a USB cable and type the following commands from your PC's terminal:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
cd out/target/product/nanopi-k2
 
cd out/target/product/nanopi-k2
Line 390: Line 459:
 
sudo fastboot reboot
 
sudo fastboot reboot
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
{{MoreOS}}
 +
 +
==Update Log==
 +
===April-14-2017===
 +
* Released English version
 +
 +
===June-4-2017===
 +
* Added section 4.5: kodi support
 +
 +
===July-21-2017===
 +
* Added sections 3 and 5.5
 +
 +
===Nov-17-2017===
 +
* Added sections 5.3.1.2
 +
* Updated sections 5.3.1, 5.3.3, 6.2 and 6.3

Latest revision as of 07:18, 21 February 2022

查看中文

1 Introduction

NanoPi K2-1.jpg
NanoPi K2-2.jpg
NanoPi K2-3.jpg
  • FriendlyElec's NanoPi K2 uses Amlogic's 64-bit quad-core A53 S905 SoC. This SoC has an internal Mali450 GPU. S905's dynamic frequency scales up to 2G Hz.In FriendlyElec's tests it can scale up to 2G. Its most significant feature is that it supports various video formats and has strong video decoding capability
  • The NanoPi K2 has 2GB DDR3 RAM, onboard WiFi & Bluetooth, 1000M Ethernet, USB, HDMI, IR and more. It has a socket for adding an external eMMC card. It boots an OS from a TF card. It has the same form factor, GPIO interface and port layout as the RPi 3. An Android image is ready for K2. Later on a Ubuntu image will be ready.
  • A special feature of the NanoPi K2 is that it supports DVFS and can play high-definition video steams stably and smoothly. It is a good platform for applications such as advertisement machines, TV boxes, home entertainment appliances, multi-media devices and etc.

2 Hardware Spec

  • SoC: Amlogic S905, Quad-core ARM Cortex-A53@1.5GHz, DVFS
  • GPU: Penta-core ARM Mali™-450
  • RAM: 2GB DDR3
  • Network Connectivity: 10/100/1000M (RTL8211F)
  • Wireless:802.11 b/g/n
  • Bluetooth:4.0 dual mode
  • Antenna: One onboard porcelain antenna shared by both WiFi and Bluetooth. One individual IPEX connector.
  • IR: Onboard IR receiver
  • Audio: Via HDMI/Bluetooth
  • eMMC interface: eMMC socket
  • I2S: 7-Pin, 2.54mm pitch pin-header
  • SD: 1 x MicroSD slot
  • USB Host: 4 x USB 2.0 Host, standard type A
  • Micro USB: 1 x USB 2.0, OTG, power input and data transmission
  • HDMI: HDMI 2.0, Type-A. It supports 4K video
  • GPIO: 40-Pin, 2.54mm pitch pin-header including I2C, ADC, GPIO, UART, PWM, SPDIF and CVBS
  • Serial debug port: 4-Pin, 2.54mm pitch single-row pin-header
  • User Key: 1 x power key
  • LED: 1 x power LED and 1 x status LED
  • Power Interface: DC jack, MicroUSB
  • Power Supply: DC 5V/2A
  • PCB dimension: 56 x 85mm,6-layer, ENIG

3 Software Features

3.1 UbuntuCore

  • it supports output to an HDMI monitor
  • it supports WiFi
  • it supports Ethernet
  • it supports Bluetooth
  • built-in Qt-Embedded

3.2 Android

  • Kodi integrated

4 Diagram, Layout and Dimension

4.1 Layout

NanoPi-K2 Layout
  • GPIO Pin Description
Pin# Name Pin# Name
1 SYS_3.3V 2 VDD_5V
3 GPIODV_24/I2C_SDA_A 4 VDD_5V
5 GPIODV_25/I2C_SCK_A 6 GND
7 GPIOY_0 8 GPIOY_13/UART_TX_C
9 DGND 10 GPIOY_13/UART_RX_C
11 GPIOY_1 12 GPIOY_16/PWM_A
13 GPIOY_2 14 GND
15 GPIOY_3 16 GPIOY_15/PWM_F
17 SYS_3.3V 18 GPIOY_4
19 GPIOY_5 20 GND
21 GPIOY_7 22 GPIOY_6
23 GPIOY_9 24 GPIOY_8
25 DGND 26 GPIOY_10
27 GPIODV_26/I2C_SDA_B 28 GPIODV_27/I2C_SCK_B
29 GPIOY_11/SPDIF_IN 30 GND
31 GPIOAO_5 32 GPIOY_12/SPDIF_OUT
33 GPIOH_3 34 GND
35 GPIOCLK_1 36 CVBS
37 AIN1 38 1.8V Vref Out
39 GND 40 AIN0
  • eMMC Interface Pin Description
Pin# Name Pin# Name
1 eMMC_D0 2 eMMC_D1
3 eMMC_D2 4 eMMC_D3
5 eMMC_D4 6 eMMC_D5
7 eMMC_D6 8 eMMC_D7
9 eMMC_DS 10 GND
11 eMMC_CMD 12 eMMC_CLK
13 NC 14 GND
15 NC 16 1.8V OUT
17 eMMC_RST 18 3.3V OUT
19 GPIOY_5 20 GND
  • Debug Port(UART0)
Pin# Name
1 GND
2 VDD_5V
3 UART_TX_AO_A
4 UART_RX_AO_A
  • 7Pin I2S Interface Pin Description
Pin# Name
1 GND
2 SYS_3.3V
3 I2S_SCLK
4 I2S_LRCLK
5 I2S_DATA_OUT
6 I2S_DATA_IN
7 I2S_MCLK
Notes
  1. SYS_3.3V: 3.3V power output
  2. VDD_5V: 5V power output5V. The input range is 4.7V ~ 5.6V
  3. All pins are 3.3V
  4. For more details refer to the document:NanoPi-K2-1701-Schematic.pdf

4.2 Board Dimension

NanoPi K2 Dimensions

For more details refer to the document:NanoPi-K2-1701-dxf.zip

5 Get Started

5.1 Essentials You Need

Before starting to use your NanoPi K2 get the following items ready

  • NanoPi K2
  • MicroSD Card/TF Card: Class 10 or Above, minimum 8GB SDHC
  • A DC 5V/2A power is a must
  • HDMI monitor
  • USB keyboard and USB mouse
  • A host computer running Ubuntu 18.04 64 bit system

5.2 TF Cards We Tested

To make your device boot and run fast we highly recommend you use a Class10 8GB SDHC TF card or a better one. The following cards are what we used in all our test cases presented here:

  • Sandisk MicroSDHC V30 32GB Extreme Pro (Developer choice)

SanDiskExtremePro

  • SanDisk 32GB High Endurance Video MicroSDHC Card with Adapter for Dash Cam and Home Monitoring Systems (High reliability)

SanDiskHighEndurance

  • SanDisk TF 8G Class10 Micro/SD High Speed TF card:

SanDisk microSD 8G

  • SanDisk TF128G MicroSDXC TF 128G Class10 48MB/S:

SanDisk microSD 128G

  • 川宇 8G C10 High Speed class10 micro SD card:

chuanyu microSD 8G

5.3 Make an Installation TF Card/eMMC Module

5.3.1 Boot OS from TF Card/eMMC Module

Get the following files from download link:

  • Download needed image files and utilities
Image File:
nanopi-k2_android_5.1.1-YYYYMMDD.img.zip Android5.1 Image File for flashing a TF card
nanopi-k2_ubuntu_core_xenial-YYYYMMDD.img.zip Ubuntu-Core with Qt-Embedded Image File for flashing a TF card
nanopi-k2_android_5.1.1-emmc-YYYYMMDD.img.zip Android5.1 Image File for flashing an eMMC module
nanopi-k2_ubuntu_core_xenial-emmc-YYYYMMDD.img.zip Ubuntu-Core with Qt-Embedded Image File for flashing an eMMC module
Flash Utility:
win32diskimager.rar Windows utility. Under Linux users can use "dd"
5.3.1.1 Flash Image to TF Card
  • Extract an image file and win32diskimager.rar. Insert a TF card(at least 8G) into a Windows PC and run the win32diskimager utility as administrator. On the utility's main window select your TF card's drive, the wanted image file and click on "write" to start flashing the TF card.
  • Insert this card into your NanoPi K2's BOOT slot and power on (with a 5V/2A power source). If both the green LED and blue LED are solid on this indicates your NanoPi K2 has successfully booted.
5.3.1.2 Flash Image to eMMC Module
  • Extract an image file and win32diskimager.rar on a Window PC. Connect an eMMC module to a TF card to eMMC adapter, insert this TF card adapter to a TF to USB adapter and insert this USB adapter to the Windows PC. Run the win32diskimager utility as administrator. On the utility's main window select this TF adapter's drive, the wanted image file and click on "write" to start flashing the eMMC module.

EMMC module 1.jpgEMMC module 4.jpg

  • After flashing is done take off the eMMC module of the TF card adapter. Insert the eMMC module to the eMMC slot on a NanoPi K2 and power on (with a 5V/2A power source) the board. If both the green LED and blue LED are solid on this indicates your NanoPi K2 has successfully booted.

Emmc k2.jpg

  • When a K2 board has both a TF card and an eMMC module inserted it will always boot from the eMMC module. If you want to boot your K2 from a TF card just insert a TF card only and leave the eMMC slot empty.

5.3.2 Make Installation Card under Linux Desktop

  • 1) Insert your TF card/TF adapter with eMMC flash into a host computer 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 has been recognized as "/dev/sdc". Or you can check that by commanding "cat /proc/partitions".

  • 2) Downlaod Linux script
git clone https://github.com/friendlyarm/sd-fuse_amlogic.git
cd sd-fuse_amlogic
  • 3) Make Android TF Card
su
./fusing.sh /dev/sdx android

(Note: you need to replace "/dev/sdx" with the device name in your system)
When you run the script for the first time it will prompt you to download an image you have to hit “Y” within 10 seconds otherwise you will miss the download

  • 4) Make Android eMMC Module
su
./fusing.sh /dev/sdx android emmc

(Note: you need to replace "/dev/sdx" with the device name in your system)
When you run the script for the first time it will prompt you to download an image you have to hit “Y” within 10 seconds otherwise you will miss the download

5.3.3 Extend NanoPi K2's TF Card/eMMC Module Section

  • If your board runs Ubuntu you can skip this section since Ubuntu will automatically extend your TF card's section. When Android is loaded you need to run the following commands on your host PC to extend your TF card's section:
sudo umount /dev/sdx?
sudo parted /dev/sdx unit % resizepart 4 100 unit MB print
sudo resize2fs -f /dev/sdx4

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

5.3.4 HDMI Resolution

If your NanoPi K2 is connected to an HDMI monitor and it runs Android it will automatically set the resolution to an appropriate HDMI mode by checking the "EDID".

5.4 Run Android

  • Insert an SD card with Android image into your NanoPi K2, connect the board to an HDMI monitor, power on the board K2 will boot from the SD card. If you can see the PWR LED on and the blue LED are solid on it means your board is working and you will see Android being loaded on the HDMI monitor.


NanoPi K2 Android5.1

  • It is recommended to turn off its power by pressing the PWR key otherwise the system data in the TF card will be damaged.

5.4.1 Play Multi-Media Stream with Kodi

Kodi is pre-installed on Android. It supports hard-decoding. Here is how Kodi looks like:
Kodi-Homepage
Insert a USB storage card with a video file to K2's USB port and on Kodi's main window select "Videos -> udisk0" to load and play the video file in the storage card:
Kodi-Playing

5.5 Run Ubuntu core

5.5.1 Introduction to Ubuntu core

Ubuntu Core with Qt-Embedded is a light Linux system without X-windows. It uses the Qt-Embedded's GUI and is popular in industrial and enterprise applications. Besides the regular Ubuntu core's features our Ubuntu-Core has the following additional features:

  • it supports output to an HDMI monitor
  • it supports WiFi
  • it supports Ethernet
  • it supports Bluetooth
  • built-in Qt-Embedded

Thanks to A53 SoC's powerful performance, 2G RAM and Gbps Ethernet the NanoPi K2 with Ubuntu is well suited for IoT applications and light server applications such as NAS.

5.5.2 Applications under Ubuntu core

After you insert an SD card pre-installed with Ubuntu to a NanoPi K2 and power up the board you will observe the following GUI:
K2-ubuntu

To enable Qt-Embedded GUI you can run the following command:

$ sudo /opt/QtE-Demo/run.sh

Here is a what you expect to observe. This is an open source Qt Demo application:
K2-QtE
For more details about Ubuntu Core refer to: Ubuntu Core with Qt-Embedded

6 Make Your Own OS Image

6.1 Install Cross Compiler

  • Install ARMv7 Cross Compiler

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 take effect. Note that there is a space after the first ".":

. ~/.bashrc

This compiler is a 64-bit one therefore it cannot be run on a 32-bit Linux machine. 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)
  • Install AArch64 Cross Compiler

The AArch64 cross compiler is needed to compile U-Boot and Linux. We used linaro toolchain:

wget http://releases.linaro.org/components/toolchain/binaries/4.9-2017.01/aarch64-linux-gnu/gcc-linaro-4.9.4-2017.01-x86_64_aarch64-linux-gnu.tar.xz
tar xf gcc-linaro-4.9.4-2017.01-x86_64_aarch64-linux-gnu.tar.xz
export PATH=~/gcc-linaro-4.9.4-2017.01-x86_64_aarch64-linux-gnu/bin:$PATH

Add the compiler's directory to "PATH".

6.2 Compile U-Boot

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

git clone https://github.com/friendlyarm/u-boot.git uboot
cd uboot
git checkout nanopi-k2-v2015.01
make nanopi-k2_defconfig
make

After your compilation succeeds a u-boot.bin will be generated. If you want to test it flash it to your installation TF card via fastboot. Here is how you can do it:

sudo ./fusing.sh /dev/sdc

You can type the following command to update both a TF card and an eMMC Flash

sudo ./fusing.sh /dev/sdc emmc

Or you can do it with fastboot:
1) On your host PC run "sudo apt-get install android-tools-fastboot" to install the fastboot utility;
2) Connect your NanoPi K2 to your host PC via a serial cable (e.g. PSU-ONECOME). Press the enter key within two seconds right after you power on your NanoPi K2 and you will enter uboot's command line mode;
3) After type in "fastboot" and press "enter" you will enter the fastboot mode;
4) Connect your NanoPi K2 to this host PC via a microUSB cable and type in the following command to flash u-boot.bin:

fastboot flash bootloader fip/gxb/u-boot.bin

We haven't found a way to update the uboot on an eMMC flash with fastboot.

6.3 Compile Linux kernel

6.3.1 Compile Kernel

  • Download Kernel Source Code
git clone https://github.com/friendlyarm/linux.git
cd linux
git checkout nanopi-k2-3.14.y

The NanoPi K2's kernel source code lies in the "nanopi-k2-3.14.y" branch.

  • Compile Android Kernel
touch .scmversion
make ARCH=arm64 nanopi-k2_android_defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image nanopi-k2.dtb

After your compilation succeeds an arch/arm64/boot/dts/amlogic/nanopi-k2.dtb file and an arch/arm64/boot/Image will be generated. You can use them to replace the existing files under your SD card's boot section.

  • Compile Ubuntu Kernel
touch .scmversion
make ARCH=arm64 nanopi-k2_ubuntu_defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image nanopi-k2.dtb

6.3.2 User Your Generated Kernel

  • Update the kernel file in SD card

If you use an SD card to boot Android you can copy your generated uImage file and nanopi-k2.dtb file to your SD card's boot section(e.g. section 1 /dev/sdX1).

  • Update kernel with adb

You can update your kernel with adb and here is how you can do it:

adb shell mount -t ext4 /dev/block/mmcblk0p1 /storage/sdcard1/
adb push arch/arm64/boot/Image /storage/sdcard1/
adb push arch/arm64/boot/dts/amlogic/nanopi-k2.dtb /storage/sdcard1/
adb reboot
  • Update Image and nanopi-k2.dtb

If you want to generate a new Android's boot.img you need to use your newly generated image and nanopi-k2.dtb to replace the existing files under "device/friendly-arm/nanopi-k2-kernel" and recompile Android.

6.4 Compile Android

  • Install Cross Compiler

Install a 64-bit Ubuntu 16.04 on your host PC

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 refer to https://source.android.com/source/initializing.html

  • Download Android5.1 Source Code

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

mkdir android && cd android
repo init -u https://github.com/friendlyarm/android_manifest.git -b nanopi-k2-lollipop
repo sync

"android" is the working directory.

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

After compilation succeeds an image file will be generated under "out/target/product/nanopi-k2"

filename partition Description
u-boot.bin bootloader -
boot.img boot -
cache.img cache -
userdata.img userdata -
system.img system -
partmap.txt - partition file
  • Flash Image to SD Card

If you want to boot your board from an SD card you need to copy your generated image file to the "sd-fuse_amlogic/android/" directory and flash it to your SD card with our script. For more details refer to # Make Installation Card under Linux Desktop.

  • Update Image with fastboot

Right after the NanoPi K2 is booted press any key to enter the uboot commandline mode and type in "fastboot usb"
Connect your K2 to a host PC with a USB cable and type the following commands from your PC's terminal:

cd out/target/product/nanopi-k2
sudo fastboot flash boot boot.img
sudo fastboot flash cache cache.img
sudo fastboot flash userdata userdata.img
sudo fastboot flash system system.img
sudo fastboot reboot

7 More OS Support

7.1 DietPi

Dietpi-logo.png
DietPi is a highly optimised & minimal Debian-based Linux distribution. DietPi is extremely lightweight at its core, and also extremely easy to install and use.
Setting up a single board computer (SBC) or even a computer, for both regular or server use, takes time and skill. DietPi provides an easy way to install and run favourite software you choose.
For more information, please visit this link https://dietpi.com/docs/.

DietPi supports many of the NanoPi board series, you may download the image file from here:

8 Update Log

8.1 April-14-2017

  • Released English version

8.2 June-4-2017

  • Added section 4.5: kodi support

8.3 July-21-2017

  • Added sections 3 and 5.5

8.4 Nov-17-2017

  • Added sections 5.3.1.2
  • Updated sections 5.3.1, 5.3.3, 6.2 and 6.3