⚠️Galaxy A51 Root || Unlock Bootloader || Flash Official Firmware [Binary 3] May

map220v

Member
Jul 26, 2016
49
36
18
Could you tell how you used lpmake to repack the image? It's always creating an empty image in my case.:eek:
lpmake --metadata-size 65536 --super-name super --metadata-slots 2 --device super:4294967296 --group main:4293513600 --partition product:readonly:1516761088:main --image product=./product.img --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

product:readonly:1516761088:main (size of product.img in bytes)
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)

--group main:4293513600 (main partition size 1516761088+1577095168+342155264+643456=4293513600)
 

gabrielfrias

Senior Member
May 27, 2012
63
37
0
I used this command to get super.img from super.img.lz4
lz4 -d super.img.lz4 super.img
still having no success at all. this is what I did:

1) downloaded firmware file.zip using Frija
2) extracted the AP_file.tar.md5 from firmware file.zip using 7zip
3) extracted the super.img.lz4 file from the Ap_file.tar.md5 using 7zip
4) tried to extract the super.img from super.img.lz4 using the command "lz4.exe -d super.img.lz4 super.img" using lz4 1.9.2
in this step I get the super.img, but I can't do anything with it. I try to mount using Diskinternals Linux Reader, but it returns unallocated space; try to open it using ext2explore, nothing happens.
I also tried to unpack the .lz4 file in Linux using lpunpack I downloaded from https://drive.google.com/file/d/1mgEnQqFOajLnRBX2YYsLL11J2-osPKD_/view, it gives me that error I told you before.
I tried to convert the super.img, extracted from the .lz4 file using lz4.exe, with sgs2toext4.jar, no success, I can't open or mount it too.
It seems to be easy steps, but I can't figure out what I'm missing.

thank you for your support.
 
  • Like
Reactions: YOisuPU

map220v

Member
Jul 26, 2016
49
36
18
still having no success at all. this is what I did:

1) downloaded firmware file.zip using Frija
2) extracted the AP_file.tar.md5 from firmware file.zip using 7zip
3) extracted the super.img.lz4 file from the Ap_file.tar.md5 using 7zip
4) tried to extract the super.img from super.img.lz4 using the command "lz4.exe -d super.img.lz4 super.img" using lz4 1.9.2
in this step I get the super.img, but I can't do anything with it. I try to mount using Diskinternals Linux Reader, but it returns unallocated space; try to open it using ext2explore, nothing happens.
I also tried to unpack the .lz4 file in Linux using lpunpack I downloaded from https://drive.google.com/file/d/1mgEnQqFOajLnRBX2YYsLL11J2-osPKD_/view, it gives me that error I told you before.
I tried to convert the super.img, extracted from the .lz4 file using lz4.exe, with sgs2toext4.jar, no success, I can't open or mount it too.
It seems to be easy steps, but I can't figure out what I'm missing.

thank you for your support.
After using lz4 and simg2img(sgs2toext4.jar?) you need to use lpunpack.
Also super.img not using ext4 filesystem so it's impossible to mount.
 

gabrielfrias

Senior Member
May 27, 2012
63
37
0
After using lz4 and simg2img(sgs2toext4.jar?) you need to use lpunpack.
Also super.img not using ext4 filesystem so it's impossible to mount.
I manage to install the AOSP 10, thank you so much! It was very hard and I would not achieve this without your help, so, I'll make a tutorial to help others later. But, there is a last problem: my SU is not working. When Android starts, the app shows a messagem from the SU telling me to update it, but when I click, nothing happens. Do you know how to fix it and root it? Thanks!
 

map220v

Member
Jul 26, 2016
49
36
18
I manage to install the AOSP 10, thank you so much! It was very hard and I would not achieve this without your help, so, I'll make a tutorial to help others later. But, there is a last problem: my SU is not working. When Android starts, the app shows a messagem from the SU telling me to update it, but when I click, nothing happens. Do you know how to fix it and root it? Thanks!
We need kernel without forced Enforced SELinux.
I already compiled it not sure if it's works on Binary 3 Firmwares

https://drive.google.com/file/d/1Jq8JeEnzBPCDBjC_ewVxbWjhJ9q4G21G/view?usp=sharing

After installing do Wipe data/factory reset in recovery
Then you need Terminal Emulator (Like Termux) do su command and then write "setenforce 0" and check with "getenforce" it's should say Permissive
 

kkosnuss

Member
Apr 8, 2020
32
3
8
I manage to install the AOSP 10, thank you so much! It was very hard and I would not achieve this without your help, so, I'll make a tutorial to help others later. But, there is a last problem: my SU is not working. When Android starts, the app shows a messagem from the SU telling me to update it, but when I click, nothing happens. Do you know how to fix it and root it? Thanks!
At least magic is going to happens after 4 months on this device !! I am so hyped now :victory:
 

ibtsam3301

Member
Apr 2, 2018
17
0
0
I manage to install the AOSP 10, thank you so much! It was very hard and I would not achieve this without your help, so, I'll make a tutorial to help others later. But, there is a last problem: my SU is not working. When Android starts, the app shows a messagem from the SU telling me to update it, but when I click, nothing happens. Do you know how to fix it and root it? Thanks!
kindly make a tutorial thread for newbies like me. Thank you
 

gabrielfrias

Senior Member
May 27, 2012
63
37
0
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.
 
Last edited:

kkosnuss

Member
Apr 8, 2020
32
3
8
@gabrielfrias Man, I was like refreshing XDA every day to get news from.
IMPRESSIVE JOB !! Honestly U shall do another thread for this.

Shame haven't no linux gnu ready to try with. And yh it seems definitely tricky ! So I guess I'll wait for TWRP then... Hope u'll still here :highfive:

Nice start for some custom rom (•‿•)
 

phhusson

Recognized Developer
Jul 23, 2009
2,448
4,674
0
Paris
Last edited:

gabrielfrias

Senior Member
May 27, 2012
63
37
0
How do you boot it and flash it? Edit: Nevermind, Samsung's ****ty broken secure boot only apply on recovery not boot.img. Idiots.


Just remove product partition, it isn't used at all when running GSI
Thanks for the tip and for the nice ROM :good: :)

---------- Post added at 08:31 PM ---------- Previous post was at 08:25 PM ----------

@gabrielfrias Man, I was like refreshing XDA every day to get news from.
IMPRESSIVE JOB !! Honestly U shall do another thread for this.

Shame haven't no linux gnu ready to try with. And yh it seems definitely tricky ! So I guess I'll wait for TWRP then... Hope u'll still here :highfive:

Nice start for some custom rom (•‿•)
@gabrielfrias Thank you very much for tutorial and thanks @map220v for everything you did. It's really great!
thanks, you're welcome!

---------- Post added at 08:33 PM ---------- Previous post was at 08:31 PM ----------

By the way, @gabrielfrias, can't you send your "anyname.tar" file so as not to waste time for all those steps?
I can't. It must be done exclusively for your Android version and region. If you try to use another original ROM, you may face problems.
 

YOisuPU

Member
Jul 29, 2019
25
16
0
please tell me. 1) why should we follow your instructions, we can not just flash gsi from phhusson? What will happen? sorry for the stupid questions. thank you.
2) I have the original Thailand firmware installed. it has less junk than the firmware for my region. phone released for another region. It works much better than for the native region. There are no problems. bootloader third. I suspect that all firmware are the same. the only difference is the set of additional applications for a particular region. I don't need regional trash. can we use the file you received - if there is no difference in the firmware? if not. can we get more detailed instructions for even less advanced users (than you imagine). I read your instructions a thousand times. but did not understand the whole picture. step by step. in the terminal all at once to write or alternately applying? flash odin without rebooting? one by one? make indulgence - describe the process in more detail, in simple words. step by step. since we have to translate the instruction into our language, the instruction becomes little understood at all. thanks. Have a good mood.
 

ToddNachste

Member
Apr 15, 2020
8
12
0
2) I have the original Thailand firmware installed. it has less junk than the firmware for my region. phone released for another region. It works much better than for the native region. There are no problems. bootloader third. I suspect that all firmware are the same. the only difference is the set of additional applications for a particular region. I don't need regional trash. can we use the file you received - if there is no difference in the firmware?
Agree with you, in my opinion the region does not affect anything
 
  • Like
Reactions: YOisuPU

phhusson

Recognized Developer
Jul 23, 2009
2,448
4,674
0
Paris
please tell me. 1) why should we follow your instructions, we can not just flash gsi from phhusson?
If you were able to, you could, but it's not possible :)
You're supposed to flash my gsi on "system" partition, but Odin only sees "super" partition which contains all of system,vendor,product,odm. And for GSI to work you need to keep origin vendor and odm partition.
All other devices with "super" partition just have a recovery with a special fastbootd integrated in the recovery.
But Samsung decided they are special, so they disabled fastbootd from their recovery (it's still there though)!
Other Samsung devices went on with it by using a custom recovery, which is what I was planning to do, but Galaxy A51 is special, and won't let you boot custom recovery.

So uh. Yeah their instructions are correct.

As for 2), yeah region doesn't matter, but vendor version does. You must pick the one that match what's already on your device.
 

gabrielfrias

Senior Member
May 27, 2012
63
37
0
If you were able to, you could, but it's not possible :)
You're supposed to flash my gsi on "system" partition, but Odin only sees "super" partition which contains all of system,vendor,product,odm. And for GSI to work you need to keep origin vendor and odm partition.
All other devices with "super" partition just have a recovery with a special fastbootd integrated in the recovery.
But Samsung decided they are special, so they disabled fastbootd from their recovery (it's still there though)!
Other Samsung devices went on with it by using a custom recovery, which is what I was planning to do, but Galaxy A51 is special, and won't let you boot custom recovery.

So uh. Yeah their instructions are correct.

As for 2), yeah region doesn't matter, but vendor version does. You must pick the one that match what's already on your device.
Thanks for clarifying that!
Samsung did I lot of sh*t in this phone, I can't imagine why, there's really no need to all this. By the way, @map220v said geiti94 is able to sign and flash the recovery, but this only works if the recovery is signed to each phone. Do know how to do this or can you point me in the right direction? I would like to learn and share this information.
 
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone