Difference between revisions of "Template:S5P6818BuildFromSource"
(→Compile Kernel) |
(updated by API) |
||
(22 intermediate revisions by 3 users not shown) | |||
Line 4: | Line 4: | ||
Download the compiler package: | 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 -b master --depth 1 |
− | + | cd prebuilts/gcc-x64 | |
− | + | cat toolchain-4.9.3-armhf.tar.gz* | sudo tar xz -C / | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | sudo tar | + | |
</syntaxhighlight> | </syntaxhighlight> | ||
Line 71: | Line 36: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | ===Compile Linux kernel | + | ===Compile Linux kernel for FriendlyCore/Lubuntu/EFlasher=== |
====Compile Kernel==== | ====Compile Kernel==== | ||
* Download Kernel Source Code | * 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 -b nanopi2-v4.4.y --depth 1 |
cd linux | cd linux | ||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
− | The | + | The kernel source for S5P6818 is in the "nanopi2-v4.4.y" branch. Before you start compiling it you need to switch to this branch. |
* Compile Ubuntu Kernel | * Compile Ubuntu Kernel | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 86: | Line 50: | ||
make ARCH=arm64 | make ARCH=arm64 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | After your compilation succeeds an "arch/arm/boot/Image" will be generated and a DTB file(s5p6818- | + | After your compilation succeeds an "arch/arm/boot/Image" will be generated and a DTB file(s5p6818-nanopi3-rev*.dtb) will be generated in the "arch/arm/boot/dts/nexell" directory. You can use them to replace the existing Image and DTB files in the boot partition of your bootable SD card.<br /> |
====Use Your Generated Kernel==== | ====Use Your Generated Kernel==== | ||
* Update kernel in SD card | * Update kernel in SD card | ||
− | If you use an SD card to boot Ubuntu you can copy your generated Image and DTB files to your SD card's boot | + | If you use an SD card to boot Ubuntu you can copy your generated Image and DTB files to your SD card's boot partition(e.g. partition 1 /dev/sdX1). |
* Update kernel in eMMC | * Update kernel in eMMC | ||
If you boot your board from eMMC you can update your kernel file by following the steps below:<br /> | If you boot your board from eMMC you can update your kernel file by following the steps below:<br /> | ||
− | 1) Usually after OS is loaded eMMC's boot | + | 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"<br /> |
− | 2) Connect your board to a host PC running Ubuntu and copy the Image and DTB files to eMMC's boot | + | 2) Connect your board to a host PC running Ubuntu and copy the Image and DTB files to eMMC's boot partition<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 | + | 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" 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 /> | 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<br /> | ||
* Generate Your boot.img | * Generate Your boot.img | ||
− | + | Refer to this repo: https://github.com/friendlyarm/sd-fuse_s5p6818<br /> | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | ===Compile | + | ===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/ | + | git clone https://github.com/friendlyarm/linux.git -b nanopi2-v4.4.y --depth 1 |
− | + | cd linux | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | 4 | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | cd | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
touch .scmversion | touch .scmversion | ||
− | make | + | make ARCH=arm64 nanopi3_nougat_defconfig |
+ | make ARCH=arm64 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | * | + | The newly generated kernel is arch/arm64/boot/Image,The new DTB file is also included under the directory arch/arm64/boot/dts/nexell/.(s5p6818-nanopi3-rev*.dtb).<br /> |
+ | If you only want to debug the kernel, you can quickly update it with adb: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | + | adb root; adb shell mkdir /storage/sdcard1/; adb shell mount -t ext4 /dev/block/mmcblk0p1 /storage/sdcard1/; | |
− | + | adb push arch/arm64/boot/Image arch/arm64/boot/dts/nexell/s5p6818-nanopi3-rev*.dtb /storage/sdcard1/ | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | If you want to generate boot.img for burning, you can copy the kernel Image and DTB files to the Android7 source code directory: device/friendlyelec/nanopi3/boot, then recompile Android7. | ||
− | === | + | ===Compile U-Boot for Android7/FriendlyCore/Lubuntu/EFlasher=== |
− | + | Download the U-Boot v2016.01 source code and compile it. Note that the github's branch is nanopi2-v2016.01: | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | + | git clone https://github.com/friendlyarm/u-boot.git | |
− | + | cd u-boot | |
+ | git checkout nanopi2-v2016.01 | ||
+ | make s5p6818_nanopi3_config | ||
+ | make CROSS_COMPILE=aarch64-linux- | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | After your compilation succeeds a fip-nonsecure.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_s5p6818 or eflasher ROM.<br/> | |
− | + | For Android7: You can copy fip-nonsecure.img to the Android7 source directory device/friendlyelec/nanopi3/boot and 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. | |
− | + | ||
− | + | ||
− | + | ||
− | + | ===Compile Android 7.1.2=== | |
− | + | ====Install Cross Compiler==== | |
− | 1 | + | Install 64 bit Ubuntu 16.04 on your host PC. |
− | 2 | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | git | + | 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 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | For more details refer to https://source.android.com/source/initializing.html 。 | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | ./ | + | |
− | + | ||
− | + | ||
− | + | ||
− | ==== | + | ====Download Android7 Source Code==== |
− | + | There are two ways to download the source code: | |
− | + | * '''repo archive file on netdisk''' | |
+ | Netdisk URL: [http://download.friendlyelec.com/{{#replace:{{#replace:{{BASEPAGENAME}}| |}}|/zh|}} Click here]<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: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | + | tar xvzf /path/to/netdisk/sources/s5pxx18-android-7.git-YYYYMMDD.tgz | |
− | + | cd s5pxx18-android-7 | |
+ | ./sync.sh | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | * '''git clone from gitlab''' | |
+ | {{{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-android-7.git -b master | |
− | ./ | + | |
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | ====Compile Android7==== | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
+ | cd s5pxx18-android-7 | ||
source build/envsetup.sh | source build/envsetup.sh | ||
lunch aosp_nanopi3-userdebug | lunch aosp_nanopi3-userdebug | ||
make -j8 | make -j8 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | After your compilation succeeds | + | After your compilation succeeds the following files will be generated in the "out/target/product/nanopi3/" directory. |
::{| class="wikitable" | ::{| class="wikitable" | ||
|- | |- | ||
− | |filename | + | |filename || partition || Description |
|- | |- | ||
− | |boot.img | + | |bl1-mmcboot.bin || raw || boot firmware |
+ | |- | ||
+ | |fip-loader.img || raw || boot firmware | ||
+ | |- | ||
+ | |fip-secure.img || raw || boot firmware | ||
+ | |- | ||
+ | |fip-nonsecure.img || raw || uboot-v2016.01 | ||
|- | |- | ||
− | | | + | |env.conf || - || Uboot environment variable containing Android kernel command line parameters |
+ | |- | ||
+ | |boot.img || boot || kernel Image, DTBs; logo; Android ramdisk | ||
|- | |- | ||
− | | | + | |cache.img || cache || - |
|- | |- | ||
− | | | + | |userdata.img || userdata || - |
|- | |- | ||
− | |partmap.txt | + | |system.img || system || - |
+ | |- | ||
+ | |partmap.txt || - || Partition description file | ||
|- | |- | ||
|} | |} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 07:19, 21 February 2022
Contents
1 Make Your Own OS Image
1.1 Install Cross Compiler
1.1.1 Install aarch64-linux-gcc 6.4
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 kernel source for S5P6818 is in the "nanopi2-v4.4.y" branch. Before you start compiling it you need to switch to this branch.
- Compile Ubuntu Kernel
touch .scmversion make ARCH=arm64 nanopi3_linux_defconfig make ARCH=arm64
After your compilation succeeds an "arch/arm/boot/Image" will be generated and a DTB file(s5p6818-nanopi3-rev*.dtb) will be generated in the "arch/arm/boot/dts/nexell" directory. You can use them to replace the existing Image 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 Image 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 Image 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_s5p6818
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=arm64 nanopi3_nougat_defconfig make ARCH=arm64
The newly generated kernel is arch/arm64/boot/Image,The new DTB file is also included under the directory arch/arm64/boot/dts/nexell/.(s5p6818-nanopi3-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/arm64/boot/Image arch/arm64/boot/dts/nexell/s5p6818-nanopi3-rev*.dtb /storage/sdcard1/
If you want to generate boot.img for burning, you can copy the kernel Image and DTB files to the Android7 source code directory: device/friendlyelec/nanopi3/boot, then recompile Android7.
1.4 Compile U-Boot for Android7/FriendlyCore/Lubuntu/EFlasher
Download the U-Boot v2016.01 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 s5p6818_nanopi3_config make CROSS_COMPILE=aarch64-linux-
After your compilation succeeds a fip-nonsecure.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_s5p6818 or eflasher ROM.
For Android7: You can copy fip-nonsecure.img to the Android7 source directory device/friendlyelec/nanopi3/boot and 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.5 Compile Android 7.1.2
1.5.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.5.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.5.3 Compile Android7
cd s5pxx18-android-7 source build/envsetup.sh lunch aosp_nanopi3-userdebug make -j8
After your compilation succeeds the following files will be generated in the "out/target/product/nanopi3/" directory.
filename partition Description bl1-mmcboot.bin raw boot firmware fip-loader.img raw boot firmware fip-secure.img raw boot firmware fip-nonsecure.img raw uboot-v2016.01 env.conf - Uboot environment variable containing Android kernel command line parameters boot.img boot kernel Image, DTBs; logo; Android ramdisk cache.img cache - userdata.img userdata - system.img system - partmap.txt - Partition description file