• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

GSIs on A51 5G

Search This thread

AndyYan

Recognized Contributor
Jan 30, 2012
4,337
3,646
Beijing
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
Code:
lpdump
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 <dir>
6) Replace system.img in <dir> 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).
 
D

Deleted member 5437200

Guest
I'm unsure where you are getting the sizes for the partitions, could you please elaborate on that? The rest is self explanatory.
 

lkj00

Member
Sep 14, 2020
10
1
When i lpmake i get invalid sparse image header
其他型号的手机修改super.img 最后打包的时候也可以使用么? lpmake 这个文件提取到system.img同目录执行?还是在复制system.img文件到otg\bin文件夹下执行?
并不很明白 ./lpmake ....命令各个参数的意思。

---------- Post added at 02:19 AM ---------- Previous post was at 02:16 AM ----------

lpmake这个文件提取到system.img同目录执行?还是在复制system.img文件到otg \ bin文件夹下执行?
并不很明白。 / lpmake ....命令各个参数的意思。
lpmake文件提取到system.img同目录执行命令后 出现了错误.
 

lkj00

Member
Sep 14, 2020
10
1
Sub-partition sizes are arbitrary, as long as they can contain the respective content (e.g. system has to be larger than your GSI) while still fit inside super.
-metadata-size 65536 65536 Does the number represent partition size or permissions? Will the numbers never change?
-metadata-slots 2 The slots2 parameter will never change?
-device super:7549747200 Does this number represent the total generation of the super partition?
-group main:7545552896 What does the back number mean? The total size of the other three partitions?

Thank you
 
Last edited:

AndyYan

Recognized Contributor
Jan 30, 2012
4,337
3,646
Beijing
lpmake文件提取到system.img同目录执行命令后 出现了错误.

That's because lpmake has supporting libraries. Call lpmake by its original path.

-metadata-size 65536 65536 Does the number represent partition size or permissions? Will the numbers never change?
-metadata-slots 2 The slots2 parameter will never change?
-device super:7549747200 Does this number represent the total generation of the super partition?
-group main:7545552896 What does the back number mean? The total size of the other three partitions?

Check your own lpdump result for all these parameters.
 
  • Like
Reactions: extended84

lkj00

Member
Sep 14, 2020
10
1
I'm very much obliged to you! Test other brands as common! !
 
Last edited:

lebigmac

Senior Member
Jan 31, 2017
940
557
@AndyYan thank you so much for writing this detailed guide.
Thanks to your detailed guide I was able to create an automated bash script that performs all of these steps automatically and makes all read only partitions inside super.img (system, vendor , product, etc...) into read write-able partitions again and flash to device as a brand new super.img.
It would be an honor for me if you could please try it and let me know if it works on your device. Thanks.

Here is the link:
https://forum.xda-developers.com/t/script-mount-system-as-read-write-android-10.4240703/
 
Last edited:

LichtEstarossx

Senior Member
Nov 23, 2017
67
19
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
Code:
lpdump
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 <dir>
6) Replace system.img in <dir> 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).
It may sound stupid, but how do I get the lp command tools?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 4
    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
    Code:
    lpdump
    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 <dir>
    6) Replace system.img in <dir> 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).
    3
    It would be an honor for me if you could please try it and let me know if it works on your device. Thanks.

    Aww, sold my A51 just yesterday...
    3
    Why do you give so much extra space in --group main:7545552896
    Is that just an arbitrary number that you used or is that the original group size from the lpdump? Is it safe to simply recycle that number?
    IIRC I take as much data from the stock lpdump result as possible.
    2
    When i lpmake i get invalid sparse image header

    Can be safely ignored.
    2
    I'm unsure where you are getting the sizes for the partitions, could you please elaborate on that? The rest is self explanatory.

    Sub-partition sizes are arbitrary, as long as they can contain the respective content (e.g. system has to be larger than your GSI) while still fit inside super.