[ASUS ZenFone 8] bnsmb:
Update 31.03.2024:

Please see also the Infos for building aCustomROM image for changes in the build process since Q1 2024.

Compiling the CustomROM OmniROM 14 from within Linux is again a very simple and straight forward process -- the developer for the OmniROM did once again a really amazing good job setting up the build environment for the OmniROM 14.

(I'm repeating myself here - but it can't be said often enough)

Notes:

This HowTo is about how to compile the OmniROM 14 for the ASUS Zenfone 8 -- see How to compile the OmniROM 13 for the ASUS Zenfone 8 for how to compile the OmniROM 13 for the ASUS Zenfone 8; see How to compile the OmniROM for the ASUS Zenfone 8 for how to compile the OmniROM 12 for the ASUS Zenfone 8.

Hardware requirements

Message from the repo tool:

"The minimum required amount of free memory is around 16GB, and even with that, some configurations may not work."

In my experience, the computer on which OmniROM is compiled should have at least 32 GB RAM and 4 CPU cores.

(The numbers in this document are for a PC with 16 CPU cores and 128 GB RAM)

Note that the scripts used to create the OmniROM image start one process per CPU and each process requires about 4 GB of RAM. Additional 2 GB RAM are required for the general tasks.

As of 09.01.2024, the repositories for OmniROM 14 occupy about 290 GB of disk space; the additional repositories for the hardware-specific repositories for the ASUS Zenfone 8 occupy about 30 GB of disk space.

The compile process will occupy additional 140 GB for the temporary output files.

In total, the repositories for OmniROM 14 require around 500 GB of storage space (the space used will increase with every "repo sync")

Prerequisites

Some of the repositories for OmniROM 14 are on https://gitlab.com and the access to these repositories for the repository sync is done via ssh. Therefore, to sync these repositories a user account on gitlab.com with configured public ssh key is required. The user account on gitlab.com is free of charge and the public ssh key can be uploaded into the user profile on gitlab.com (see here: https://docs.gitlab.com/ee/user/ssh.html)

The repositories on http://github.com are currently accessed via https but that might change in the future. Therefor it's recommended to create a user on github.com and add the ssh public key to the profile of that user also.

Note:

To check how the access to the repositories is configured use this command

[ OmniRom 14 Dev - xtrnaw7@t15g [B]/data/develop/android/OmniROM_14.0/.repo [/B]] $ [B] grep fetch $( find . -name "*xml" )[/B]
./local_manifests/local_manifest.xml: fetch="https://github.com/DonkeyCoyote" />
./manifests/omni-aosp.xml: fetch="https://github.com/" />
./manifests/omni-aosp.xml: fetch="ssh://git@gitlab.com/omnirom" />
./manifests/omni-aosp.xml: fetch="https://github.com/omnirom"
./manifests/omni-caf.xml: fetch="https://github.com/" />
./manifests/omni-caf.xml: fetch="https://github.com/omnirom"
./manifests/omni-caf.xml: fetch="https://git.codelinaro.org/clo/la"
./manifests/omni-private.xml: fetch="ssh://git@github.com/omnirom"
./manifests/default.xml: fetch="https://android.googlesource.com"
[ OmniRom 14 Dev - xtrnaw7@t15g /data/develop/android/OmniROM_14.0/.repo ] $

Use the commands

ssh git@github.com
ssh git@gitlab.com

to test the access via ssh and add the ssh hostkeys of the hosts github.com and gitab.com to the known_hosts file.

Or use

grep "^gitlab.com" ~/.ssh/known_hosts || ssh-keyscan gitlab.com >>~/.ssh/known_hosts
grep "^github.com" ~/.ssh/known_hosts || ssh-keyscan github.com >>~/.ssh/known_hosts

to add the ssh hostkeys of the repository server used to the local known_hosts file of the user used to retrieve the repositories.

It's recommended to start the ssh-agent and load the private ssh keys before starting the sync of the repositories, e.g. if no global ssh-agent is running use:

$( eval ssh-agent )
ssh-add

Use

ssh-add -l

to list the ssh keys already loaded by the ssh-agent.

The tool repo is required to maintain the repositories for the OmniROM 14; you can download the tool "repo" from https://gerrit.googlesource.com/git-repo or download it with this command:

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

It's not necessary to install additional tools for creating an OmniROM 14 image -- all necessary tools to create the image are in the repositories for the OmniROM 14.

The repositories used for the OmniROM 14 use the git command line extension git lfs. At least in Fedora this extension is not installed by default while installing git.

In Fedora git lfs can be installed using this command:

sudo dnf install git-lfs

Creating the local copies of the repositories for the OmniROM 14

Most (but not all) of the necessarry steps to sync the repositories necessary to create an OmniROM 14 installation image are described in the section "Getting Started" here: https://github.com/omnirom/android but some instructions are missing the details.

To create a local copy of the repositories for OmniROM 14 these steps are required:

First create a new directory for the repositories and change the working directory to the new directory, e.g.:

mkdir /data/develop/android/OmniROM_14.0
cd /data/develop/android/OmniROM_14.0

Then init the local repositories using the command:

repo init -u https://github.com/omnirom/android.git -b android-14.0 --git-lfs

Note that the command repo init only creates a hidden directory called .repo.

Next do the initial sync of the repositories using the command:

repo sync

The initial repository sync will download all repositories necessary to create the OmniROM 14 image except the hardware dependent repositories (these repos are different for the various phone models).

Therefor you must add the repositories for the vendor and device tree for your phone to the manifests in the local repositories after the download finished.

This should be done in the file .repo/local_manifests/local_manifest.xml (just create the directory .repo/local_manifests if it does not exist).

For the ASUS Zenfone 8 the file should look like this:

[ OmniRom 14 Dev - xtrnaw7@t15g /data/develop/android/OmniROM_14.0 ] $ cat .repo/local_manifests/local_manifest.xml
<?xml version="1.0" encoding="UTF-8"?>

<manifest>
<remote name="DonkeyCoyote"
fetch="https://github.com/DonkeyCoyote" />

<project path="device/asus/zenfone8" name="android_device_asus_zenfone8" remote="omnirom" revision="android-14.0" />
<project path="vendor/asus" name="proprietary_vendor_asus" remote="DonkeyCoyote" revision="android-14.0" />
<project path="vendor/microg" name="android_prebuilts_prebuiltapks" remote="omnirom" revision="android-13.0" />
<project path="vendor/images/asus" name="android_vendor_images_asus" remote="gitlab" revision="android-13.0" />

</manifest>
[ OmniRom 14 Dev - xtrnaw7@t15g /data/develop/android/OmniROM_14.0 ] $

Notes:

The repository android_prebuilts_prebuiltapks is only necessary for OmniROM 14 images that should include the MicroG packages.

After updating the file local_manifest.xml do another

repo sync

to sync the added repositories. This time the download will be faster because only the additional repos will be downloaded.

Now you can start the build with these commands:

# optional:
#
# to create an OmniROM image with MicroG packages set the environment variable ROM_BUILDTYPE to MICROG before starting the build
#
# to create an OmniROM image with GAPPS packages set the environment variable ROM_BUILDTYPE to GAPPS before starting the build
# (that will only work if the repositories for the GAPPS are configured, of course)
#
export ROM_BUILDTYPE=MICROG

. build/envsetup.sh

brunch omni_zenfone8-user

in the directory with the downloaded repositories (use the command "breakast" without parameter instead of "brunch" to see other possible targets)

Be aware that the first time the compile process will take 4 hours or more.

If everything is fine there will be a ZIP file with your own Custom OmniROM 14 image in the directory ./out/target/product/zenfone8/ when the compile script is done, e.g. for images with the MicroG packages:

[ OmniRom 14 Dev - xtrnaw7@t15g /data/develop/android/OmniROM_14.0 ] $ ls -l out/target/product/zenfone8/omni-14-202311*zip
-rw-rw-r--. 3 xtrnaw7 xtrnaw7 1363298353 Nov 20 10:22 out/target/product/zenfone8/omni-14-20231119-zenfone8-MICROG.zip
[ OmniRom 14 Dev - xtrnaw7@t15g /data/develop/android/OmniROM_14.0 ] $

The image can now be installed on the ASUS Zenfone 8 using the LineageOS Recovery or TWRP.

Notes:

Be aware that each new OmniROM 14 image created with brunch will overwrite the existing OmniROM 14 image (the name of the image is different but the used inodes are the same for all zip files):

[ OmniRom 14 Dev - xtrnaw7@t15g /data/develop/android/OmniROM_14.0 ] $ ls -il out/target/product/zenfone8/omni-14-202311*zip
80813412 -rw-rw-r--. 3 xtrnaw7 xtrnaw7 1363298353 Nov 20 10:22 out/target/product/zenfone8/omni-14-20231119-zenfone8-MICROG.zip
80813412 -rw-rw-r--. 3 xtrnaw7 xtrnaw7 1363298353 Nov 20 10:22 out/target/product/zenfone8/omni-14-20231120-zenfone8-MICROG.zip
[ OmniRom 14 Dev - xtrnaw7@t15g /data/develop/android/OmniROM_14.0 ] $

[ OmniRom 14 Dev - xtrnaw7@t15g /data/develop/android/OmniROM_14.0 ] $ cksum out/target/product/zenfone8/omni-14-202311*zip
1217746399 1363298353 out/target/product/zenfone8/omni-14-20231119-zenfone8-MICROG.zip
1217746399 1363298353 out/target/product/zenfone8/omni-14-20231120-zenfone8-MICROG.zip
[ OmniRom 14 Dev - xtrnaw7@t15g /data/develop/android/OmniROM_14.0 ] $

Therefor you should copy the existing zip file with the image to a new directory before building a new image.

Certificates for the OS images

For OS images that should be used on the phone for daily use I strongly recommend to create your own certificates for the OS.

In the OmniROM development directory tree the neccessary files, platform.pk8 and platform.x509.pem, are in the directory

./build/make/target/product/security

in your build tree for the CustomROM, e.g.

[ OmniRom 14 Dev - xtrnaw7@t15g /data/develop/android/OmniROM_14.0 ] $ ls -l ./build/make/target/product/security/platform.*
-rw-rw-r--. 1 xtrnaw7 xtrnaw7 1216 Nov 14 15:24 ./build/make/target/product/security/platform.pk8
-rw-rw-r--. 1 xtrnaw7 xtrnaw7 1675 Nov 14 15:24 ./build/make/target/product/security/platform.x509.pem
[ OmniRom 14 Dev - xtrnaw7@t15g /data/develop/android/OmniROM_14.0 ] $

Replace these files with your own certificate files and recreate the image using the command brunch (see above).

See here https://source.android.com/devices/tech/ota/sign_builds for how to create your own certificate.

Spoiler content hidden.

Updating the local repositories

To update the local repositories change the working directory to the directory with the repositories for OmniROM 14 and execute

repo sync

After the synchronization is complete, create a new operating system image using the commands described above.

It is recommended to create a new image at least once a month after the new security patches for Android are added to the repositories for OmniROM 14.

To view the date of the security patch in the source files for the OmniROM 14 execute this command in the directory with the source files for the OmniROM 14:

[ OmniRom 14 Dev - xtrnaw7@t15g /data/develop/android/OmniROM_14.0 ] $ date
Tue Jan 9 07:24:05 PM CET 2024
[ OmniRom 14 Dev - xtrnaw7@t15g /data/develop/android/OmniROM_14.0 ] $ grep "^[[:space:]]*PLATFORM_SECURITY_PATCH[[:space:]]*:=" ./build/make/core/version_defaults.mk
PLATFORM_SECURITY_PATCH := 2024-01-05
[ OmniRom 14 Dev - xtrnaw7@t15g /data/develop/android/OmniROM_14.0 ] $

See How to apply the Android Security patches to a local repository for how to apply an Android Security patch to the local repository.

Moving the repositories to another directory

In case you want to move the repositories for OmniROM 14 to another directory or rename the directory with the repositories:

Be aware that the make scripts create some absolute links in the output directory; to list these absolute links use this command while in the directory with the repositories for OmniROM 14 :

find . -type l -ls | grep " $PWD"

e.g. there are currently a lot of absolute links in the output directory:

[ OmniRom 14 Dev - xtrnaw7@t15g /data/develop/android/OmniROM_14.0 ] $ find . -type l -ls | grep " $PWD" | wc -l
131245
[ OmniRom 14 Dev - xtrnaw7@t15g /data/develop/android/OmniROM_14.0 ] $

Before starting another build after moving the directories with the repositories you must correct these links (or clean the directory ./out)

Log files

The verbose log of the compile scripts is always written to a compressed file in the output directory, e.g.:

Spoiler content hidden.

Other options of the make tools

To create the image with other options use

. build/envsetup.sh
lunch
$ make <options>

To list the known options for the make command use this command:

Spoiler content hidden.

Creating only the kernel or the boot image

To create only the kernel or the boot image use these commands

. build/envsetup

# select the target hardware
#
breakfast omni_zenfone8-user

# Now instead of following the rest of the guide (which will compile both Android and the kernel
# for your device), simply compile the kernel:
#
mka kernel

# This command will also generate the device tree, initramfs and boot.img images
#
mka bootimage

Trouble Shooting

Update 08.02.2024:

see Some hints for repo sync troubleshooting for how to fix some common errors while executing the command "repo sync".

see Some hints for fixing errors building an Custom ROM Android image for how to fix some common errors while creating the image

TWRP and OmniROM 14

Update 10.01.2024

For OmniROM 14 and other Android 14 based CustomROMs on the ASUS Zenfone 8 the TWRP version 3.7.0.12-1 or newer is required (because TWRP version 3.7.0.12-0 or older can not mount the /data partitions created by Android 14).

TWRP version 3.7.0.12-1 can now be downloaded from the TWRP webpage:

https://eu.dl.twrp.me/I006D/

Notes:

After dirty flashing an installed OmniROM 13 with OmniROM 14 the current official TWRP 3.7.0.12-0 can still access the /data partition - the "problem" only exists after a clean installation of OmniROM 14 (= with factory reset).

Spoiler content hidden.