GSIs on A51 5G | Samsung Galaxy A51

Uncategorized

First up, shoutouts to both @

phhusson

and part of

this thread

from @

YOisuPU

for vital guidance throughout my first journey with super-partition devices.

A51 5G runs on Exynos 980 unlike the 4G variant which runs on Exynos 9611. People have been running into trouble rooting the 4G variant and even resorted to GSIs just for rooting, but on the 5G variant all you had to do is to patch boot+vbmeta (don’t include recovery) with Magisk. If you just need root, stopping here is enough.

For me, running my

LOS GSI

is absolutely necessary, but Android 10’s super-partition compounded with Samsung not making fastbootd available means an even harder time than what I’ve had with

A60/M40

. Below steps apply to this device and might also serve as a general skeleton for other Samsung devices with super-partition.

0) Get Linux – some tools used here just don’t have a Windows version

1) On stock firmware, open shell and run

to get some partition info that’ll be used next – example output

here

2) Get stock firmware

3) Extract super.img.lz4 from AP and then super.img (sparse) from super.img.lz4 with your tool of choice (e.g. 7-Zip ZS)

4) Unsparse super.img:

Code:

./simg2img super.img super.raw.img

5) Extract partitions from super.raw.img:

Code:

./lpunpack –slot=0 super.raw.img

6) Replace system.img in

with GSI image

7) Repack your own super.img:

Code:

./lpmake –metadata-size 65536 –super-name super –metadata-slots 2 –device super:7549747200 –group main:7545552896 –partition system:readonly:2147483648:main –image system=./system.img –partition vendor:readonly:729890816:main –image vendor=./vendor.img –partition odm:readonly:4349952:main –image odm=./odm.img –sparse –output ./super.img

Compare the command to the lpdump output obtained earlier – many of the numerical parameters here directly match. For the 3 partition declarations, assign them sizes equal to or larger than (recommended) their byte sizes.

8) Compress your super.img into a tar and flash it via Odin in the AP slot

9) Make sure that the device runs patched vbmeta (but stock boot image – somehow the patched one causes a bootloop on GSIs), do a factory reset in stock recovery, reboot

simg2img, lpunpack and lpmake binaries can be obtained online (e.g. from the aforementioned thread) or built from source.

By the way, I’ve fixed some sepolicy issues with PHH’s Superuser, so in future builds, unlike what was described in the thread, 4G variant users likely won’t need a permissive kernel to get root on GSIs (at least it doesn’t here).

Source

Sharing is caring!

Leave a Reply