Fully Working Root Solution
HOW TO ROOT A51 (WORKING EVEN WITH BINARY 3)
First, I would like to thanks
@map220v, without his efforts, none of this would be possible. I’m justing putting the pieces together to help others root this phone as he helped me.
Second, this is an ADVANCED process, so I deduce most of you know how to do many things needed in here, so I’ll not explain, for example, how you get your bootloader unlocked.
Tird, I recommend you do this ony if you REALLY can’t use your phone without root, otherwise, wait for TWRP release.
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)
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:
1) Extract the AP_file.tar.md5 from your firmware.zip file using 7zip
2) Extract the super.img.lz4 file from the AP_file.tar.md5 file using 7zip
3) Put super.img.lz4 file in LZ4 folder and run in CMD the command
lz4.exe -d super.img.lz4 superLZ4.img
4) Put superLZ4.img file in Simg2img folder and run in CMD the command
simg2img.exe -i superLZ4.img -o superSIMG.img
In Linux OR 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:
1) Odm.img file requested a not avaliable space. Just sum and update main’s size.
2) 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:
1) Create, using 7zip, anyname.tar file cointaining just the super.img you created. Simple.
2) 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.
3) Reboot your phone, do a Factory Reset in original recovery.
In Android:
1) Install terminal emulator and run the following commands:
su
setenforce 0
getenforce (it should show Permissive)
Job is done.