Blogger Jateng

HOW TO ROOT Galaxy A51 (Manual Ways To Create Samsung Build ROM)

This is a method to create modified samsung ROM from AOSP GSI that can be installed using ODIN.

Pre-requisites

  • Unlocked bootloader
  • A full backup (you’ll lose everything stored in your phone)
    Both Windows AND Linux (I used Windows installed and Kalix Live USB) OR Windows with Linux Bash System (https://itsfoss.com/install-bash-on-windows/) -tip given by @ToddNachste
  • Patience (A LOT)
  • About 30 GB free

Files needed

  • Download with Frija or SamFirm THE SAME firmware you’re running now
  • Download a GSI Android 10 A/B Gapps arm64v8 from (https://github.com/phhusson/treble_experimentations/wiki/Generic-System-Image-(GSI)-list) -I’m using AOSP 10 v215, but I believe it’s working with more GSI’s
  • LZ4 Extractor (https://github.com/lz4/lz4/releases)
  • Simg2img (https://forum.xda-developers.com/general/general/dev-simg2img-windows-t3156459)
  • LPunpack Tool (https://drive.google.com/file/d/1mgEnQqFOajLnRBX2YYsLL11J2-osPKD_/view)
  • Odin (https://dl2018.sammobile.com/Odin3-v3.14.1.zip)
  • 7zip
  • Permissive kernel (https://drive.google.com/file/d/1Jq8JeEnzBPCDBjC_ewVxbWjhJ9q4G21G/view?usp=sharing) -thanks to map220v

In Windows

  • Extract the AP_file.tar.md5 from your firmware.zip file using 7zip
  • Extract the super.img.lz4 file from the AP_file.tar.md5 file using 7zip
  • Put super.img.lz4 file in LZ4 folder and run in CMD the command lz4.exe -d super.img.lz4 superLZ4.img
  • Put superLZ4.img file in Simg2img folder
  • and run in CMD the command simg2img.exe -i superLZ4.img -o superSIMG.img

In WSL (Bash Shell)

  1. Put superSIMG.img in otatools/bin folder and extract it in Linux terminal using the command
    ./lpunpack --slot=0 superSIMG.img <destination dir> (I recommend you create a folder for this)
  2. Put, in the folder where you extracted superSIMG.img, the GSI file you downloaded and rename it to system.img. Now you should have odm.img, system.img, vendor.img and product.img files in the same folder. You may also need to delete/remane the original system.img file before renaming the GSI file.
  3. Now you’re going to make a brand new super.img file containing all 4 files of the previous step. This is a critical and tricky step. Run Linux terminal and type:
    ./lpmake --metadata-size 65536 --super-name super --metadata-slots 2 --device super:4294967296 --group main:4293513600 --partition system:readonly:1577095168:main --image system=./system.img --partition vendor:readonly:342155264:main --image vendor=./vendor.img --partition odm:readonly:643456:main --image odm=./odm.img --sparse --output ./super.img

Note that in this code, the numbers highlighted in bold are the sizes of the 3 .img files you extracted (odm, vendor and product) in step 2 plus system.img you downloaded/renamed, IN BYTES. Update the code with YOUR files’s sizes!

  • system:readonly:1577095168:main (size of unsparsed system.img in bytes)
  • vendor:readonly:342155264:main (size of vendor.img in bytes)
  • odm:readonly:643456:main (size of odm.img in bytes)
    as @phhusson stated (thanks!), no need sto use product.img, just supress it at all
  • –group main:4293513600 (main partition size 1577095168+342155264+643456=2776752512)
    *The size of main is the sum of the 4 .img files*

You may face two different problems here

  • Odm.img file requested a not avaliable space. Just sum and update main’s size.
  • System.img is larger than expected. Just sum and update main’s size again.
  • Your original super.img file is now created, like Samsung does. Congrats!

Back in Windows

  • Create, using 7zip, anyname.tar file cointaining just the super.img you created. Simple.
  • Open Odin, untick Auto Reboot, add anyname.tar file to AP, put your phone in Download Mode and flash it Flash boot(NoForcedEnforce).tar the same way.
  • Reboot your phone, do a Factory Reset in original recovery.

In Android

  • Install terminal emulator and run the following commands:
  • su
  • setenforce 0
  • getenforce (it should show Permissive)

Job is done.

PROS

  • Root
  • No bloatware
  • More space available
  • Battery drains slowly
  • Frequent updates
  • 178044 points in Antutu v8

CONS

  • YOUR WARRANTY IS NOW VOID and blablabla
  • Poor interface (it’s an Android 10 PURE system)
  • No Samsung’s facilitations/resources/beauty
  • Screen transitions are flickering (no big deal)

source credit to gabrielfrias for the tutor