HiKey(LeMaker version):快速入门

From BananaPro/Pi
Jump to: navigation, search
This page is a translated version of the page HiKey(LeMaker version):Quick Start and the translation is 74% complete.

Other languages:
English • ‎中文(简体)‎

按照本快速入门指南,可以在很短的时间配置并使用Hikey。启动Hikey需要完成以下步骤。

Get what we need

MicroSD Card(Optional)
We recommend a 4GB or greater class 10 MicroSD card.

标准HDMI转HDMI或VGA线
如果没有HDMI显示器,可以使用标准HDMI转 VGA 线连接显示设备。

键盘鼠标(可选)
任何标准USB接口的键盘鼠标都可以,键盘和鼠标可能会需要较大的功率,所以可能需要使用一个USB集线器。

DC插电源适配器
12V@2A,5.5*2.1 mm直流电源适配器。

Linux PC电脑
建议在WindowsPC上安装VMware Workstation虚拟机,再在虚拟机上安装Ubuntu系统。

USB线
用于烧写系统镜像。

跳线帽
用于烧写系统镜像。

附件图片如下图所示:
HiKey accessories.png

Prepare for installing OS

In order to enjoy our HiKey, we will need to install an Operating System (OS) onto the Micro SD card or the EMMC NAND Flash, we can install an Debian OS into the Micro SD card or the EMMC NAND Flash, but we only can install an Android OS onto the EMMC NAND Flash now. The instructions below will teach us how to flash an OS image to the Micro SD card or EMMC NAND Flash with the help of the Linux PC.

下载系统镜像文件

我们可以从LeMaker Hikey Resourse下载Release版本系统镜像文件,并且在https://builds.96boards.org/releases/hikey/linaro/binaries/latest/下载烧写环境工具和bootloader。

(注意:Release版本是稳定的版本,Snapshot是不稳定的版本,因此,我们应该下载Release版本的系统镜像文件。)

在烧写系统镜像之前,我们需要下面的文件:

文件类型 Debian系统EMMC Debian系统SD卡 Android系统
烧写环境 hisi-idt.py
l-loader.bin
hisi-idt.py
l-loader.bin
hisi-idt.py
l-loader.bin
引导加载程序 fip.bin
ptable-linux-8g.img
nvme.img
fip.bin
ptable-linux-8g.img
nvme.img
fip.bin
ptable-aosp-8g.img
nvme.img
内核 boot-fat.uefi.img hikey-jessie_alip_2015MMDD-nnn.img(包括内核和文件系统) boot_fat.uefi.img
文件系统 hikey-jessie_alip_2015MMDD-nnn-8g.emmc.img cache.img
system.img
userdata-8g.img

注意: Debian SD卡启动镜像只有一个包含了内核和文件系统的镜像文件(hikey-jessie_alip_2015MMDD-nnn.img) 如果是系统是从SD卡启动,Debian OS将运行EMMC中的bootloader,从SD卡的第一个分区加载kernel,并挂载SD卡的第二个分区为根文件系统。

准备软件硬件环境

第1步: 在桌面PC机上安装Ubuntu Ubuntu 14.04 LTSFedora

第2步: 在桌面PC机上安fastboot工具。
I. 输入下面命令安装fastboot工具

sudo apt-get update
sudo apt-get install android-tools-fastboot      // On Debian/Ubuntu

sudo yum update
sudo yum install android-tools                   // On Fedora

注意:如果安装失败,请在/etc/apt/sources.list文件中添加以下内容:

deb http://archive.ubuntu.com/ubuntu trusty universe restricted main multiverse

II. 创建文件/etc/udev/rules.d/51-android.rules,使用超级用户权限,打开文件。

$ sudo vim /etc/udev/rules.d/51-android.rules 
或者,我们也可以用下面命令:
$ sudo gedit /etc/udev/rules.d/51-android.rules

然后,添加下面的内容到文件中:

# fastboot protocol on HiKey
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="d00d", MODE="0660", GROUP="dialout"
# adb protocol on HiKey
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", ATTR{idProduct}=="1057", MODE="0660", GROUP="dialout"
# rndis for HiKey
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", ATTR{idProduct}=="1050", MODE="0660", GROUP="dialout"

第3步:连接跳线帽1和2,通过microUSB线连接Linux PC和Hikey,再接通电源。准备Hikey烧录。

请参考Setting_Jumper了解它们是如何工作的。

1-4-1.png
第4步: 配置烧录环境
I. 下载系统镜像文件并解压后,我们需要下列这些文件并复制到Linux PC。

hisi-idt.py
l-loader.bin

II. 检查Hikey是否被Linux PC识别。通过执行ls /dev/ttyUSB*命令,如果出现/dev/ttyUSB0节点则被识别,否则没有被识别。

ls /dev/ttyUSB*
/dev/ttyUSB0

III. 进入下载文件当前目录下,执行下列命令准备fastboot烧写环境。

sudo apt-get install python2.7 python2.7-dev
alias python=python2.7
sudo python hisi-idt.py -d /dev/ttyUSB0 --img1=l-loader.bin

如果运行成功,将会打印出下面的消息:

+----------------------+
 Serial:  /dev/ttyUSB0
 Image1:  l-loader.bin
 Image2:  
+----------------------+
Sending l-loader.bin ...
Done

Install Debian OS

HiKey boot sequence and condition on Debian:
EMMC boot: if we don’t insert an SD card which already had the Debian OS, HiKey will boot from EMMC.
SD boot: if we insert an SD card which already had Debian OS, HiKey will boot from SD card.

SD卡与EMMC烧录差异在于烧录文件系统镜像

烧写EMMC sudo fastboot flash system hikey-jessie_alip_2015MMDD-nnn-8g.emmc.img
烧写SD卡 sudo dd if=hikey-jessie_alip_2015MMDD-nnn.img of=/dev/sdb bs=4M oflag=sync status=noxfer

EMMC启动烧录

第1步: 烧录Bootloader。(一般情况下,Hikey已经预装了Bootloader,所以不用安装)。
I.下载系统镜像文件并解压后,我们需要下列这些文件并复制到Linux PC:

fip.bin
ptable-linux-8g.img
nvme.img

II.执行sudo fastboot devices命令,检查Hikey是否被Linux PC识别。如果出现“0123456789abcdef fastboot”则被识别。(有时需要多尝试几次)

sudo fastboot devices
0123456789abcdef fastboot

III.执行下列命令烧写镜像文件

sudo fastboot flash ptable ptable-linux-8g.img
sudo fastboot flash fastboot fip.bin
sudo fastboot flash nvme nvme.img

如果烧写成功,将会打印下面的信息

sudo fastboot flash ptable ptable-linux-8g.img
target reported max download size of 268435456 bytes
sending 'ptable' (17 KB)...
OKAY [  0.008s]
writing 'ptable'...
OKAY [  0.006s]
finished. total time: 0.014s
sudo fastboot flash fastboot fip.bin
target reported max download size of 268435456 bytes
sending 'fastboot' (1389 KB)...
OKAY [  0.172s]
writing 'fastboot'...
OKAY [  0.066s]
finished. total time: 0.239s
sudo fastboot flash nvme nvme.img
target reported max download size of 268435456 bytes
sending 'nvme' (128 KB)...
OKAY [  0.015s]
writing 'nvme'...
OKAY [  0.009s]
finished. total time: 0.024s

第2步: 烧写内核镜像
I. 下载系统镜像文件并解压后,我们需要下列这些文件并复制到Linux PC。

boot-fat.uefi.img

II. 执行sudo fastboot devices命令,检查Hikey是否被Linux PC识别。如果出现“0123456789abcdef fastboot”则被识别。(有时需要多尝试几次)

sudo fastboot devices
0123456789abcdef fastboot

III.执行下面命令烧录系统镜像文件。

sudo fastboot flash boot boot-fat.uefi.img

如果运行成功,将会打印下面的信息:

sudo fastboot flash boot boot-fat.uefi.img
target reported max download size of 268435456 bytes
sending 'boot' (65536 KB)...
OKAY [  8.560s]
writing 'boot'...
OKAY [  3.007s]
finished. total time: 11.577s

第3步:烧写文件系统到EMMC
I. 下载系统镜像文件并解压后,我们需要下列这些文件并复制到Linux PC:

hikey-jessie_alip_2015MMDD-nnn-8g.emmc.img (for 8G board)

II. 执行sudo fastboot devices命令,检查Hikey是否被Linux PC识别。如果出现“0123456789abcdef fastboot”则被识别。(有时需要多尝试几次)

sudo fastboot devices
0123456789abcdef fastboot

III. 执行下面命令烧录文件系统镜像文件。

sudo fastboot flash system hikey-jessie_alip_2015MMDD-nnn-8g.emmc.img

如果运行成功,将打印下面的信息:

sudo fastboot flash system hikey-jessie_alip_2015MMDD-nnn-8g.emmc.img
target reported max download size of 268435456 bytes
sending sparse 'system' (260454 KB)...
OKAY [ 38.809s]
writing 'system'...
OKAY [ 15.000s]
sending sparse 'system' (260459 KB)...
OKAY [ 44.258s]
writing 'system'...
OKAY [ 17.645s]
sending sparse 'system' (260424 KB)...
OKAY [ 35.242s]
writing 'system'...
OKAY [ 13.537s]
sending sparse 'system' (260492 KB)...
OKAY [ 53.653s]
writing 'system'...
OKAY [ 21.689s]
sending sparse 'system' (258533 KB)...
OKAY [ 75.170s]
writing 'system'...
OKAY [ 29.901s]
sending sparse 'system' (262083 KB)...
OKAY [ 66.641s]
writing 'system'...
OKAY [ 26.263s]
sending sparse 'system' (200149 KB)...
OKAY [ 88.677s]
writing 'system'...
OKAY [ 33.593s]
finished. total time: 560.080s

这时Hikey系统烧录完成,拔掉跳线帽2,通过HDMI连接显示屏,重新拔插电源即可从EMMC启动系统,进入Debian系统。

Flashing SD Card

We have two methods to flash SD Card.

在Ubuntu下烧录SD卡

步骤1和烧写EMMC完全一致,因为我们必须将bootloader安装到EMMC上,我仅需将内核和文件系统烧写到SD卡中。

第1步: 烧写bootloader和烧写EMMC过程一样。(一般情况下,Hikey已经预装了Bootloader,所以不用安装)

第2步: 烧写文件系统到SD卡。
I. 格式化SD卡。
II. 下载系统镜像文件并解压后,我们需要下列这些文件并复制到Linux PC:

hikey-jessie_alip_2015MMDD-nnn.img

III.将SD卡插入Linux PC中,使用sudo fdisk命令查看SD卡的设备节点。如/dev/sdb,/dev/sdc。如果SD卡被挂载,使用mount命令也可以查看。

sudo fdisk -l
 
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00023435
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048    39845887    19921920   83  Linux
/dev/sda2        39847934    41940991     1046529    5  Extended
/dev/sda5        39847936    41940991     1046528   82  Linux swap / Solaris
 
WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
 
 
Disk /dev/sdb: 7948 MB, 7948206080 bytes
255 heads, 63 sectors/track, 966 cylinders, total 15523840 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1     7167999     3583999+  ee  GPT

IV. 执行下面命令烧录系统镜像文件。(当SD卡设备节点为/dev/sdb时,如果是其他节点,替换即可)

sudo dd if= hikey-jessie_alip_2015MMDD-nnn.img of=/dev/sdb bs=4M oflag=sync status=noxfer

如果运行成功,将打印下面的信息:

sudo dd if= hikey-jessie_alip_2015MMDD-nnn.img of=/dev/sdb bs=4M oflag=sync status=noxfer
512+0 records in
512-0 records out

这时系统镜像已经烧录到SD卡中。可以从Linux PC中拔出SD卡。拔掉跳线帽2,SD卡插入到Hikey,通过HDMI连接显示屏,重新拔插电源即可从SD卡启动系统,进入Debian系统。

Flashing SD Card on Windows

The step 1 for flashing SD card are the same as flashing EMMC . Because we must install the bootloader into the EMMC, we just need to flash the kernel and file system into the SD card.

第1步: 烧写bootloader和烧写EMMC过程一样。(一般情况下,Hikey已经预装了Bootloader,所以不用安装)。

第2步: 烧写文件系统到SD卡。
I. 格式化SD卡。
下载并安装SDFormatter工具SDFormatter。在"Options"菜单中,设置 "FORMAT TYPE"选项为 QUICK, "FORMAT SIZE ADJUSTMENT"选项为"ON". 然后点击“OK”完成选项设置,点击“Format”按钮格式化SD卡。
SDFormatter.png

Formatter Setting.png
II. 下载系统镜像文件并解压后,我们需要下列这些文件并复制到Windows PC。

hikey-jessie_alip_2015MMDD-nnn.img

III. 复制hikey-jessie_alip_2015MMDD-nnn.img到PC机。
IV. 烧写系统镜像到MicroSD卡。
下载安装Win32DiskImage ,这个工具可以把系统镜像写入SD卡中。选择SD卡启动的镜像,选择“write”,等待片刻系统镜像将写入SD卡。
HiKey win32 disk imager.png
这时系统镜像已经烧录到SD卡中。可以从Windows PC中拔出SD卡。拔掉跳线帽2,SD卡插入到Hikey,通过HDMI连接显示屏,重新拔插电源即可从SD卡启动系统,进入Debian系统。

Install Android OS

(We suggest to refer to https://source.android.com/source/devices.html to run Android on HiKey.)

Flashing EMMC

Step 1: Flashing bootloader.
I. After we downloading the OS image file and extracting it,we need to use the following files and copy them to Linux PC:

fip.bin
ptable-aosp-8g.img
nvme.img

II. Power on the HiKey board and verify communications from the Linux PC, run the command “sudo fastboot devices”. if show “0123456789abcdef fastboot”, it will be OK.

sudo fastboot devices
0123456789abcdef fastboot

III. The following fastboot commands then load the partition table, the bootloaders and other necessary files into the HiKey EMMC flash memory.

sudo fastboot flash ptable ptable-aosp-8g.img
sudo fastboot flash fastboot fip.bin
sudo fastboot flash nvme nvme.img

It will displays the fllowing caption on your Ubuntu,if you execute the above command successfully.

sudo fastboot flash ptable ptable-aosp-8g.img
target reported max download size of 268435456 bytes
sending 'ptable' (17 KB)...
OKAY [  0.009s]
writing 'ptable'...
OKAY [  0.007s]
finished. total time: 0.016s
sudo fastboot flash fastboot fip.bin
target reported max download size of 268435456 bytes
sending 'fastboot' (1389 KB)...
OKAY [  0.183s]
writing 'fastboot'...
OKAY [  0.065s]
finished. total time: 0.248s
sudo fastboot flash nvme nvme.img
target reported max download size of 268435456 bytes
sending 'nvme' (128 KB)...
OKAY [  0.023s]
writing 'nvme'...
OKAY [  0.010s]
finished. total time: 0.033s

第2步: 烧录系统内核镜像
I. 下载系统镜像文件并解压后,我们需要下列这些文件并复制到Linux PC:

boot-fat.uefi.img

II. 执行sudo fastboot devices命令,检查Hikey是否被Linux PC识别。如果出现“0123456789abcdef fastboot”则被识别。(有时需要多尝试几次)

sudo fastboot devices
0123456789abcdef fastboot

III. 执行下面命令烧写内核镜像

sudo fastboot flash boot boot_fat.uefi.img 
target reported max download size of 268435456 bytes
sending 'boot' (49152 KB)...
OKAY [  6.308s]
writing 'boot'...
OKAY [  2.204s]
finished. total time: 8.512s

第3步: 烧写系统文件
I. 下载系统镜像文件并解压后,我们需要下列这些文件并复制到Linux PC:

cache.img
system.img
userdata-8g.img (for 8G board)

II. 执行sudo fastboot devices命令,检查Hikey是否被Linux PC识别。如果出现“0123456789abcdef fastboot”则被识别。(有时需要多尝试几次)

sudo fastboot devices
0123456789abcdef fastboot

III. 执行下面的命令烧写系统镜像

sudo fastboot flash cache cache.img
target reported max download size of 268435456 bytes
sending 'cache' (6248 KB)...
OKAY [  0.795s]
writing 'cache'...
OKAY [  0.295s]
finished. total time: 1.090s
sudo fastboot flash system system.img
target reported max download size of 268435456 bytes
sending sparse 'system' (262132 KB)...
OKAY [ 36.623s]
writing 'system'...
OKAY [ 12.683s]
sending sparse 'system' (258624 KB)...
OKAY [ 34.501s]
writing 'system'...
OKAY [ 12.081s]
sending sparse 'system' (257367 KB)...
OKAY [ 34.143s]
writing 'system'...
OKAY [ 12.336s]
finished. total time: 142.366s
sudo fastboot flash userdata userdata-8g.img
target reported max download size of 268435456 bytes
sending 'userdata' (90185 KB)...
OKAY [ 11.334s]
writing 'userdata'...
OKAY [  4.100s]
finished. total time: 15.434s

这时系统镜像已经烧录到EMMC卡中。拔掉跳线帽2,通过HDMI连接显示屏,重新拔插电源即可从EMMC卡启动系统,进入Android系统。


安装Snappy Ubuntu Core

我们可以从这里下载系统镜像文件:http://www.lemaker.org/product-hikey-download-54.html

烧写镜像到SD卡

第1步: 烧写bootloader.
下载系统镜像后,解压压缩包。我们需要用到下面的文件:

ptable-linux.img
fip.bin
nvme.img

使用下面命令烧写分区表、bootloaders和其它必要的文件到HiKey EMMC Flash:

sudo fastboot flash ptable ptable-linux.img
sudo fastboot flash fastboot fip.bin
sudo fastboot flash nvme nvme.img

第2步: 烧写writable.
在我们烧写writabe之前, 我先要复位一下HiKey.
然后执行下面命令烧写writable:

sudo ./hisi-idt.py -d /dev/ttyUSB0 --img1=l-loader.bin
sudo fastboot flash writable writable.img

第3步: 烧写系统镜像
执行下面命令烧写系统镜像到SD卡:

sudo dd if=hikey-snappy.img of=/dev/sdc bs=32M
sync

最后,将烧写好系统镜像的SD卡插入SD卡插槽,启动HiKey。

Shut down HiKey

We can use the GUI to shut down the Hikey safely. Also we can run the command in the terminal to shut down the HIkey:

sudo halt

or execute the below command to instead the above command

sudo shutdown –h now.