Difference between revisions of "Template:S5P4418BuildFromSource"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
Line 1: Line 1:
 
==Make Your Own OS Image==
 
==Make Your Own OS Image==
 
===Install Cross Compiler===
 
===Install Cross Compiler===
 +
====Install arm-linux-gcc 4.9.3====
 
Download the compiler package:
 
Download the compiler package:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Line 35: Line 36:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
===Compile Linux kernel 4.4.y===
+
===Compile Linux kernel for FriendlyCore/Lubuntu/EFlasher===
 
====Compile Kernel====
 
====Compile Kernel====
 
* Download Kernel Source Code
 
* Download Kernel Source Code
Line 63: Line 64:
  
 
* Generate Your boot.img
 
* Generate Your boot.img
If you want to generate an image file that can be flashed to eMMC you need to generate a boot.img file and then copy it to your installation SD card<br />
+
Refer to this repo: https://github.com/friendlyarm/sd-fuse_s5p4418<br />
For Ubuntu follow the steps below to generate a boot.img file:<br />
+
 
1) Download debian_nanopi2
+
===Compile Linux kernel for Android7===
 +
The Android 7.1.2 source code already contains the pre-compiled kernel. If you need to customize it, you can compile the kernel according to the following guide.
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
git clone https://github.com/friendlyarm/debian_nanopi2.git
+
git clone https://github.com/friendlyarm/linux.git -b nanopi2-v4.4.y --depth 1
 +
cd linux
 +
touch .scmversion
 +
make ARCH=arm nanopi2_nougat_defconfig
 +
make ARCH=arm
 
</syntaxhighlight>
 
</syntaxhighlight>
2) Copy the zImage and DTB files to replace the corresponding files under the "debian_nanopi2/boot/" directory<br />
+
The newly generated kernel is arch/arm/boot/zImage,The new DTB file is also included under the directory arch/arm/boot/dts/.(s5p4418-nanopi2-rev*.dtb).<br />
3) Generate boot.img
+
If you only want to debug the kernel, you can quickly update it with adb:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
cd debian_nanopi2
+
adb root; adb shell mkdir /storage/sdcard1/; adb shell mount -t ext4 /dev/block/mmcblk0p1 /storage/sdcard1/;
mkdir rootfs
+
adb push arch/arm/boot/zImage arch/arm/boot/dts/s5p4418-nanopi2-rev*.dtb /storage/sdcard1/
./build.sh
+
 
</syntaxhighlight>
 
</syntaxhighlight>
A newly generated boot.img will be under the "debian_nanopi2/sd-fuse_nanopi2/debian" directory.<br />
+
If you want to generate boot.img for burning, you can copy the kernel zImage and DTB files to the Android7 source code directory: device/friendlyelec/nanopi2/boot, then recompile Android7.
The "mkdir rootfs" command creates a working directory for the build.sh script to run. It also creates some files such as "rootfs.img" but these files are useless.
+
  
====Compile U-Boot====
+
====Compile U-Boot for Android7/FriendlyCore/Lubuntu/EFlasher====
 
Download the U-Boot source code and compile it. Note that the github's branch is nanopi2-v2016.01:
 
Download the U-Boot source code and compile it. Note that the github's branch is nanopi2-v2016.01:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Line 88: Line 92:
 
make CROSS_COMPILE=arm-linux-
 
make CROSS_COMPILE=arm-linux-
 
</syntaxhighlight>
 
</syntaxhighlight>
After your compilation succeeds a bootloader.img will be generated. If you want to test it flash it to your installation SD card to replace an existing U-Boot v2016.01 file via fastboot, sd-fuse_nanopi2 or eflasher ROM.<br/>
+
After your compilation succeeds a bootloader.img will be generated. If you want to test it flash it to your installation SD card to replace an existing U-Boot v2016.01 file via fastboot, sd-fuse_s5p4418 or eflasher ROM.<br/>
 +
For Android7: Copy bootloader.img to Android7 source directory device/friendlyelec/nanopi2/boot, then recompile Android7. <br />
 
Note: you cannot use mixed U-Boot files. For example you cannot use fastboot to update an existing U-Boot V2014.07 and you cannot use bootloader.img to replace an existing u-boot.bin
 
Note: you cannot use mixed U-Boot files. For example you cannot use fastboot to update an existing U-Boot V2014.07 and you cannot use bootloader.img to replace an existing u-boot.bin
  
===Compile Linux kernel 3.4.y===
+
===Compile Android 7.1.2===
====Prepare mkimage====
+
You need the mkimage utility to compile a U-Boot source code package. Make sure this utility works well on your host before you start compiling a uImage.<br/>
+
You can install this utility by either commanding "sudo apt-get install u-boot-tools" or following the commands below:
+
<syntaxhighlight lang="bash">
+
cd uboot_nanopi2
+
make CROSS_COMPILE=arm-linux- tools
+
sudo mkdir -p /usr/local/sbin && sudo cp -v tools/mkimage /usr/local/sbin
+
</syntaxhighlight>
+
 
+
====Compile Linux Kernel====
+
* Download Kernel Source Code
+
<syntaxhighlight lang="bash">
+
git clone https://github.com/friendlyarm/linux-3.4.y.git
+
cd linux-3.4.y
+
git checkout nanopi2-lollipop-mr1
+
</syntaxhighlight>
+
The {{{1}}}'s kernel source code lies in the "nanopi2-lollipop-mr1" branch.
+
* Compile Android Kernel
+
<syntaxhighlight lang="bash">
+
make nanopi2_android_defconfig
+
touch .scmversion
+
make uImage
+
</syntaxhighlight>
+
* Compile Debian Kernel
+
<syntaxhighlight lang="bash">
+
make nanopi2_linux_defconfig
+
touch .scmversion
+
make uImage
+
</syntaxhighlight>
+
After your compilation succeeds a uImage will be generated in the "arch/arm/boot/" directory. This kernel is for LCD output. You can use it to replace the existing uImage.<br/>
+
If you want to generate a kernel for HDMI output you need to run nanopi2_linux_hdmi_defconfig and do it this way:
+
<syntaxhighlight lang="bash">
+
make nanopi2_linux_hdmi_defconfig
+
touch .scmversion
+
make uImage
+
</syntaxhighlight>
+
After your compilation succeeds a uImage.hdmi will be generated for HDMI 720P. If you want a uImage.hdmi for 1080P you can do it this way:
+
<syntaxhighlight lang="bash">
+
touch .scmversion
+
make nanopi2_linux_hdmi_defconfig
+
make menuconfig
+
  Device Drivers -->
+
    Graphics support -->
+
      Nexell Graphics -->
+
        [ ] LCD
+
        [*] HDMI
+
        (0)  Display In  [0=Display 0, 1=Display 1]
+
              Resolution (1920 * 1080p)  --->
+
make uImage
+
</syntaxhighlight>
+
After your compilation succeeds a uImage.hdmi will be generated for HDMI 1080P. You can use it to replace the existing uImage.hdmi.
+
 
+
====Use 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 to your SD card's boot partition(e.g. partition 1 /dev/sdX1).<br />
+
If you use an SD card to Debian and you generated a uImage for an HDMI monitor you can use that uImage to replace the uImage.hdmi file in the SD card's boot partition. If you use an SD card to Debian and you generated a uImage for an LCD you can use that uImage to replace the uImage file in the SD card's boot partition.
+
 
+
* Update Android kernel file in eMMC
+
If you want to update the kernel file in eMMC you need firstly boot your board, then mount eMMC's boot partition, replace the boot partition's kernel file with your generated one and reboot your board.<br />
+
If you boot your board from eMMC you can update your kernel file by following the steps below:<br />
+
1) After Android is loaded mount eMMC's boot partition (in our example eMMC's device name was /dev/mmcblk0p1) by using the following commands:<br />
+
<syntaxhighlight lang="bash">
+
su
+
mount -t ext4 /dev/block/mmcblk0p1 /mnt/media_rw/sdcard1/
+
</syntaxhighlight>
+
2) Connect your board to a host PC running Ubuntu with a MicroUSB cable and copy the uImage file to eMMC's boot partition by running the following commands<br />
+
<syntaxhighlight lang="bash">
+
adb push uImage /mnt/media_rw/sdcard1/
+
</syntaxhighlight>
+
3) Or you can copy your generated kernel file to an external storage card(e.g. an SD card or a USB drive), connect the storage card to your board the move the file from the card to eMMC's boot partition<br />
+
4) After update is done type "reboot" and enter to reboot your board. Note: don't just directly disconnect your board from its power source or press the reset button to reboot the board. These actions will damage your kernel file<br />
+
 
+
* Update Debian kernel file in eMMC
+
If you boot your board from eMMC you can update your kernel file by following the steps below:<br />
+
1) When Debian is being loaded eMMC's boot partition will be automatically mounted(in our example eMMC's device name was /dev/mmcblk0p1). You can use "mount" to verify that<br />
+
2) Connect your board to a host PC via Ethernet and copy your generated uImage file via scp/ftp to eMMC's boot partition and replace the existing file. If your file is for LCD output use your uImage file to replace the existing uImage. If your file is for HDMI output use your uImage.hdmi file to replace the existing uImage.hdmi file<br />
+
3) Or you can copy your generated kernel file to an external storage card(e.g. an SD card or a USB drive), connect the storage card to your board the move the file from the card to eMMC's boot partition<br />
+
4) After update is done type in "reboot" to reboot your board. Note: don't just directly disconnect your board from its power source or press the reset button to reboot the board. These actions will damage your kernel file<br />
+
 
+
* Generate Your boot.img
+
If you want to generate an image file that can be flashed to eMMC you need to generate a boot.img file and copy it to your installation SD card<br />
+
For Android copy the uImage file to Android source code's "device/friendly-arm/nanopi2/boot/" directory and compile this whole Android source code. After your compilation is successful you will get a boot.img file.<br />
+
For Debian follow the steps below to generate a boot.img file<br />
+
1) Download debian_nanopi2
+
<syntaxhighlight lang="bash">
+
git clone https://github.com/friendlyarm/debian_nanopi2.git
+
</syntaxhighlight>
+
2) Copy the image file for an HDMI monitor and use it to replace the "debian_nanopi2/boot/uImage.hdmi" file and copy the image file for an LCD and use it to replace the "debian_nanopi2/boot/uImage" file<br />
+
3) Generate Debian's boot.img
+
<syntaxhighlight lang="bash">
+
cd debian_nanopi2
+
mkdir rootfs
+
./build.sh
+
</syntaxhighlight>
+
A newly generated boot.img will be under the "debian_nanopi2/sd-fuse_nanopi2/debian" directory.<br />
+
The "mkdir rootfs" command creates a working directory for the build.sh script to run. It also creates some files such as "rootfs.img" but these files are useless.
+
 
+
====Compile Kernel Modules====
+
Android contains kernel modules which are in the "/lib/modules" directory in the system partition. If you want to add your own modules to the kernel or you changed your kernel configurations you need to recompile these new modules.<br/>
+
Compile Original Kernel Modules:
+
<syntaxhighlight lang="bash">
+
cd linux-3.4.y
+
make CROSS_COMPILE=arm-linux- modules
+
</syntaxhighlight>
+
Here we have two new modules and we can compile them by running the commands below:
+
<syntaxhighlight lang="bash">
+
cd /opt/FriendlyARM/s5p4418/android
+
./vendor/friendly-arm/build/common/build-modules.sh
+
</syntaxhighlight>
+
The "/opt/FriendlyARM/s5p4418/android" directory points to the top directory of Android source code. You can get more details by specifying option "-h".<br />
+
After your compilation succeeds new modules will be generated
+
 
+
====Compile U-Boot====
+
Download the U-Boot v2014.07 source code and compile it. Note that the github's branch is nanopi2-lollipop-mr1:
+
<syntaxhighlight lang="bash">
+
git clone https://github.com/friendlyarm/uboot_nanopi2.git
+
cd uboot_nanopi2
+
git checkout nanopi2-lollipop-mr1
+
make s5p4418_nanopi2_config
+
make CROSS_COMPILE=arm-linux-
+
</syntaxhighlight>
+
 
+
After compilation is done a u-boot.bin will be generated and you can update your {{{1}}}'s u-boot with fastboot by running the following commands:<br/>
+
1) On your host PC run "sudo apt-get install android-tools-fastboot" to installl the fastboot utility;<br />
+
2) Connect your {{{1}}} to your host PC, boot your {{{1}}} and press "Enter" within two seconds right after your board is powered on and you will enter the u-boot commandline:<br />
+
3) In the commandline window type "fastboot" and then press "Enter" to enter the fastboot mode:<br />
+
4) Connect your {{{1}}} to a host PC with a MicroUSB cable and run the following commands in the commandline window to flash u-boot.bin to your {{{1}}}:<br />
+
<syntaxhighlight lang="bash">
+
fastboot flash bootloader u-boot.bin
+
</syntaxhighlight>
+
<br />
+
Note:you cannot use "dd" to update your SD card in this situation.<br />
+
 
+
===Compile Android===
+
We provide two Android versions: Android 4.4 and Android 5.1. Both of them are compiled the same way.
+
 
====Install Cross Compiler====
 
====Install Cross Compiler====
 
Install 64 bit Ubuntu 16.04 on your host PC.
 
Install 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 curl libncurses5-dev libssl-dev zlib1g-dev gawk minicom
 +
sudo apt-get install openjdk-8-jdk
 +
sudo apt-get install exfat-fuse exfat-utils device-tree-compiler liblz4-tool
 
</syntaxhighlight>
 
</syntaxhighlight>
 
For more details refer to https://source.android.com/source/initializing.html 。
 
For more details refer to https://source.android.com/source/initializing.html 。
  
====Download Android5.1 source code====
+
====Download Android7 Source Code====
 
There are two ways to download the source code:  
 
There are two ways to download the source code:  
 
* '''repo archive file on netdisk'''
 
* '''repo archive file on netdisk'''
 
Netdisk URL: [http://download.friendlyarm.com/{{#replace:{{#replace:{{BASEPAGENAME}}| |}}|/zh|}} Click here]<br />
 
Netdisk URL: [http://download.friendlyarm.com/{{#replace:{{#replace:{{BASEPAGENAME}}| |}}|/zh|}} Click here]<br />
File location on netdisk:sources/s5pxx18-android5.git-YYYYMMDD.tgz (YYYYMMDD表示打包的日期)<br />
+
File location on netdisk:sources/s5pxx18-android-7.git-YYYYMMDD.tgz (YYYYMMDD means the date of packaging)<br />
 
After extracting the repo package from the network disk, you need to execute the sync.sh script, which will pull the latest code from gitlab:
 
After extracting the repo package from the network disk, you need to execute the sync.sh script, which will pull the latest code from gitlab:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
tar xvzf /path/to/netdisk/sources/s5pxx18-android5.git-20181228.tgz
+
tar xvzf /path/to/netdisk/sources/s5pxx18-android-7.git-YYYYMMDD.tgz
cd s5pxx18-android5
+
cd s5pxx18-android-7
 
./sync.sh
 
./sync.sh
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 249: Line 121:
 
{{{1}}} source code is maintained in gitlab, You can download it by running the following command:
 
{{{1}}} source code is maintained in gitlab, You can download it by running the following command:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
git clone https://gitlab.com/friendlyelec/s5pxx18-android5
+
git clone https://gitlab.com/friendlyelec/s5pxx18-android-7.git -b master
cd s5pxx18-android5
+
 
</syntaxhighlight>
 
</syntaxhighlight>
====Compile Android====
+
 
 +
====Compile Android7====
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 +
cd s5pxx18-android-7
 
source build/envsetup.sh
 
source build/envsetup.sh
 
lunch aosp_nanopi2-userdebug
 
lunch aosp_nanopi2-userdebug
Line 261: Line 134:
 
::{| class="wikitable"
 
::{| class="wikitable"
 
|-
 
|-
|filename     || partition || Description   
+
|filename         || partition || Description   
 
|-
 
|-
|boot.img     || boot     || -
+
|bl1-mmcboot.bin  || raw      || boot firmware
 +
|-
 +
|loader-mmc.img   || raw      || boot firmware
 +
|-
 +
|bl_mon.img        || raw      || boot firmware
 +
|-
 +
|bootloader.img    || raw      || uboot-v2016.01
 
|-  
 
|-  
|cache.img    || cache    || -
+
|env.conf          || -        || Uboot environment variable containing Android kernel command line parameters
 +
|-
 +
|boot.img          || boot      || kernel zImage, DTBs; logo; Android ramdisk
 
|-  
 
|-  
|userdata.img || userdata  || -
+
|cache.img         || cache    || -
 
|-  
 
|-  
|system.img   || system    || -
+
|userdata.img     || userdata  || -
 
|-  
 
|-  
|partmap.txt || -        || partition description file
+
|system.img        || system    || -
 +
|-
 +
|partmap.txt       || -        || Partition description file
 
|-  
 
|-  
 
|}
 
|}
====Flash Image to SD Card====
 
If you boot your board from an SD card you can copy your new image file to the sd-fuse_nanopi2/android/ directory and flash this image to your SD card with an installation script. For more details refer to https://github.com/friendlyarm/sd-fuse_nanopi2。
 
 
====Flash Image to eMMC====
 
After compiling Android successfully you can flash it to eMMC with either of the following methods<br />
 
1) fastboot: right after the {{{1}}} is booted from eMMC press any key to enter the uboot commandline mode and type in "fastboot"<br />
 
Connect your board to a host PC running Ubuntu with a USB cable and run the following commands in the PC's terminal:
 
<syntaxhighlight lang="bash">
 
cd out/target/product/nanopi2
 
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
 
</syntaxhighlight>
 
2) Use an SD Card<br />
 
Copy these files: boot.img, cache.img, userdata.img, system.img, partmap.txt from the out/target/product/nanopi2 directory to your installation SD card's images/android directory and you can use this SD card to flash Android to eMMC<br />
 
 
====Download Android4 source code====
 
If you want to try Android4.4's source code you can run the following commands:
 
<syntaxhighlight lang="bash">
 
mkdir android && cd android
 
repo init -u https://github.com/friendlyarm/android_manifest.git -b nanopi2-kitkat
 
repo sync
 
</syntaxhighlight>
 
Option "-b" specifies a branch
 

Revision as of 07:46, 6 November 2019

1 Make Your Own OS Image

1.1 Install Cross Compiler

1.1.1 Install arm-linux-gcc 4.9.3

Download the compiler package:

git clone https://github.com/friendlyarm/prebuilts.git -b master --depth 1
cd prebuilts/gcc-x64
cat toolchain-4.9.3-armhf.tar.gz* | sudo tar xz -C /

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)

1.2 Compile Linux kernel for FriendlyCore/Lubuntu/EFlasher

1.2.1 Compile Kernel

  • Download Kernel Source Code
git clone https://github.com/friendlyarm/linux.git -b nanopi2-v4.4.y --depth 1
cd linux

The {{{1}}}'s kernel source code is in the "nanopi2-v4.4.y" branch.You need to switch to this branch.

  • Compile Ubuntu Kernel
touch .scmversion
make ARCH=arm nanopi2_linux_defconfig
make ARCH=arm

After your compilation succeeds an "arch/arm/boot/zImage" will be generated and a DTB file(s5p4418-nanopi2-rev*.dtb) will be generated in the "arch/arm/boot/dts/" directory. You can use them to replace the existing zImage and DTB files in the boot partition of your bootable SD card.

1.2.2 Use Your Generated Kernel

  • Update kernel in SD card

If you use an SD card to boot Ubuntu you can copy your generated zImage and DTB files to your SD card's boot partition(e.g. partition 1 /dev/sdX1).

  • Update kernel in eMMC

If you boot your board from eMMC you can update your kernel file by following the steps below:
1) Usually after OS is loaded eMMC's boot partition (in our example eMMC's device name was /dev/mmcblk0p1) will be automatically mounted and you can verify that by running "mount"
2) Connect your board to a host PC running Ubuntu and copy the zImage and DTB files to eMMC's boot partition
3) Or you can copy your generated kernel file to an external storage card(e.g. an SD card or a USB drive), connect the storage card to your board the move the file from the card to eMMC's boot partition
4) After update is done type "reboot" to reboot your board. Note: don't just directly disconnect your board from its power source or press the reset button to reboot the board. These actions will damage your kernel file

  • Generate Your boot.img

Refer to this repo: https://github.com/friendlyarm/sd-fuse_s5p4418

1.3 Compile Linux kernel for Android7

The Android 7.1.2 source code already contains the pre-compiled kernel. If you need to customize it, you can compile the kernel according to the following guide.

git clone https://github.com/friendlyarm/linux.git -b nanopi2-v4.4.y --depth 1
cd linux
touch .scmversion
make ARCH=arm nanopi2_nougat_defconfig
make ARCH=arm

The newly generated kernel is arch/arm/boot/zImage,The new DTB file is also included under the directory arch/arm/boot/dts/.(s5p4418-nanopi2-rev*.dtb).
If you only want to debug the kernel, you can quickly update it with adb:

adb root; adb shell mkdir /storage/sdcard1/; adb shell mount -t ext4 /dev/block/mmcblk0p1 /storage/sdcard1/;
adb push arch/arm/boot/zImage arch/arm/boot/dts/s5p4418-nanopi2-rev*.dtb /storage/sdcard1/

If you want to generate boot.img for burning, you can copy the kernel zImage and DTB files to the Android7 source code directory: device/friendlyelec/nanopi2/boot, then recompile Android7.

1.3.1 Compile U-Boot for Android7/FriendlyCore/Lubuntu/EFlasher

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

git clone https://github.com/friendlyarm/u-boot.git 
cd u-boot
git checkout nanopi2-v2016.01
make s5p4418_nanopi2_defconfig
make CROSS_COMPILE=arm-linux-

After your compilation succeeds a bootloader.img will be generated. If you want to test it flash it to your installation SD card to replace an existing U-Boot v2016.01 file via fastboot, sd-fuse_s5p4418 or eflasher ROM.
For Android7: Copy bootloader.img to Android7 source directory device/friendlyelec/nanopi2/boot, then recompile Android7.
Note: you cannot use mixed U-Boot files. For example you cannot use fastboot to update an existing U-Boot V2014.07 and you cannot use bootloader.img to replace an existing u-boot.bin

1.4 Compile Android 7.1.2

1.4.1 Install Cross Compiler

Install 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 curl libncurses5-dev libssl-dev zlib1g-dev gawk minicom
sudo apt-get install openjdk-8-jdk
sudo apt-get install exfat-fuse exfat-utils device-tree-compiler liblz4-tool

For more details refer to https://source.android.com/source/initializing.html

1.4.2 Download Android7 Source Code

There are two ways to download the source code:

  • repo archive file on netdisk

Netdisk URL: Click here
File location on netdisk:sources/s5pxx18-android-7.git-YYYYMMDD.tgz (YYYYMMDD means the date of packaging)
After extracting the repo package from the network disk, you need to execute the sync.sh script, which will pull the latest code from gitlab:

tar xvzf /path/to/netdisk/sources/s5pxx18-android-7.git-YYYYMMDD.tgz
cd s5pxx18-android-7
./sync.sh
  • git clone from gitlab

{{{1}}} source code is maintained in gitlab, You can download it by running the following command:

git clone https://gitlab.com/friendlyelec/s5pxx18-android-7.git -b master

1.4.3 Compile Android7

cd s5pxx18-android-7
source build/envsetup.sh
lunch aosp_nanopi2-userdebug
make -j8

After your compilation succeeds the following files will be generated in the "out/target/product/nanopi2/" directory.

filename partition Description
bl1-mmcboot.bin raw boot firmware
loader-mmc.img raw boot firmware
bl_mon.img raw boot firmware
bootloader.img raw uboot-v2016.01
env.conf - Uboot environment variable containing Android kernel command line parameters
boot.img boot kernel zImage, DTBs; logo; Android ramdisk
cache.img cache -
userdata.img userdata -
system.img system -
partmap.txt - Partition description file