[Samsung Galaxy M02s] ragebreaker1:
Edit: You can flash the clean vbmeta.img and flash the twrp in the link (Read the Instructions in the link afterwards)

Hi everyone, this is a guide on how to flash a GSI on the M02s with and without TWRP (need a OTG mouse for TWRP currently, not all OTG connectors seem to work based on few personal replies i've recieved).

I used Andy Yan's latest LineageOS GSI for android 12 for my device when making this guide but am currently using crDroid A13 (Ancient OS and crDroid for android 12 booted but used to restart every minute). While other roms that i tried and worked are:

A13 crDroid (whatsapp calls only work, normal calls don't work) - https://github.com/naz664/crDroid_g....10.20/crDroid-9.10-a64_bvN-Unofficial.img.xz

A14 AOSP - https://github.com/TrebleDroid/treb...25/system-td-arm32_binder64-ab-vanilla.img.xz

(su not working) A12 LineageOS - https://sourceforge.net/projects/an...1-20231017-UNOFFICIAL-a64_bvS.img.xz/download

As always do this at your own risk. You may brick your device. You will void your warranty.

Follow the guide only if you know what your are doing. Read each step carefully and avoid copy pasting stuff randomly.

The procedure was tested it on a M02s but I think would work (without twrp guide) for other similar devices too.

I did this on Linux with Windows VM for odin and some of the steps. (You could use Windows using WSL)

Feel free to correct any mistakes in the comments below.

Sources​

Thanks to @kkoo, @Brepro1, @abg95a for the useful info and @Ravindu_Deshan for the twrp

- https://xdaforums.com/t/guide-custo...sing-odin-without-twrp-phh-lineageos.4114435/

- https://xdaforums.com/t/editing-system-img-inside-super-img-and-flashing-our-modifications.4196625/

- https://xdaforums.com/t/guide-t220-t225-flash-a-gsi-on-the-a7-lite-without-twrp.4456821/

Requirements​

- Unlocked bootloader

If you haven't done this already follow the steps in this video:

- Latest official ROM

I used M025FXXU6CWI1 for Indian(INS) region

https://samfw.com/firmware/SM-M025F

- Download your preferred GSI

Releases · phhusson/treble_experimentations​

- Clean vbmeta.img from Google

https://dl.google.com/developers/android/qt/images/gsi/vbmeta.img

Tools​

- lz4

Releases · lz4/lz4​

- simg2img (only linux version works properly)

https://xdaforums.com/t/dev-tools-simg2img-for-windows.3156459/

- lpunpack and lpmake (Used in linux although windows would work using otatools)

https://xdaforums.com/t/guide-ota-tools-lpunpack.4041843/

- Ota-tools

https://drive.google.com/drive/folders/1BmBmFuYZXbISAncrnrMybQ0uQk0-cZXl?usp=sharing

Edit: The google drive links have expired, clone this repo for the lpunpack.py with instructions in the link on how to clone and use, below 4th step.

The tools required are present in the bin folder so please transfer all the imgs you are using to that folder and (shift + right_click) on windows -> open powershell/terminal window here

- tar-md5-script-tool

Use the attached tar-md5-script-tool.zip

Steps​

1. Extract official ROM files (BL, AP, CP, CSC)

2. Extract AP .tar.md5

3. Decompress the extracted super.img.lz4

Code:

4. Convert the sparse super.img

Code:

Edit: Cloning and using it the folder (or directiory) of super.img

git clone https://github.com/unix3dgforce/lpunpack
sudo python3 lpunpack/lpunpack.py super.ext4.img super

(Install python3 if u haven't done it yet. Also u could omit the sudo and run it with the super.img directly ig, I did try it)

Skip step 5 if u followed the edit.

5. Unpack super.ext4.img

Code:

I got 4 partitions in my image :

- odm.img

- product.img

- system.img

- vendor.img

6. Replace system.img with your GSI (rename it to system.img)

7. Get the size of all partitions and the size of the original super.ext4.img (not the sparse super.img)

Code:

8. Repack super.img

./lpmake --metadata-size 65536 \

--super-name super \

--metadata-slots 2 \

--device super:ORIGINAL_SUPER_IMG_SIZE \

--group main:SUM_OF_ALL_PARTITIONS_SIZES \

--partition odm:readonly:ODM_PARTITION_SIZE:main \

--image odm=./odm.img \

--partition product:readonly:PRODUCT_PARTITION_SIZE:main \

--image product=./product.img \

--partition system:readonly:SYSTEM_PARTITION_SIZE:main \

--image system=./system.img \

--partition vendor:readonly:VENDOR_PARTITION_SIZE:main \

--image vendor=./vendor.img \

--sparse \

--output ./super_new.img

Replace ORIGINAL_SUPER_IMG_SIZE, SUM_OF_ALL_PARTITIONS_SIZES, ODM_PARTITION_SIZE, PRODUCT_PARTITION_SIZE, SYSTEM_PARTITION_SIZE, VENDOR_PARTITION_SIZE with the values you obtained in 7th step.

Read lpmake docs for a more detailed expalation of the args used above:

partition_tools - platform/system/extras - Git at Google

9. Convert the super_new.img into a tar using 7zip

10. Compress the clean vmbeta.img to vmbeta.tar using 7zip

11. In Odin flash the vmbeta.tar in AP

12. Reboot to download mode again and flash super.tar or super.img.tar file using odin in AP again.

13. Go to recovery to factory reset or let it boot to recovery asking for a factory reset.

14. Reboot to system after the factory reset/data wipe

(or)

(Old school steps below till step 16.)

9. Compress the super_new.img to a super_new.img.lz4

Code:

10. Compress the vmbeta.img to vmbeta.img.lz4

Code:

11. Extract tar-md5-script-tool.zip

12. Put all the *.img.lz4 files extracted from AP .tar.gz in tar-md5-script-tool dir

13. Replace super.img.lz4 and vbmeta.img.lz4 in tar-md5-script-tool dir with your repacked and compressed super_new.img.lz4 (rename it to super.img.lz4) and the clean compressed vbmeta.img.lz4

14. Run batch.bat in tar-md5-script-tool dir

You will find the new AP .tar.md5 in the temp-folder subdir

15. Flash your custom AP .tar.md5 with Odin along with BL, CP, CSC from original ROM

16. Reboot into recovery and do a factory reset

Tutorial with TWRP (You would be requiring an USB-B to USB-C adapter and a mouse for this part, check if the mouse/OTG works with your device first)

Make sure you have unlocked the bootloader and downloaded the clean vmbeta.img

Do not boot the rom until u flash the treble gsi or else u have to start over from step 3.

1. (optional) Compress the vmbeta.img to vmbeta.tar

2. Reboot to download mode and flash the vmbeta.tar (or vbmeta.img) in AP using odin (Turn off auto-reboot or you have to reboot to download mode again)

3.Download the twrp from the link below and flash the tar (or .img) file in AP using odin. (or from here if step 4 doesnt work at all)

TWRP for M02s

Samsung M02s is such a device, Can't even root with magisk. Damn bootloops. Btw, Ravindu_Deshan successfully compiled TWRP from source and flashed in M02s. But the only bug is touch screen is not working; Did everything like swapping the kernel...

xdaforums.com

4.Plug in your mouse using the OTG adapter to your mobile after the flash completes and then reboot to recovery directly. (If mouse doesn't work in twrp sometimes, just hold down volume_down + power button and reboot to recovery again)

5. Swipe to allow modifications and then format data by clicking yes (do not reboot now itself)

5.5. open terminal and run "multidisabler execute" (using mouse, wait till it shows finished.)

6. Then proceed to advanced wipe and wipe dalvik cache, cache, data, system (still do not reboot)

(If it hasnt worked before, u can try rooting your device before proceeding)

7. Go to install -> flash image -> select your GSI from SD card or internal storage (extract the .img from .xz beforehand)

8. Flash the .img as system image and reboot to system (ignore the no os installed warning)

9.Let it boot, It will take some time and voilà! You are running a treble GSI :)

I will be attaching the tar-md5-script-tool.zip just in case someone wants to use the old method.

Edit:

step 9.5: Try factory reseting after install if it doesnt boot after flashing

After flashing stock fw, If download mode says only official binaries are allowed, click here (or here for more info,

connect to wifi after setting your clock ahead by a week.)

I would not recommend trying to install a gsi anymore as i have received messages suggesting that some OTG adapters don't work for some people.

If u want a debloated experience, just use uad debloater following the instructions on their github page and debloat system packages that are not needed.

I am not using this device anymore and cannot perform any tests regarding any problems.

So if there is a problem, I can only give suggestions so try them at your own risk.