0

I have a Mi 8 Lite (platina), for which there is no official LineageOS support. But LineageOS custom ROM for the device is available on XDA. On further research, I can see that vendor files, device tree and kernel source code is available for my device:

  1. Kernel Source
  2. Device Tree
  3. Vendor Files

How do I build a LineageOS ROM for my device without official support?

closed as off-topic by Irfan Latif, Firelord Sep 2 at 9:03

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about writing and publishing Android apps, writing custom ROMs, and other topics that are primarily of concern to developers are off-topic. Consider taking advantage of other resources that may be appropriate for your question." – Irfan Latif, Firelord
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Hello daltonfury42. Sorry, but development related questions are off-topic here. Please visit help center to know the scope of our site. I don't know whether Stack Overflow takes up such questions. Since you've already put efforts into helping others, I suggest you consider XDA, Medium, or some other platform to share this category of information. :-) – Firelord Sep 2 at 9:06
  • @Firelord This is not related to development, or writing custom ROMs. These are steps to 'build' a ROM by downloading and compiling it's source code. But if you still think it's a development question, I will move it to stackoverflow. – daltonfury42 Sep 2 at 10:21
  • Questions related to building apps or ROMs are not considered within the scope of this website, so you're free to take it wherever it pleases you. – Firelord Sep 2 at 10:27
  • @Firelord Can you help me move this to stackoverflow? – daltonfury42 Sep 2 at 11:12
  • @daltonfury42 I asked a moderator on Stack Overflow and he responded that it is too broad for their site. May be try their meta or chat room and see if this can be turned to fit into their site's scope? – Firelord Sep 2 at 11:56
3

Firstly you need to setup the build environment. You should be running Ubuntu 18.04. LineageOS build guide for a random device can be used as a reference. Reproducing the steps here:

Install the build packages:

sudo apt install bc bison build-essential ccache curl flex g++-multilib gcc-multilib git gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev liblz4-tool libncurses5-dev libsdl1.2-dev libssl-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev adb fastboot

Create the directories:

mkdir -p ~/bin
mkdir -p ~/android/lineage

Install the repo command:

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

Put the ~/bin directory in your path of execution by adding the following to your ~/.profile if it's missing:

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

Then, run source ~/.profile to update your environment. After that, initialize the LineageOS source repository and start downloading:

cd ~/android/lineage
repo init -u https://github.com/LineageOS/android.git -b lineage-16.0
repo sync

Downloading LineageOS source will take some time. After that we will deviate from the official build guide. Create a local manifest file telling the repo tool where to pick up the kernel source, device tree and vendor files. The corresponding file for platina can be downloaded from here. If you are building for a different device, use this manifest file as a reference and edit it accordingly. Save the file as

.repo/local_manifests/platina.xml 

Rerun repo tool to fetch them:

repo sync

Initialise your build environment:

source build/envsetup.sh

Enable caching to speed up the build:

export USE_CCACHE=1

You should add the above line to your .bashrc file. Then set the max cache size:

ccache -M 50G

Configure jack:

export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"

Edit device/xiaomi/platina/BoardConfig.mk and set the parameter TARGET_KERNEL_CONFIG to platina_user_defconfig:

enter image description here

TARGET_KERNEL_SOURCE points to the kernel code that is to be used during the build. TARGET_KERNEL_CONFIG specifies which configuration is to be used. By looking in arch/arm64/configs/ in the kernel source, I set the value to platina_user_defconfig

Finally start the build:

lunch 16
mka bacon -j8

This should lake a few hours to complete. I usually leave it running overnight. Here is where things get challenging. It’s possible that the build can fail due to errors, in which case you will have to fix it. Once the build has completed, you will find the zip file, ready to flash:

enter image description here

  • Do you know which signature key will be used when building a LineageOS image this way? – Robert Sep 2 at 7:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.