Difference between revisions of "Building U-boot and Linux for H5/H3/H2+"

From FriendlyELEC WiKi
Jump to: navigation, search
(Update Log)
(updated by API)
 
(61 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[H3 Mainline U-boot & Linux/zh|查看中文]]
+
[[Building U-boot and Linux for H5/H3/H2+/zh|查看中文]]
  
==Introduction to Mainline==
+
==Introduction to Linux Mainline==
 
Linux kernel distributions have several lines. The Mainline is maintained by Linus. Other variants and distributions are maintained by various groups and organizations. All the variants and distributions are submitted to Linux and will be merged to the Mainline.
 
Linux kernel distributions have several lines. The Mainline is maintained by Linus. Other variants and distributions are maintained by various groups and organizations. All the variants and distributions are submitted to Linux and will be merged to the Mainline.
The latest mainline of U-boot and Linux kernel already has support for H3/H5 SoC. FriendlyElec customized the latest mainline u-boot and Linux kernel and made that u-boot and kernel work for all FriendlyElec's H3/H5 boards.
+
The latest mainline of U-boot and Linux kernel already has support for H3/H5 SoC. FriendlyElec customized the latest mainline u-boot and Linux kernel and made that u-boot and kernel work for all FriendlyElec's H5/H3/H2+ boards.<br>
 +
Note: all the operations and instructions listed in this topic only apply to Linux-4.14.y. Don't apply them to H5-Linux-3.10/H3-Linux-3.4 .
  
==Make an Installation SD Card==
+
==Features==
===Download Image Files===
+
* [http://wiki.friendlyelec.com/wiki/index.php/File:Sunxi-mainline-kernel-4.14-features.xlsx Sunxi-mainline-kernel-4.14-features]
<!---
+
<!--
Visit this [https://www.mediafire.com/folder/654db9i7w8h1b/H3-mainline download link] to download the image files under the "officail-ROMs" directory and flashing utility under the "tools" directory:<br />--->
+
* [http://wiki.friendlyelec.com/wiki/index.php/File:Sunxi-mainline-kernel-4.16-features.xlsx Sunxi-mainline-kernel-4.16-features]
 
+
-->
::{| class="wikitable"
+
|-
+
|Board Type||Download Link to Image File||Image File
+
|-
+
|NanoPi NEO||[http://pan.baidu.com/s/1boQFxN5 Download]|| official-ROMs/nanopi-neo_ubuntu-core-xenial_4.11.0.img.zip
+
|-
+
|NanoPi NEO Air||[https://pan.baidu.com/s/1kUMRucf Download] || official-ROMs/nanopi-neo-air_ubuntu-core-xenial_4.11.0.img.zip
+
|-
+
|NanoPi M1||[https://pan.baidu.com/s/1dF7HL0P Download] || official-ROMs/nanopi-m1_ubuntu-core-xenial_4.11.0.img.zip
+
|-
+
|NanoPi M1 Plus||[https://pan.baidu.com/s/1boNTLKF Download] || official-ROMs/nanopi-m1-plus_ubuntu-core-xenial_4.11.0.img.zip
+
|-
+
|NanoPi NEO2||[https://pan.baidu.com/s/1eRDbeG6 Download] || official-ROMs/nanopi-neo2_ubuntu-core-xenial_4.11.0.img.zip
+
|-
+
|}
+
<!---
+
|-
+
|colspan=2| Image Files
+
|-
+
|h3-mainline-ubuntu-core-qte-sd4g.img.zip      || Ubuntu-Core with Qt-Embedded Image File, for NanoPi NEO Only                 
+
|-
+
|colspan=2|Flash Utility: 
+
|-
+
|win32diskimager.rar || Windows utility. Under Linux users can use "dd"
+
|-
+
|}
+
--->
+
 
+
===Make an Installation TF Card with Ubuntu-Core with Qt-Embedded===
+
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 SD card till it is done.Insert this card into your H3/H5 board's MicroSD card slot and power on (with a 5V/2A power source). If the blue LED blinks this indicates your board has successfully booted.<br/>
+
 
+
==Mainline Linux Development Timetable==
+
[[File:mainline-effort.jpg|frameless|1000px|]]
+
  
 
<!---
 
<!---
 
==Mainline ROM Features==
 
==Mainline ROM Features==
===Ubuntu-Core with Qt-Embedded===
+
===FriendlyCore===
 
::{| class="wikitable"
 
::{| class="wikitable"
 
|-
 
|-
Line 66: Line 34:
 
|}
 
|}
 
--->
 
--->
==How to Compile Mainline BSP==
+
 
===How to Compile Mainline BSP for H3===
+
==How to Compile Linux-4.14 BSP==
 +
===How to Compile Linux-4.14 BSP for H3/H2+===
 
====Install Cross Compiler====
 
====Install Cross Compiler====
Download and extract cross compiler:
+
Visit here [http://download.friendlyelec.com/nanopineo download link] and enter the toolchain directory to download the cross compiler:arm-cortexa9-linux-gnueabihf-4.9.3.tar.xz and extract it:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ git clone https://github.com/friendlyarm/prebuilts.git
 
 
$ mkdir -p /opt/FriendlyARM/toolchain
 
$ mkdir -p /opt/FriendlyARM/toolchain
$ tar xf prebuilts/gcc-x64/arm-cortexa9-linux-gnueabihf-4.9.3.tar.xz -C /opt/FriendlyARM/toolchain/
+
$ tar xf arm-cortexa9-linux-gnueabihf-4.9.3.tar.xz -C /opt/FriendlyARM/toolchain/
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 109: Line 77:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
===Compile U-boot===
+
====Compile U-boot====
 
Download the U-boot source code and enter the master-h3 branch:
 
Download the U-boot source code and enter the master-h3 branch:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ git clone https://github.com/friendlyarm/u-boot.git
+
$ git clone https://github.com/friendlyarm/u-boot.git -b sunxi-v2017.x --depth 1
$ cd u-boot
+
$ git checkout sunxi-v2017.03
+
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
Compile U-boot:
 
Compile U-boot:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ make nanopi_neo_defconfig ARCH=arm CROSS_COMPILE=arm-linux-
+
$ apt-get install swig python-dev python3-dev
 +
$ make nanopi_h3_defconfig ARCH=arm CROSS_COMPILE=arm-linux-
 
$ make ARCH=arm CROSS_COMPILE=arm-linux-
 
$ make ARCH=arm CROSS_COMPILE=arm-linux-
 
</syntaxhighlight>
 
</syntaxhighlight>
 
+
Although this configuration file was originally made for the NanoPi M1 Plus it works for other H3 based boards too.
Update U-boot on SD Card:
+
After compilation is done successfully a "u-boot-sunxi-with-spl.bin" file will be generated.
 +
<br>
 +
Update the u-boot in your installation SD card in a PC host:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=1024 seek=8
 
$ dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=1024 seek=8
 +
$ sync && eject /dev/sdX
 
</syntaxhighlight>
 
</syntaxhighlight>
Note: you need to replace "/dev/sdx" with the device name in your system.
+
Please replace "/dev/sdx" with your TF card's device name recognized by your system.<br>
 +
The "sync" command writes data to your TF card. The "eject" command ejects your TF card safely.<br>
  
===Compile Linux Kernel===
+
When your system boots from an SD card you can use the "scp" command to copy the "u-boot-sunxi-with-spl.bin" file to your board first and then use the "dd" command to update the U-boot in the SD card:
 +
<syntaxhighlight lang="bash">
 +
$ scp u-boot-sunxi-with-spl.bin root@192.168.1.230:/root/
 +
$ dd if=/root/u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=1024 seek=8
 +
</syntaxhighlight>
 +
<br>
 +
 
 +
If your board has eMMC flash and boots from eMMC you can use the "scp" command to copy the "u-boot-sunxi-with-spl.bin" file to your board first and then use the "dd" command to update the U-boot in eMMC:
 +
<syntaxhighlight lang="bash">
 +
$ scp u-boot-sunxi-with-spl.bin root@192.168.1.230:/root/
 +
$ dd if=/root/u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=1024 seek=8
 +
</syntaxhighlight>
 +
The boot device's name recognized by system under NanoPi H3/H2+ is always "/dev/mmcblk0".
 +
 
 +
====Compile and Update Linux Kernel====
 
Download Linux Kernel Source Code:
 
Download Linux 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 -b sunxi-4.14.y --depth 1
$ cd linux
+
$ git checkout sunxi-4.11.y
+
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
Compile Linux Kernel:
 
Compile Linux Kernel:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 +
$ cd linux
 
$ touch .scmversion
 
$ touch .scmversion
 
$ make sunxi_defconfig ARCH=arm CROSS_COMPILE=arm-linux-
 
$ make sunxi_defconfig ARCH=arm CROSS_COMPILE=arm-linux-
Line 145: Line 129:
 
If your compilation is successful a zImage will be generated under "arch/arm/boot/" and a dtb file will be generated under "arch/arm/boot/dts/".
 
If your compilation is successful a zImage will be generated under "arch/arm/boot/" and a dtb file will be generated under "arch/arm/boot/dts/".
  
If your SD card's boot section is mounted at "/media/SD/boot/" you can update the zImage and dtb files by running the following commands:
+
If your SD card's boot partition is mounted at "/media/SD/boot/" you can update its zImage and dtb files by running the following commands:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ cp arch/arm/boot/zImage /media/SD/boot/
 
$ cp arch/arm/boot/zImage /media/SD/boot/
$ cp arch/arm/boot/dts/sun8i-h3-nanopi*.dtb /media/SD/boot/
+
$ cp arch/arm/boot/dts/sun8i-*-nanopi-*.dtb /media/SD/boot/
 
</syntaxhighlight>
 
</syntaxhighlight>
  
===如何为H5编译mainline BSP===
+
Compile and Update Modules:
====安装交叉编译器====
+
<syntaxhighlight lang="bash">
首先下载并解压编译器:
+
$ cd linux
 +
$ make modules ARCH=arm CROSS_COMPILE=arm-linux-
 +
</syntaxhighlight>
 +
 
 +
If your SD card's rootfs partition is mounted at "/media/SD/rootfs/" you can update its modules by running the following commands:
 +
<syntaxhighlight lang="bash">
 +
$ cd linux
 +
$ make modules_install INSTALL_MOD_PATH=/media/SD/rootfs/ ARCH=arm CROSS_COMPILE=arm-linux-
 +
</syntaxhighlight>
 +
 
 +
===How to Compile Mainline BSP for H5===
 +
====Install Cross Compiler====
 +
Visit here [http://download.friendlyelec.com/nanopineo2 download link] and enter the toolchain directory to download the cross compiler gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu.tar.xz and extract it:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ mkdir -p /opt/FriendlyARM/toolchain
 
$ mkdir -p /opt/FriendlyARM/toolchain
Line 159: Line 155:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
然后将编译器的路径加入到PATH中,用vi编辑vi ~/.bashrc,在末尾加入以下内容:
+
Add the compiler's path to the "PATH" variable by appending the following lines in the ~/.bashrc file:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ export PATH=/opt/FriendlyARM/toolchain/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin:$PATH
 
$ export PATH=/opt/FriendlyARM/toolchain/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin:$PATH
Line 165: Line 161:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
执行一下~/.bashrc脚本让设置立即在当前shell窗口中生效,注意"."后面有个空格:
+
Run the ~/.bashrc script to make the changes in effect immediately in your working shell. Attention: there is a space after ".":
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ . ~/.bashrc
 
$ . ~/.bashrc
 
</syntaxhighlight>
 
</syntaxhighlight>
  
安装完成后,你可以快速的验证是否安装成功:
+
You can check whether or not your compiler is setup correctly by running the following commands:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ aarch64-linux-gnu-gcc -v
 
$ aarch64-linux-gnu-gcc -v
Line 176: Line 172:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
====编译U-boot====
+
====Compile U-boot====
下载U-boot源码,并切换分支:
+
Download the U-boot source code and enter the master-h3 branch:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ git clone https://github.com/friendlyarm/u-boot.git
+
$ git clone https://github.com/friendlyarm/u-boot.git -b sunxi-v2017.x --depth 1
$ cd u-boot
+
$ git checkout sunxi-v2017.03
+
 
</syntaxhighlight>
 
</syntaxhighlight>
  
编译U-boot:
+
Compile U-boot:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ make nanopi_neo2_defconfig ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
+
$ apt-get install swig python-dev python3-dev
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
+
$ make nanopi_h5_defconfig CROSS_COMPILE=aarch64-linux-gnu-
 +
$ make CROSS_COMPILE=aarch64-linux-gnu-
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
The "nanopi_h5_defconfig" works for all existing FriendlyElec's H5 based boards.
  
更新SD上的U-boot:
+
Update U-boot on SD Card:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ dd if=spl/sunxi-spl.bin of=/dev/sdX bs=1024 seek=8
 
$ dd if=spl/sunxi-spl.bin of=/dev/sdX bs=1024 seek=8
$ dd if=u-boot.itb of=/dev/sdg bs=1024 seek=40
+
$ dd if=u-boot.itb of=/dev/sdX bs=1024 seek=40
 
</syntaxhighlight>
 
</syntaxhighlight>
/dev/sdx请替换为实际的TF卡设备文件名。
+
Note: you need to replace "/dev/sdx" with the device name in your system.
  
====编译Linux内核====
+
====Compile Linux Kernel====
下载Linux内核源码,并切换分支:
+
Download Linux 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 -b sunxi-4.14.y --depth 1
$ cd linux
+
$ git checkout sunxi-4.11.y
+
 
</syntaxhighlight>
 
</syntaxhighlight>
  
编译Linux内核:
+
Compile and Update Linux Kernel:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 +
$ cd linux
 
$ touch .scmversion
 
$ touch .scmversion
 
$ make sunxi_arm64_defconfig ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
 
$ make sunxi_arm64_defconfig ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
 
$ make Image dtbs ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
 
$ make Image dtbs ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
 
</syntaxhighlight>
 
</syntaxhighlight>
编译完成后会在arch/arm64/boot/目录下生成Image,并且在arch/arm64/boot/dts/allwinner/目录下生成dtb文件。
+
If your compilation is successful an Image will be generated under "arch/arm64/boot/" and a dtb file will be generated under "arch/arm64/boot/dts/allwinner/".
  
假设SD卡的boot分区挂载在/media/SD/boot/,更新SD卡上的Image和dtb文件:
+
If your SD card's boot partition is mounted at "/media/SD/boot/" you can update its Image and dtb files by running the following commands:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ cp arch/arm64/boot/Image /media/SD/boot/
 
$ cp arch/arm64/boot/Image /media/SD/boot/
 
$ cp arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi*.dtb /media/SD/boot/
 
$ cp arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi*.dtb /media/SD/boot/
 +
</syntaxhighlight>
 +
 +
Compile and Update Modules:
 +
<syntaxhighlight lang="bash">
 +
$ cd linux
 +
$ make modules ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
 +
</syntaxhighlight>
 +
 +
If your SD card's rootfs partition is mounted at "/media/SD/rootfs/" you can update its modules by running the following commands:
 +
<syntaxhighlight lang="bash">
 +
$ cd linux
 +
$ make modules_install INSTALL_MOD_PATH=/media/SD/rootfs/ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 222: Line 229:
 
===March-05-2017===
 
===March-05-2017===
 
* Released English Version
 
* Released English Version
 +
 +
===May-05-2017===
 +
* Added Section 3 by adding a mainline kernel development timetable
 +
* Added Section 4.4 by adding support for H5
 +
 +
===June-04-2017===
 +
* Updated section 2.1: updated image files' version numbers
 +
 +
===July-02-2017===
 +
* Updated section 1, 3.1.2 and 3.2.2
 +
 +
===Dec-12-2017===
 +
* Updated sections 3.1.2 and 3.2.2
 +
 +
===August-28-2019===
 +
* Updated sections 3.1.2 and 3.2.2

Latest revision as of 07:17, 21 February 2022

查看中文

1 Introduction to Linux Mainline

Linux kernel distributions have several lines. The Mainline is maintained by Linus. Other variants and distributions are maintained by various groups and organizations. All the variants and distributions are submitted to Linux and will be merged to the Mainline. The latest mainline of U-boot and Linux kernel already has support for H3/H5 SoC. FriendlyElec customized the latest mainline u-boot and Linux kernel and made that u-boot and kernel work for all FriendlyElec's H5/H3/H2+ boards.
Note: all the operations and instructions listed in this topic only apply to Linux-4.14.y. Don't apply them to H5-Linux-3.10/H3-Linux-3.4 .

2 Features


3 How to Compile Linux-4.14 BSP

3.1 How to Compile Linux-4.14 BSP for H3/H2+

3.1.1 Install Cross Compiler

Visit here download link and enter the toolchain directory to download the cross compiler:arm-cortexa9-linux-gnueabihf-4.9.3.tar.xz and extract it:

$ mkdir -p /opt/FriendlyARM/toolchain
$ tar xf arm-cortexa9-linux-gnueabihf-4.9.3.tar.xz -C /opt/FriendlyARM/toolchain/

Add the compiler's path to the "PATH" variable by appending the following lines in the ~/.bashrc file:

$ export PATH=/opt/FriendlyARM/toolchain/4.9.3/bin:$PATH
$ export GCC_COLORS=auto

Run the ~/.bashrc script to make the changes in effect immediately in your working shell. Attention: there is a space after ".":

$ . ~/.bashrc

This is a 64-bit compiler and it cannot run on a 32-bit Linux. You can check whether or not your compiler is setup correctly by running the following commands:

$ arm-linux-gcc -v
gcc version 4.9.3 (ctng-1.21.0-229g-FA)

3.1.2 Compile U-boot

Download the U-boot source code and enter the master-h3 branch:

$ git clone https://github.com/friendlyarm/u-boot.git -b sunxi-v2017.x --depth 1

Compile U-boot:

$ apt-get install swig python-dev python3-dev
$ make nanopi_h3_defconfig ARCH=arm CROSS_COMPILE=arm-linux-
$ make ARCH=arm CROSS_COMPILE=arm-linux-

Although this configuration file was originally made for the NanoPi M1 Plus it works for other H3 based boards too. After compilation is done successfully a "u-boot-sunxi-with-spl.bin" file will be generated.
Update the u-boot in your installation SD card in a PC host:

$ dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=1024 seek=8
$ sync && eject /dev/sdX

Please replace "/dev/sdx" with your TF card's device name recognized by your system.
The "sync" command writes data to your TF card. The "eject" command ejects your TF card safely.

When your system boots from an SD card you can use the "scp" command to copy the "u-boot-sunxi-with-spl.bin" file to your board first and then use the "dd" command to update the U-boot in the SD card:

$ scp u-boot-sunxi-with-spl.bin root@192.168.1.230:/root/
$ dd if=/root/u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=1024 seek=8


If your board has eMMC flash and boots from eMMC you can use the "scp" command to copy the "u-boot-sunxi-with-spl.bin" file to your board first and then use the "dd" command to update the U-boot in eMMC:

$ scp u-boot-sunxi-with-spl.bin root@192.168.1.230:/root/
$ dd if=/root/u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=1024 seek=8

The boot device's name recognized by system under NanoPi H3/H2+ is always "/dev/mmcblk0".

3.1.3 Compile and Update Linux Kernel

Download Linux Kernel Source Code:

$ git clone https://github.com/friendlyarm/linux.git -b sunxi-4.14.y --depth 1

Compile Linux Kernel:

$ cd linux
$ touch .scmversion
$ make sunxi_defconfig ARCH=arm CROSS_COMPILE=arm-linux-
$ make zImage dtbs ARCH=arm CROSS_COMPILE=arm-linux-

If your compilation is successful a zImage will be generated under "arch/arm/boot/" and a dtb file will be generated under "arch/arm/boot/dts/".

If your SD card's boot partition is mounted at "/media/SD/boot/" you can update its zImage and dtb files by running the following commands:

$ cp arch/arm/boot/zImage /media/SD/boot/
$ cp arch/arm/boot/dts/sun8i-*-nanopi-*.dtb /media/SD/boot/

Compile and Update Modules:

$ cd linux
$ make modules ARCH=arm CROSS_COMPILE=arm-linux-

If your SD card's rootfs partition is mounted at "/media/SD/rootfs/" you can update its modules by running the following commands:

$ cd linux
$ make modules_install INSTALL_MOD_PATH=/media/SD/rootfs/ ARCH=arm CROSS_COMPILE=arm-linux-

3.2 How to Compile Mainline BSP for H5

3.2.1 Install Cross Compiler

Visit here download link and enter the toolchain directory to download the cross compiler gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu.tar.xz and extract it:

$ mkdir -p /opt/FriendlyARM/toolchain
$ tar xf gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu.tar.xz -C /opt/FriendlyARM/toolchain/

Add the compiler's path to the "PATH" variable by appending the following lines in the ~/.bashrc file:

$ export PATH=/opt/FriendlyARM/toolchain/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin:$PATH
$ export GCC_COLORS=auto

Run the ~/.bashrc script to make the changes in effect immediately in your working shell. Attention: there is a space after ".":

$ . ~/.bashrc

You can check whether or not your compiler is setup correctly by running the following commands:

$ aarch64-linux-gnu-gcc -v
gcc version 6.3.1 20170109 (Linaro GCC 6.3-2017.02)

3.2.2 Compile U-boot

Download the U-boot source code and enter the master-h3 branch:

$ git clone https://github.com/friendlyarm/u-boot.git -b sunxi-v2017.x --depth 1

Compile U-boot:

$ apt-get install swig python-dev python3-dev
$ make nanopi_h5_defconfig CROSS_COMPILE=aarch64-linux-gnu-
$ make CROSS_COMPILE=aarch64-linux-gnu-

The "nanopi_h5_defconfig" works for all existing FriendlyElec's H5 based boards.

Update U-boot on SD Card:

$ dd if=spl/sunxi-spl.bin of=/dev/sdX bs=1024 seek=8
$ dd if=u-boot.itb of=/dev/sdX bs=1024 seek=40

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

3.2.3 Compile Linux Kernel

Download Linux Kernel Source Code:

$ git clone https://github.com/friendlyarm/linux.git -b sunxi-4.14.y --depth 1

Compile and Update Linux Kernel:

$ cd linux
$ touch .scmversion
$ make sunxi_arm64_defconfig ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
$ make Image dtbs ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

If your compilation is successful an Image will be generated under "arch/arm64/boot/" and a dtb file will be generated under "arch/arm64/boot/dts/allwinner/".

If your SD card's boot partition is mounted at "/media/SD/boot/" you can update its Image and dtb files by running the following commands:

$ cp arch/arm64/boot/Image /media/SD/boot/
$ cp arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi*.dtb /media/SD/boot/

Compile and Update Modules:

$ cd linux
$ make modules ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

If your SD card's rootfs partition is mounted at "/media/SD/rootfs/" you can update its modules by running the following commands:

$ cd linux
$ make modules_install INSTALL_MOD_PATH=/media/SD/rootfs/ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

4 Update Log

4.1 March-05-2017

  • Released English Version

4.2 May-05-2017

  • Added Section 3 by adding a mainline kernel development timetable
  • Added Section 4.4 by adding support for H5

4.3 June-04-2017

  • Updated section 2.1: updated image files' version numbers

4.4 July-02-2017

  • Updated section 1, 3.1.2 and 3.2.2

4.5 Dec-12-2017

  • Updated sections 3.1.2 and 3.2.2

4.6 August-28-2019

  • Updated sections 3.1.2 and 3.2.2