Hikey960 linux版本烧录办法
最近看到很多群友和坛友一直在询问linux版本什么时候能够出来,现在linux版本终于出来了
遗憾的是Hikey960现在只提供linux版本的镜像供尝鲜
不过有镜像了也就离开源更近了一步,我们还是先让linux 在hikey960上面run起来再说
那么如何让linux在hikey960上面跑起来呐?
1. 下载代码及镜像:
a. ARM Trusted Firmware:
https://github.com/ARM-software/arm-trusted-firmware/tree/integration
edk2:
https://github.com/96boards-hikey/edk2/tree/testing/hikey960_v2.5
OpenPlatformPkg:
https://github.com/96boards-hikey/OpenPlatformPkg/tree/testing/hikey960_v1.3.4
l-loader:
https://github.com/96boards-hikey/l-loader/tree/testing/hikey960_v1.2
uefi-tools: (master branch)
https://git.linaro.org/uefi/uefi-tools.git
atf-fastboot:
https://github.com/96boards-hikey/atf-fastboot/tree/master
b. 下载boot及system镜像文件 http://builds.96boards.org/snapshots/reference-platform/openembedded/morty/hikey960/rpb/latest/
2. 编译代码
a. 准备交叉编译链
交叉编译链的地址在:
http://releases.linaro.org/components/toolchain/binaries/latest/aarch64-linux-gnu/ 中
选择下载gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu.tar.xz
具体可以看论坛的另一篇帖子,《如何安装交叉编译器》
b. 编译
ü 将代码下载后解压在同一个文件夹里$(BUILD_PATH)
ü 在目录edk2中建立OpenPlatformPkg的符号链接
$cd ${BUILD_PATH}/edk2
$ln -sf ../OpenPlatformPkg
ü 以debug模式build,可以建立一个脚本方便编译
export BUILD_OPTION=DEBUG
export BUILD_PATH=自己创建的那个放源码的文件夹
export AARCH64_TOOLCHAIN=GCC5
export UEFI_TOOLS_DIR=${BUILD_PATH}/uefi-tools
export EDK2_DIR=${BUILD_PATH}/edk2
EDK2_OUTPUT_DIR=${EDK2_DIR}/Build/HiKey960/DEBUG_GCC5/
# Build UEFI & ARM Trust Firmware
cd ${EDK2_DIR}
${UEFI_TOOLS_DIR}/uefi-build.sh -b ${BUILD_OPTION} -a ${BUILD_PATH}/arm-trusted-firmware/ hikey960
# Generate l-loader.bin
cd ${BUILD_PATH}/l-loader
ln -sf ${EDK2_OUTPUT_DIR}/FV/bl1.bin
ln -sf ${EDK2_OUTPUT_DIR}/FV/fip.bin
ln -sf ${EDK2_OUTPUT_DIR}/FV/BL33_AP_UEFI.fd
python gen_loader_hikey960.py -o l-loader.bin --img_bl1=bl1.bin --img_ns_bl1u=BL33_AP_UEFI.fd
# Generate partition table
PTABLE=aosp-32g SECTOR_SIZE=4096 SGDISK=./sgdisk bash -x generate_ptable.sh
3. 设置控制台环境
a. 安装ser2net
$sudo apt-get install ser2net
b. 配置ser2net
$sudo vi /etc/ser2net.conf
添加如下代码
2004:telnet:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT banner
配置完之后重启一下ser2net
c. 测试终端是否配置正常
$telnet localhost 2004
能够正常打开并看到回执信息才算正常
4. 在recovery模式下安装UEFI
a. 下载烧录UEFI过程中会用得到的其他镜像
https://github.com/96boards-hikey/tools-images-hikey960
$cd tools-images-hikey960
$ln -sf ${BUILD_PATH}/l-loader/l-loader.bin
$ln -sf ${BUILD_PATH}/l-loader/fip.bin
b. 准备conifg文件
$vi config
# The content of config file
./sec_usb_xloader.img 0x00020000
./sec_uce_boot.img 0x6A908000
./l-loader.bin 0x1AC00000
c. 卸载modemmanager,这个软件可能会引起hikey_idt的无法使用
$ sudo apt-get purge modemmanager
d. 下载l-loader.bin到hikey960上
$sudo ./hikey_idt -c config -p /dev/ttyUSB1
e. 当串口输出了’…’这样的字符时,点击’f’打断,使fastboot运行起来
f. 当板子的fastboot跑起来以后使用如下命令烧写
$sudo fastboot flash ptable prm_ptable.img
$sudo fastboot flash xloader sec_xloader.img
$sudo fastboot flash fastboot l-loader.bin
$sudo fastboot flash fip fip.bin
5. 下载boot及 system镜像,现在的镜像只支持串口输出但是却没有任何图像输出
在上述环境下继续下载boot及system
$sudo fastboot flash boot boot.img
$sudo fastboot flash system rpb.img
6. 拨码到正常模式开机
在${UEFI_TOOLS_DIR}/uefi-build.sh -b ${BUILD_OPTION} -a ${BUILD_PATH}/arm-trusted-firmware/ hikey960步骤的时候出现如下提示:
OK
make[1]: Leaving directory `/home/icebaby/96board/download/edk2/BaseTools/Tests'
make: Leaving directory `/home/icebaby/96board/download/edk2/BaseTools'
Target: AARCH64
Build: X64
Building Hikey960 - AARCH64
CROSS_COMPILE="aarch64-linux-gnu-"
hikey960_BUILDFLAGS=' -D FIRMWARE_VER=9d69f68-dirty'
TOOLCHAIN is GCC5
Toolchain prefix: GCC5_AARCH64_PREFIX=aarch64-linux-gnu-
Build environment: Linux-3.16.0-77-generic-x86_64-with-Ubuntu-14.04-trusty
Build start time: 20:24:35, Jul.19 2017
build: : warning: Tool chain [GCC5] is not defined
build.py...
: error 4000: Not available
[GCC5] not defined. No toolchain available for build!
- Failed -
Build end time: 20:24:35, Jul.19 2017
Build total time: 00:00:00
------------------------------------------------------------
Hikey960 DEBUG fail
------------------------------------------------------------
pass 0
fail 1
说是[GCC5]没有定义,这是为什么阿?谢谢了。
是不是交叉编译环境没有设置好?
-------:~/96board/download/edk2$ echo $BUILD_PATH
/home/-----/96board/download/
-------:~/96board/download/edk2$ echo $GCC5
/home/------/96board/download/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
-------:~/96board/download/edk2$ echo $AARCH64_TOOLCHAIN
/home/------/96board/download/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
------:~/96board/download/edk2$
还是不行阿。提示如下:
Build start time: 10:23:50, Jul.20 2017
build: : warning: Tool chain [GCC5] is not defined
build.py...
: error 4000: Not available
[GCC5] not defined. No toolchain available for build!
- Failed -
Build end time: 10:23:50, Jul.20 2017
Build total time: 00:00:00
------------------------------------------------------------
Hikey960 DEBUG fail
------------------------------------------------------------
pass 0
fail 1
很多96boarder提出了烧录方面的问题,为了简化烧录,我将镜像编译完毕后和相关需要的镜像合并形成一个烧录包供大家下载
包中已经包含了要用到的脚本,分享链接:
链接: http://pan.baidu.com/s/1boC8wSv 密码:gm7l
烧录办法:
1.将hikey960拨至recovery模式
2.在文件夹中执行sudo ./hikey_idt -c config -p /dev/ttyUSB1
3.当串口输出了'...'点击'f'打断,使fastboot运行起来
4.执行脚本./recovery-flash.sh
5.烧录完毕,切到正常模式开机能看到串口正常输出,password为root输入后即可正常进入系统
你好,我想问问烧录时用到两个ttyusb吗?一个用于执行2.在文件夹中执行sudo ./hikey_idt -c config -p /dev/ttyUSB1,另一个用于看串口输出。
我执行完$telnet localhost 2004,得到的只有
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
ser2net port 2004 device /dev/ttyUSB0 [115200 N81] (Debian GNU/Linux)
请问这算正常吗?
我执行2.在文件夹中执行sudo ./hikey_idt -c config -p /dev/ttyUSB1时,ttyUSB0串口没有输出任何信息
谢谢
Working