This is the Custom Rom build guide for Redmi Note 11 (spes/spesn)
#Requirements
1. A cloud server
2. Minimum 8-core & 64 GB RAM
3. Higher specs are better
4. 500 GB+ storage
5. Device: Redmi Note 11
6. Codename: spes/spesn
7. Stable internet connection
8. OS Ubuntu 20.04 LTS or latest
9. Working brain
OS
: Ubuntu 18.04 and higher [Any operating system would do (Debian Recommended)]
Version
: 64-bit
Installing required packages
sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev libc6-dev-i386 libncurses5 x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig
Setting Up Build Environment
Akhil Narang Scripts
Directly paste these one by one
First This
sudo su add-apt-repository ppa:openjdk-r/ppa && apt-get update && sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 libncurses5 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig && exit
Than This
mkdir ~/bin && PATH=~/bin:$PATH && cd ~/bin && curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo && chmod a+x ~/bin/repo && git clone https://github.com/akhilnarang/scripts.git scripts && cd scripts && bash setup/android_build_env.sh && cd
Our modified scripts
git clone https://github.com/tanvirr007/CustomROM_build_guide_aosp && cd CustomROM_build_guide_aosp && rm -rf README.md && sh setup.sh
Notes: Akhil Narang Scripts is Recommended
ROM_NAME/
|-- .repo/
|-- device/
| |-- (xiaomi)/
| |-- (spes)/ <-- This is where your device tree goes
|-- vendor/
| |-- (xiaomi)/
| |-- (spes)/ <-- This is where your vendor files go
|-- kernel/
| |-- (xiaomi)/
| |-- (sm6225)/ <-- This is where your kernel sources go
|-- (other project directories)
Device Directory Structure Explanation
-
device/xiaomi/spes
: This directory contains device-specific configuration files that are unique to thespes
codenamed Xiaomi device. These files may include details about the device's hardware components, such as the memory layout, peripheral interfaces, and power management settings. -
vendor/xiaomi/spes
: This directory contains vendor-specific configuration files that are specific to Xiaomi devices. These files may include proprietary drivers, software modules, and optimizations provided by Xiaomi. -
hardware/xiaomi
: This directory contains generic hardware configuration files that are shared across multiple Xiaomi devices. These files may include common hardware abstraction layers (HALs) and device-agnostic configurations. -
kernel/xiaomi/sm6225
: This directory contains kernel-specific configuration files that are tailored to the Qualcomm SM6225 as known as Snapdragon 680 chipset used in thespes
device. These files may include kernel modules, device drivers, and chipset-specific optimizations.
SPES is my device codename It varies phone to phone
I will use my pre-merged device tree, which contains vendorsetup.sh
. I've specified the cloning directory for the kernel and vendor trees in the vendorsetup.sh
, so manual cloning isn't necessary for me. However, if your device tree lacks this file, you'll need to manually clone the device/vendor/hardware/kernel
trees from GitHub or GitLab into the directory mentioned above.
Thanks Anar Jabiyev for device tree
Thanks Dblenk for device tree
Thanks Sayan Sarkar (bro) for base
Thanks Ascending (bro) for help
Thanks Aditya Bhaiyaa for the guidelines
Thanks Muralidharan for Mi680 kernel
Thanks Akira for Mi680 kernel
Thanks Jashkirat for recovery
Thanks Harshit (bro) for base setup/env script
Thanks ChatGPT && Bard for helping me debugging the rom
I am going to build LibreMobileOs (LMODroid)
mkdir rom_name
cd rom_name
Note: Here, rom_name
means use the rom name that you're going to build or you can choose any kind names whatever the fuck you want
Download/Clone rom manifest from GitHub or GitLab into the rom_name
folder
Initialize local repository
repo init -u https://git.libremobileos.com/LMODroid/manifest.git -b fourteen --git-lfs
Here,
-b
stands for branch
fourteen
stands for branch name
Note: Here you can can add --depth=1
it's optional.
This --depth=1
in Git means "clone only the latest commit, using less storage and reducing download time." While, it reduces storage and speeds up cloning, it also limits your access to historical changes beyond the specified depth. If you need to access historical changes or work with multiple branches, you should use a full clone instead. It is a good option for situations where you only need to work with the most recent changes in a repository.
For e.g.
repo init -u https://git.libremobileos.com/LMODroid/manifest.git -b fourteen --git-lfs --depth=1
Sync
repo sync -c -j$(nproc --all) --force-sync --no-clone-bundle --no-tags
Download/Clone Device/Vendor/Hardware/Kernel tree
from GitHub or GitLab into the rom_name
folder. I'll use my Pre merged Device/Vendor/Hardware/Kernel Tree
git clone https://github.com/tanvirr007/device_xiaomi_spes -b 14.0 device/xiaomi/spes
Here,
-b
stands for branch
14.0
for branch name
device/xiaomi/spes
is the download path
Now clone this hardware tree π
git clone https://github.com/LineageOS/android_hardware_xiaomi.git -b lineage-21 hardware/xiaomi
Now navigate to this path π
cd device/xiaomi/spes
ls
Note: The ls
command is a fundamental tool in the Linux operating system used to list the contents of a directory. It is one of the most frequently used commands and is essential for navigating the filesystem.
Now, you must have to modify these 2
files on device tree named
-
AndroidProducts.mk
-
blaze_spes.mk
Each rom use different/same
code names likes
Pixel Experience use: aosp
LMODroid use: lmodroid
PixelOS use: aosp
Project Elixir use: aosp
it's available either on their GitHub
manifest pages or in Telegram
group
I am building LMODroid
right now
So, my code name is lmodroid
It could be something else
according to your Selected rom
now, open AndroidProducts.mk
using nano
command
nano AndroidProducts.mk
Where you can see blaze
, change it to lmodroid
Now, to save the AndroidProducts.mk
press
ctrl+o
enter
ctrl+x
After pressing ctrl+x
it will revert back to your current path.
Now, it's time to rename & modify
the second file named blaze_spes.mk
For this particular rom, my codename is lmodroid
Now, type this to rename
mv blaze_spes.mk lmodroid_spes.mk
Type
ls
To open lmodroid_spes.mk
type
nano lmodroid_spes.mk
Change these 2
things:
- Inherit some common LineageOS stuff.
$(call inherit-product, vendor/
blaze
/config/common_full_phone.mk) - Product Specifics
PRODUCT_NAME :=
blaze_spes
It could be something else according to your device tree
Change 1: replace blaze
with lmodroid
Change 2: replace blaze_spes
to lmodroid_spes
I mean, in this two subsection replace
the word blaze
with lmodroid
Now, do the same procedure to save and exit as you did to save the AndroidProducts.mk
If your rom support this option, Then you can use either FLAGS or OVERLAYS to set MAINTAINER NAME & BUILD TYPE
either it's OFFICIAL
or UNOFFICIAL
by specifying variables, enabling easy customization without changing core code.
In the context of Android custom ROMs, flags and overlays are two methods used to modify the appearance and functionality of the ROM. Flags are typically used to enable or disable specific features, while overlays are used to replace or modify existing UI elements.
The MAINTAINER NAME && BUILD TYPE
is a piece of information that is often displayed on the about section in the ROM's settings menu. It is typically used to identify BUILD TYPE
either it's OFFICIAL
or UNOFFICIAL
and the person or team who is responsible for MAINTAINING
the ROM.
To add MAINTAINER NAME && BUILD TYPE it may vary on the rom to rom.
For e.g.:
ProjectBlaze
useflag
on the other handEvolutionX
useoverlay
Default Path:
1.ProjectBlaze: device/xiaomi/spes/blaze_spes.mk
2.EvolutionX: device/xiaomi/spes/overlay/packages/apps/Settings/res/values/evolution_strings.xml
Live Path Example - Direct Link:
Most of the rom follow this method. Actually it's depends on the rom source and device tree. Some exceptional are:
i. EvolutionX by @etylix
ii. EvolutionX by @ascending
Use nano
command to edit the blaze_spes.mk
&& evolution_strings.xml
files
For e.g.:
- ProjectBlaze:
nano blaze_spes.mk
- EvolutionX:
nano evolution_strings.xml
Now, do the same procedure to save and exit as you did to save the AndroidProducts.mk
&& lmodroid_spes.mk
That's it!!!
Now manually type cd ..
to go on your rom directory, or paste this command below π
cd .. && cd .. && cd .. && ls
or this
cd ../../../ && ls
or this
cd .. && cd .. && cd ..
ls
You can also adjust the kernel by using:
nano kernel/xiaomi/sm6225/arch/arm64/configs/vendor/spes-perf_defconfig
With this command, you can just tweak the kernel configuration file however you want.
That's it. Now, follow next
step to start build the rom.
The vendor
& kernel
will be started to clone in your device After paste this command π
. build/envsetup.sh
If you want gapps
build paste this;
If you want vanilla
build then skip
this step & directly paste one of these lunch
commands
export WITH_GAPPS=true
lunch lmodroid_spes-user
lunch lmodroid_spes-userdebug
lunch lmodroid_spes-eng
Important Notes:
user:
User builds are the final product that is released to the public. They are optimized for performance and security, and most debugging features are disabled.
userdebug:
This build is similar to the user build, but it has some additional features enabled that are useful for debugging and beta testing. For example, the userdebug build allows you to connect a debugger to any process, and it enables more detailed logging.
eng (engineering):
This build is designed for engineers who are developing and testing the ROM. It has all of the features of the userdebug build, plus some additional features that are useful for development, such as root access. But it's not optimized for performance or security. Not recommended for regular users.
mka bacon -j$(nproc --all)
Caution: If you have encountered this error:
device/xiaomi/spes/parts/Android.bp:7:1: "XiaomiParts" depends on undefined module "org.lineageos.settings.resources"
This conflict may vary on ROMS. Paste these two commands one by one to nuke this conflict.
First paste thisπ
rm -fr packages/resources/devicesettings
Then Paste π
git clone https://github.com/LineageOS/android_packages_resources_devicesettings packages/resources/devicesettings
The first command
is recommended, but if it's not effective for you, you can try one of these commands below: π
mka bacon
brunch [device codename]
make bacon
mka bacon -j`X`
make bacon -j$(nproc --all)
m [bring up codename] -j"$(nproc --all)"
export CCACHE_DIR=/tmp/ccache && export CCACHE_EXEC=$(which ccache) && export USE_CCACHE=1 && ccache -M 450G && ccache -o compression=true && ccache -z && source build/envsetup.sh && lunch lmodroid_spes-userdebug && mka bacon -j$(nproc --all)
Explanation:
- Setting up Compiler Cache:
β’ export CCACHE_DIR=/tmp/ccache:
Sets the directory for the compiler cache.
β’ export CCACHE_EXEC=$(which ccache):
Specifies the path to the ccache executable.
β’ export USE_CCACHE=1:
Enables the use of ccache for caching compilation objects.
β’ ccache -M 450G:
Sets the maximum size of the ccache to 450 gigabytes.
β’ ccache -o compression=true:
Enables compression for cached objects in ccache.
β’ ccache -z:
Zeroes the statistics of the ccache.
- Setting up Environment:
β’ source build/envsetup.sh:
Sources the environment setup script for building Android.
- Selecting Build Variant:
β’ lunch lmodroid_spes-userdebug:
Selects the build variant for the Xiaomi Redmi Note 11 also known as spes/n
device.
- Compiling the ROM:
β’ make -j$(nproc --all) bacon:
Initiates the compilation process using make.
make:
Initiates the compilation.j$(nproc --all):
Specifies the number of jobs to run concurrently based on available processor cores.bacon:
Represents the target to compile the ROM.
Notes: These commands make it easier for the beginners to set up and compile Custom ROM for their own device. Rom compiling for Android is seriously addictive, even more than drugs. Keep enjoying the journey! xD
***To remove the entire build directory/start clean build
use the command clobber
make clobber
It removes previously compiled files, intermediate build artifacts, and configuration files from the build environment. This helps ensure a fresh and clean state before starting a new build process, preventing potential issues that might arise from previous build remnants. After using make clobber
you'd then run the actual build command to create the ROM from a clean state.
For e.g.:
. build/envsetup.sh
export WITH_GAPPS=true
lunch lmodroid_spes-user
mka bacon -j$(nproc --all)
You can also directly run this:
export CCACHE_DIR=/tmp/ccache && export CCACHE_EXEC=$(which ccache) && export USE_CCACHE=1 && ccache -M 450G && ccache -o compression=true && ccache -z && source build/envsetup.sh && lunch lmodroid_spes-userdebug && mka bacon -j$(nproc --all)
SFTP stands for Secure File Transfer Protocol
. It's a secure method used to transfer files between computers over a network. SFTP is an extension of the SSH (Secure Shell)
protocol, providing encryption and authentication to ensure secure data transfer. It's commonly used for securely transferring files, managing remote file systems, and performing file operations securely over a network.
SourceForge
allows user to transfer files via SFTP method, So, I'm going to use SourceForge's SFTP
protocol to copy a file from my Ubuntu
server to my SourceForge
account
Now, follow these steps below:
sftp <your_username>@frs.sourceforge.net
For example:
sftp [email protected]
After that it it prompt you to enter your password. Enter your password and press enter
cd /home/frs/project/[`your project name`]/[`target path name`]
Suppose, My project name is customromspes
and my targeted path is LMODroid
It'll transfer the rom file into LMODroid
. For that i have to paste this command
cd /home/frs/project/customromspes/AfterLife-Project
After performing this command it'll take you to LMODroid
directory. Now paste this command to start transferring the rom from Ubuntu
to your SourceForge
account
put [`file name`]
For E.g:
put AfterLife-V4.0-Wrath-UNOFFICIAL-spes-20231207-Gapps.zip
To verify the upload, you can use the ls
command to list the files in the current directory
ls
Once you're done, type bye
to exit the SFTP session
bye
That's all.
This guide is based on the work of Tanvir Hasan (tanvirr007). Please give proper credit to the author of this guide, @tanvirr007 , when using it in your own Rom.
Contact: