LineageOS SourceCode ကနေ ကိုယ့်ရဲ့ Android Device အတွက် LineageOS CustomROM တစ်ခု ဘယ်လို Build မလဲ?

date_range 22 January 2018

LineageOS SourceCode ကနေ ကိုယ့်ရဲ့ Android Device အတွက် LineageOS CustomROM တစ်ခု ဘယ်လို Build မလဲ?

visibility 480 Views

Introduction

                ဒီတခါ ကျွန်တော်ပြောပြမယ့် အကြောင်းအရာကတော့ "LineageOS SourceCode ကနေ ကိုယ့်ရဲ့ Android Device အတွက် LineageOS CustomROM တခု ဘယ်လို Build မလဲ?" ဆိုတဲ့ အကြောင်းအရာပါ။ LineageOS ဆိုတာ Android CustomROM Cummunity တွေထဲမှာ Support Device အများဆုံး၊ Popular အဖြစ်ဆုံးနဲ့ အကြီးဆုံးလို့ ပြောလို့ရပါတယ်။ Android User တော်တော်များများလည်း ရင်းနှီးကြသလို အခုမှ စလုပ်မယ့်သူတွေ အတွက်လည်း LineageOS နဲ့ စပြီး Build ကြည့်တာ အလွယ်ကူဆုံး ဖြစ်ပါတယ်။ 

                ဘာကြောင့်လဲ ဆိုတော့ LineageOS Team မှာ Developers/Contributors တွေ အများကြီးရှိသလို Android Device တော်တော်များများရဲ့ Kernel Source နဲ့ Device Tree တွေ အများကြီးရှိတဲ့အပြင် အမြဲလည်း Update လုပ်ပေးနေလို့ပါ။ ကိုယ်တိုင် Source ကနေ Modification ပိုင်းလုပ်တာ မကျွမ်းကျင်ဘူး ဆိုရင်တောင်မှပဲ အဆင်သင့်ယူလို့ ရပါတယ်။ https://github.com/LineageOS/ အောက်မှာ ကိုယ့်ဖုန်းရဲ့ Device Name အလိုက် ရှာလို့ ရပါတယ်။ 

                အခု ကျွန်တော်ရဲ့ Guide ကို ဖတ်ပြီးသွားရင် တခြား Android CustomROM တွေလည်း Build တတ်သွားပါလိမ့်မယ်။ Android OS SourceCode ယူရတဲ့ နေရာနဲ့ တချို့ Linux Make Command တွေပဲ ကွာသွားပါလိမ့်မယ်။ (Example: Android CustomROM Teams - OmniROM, AOSiP, AOKP, AOSP Extended, Dirty Unicorns, ResurrectionRemix and etc...) 

                တခုတော့ သတိပေးထားပါရစေ။ Android OS SourceCode ရဲ့ Filesize က 20GB နဲ့ အထက်မှာ ရှိပါတယ်။ အဲဒါကြောင့် Internet ကောင်းမှပဲ အဆင်ပြေပါလိမ့်မယ်။ Build တဲ့ နေရာမှာ Linux မှာပဲဖြစ်ဖြစ်၊ Mac မှာပဲဖြစ်ဖြစ် Build လို့ရပါတယ်။ ကျွန်တော်ကတော့ Linux မှာပဲ Build ပြသွားမှာပါ။ ခုလောလောဆယ်တော့ ubuntu 17.04 ပဲ သုံးဖြစ်ပါတယ်။ အဲဒါကြောင့် Ubuntu ပေါ်မှာ build တာပဲ ဥပမာပေး ပြောသွားမှာပါ။ Build မယ့် Target Android Device ကတော့ Google Nexus 5X ပါ။

LineageOS Android Distribution

Information

Project

Support

Requirements

  • Linux OS သုံးထားတဲ့ Computer တလုံးရှိရပါမယ်။
  • OpenJDK Install လုပ်ထားရပါမယ်။
  • Python 2.7+ Install လုပ်ထားရပါမယ်။ (ဘာလို့လဲဆိုတော့ Google ရဲ့ git-repo က Python နဲ့ရေးထားတာ ဖြစ်တဲ့အတွက် Python Install လုပ်မထားရင် git-repo က အလုပ်မလုပ်ပါဘူး)
  • Git အသုံးပြုတတ်ရပါမယ်။
  • Google ရဲ့ git-repo လည်း သုံးတတ်ရပါမယ်။ (git-repo အကြောင်းကို ဒီမှာ ဝင်ဖတ်နိုင်ပါတယ်။ ပြီးသွားရင် git-repo command တွေကို ဒီမှာ လေ့လာကြည့်ပါ။) 

git-repo

                git-repo ဆိုတာ Git ပေါ်မှာ အခြေခံပြီး Google က Develop လုပ်ထားတဲ့ Tool တခုပါ။ Android ROM Development ပိုင်းမှာ အရမ်းအသုံးဝင်ပါတယ်။ [ git-repo - Multiple Repository Tool ] လို့လည်း ခေါ်ပါတယ်။ သူ့ရဲ့ အသုံးဝင်ပုံက Repo တခုဆောက်၊ အဲဒီထဲမှာ xml File လေးတခုဆောက်၊ ကိုယ်လိုချင်တဲ့၊ ကိုယ် Remote လုပ်ချင်တဲ့ repo တွေကို Link ပေး၊ နောက် repo sync ဆိုတဲ့ command ကိုသုံးပြီး ကိုယ့်ရဲ့ Local Machine ထဲကို တနေရာတည်းမှာပဲ Repository တွေအမျာကြီး Download ဆွဲလို့ရပါတယ်။ သဘောက ROM တခု Build ဖို့ လိုအပ်တဲ့ Android SourceCode Repository တွေက အများကြီးထဲကမှ တခုချင်းစီလိုက်ပြီး git clone မနေပဲ xml File လေးကနေ Repository အများကြီးစုပြီး Local ထဲကို Download ဆွဲလိုက်တဲ့ သဘောပါပဲ။

Setup Your Environment

Step 1 : OpenJDK Installation

  • ပထမဦးဆုံး OpenJDK ကို ကိုယ့်ရဲ့ Computer မှာ Install လုပ်ထားဖို့ လိုပါတယ်။ Terminal ကိုဖွင့်ပြီး အောက်က Command လေးတွေ ရိုက်ပေးပါ။

    sudo apt-get update
    sudo apt-get install openjdk-8-jdk
    sudo apt-get install openjdk-8-jre

    OpenJDK Install တဲ့ နေရာမှာ ကိုယ် Build မယ့် Android Version ပေါ်မူတည်ပြီး Install လုပ်ရမယ့် OpenJDK Version တွေ ကွဲသွားမယ် ဆိုတာကို သတိပြုရပါမယ်။

  • Android Nougat ကနေ Android Oreo အတွက်ဆိုရင် OpenJDK 8 ကို Install လုပ်ပေးပါ။

  • Android Lollipop ကနေ Android Marshmallow အတွက်ဆိုရင် OpenJDK 7 ကို Install လုပ်ပေးပါ။

  • Android Gingerbread ကနေ Android KitKat အတွက်ဆိုရင် OpenJDK 6 ကို Install လုပ်ပေးပါ။ (သူ့ရဲ့ အောက်က Android Version အတွက်တော့ ဘယ်သူမှလည်း Build မှာ မဟုတ်တော့လို့ မပြောတော့ပါဘူး။)

Step 2 : Python Installation

                နောက်တဆင့်ကတော့ Python install ပေးဖို့လိုပါတယ်။ Python 2.7 လောက်ဆို အဆင်ပြေပါပြီ။ (Python 3+ ဆို git-repo အတွက် သိပ်အဆင်မပြေပါဘူး။ အဲဒါကြောင့် 2.7 ပဲ Install လုပ်ပေးပါ။)

sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python2.7

Step 3 : Build-Tools Installation

                လိုအပ်တဲ့ Build-Tools တွေ Install လုပ်ဖို့အတွက် အောက်က Command လေးကို Terminal မှာ ရိုက်ပေးပါ။

sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip

Step 4 : Git and Repo (git-repo) Installation

  • အရင်ဆုံး Git Install မလုပ်ရသေးဘူးဆိုရင် လုပ်ပေးပါ။ (Install လုပ်ထားပြီးသားဆိုရင်တော့ ဒီအဆင့်ကို ထပ်လုပ်စရာမလိုပါဘူး။)

    sudo apt-get install git-core
  • Setting your username and email in Git

  • Format :

    git config --global user.name "Your Name"
    git config --global user.email "you@example.com"
  • Example :

    git config --global user.name "zawzaw"
    git config --global user.email "zawzaw@gmail.com"
  • Google ရဲ့ git-repo ကို Install လုပ်ပေးရပါမယ်။ (အသုံးဝင်ပုံကို Introduction မှာ ရှင်းပြထားပြီးဖြစ်လို့ ထပ်မပြောတော့ပါဘူး။)

    mkdir ~/bin
    PATH=~/bin:$PATH
    curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    chmod a+x ~/bin/repo

                အဲဒါတွေ အကုန်ပြီးသွားပြီ ဆိုရင်တော့ ROM တခု Build ဖို့အတွက် Setup Environment ပိုင်းက ပြည့်စုံသွားပါပြီ။

Downloading The Sources

  • Android OS ကြီးတခုလုံးအတွက် လိုအပ်မယ့် Repositories တွေကို Android Platform Manifest Repo ကနေ Download လုပ်မှာ ဖြစ်ပါတယ်။

  • Android Platform Manifest မှာ ဘာတွေပါလဲဆိုတော့ Android OS အတွက် လိုအပ်တဲ့ Repos တွေဖြစ်တဲ့ frameworks repos, bootable recovery, kernel trees(for AOSP), device trees(for AOSP), system repos, hardware repos, system packages apps, Prebuilt GCC Toolchains and buildtools, external repos, vendor, tools repos စတာတွေ အကုန်ပါပါတယ်။ Filesize ကလည်း 20GB နဲ့ အထက်မှာရှိပါတယ်။ မူရင်း AOSP SourceCode ရဲ့ Filesize ဆိုရင် ဒီထက်မက များပါတယ်။

  • LineageOS Main SourceCode - All Repos

  • LineageOS - Android Platform Manifest

  • ပထမဆုံး Sources တွေ Download ဖို့အတွက် Directory တခု ဆောက်ပါမယ်။

    mkdir LineageOS-Project
    cd LineageOS-Project
  • LineageOS SourceCode ကို Download ပါတော့မယ်။

  • -b နောက်ကကောင်က 'lineage-15.0' က branch name ပါ။

  • lineage-15.1(Coming soon...) က Oreo(8.1.0+) build အတွက်ပါ။

  • lineage-15.0 က Oreo(8.0.0) build အတွက်ပါ။

  • cm-14.0 သုံးရင် Nougat(7.0) build အတွက်ပါ။

  • cm-14.1 သုံးရင် Nougat(7.1.1-7.1.2) build အတွက်ပါ။

  • ကြိုက်တဲ့ Android Version ကို Build နိုင်ပါတယ်။

  • Android 8.0.0 (Oreo) Version Build ချင်သူများက "lineage-15.0" branch ကို သုံးပါ။

    repo init -u git://github.com/LineageOS/android.git -b lineage-15.0
  • Android 8.1.0 (Oreo) Version Build ချင်သူများက "staging/lineage-15.1" branch ကို သုံးပါ။

    repo init -u git://github.com/LineageOS/android.git -b staging/lineage-15.1
  • Sources တွေ download ဖို့ အောက်က command လေး ရိုက်ပေးပါ။

    repo sync

                အဲဒီနောက်မှာတော့ Sources တွေ Downloading လုပ်နေတဲ့ အပိုင်းပါ။ SourceCode တွေ Download တဲ့ Process ကတော့ မိမိရဲ့ Internet Connection ပေါ်မှာ မူတည်ပြီး ကြာပါလိမ့်မယ်။

Building LineageOS

  • Official Documentation: LineageOS Building for Nexus 5X

  • အရင်ဆုံး Source ကနေ Compilation မလုပ်ခင် ကြိုတင်ပြင်ဆင်ရမယ့် အရာတွေကို ပြောပြပေးပါမယ်။

  • Introduction မှာ ပြောခဲ့သလိုပဲ ကိုယ့် Android Phone အတွက် လိုအပ်တဲ့ Kernel Source နဲ့ Device Tree Repo တွေကို github.com/LineageOS/ အောက်မှာ သွားရှာလို့ ရပါတယ်။ ဘယ်လို ရှာရမလဲ ပြောပါမယ်။ Name ပေးပုံ ပေးနည်းကို သိရင် ရပါပြီ။

  • Example for Nexus 5X (Nexus 5X ရဲ့ Device Name ကို bullhead လို့ ခေါ်ပါတယ်။)

  • Format : Device Tree

    android_device_manufacturer_devicename
  • Example : Device Tree for Nexus 5X

    android_device_lge_bullhead
  • Format : Kernel Source

    android_kernel_manufacturer_devicename
  • Example: Kernel source for Nexus 5X

    android_kernel_lge_bullhead
  • ပထမဆုံး လိုအပ်တာက ကိုယ့်ဖုန်းရဲ့ Device Tree ပါ။

  • Location က ဘယ်မှာ သွားထည့်ရမလဲဆိုရင် Download လုပ်ထားတဲ့ Source dir အောက်က /device အောက်မှာ သွားထည့်ပေးရမှာပါ။

  • Format:

    /device/manufacturer/device_name
  • Example for Nexus 5X:

    /device/lge/bullhead
  • ROM build တဲ့နေရာမှာ Kernel ပိုင်းက နှစ်မျိုးကွဲပါမယ်။ Kernel Source ကနေ Build တာရယ်၊ အဆင်သင့် Build ထားပြီးသား Prebuilt Kernel ကနေ Build တာရယ် ဆိုပြီး ရှိပါတယ်။ Kernel Source ကနေ Build တာပဲ အကြံပေးပါတယ်။

  • ပြီးတဲ့နောက် Kernel Source ကနေ Build မယ်ဆိုရင် Device Tree ထဲမှာ ပြင်ဆင်စရာရှိပါတယ်။ Nexus 5X အနေနဲ့ ပြောပါမယ် /device/lge/bullhead/BoardConfig.mk ကို TextEditor တခုနဲ့ ဖွင့်ပြီး အောက်က Code လေးတွေ ထပ်ဖြည့်လိုက်ပါ။ (အခုအဆင့်က ကိုယ်တိုင် Modify လုပ်နိုင်အောင် ပြောပေးတာပါ။ LineageOS Source ကနေဆို မလိုပါဘူး။ သူတို့ရဲ့ Official Contributor တွေ အဆင့်သင့် လုပ်ပေးထားပါတယ်။ သူတို့ Support လုပ်ပေးထားတဲ့ Device တွေအတွက်ဆိုရင် လုပ်စရာမလိုတော့ပါဘူး။)

    # Inline Kernel Build
    KERNEL_TOOLCHAIN := $(ANDROID_BUILD_TOP)/prebuilts/gcc/$(HOST_OS)-x86/aarch64/aarch64-linux-android-4.9/bin
    KERNEL_TOOLCHAIN_PREFIX := aarch64-linux-android-
    TARGET_KERNEL_SOURCE := kernel/lge/bullhead
    TARGET_KERNEL_CONFIG := purez_defconfig
    BOARD_KERNEL_IMAGE_NAME := Image.gz-dtb
  • Explanation:

    ဒီအဆင့်က ကျွန်တော် ပထမဆုံး ရေးထားခဲ့တဲ့ Building-Kernel ဆိုတဲ့ Tutorial ကို ဖတ်ပြီးမှ အဆင်ပြေပါလိမ့်မယ်။

    Line 1 - Kernel ကို Compile မယ့် Toolchain location ကို ပေးတာပါ။
    Line 2 - ကိုယ်သုံးမယ့် Toolchain ရဲ့ Kernel toolchain prefix လို့ခေါ်ပါတယ်။ (သိပ်နားမလည်ဘူးဆိုရင် Kernel Compilation Tutorial မှာ လေ့လာကြည့်ပါ)
    Line 3 - ဒါကတော့ ကိုယ် Build မယ့် Kernel Source Location ပါ။
    Line 4 - Kernel Build ဖို့အတွက် Kernel Configuration လုပ်ပေးရပါတယ်။
    Line 5 - ကိုယ့်ဖုန်းအတွက် Output ထွက်မယ့် Kernel Image Name ကို အတိအကျ ရေးပေးရပါမယ်။

  • နောက်တဆင့်က Kernel source အပိုင်းပါ။ သွားထည့်ပေးရမယ့် Location က Source dir အောက်က /kernel အောက်မှာ သွားထည့်ပေးရမှာပါ။

  • Format:

    /kernel/manufacturer/device_name
  • Example: for Nexus 5X (ဒီ Location က Device Tree ထဲမှာ Kernel Source Path လမ်းကြောင်း ပြန်ပေးရမှာပါ)

    /kernel/lge/bullhead
  • vendor အပိုင်းပါ။ အဲဒီကောင်က Source dir အောက်က /vendor အောက်မှာ သွားထည့်ပေးရမှာပါ။

  • Format:

    /vendor/manufacturer/device_name
  • Example: for Nexus 5X

    /vendor/lge/bullhead

ဒါတွေ ပြည့်စုံသွားရင်တော့ LineageOS CustomROM တခု Build ဖို့ အဆင်သင့် ဖြစ်ပါပြီ။

Final Steps

  • ဒါကတော့ နောက်ဆုံးအဆင့် ရောက်ပါပြီ။ Download လုပ်ထားတဲ့ Source Dir ထဲ ဝင်လိုက်ပြီး Terminal ကို ဖွင့်လိုက်ပါ။ အောက်က Command လေး ရိုက်ပေးပါ။

    . build/envsetup.sh

    (OR)

    source build/envsetup.sh
  • ပြီးရင် အောက်က Command လေး ဆက်ရိုက်ပေးပါ။ (AOSP တုန်းက lunch ဆိုတဲ့ command နဲ့ ဆင်တူပါတယ်)

  • Format:

    breakfast <device_name>
  • Example: for Nexus 5X (bullhead)

    breakfast bullhead

    Note: ဒီနေရာမှာ မလိုတာတွေ ချန်ထားခဲ့တာ ရှိပါတယ်။ Compilation Process Time မြန်အောင် "ccache" Setup လုပ်တဲ့ အပိုင်းတွေ မပြောတော့ပါဘူး။ ရှုပ်သွားမှာ ဆိုးလို့ပါ။ နောက်တခုက Android CustomROM Team တခုနဲ့ တခုက သူတို့ ROM Build ဖို့အတွက် Make Build Command တွေက မတူကြပါဘူး။ ဘာလို့လဲဆိုတော့ AOSP/platform/build (https://android.googlesource.com/platform/build) ဆိုတဲ့ Repo တခု ရှိပါတယ်။ သူက OS ကြီး တခုလုံးအတွက် Makefile နဲ့ ရေးထားတဲ့ Build System တခုပါ။ နားလည်ရင် စိတ်ကြိုက် ပြင်ဆင်ခွင့်ရှိပါတယ်။ အဲဒီမှာ Make Build Command တွေ ဖန်တီးနိုင်ပါတယ်။

  • Screenshots တွေကိုလည်း ထပ်ပြီး Upload မလုပ်တော့ပါဘူး။ တူတူပါပဲ။ AOSP Building Guide မှာ ကြည့်နိုင်ပါတယ်။

  • LineageOS 14.1 နဲ့ အထက်အတွက် Jack Configure လုပ်ပေးဖို့ လိုအပ်ပါတယ်။

    export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"
  • နောက်ဆုံးအဆင့် အနေနဲ့ ROM Build ဖို့အတွက် အောက်က Command လေး ဆက်ရိုက်ပေးပါ။ (bullhead ဆိုတဲ့နေရာမှာ ကိုယ်ဖုန်းရဲ့ Device Name ပေါ် မူတည်ပြီး ကွဲပြားသွားပါလိမ့်မယ်)

    croot
    brunch bullhead
  • Output ထွက်မယ့်နေရာကတော့ အောက်က Location အတိုင်း ဖြစ်ပါတယ်။

    Output - /out/target/product/bullhead/ အောက်မှာ flashablezip အနေနဲ့ ထွက်လာပါလိမ့်မယ်။

                Compilation Process Time ကတော့ မိမိ Computer ရဲ့ CPU Core ပေါ် မူတည်ပြီး ကြာပါလိမ့်မယ်။

References
TechX How To
About Author
Assinged Tags
Android Tutorial
Categorized Under
How To

Join Us On

Facebook
YouTube
Twitter
GooglePlus
TechX RSS Feed