Android Stuffs
Android Stuffs
Credits
smily9000
What You Need
• You need CRB Kitchen (download) (search as crb xda)
– Windows 10/11 need to use wls2
– 8GB ram
• Linux arch For unpack F2FS or donated version of CRB Kitchen
• Notepad ++ or xml/prop editor
• Winmerge
• 7Zip ZS
• Android Image Kitchen
• Mixlporer
Downloads
https://drive.google.com/drive/folders/1aQFhMCZt0XTEjgw1dn1DCf6pmaqtvxP6?usp=drive_link
Main Topics
• Identify Your Device • Booting GSIs
• Flashing of custom images • How to make super.img
• How to add gsis super.img
• Convert Seprse to Raw and Extract Super
• How to add Gapps to vanila build
• How to Convert F2FS to EXT4 • TWRP for Huawei/Honor
• How to Port Vendor • How to Make OEM GSIs
• How to check is stock kernel arm32 or arm64 • How to enable disabled features in
• How to Fix Bugs Android go
• Add features for oneui
• Port Custom Recovery
• How to Convert OneUI core to OneUI
• Decryption/Encryption • How Make Flashable Zip
• Build TWRP from Source • Backup IMEI
• Port System Images
• Build AOSP from Source
• How to make premissive boot
• How convert RO super to RW super
Main Topics
• Identify Your Device • Booting GSIs
• Flashing of custom images • How to make super.img
• How to add gsis super.img
• Convert Seprse to Raw and Extract Super
• How to add Gapps to vanila build
• How to Convert F2FS to EXT4 • TWRP for Huawei/Honor
• How to Port Vendor • How to Make OEM GSIs
• How to check is stock kernel arm32 or arm64 • How to enable disabled features in
• How to Fix Bugs Android go
• Add features for oneui
• Port Custom Recovery
• How to Convert OneUI core to OneUI
• Decryption/Encryption • How Make Flashable Zip
• Build TWRP from Source • Backup IMEI
• Port System Images
• Build AOSP from Source
• How to make premissive boot
• How convert RO super to RW super
• Identify Your Device
• Arm32/64 VNDK A/B Super
• File Systems and which FS you can boot
• How to Choose Vendor
Three Stages
Same android os
Same kernel version
Same family soc.
Same hardware(compass/gravity/proximity/nfc/gyro/)
Wifi only/LTE
If your device dont have nfc/gyro/compass like feature but you can use device which has
nfc/gyro/compass for port.
If your device do have nfc/gyro/compass like feature but you used device which has no
nfc/gyro/compass for port. Then in that vendor there is no nfc/gyro/compass drives so they
will not work on your device and fixing might be very hard
If you have samsung you have to use samsung device if you use ril (netowrk/calls/mobile
data/sms)
How to Choose Vendor
• But in some samsung devices you can enable fastbootd by this tool
VBMETA
• Most of time you need empty vbmeta for boot custom images (gsis/custom
recoveries)
• You have to patch your all vbmeta (vbmeta , vbmeta_system, vbmeta_vendor)files
via crb and flash them to your device
• If not you have to use magisk patched boot.img
How to Unpack Super.img
How to Unpack super.img.lz4
• Unpack super.img and get vendor.img odm.img product.img system.img etc
• If you have super.img.lz4 , then unpack it
• You can use simg2img.exe to convert super.img to raw image
– Open cmd where simgimg.exe and super.img located
– Then excute simg2img.exe super.img super.raw
• if you dont have super.img just unpack vendor.img
– Then excute simg2img.exe vendor.img vendor.raw
• Then open it in # in 7z Ez
• There will be all partitions
• Extract them and rename partitions according to partition name
• if your device is ext4 you can open them in 7zip
How to Unpack Super or
System/Vendor/Product
(EXT4)
https://www.youtube.com/watch?v=1IH7AvpwjCw
How to Convert F2FS to EXT4
Convert F2FS to Ext4
• I used Fedroa
• Duel boot or install it on vbox or any
• Open Terminal
– Open teminal form where located raw_f2fs_system.img (system/vendor/product/odm/...)
– sudo apt install f2fs-tools
– mkdir system
– sudo mount -o ro -t auto name_of_raw_f2fs_system.img system
– sudo dd if=/dev/zero of=system_new.img bs=6k count=1048576 (bs=6k 6gb)
– sudo mkfs.ext4 system_new.img
– sudo tune2fs -c0 -i0 system_new.img
– mkdir new
– sudo mount -o rw,sync,loop system_new.img new
– sudo cp -fva system/* new/
Credits
You will get a new 6GB ext4 image @nnippon
How to Port Vendor
How to Port Vendor
• unpack both vendors (stock and vendor used to be port)
• you can use CRB kitchen if your device is ext4
• you have to replace whole firmware folder and make fstab for basically boot that vendor
• replace all vendor/etc/fstab.xx with stock
• you have to replace mounting fstab lines with stock lines
– open vendor/etc/init/hw/init_target.rc and compare it with winmerge
– Replace all fstab related line (mount_all /vendor/etc/)
– Replace executing moudules line with stock.
– exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules ...
• check vendor/lib/modules/*.ko
• they are the kernel drivers (bluetooth/wifi/touch/graphic/fm_radio/gps/etc)
• if there is no modules ignore this.then you kernel dont use any modules
• replace those .ko files with stock files
• Resize Vendor if needed
• repack vendor and flash and try
• You can use this method to port arm64 vendor to arm32 device but you need a arm64 kernel. Most
of time stock kernel is arm64. you can check it by kernel config
• If you port originaly relased vendor from oem, (oneui/miui/...)
• if you ported android 10 vendor you must use your stock android 10 boot.img
• if you ported android 11 vendor you must use your stock android 11 boot.img
• if you ported android 12 vendor you must use your stock android 12 boot.img
• if you ported android 13 vendor you must use your stock android 13 boot.img
• if you ported android 10 vendor you have to check with your stock android 10 boot.img
• if you ported android 11 vendor you have to check with your stock android 10/11 boot.img
• if you ported android 12 vendor you have to check with your stock android 10/11/12 boot.img
• if you ported android 12 vendor you have to check with your stock android 10/11/12 boot.img
• if you ported android 13 vendor you have to check with your stock android 10/11/12/13 boot.img
How to Port Basic Vendor
https://www.youtube.com/watch?v=bsXy7sxz218
How to Check Kernel is arm64 or Arm32
https://www.youtube.com/watch?v=80VaUlMsxvk
Bug Fixing
Bug Fixing
• To fix camera you have to use correct camera sensnors lib files (depend on device)
• Replace with stock
• camera configs are on,
– vendor/etc/camera
• vendor/libs(64)
– libstagefright_*.so
– libOmx*.so
• vendor/etc
– media_*.xml
RIL
• There are some kind of ril
• Mediatek MTK_RIL
– (used by mtk devices,redmi/xaiomi/huweai/reamle/vivo/oppo/nokia...)
• Qualcomm QCOM_RIL (QCRIL)
– (used by qcom devices - redmi/xaiomi/huweai/reamle/vivo/oppo/nokia...)
• Unisoc- (idk the name of .so files)
– (used by unisoc devices - redmi/xaiomi/huweai/reamle/vivo/oppo/nokia...)
• Samsung RIL (SEC_RIL)
– (used by mtk/qcom/unisoc/exyons samsung devices)
• LG RIL - LGE_RIL
– (used by mtk/qcom/unisoc/exyons lg devices)
Bug Fixing
• To Fix RIL (Replace with stock)
• lib(64)/
– ril*.so
– radio*.so
• bin/
– ril*
– radio*
– modem*
– baseband*.
• vendor/radio/*
• vendor/etc/init/
– ril*.rc
– modem*.rc
– baseband.*.rc
• build.prop (ril*/radio* related line)
• Must be some lines in init/hw/init*.rc
• Highly depend on soc and oem (samsung is very diffrenet)
How to Port Recovery
How to port recovery (bugs depend on oem)
• Decryption is most common bug (data partition is not showing any files
or folders with random letters)
• Touch (lack of firmware file)
• If you ignore the above 2 lines , you cannot mount system product etc
in recovery
• Take 2 recovery images (stock and recovery you want to port)
– eg – stock recovery i renamed as stock.img
– recovery need to port i renamed as port.img
• Copy both images to root of Android Image Kitchen
• Then first drag stock.img to unpack.bat then you will get 2 folders as ramdisk and
split_image rename ramdisk to stock_ram and split_image to stock_split_image.
• Then delete stock.img and rename port.img to stock.img
• Then drag stock.img (renamed port.img) to unpack.bat then you will get 2 folders as
ramdisk and split_image
• Open stock_split_image and delete stock.img-ramdisk.cpio.gz (.gz extension may
different)
• Then replace all files in split_image with stock_split_image.
• Then replace recovery.fstab with stock fstab (ramdisk/etc or ramdisk/system/etc )
• If you have twrp.fstab or twrp.flags also replace them with stock recovery.fstab
• Click on repack.bat
Bug Fixing
• Touch
• You have to add vendor/frimware
• You have to add touch driver lib/modules/.ko (if your device use
touch driver)
How to port recovery
https://www.youtube.com/watch?v=ZJc_SKpJD9o
Encryption/Decryption
Decryption/Encyption
• This guide is for basic twrp and you have to fix bugs and bugs are depend on oem
and soc
• If your device is a/b device (if you dont have recovery.img or you have boot_a
boot_b like partitions your device is a/b) you have to build bootctrl to build fully
funtional TWRP
Bug Fixing
• Touch
• You have to add vendor/frimware
• You have to add touch driver lib/modules/.ko (if your device use
touch driver)
How to build TWRP
https://www.youtube.com/watch?app=desktop&v=ZYU5xJ2we1o
How to Port System
How to port system
Most of time you can boot system.img from another device with same soc family
without modifications
https://www.youtube.com/watch?v=TdW-gh8Ywts
I tested,
a11 rom on m01 (android 12) [i used android 12 vendor and boot.img]
miui form redmi 7a on m01 (android 10) [i used android 10 vendor and boot.img]
a20s rom on m01 (android 11) [i used android 11 vendor and boot.img]
• check about more device trees in github according to your soc and oem
Selinux Premissive Boot Image
How to make premissive boot
https://www.youtube.com/watch?v=RYkSvB8l1KE
How to convert read only super to read and write
(ext4/erofs/f2fs)
How to convert read only super to read and write
https://forum.xda-developers.com/t/magisk-twrp-arm32-64-a8-universal-read-only-to-read-write-for-android-
ro2rw-auto-converting-super-system-partitions-to-read-write-mode.4521131/
Booting GSIs
Boot GSIs
• To boot gsis you only need vendor image and system linked images by vendor
(odm like)
• You can use mixplorer and see it
super 3672 3672
product 450 5
odm 4 5
• In M01, Vendor - 582 - 582
• It uses only odm in vendor Free space 2630 3080
• Super.img has 3672MB (it has only system vendor odm product in super)
• vendor use 582mb , odm use 4mb , product use 450 mb
• you can flash only gsis around 2.6gb
• But if you flashed product image with 5mb you can flash gsi around 3.0GB
• So you have to flash empty images for all unsasory partitions like product
system_ext oem my_product etc
How to Know essential paritions for boot
https://www.youtube.com/watch?v=ZncYVg39vc4
How to add gsi to super.img
How to add a gsi to super
• Convert your spersed super.img and to raw and extract all partitions in
it
• Extract super.img via crb
• Then unpack gsi.xy and rename the image to system.img.
• Then convert it to raw with simg2img.exe
• Then copy all partitions with your raw_gsi.img to build folder of your
unpacked super
• Then Repack super.img as raw or spersed or lz4
How to add GSI to Super
https://www.youtube.com/watch?v=ZncYVg39vc4
How to Add Gapps to Vanilla
How to Add GAPPS to Vanilla
https://youtu.be/vTTN9B8BsnI
How to Make OEM GSIs (oneui myui miui)
How to Make OEM GSIs (oneui myui miui)
• In some Huawei Devices you can boot TWRP without unlocking bootloader (emui 10)
• Huawei uses erecovery_ramdisk and recovery_ramdisk instead of recovery partitions
• You have to flash twrp for both erecovery_ramdisk and recovery_ramdisk partitions
• You have to use brom/edl mode to flash it. So you need to short testpoints
• You have to use MTK Cliend or SP Flash tool. (MTK)
• Rename,
• system/etc/permissions/com.samsung.device.lite.xml to com.samsung.device.xml
• system/etc/permissions/com.samsung.feature.samsung_experience_mobile_lite.xml to
com.samsung.feature.samsung_experience_mobile.xml
• system/framework/com.samsung.device.lite.jar to com.samsung.device.jar
• system/framework/oat/arm(64)/com.samsung.device.lite.odex to com.samsung.device.odex
• system/framework/oat/arm(64)/com.samsung.device.lite.vdex to com.samsung.device.vdex
How to Meke Flashable Zips
How to Meke Flashable Zips
• You have to backup imei and network configureations before doing any thing
• Backup IMEI related partition
• Nvdata
• Nvram
• Proinfo
• EFS
• SEC_EFS
• MODEMST1
• MODEMST2
• FSG
• QCN (for qualcomm imei and network configureations)
Credits
smily9000