How To Guide [OUTDATED - PLEASE USE UNOFFICIAL LINEAGEOS INSTEAD] Installing a GSI on Samsung M12/A12.

Search This thread

ap4ss3rby

Senior Member
Sep 9, 2015
156
45
Update 1: I figured out how to make script run on boot. Instructions revised. If you followed earlier check them again
Update 2: Magisk 24.1 is now stable. Instructions revised.
Update 3: I contacted phh and he implemented the script inside his trebleapp. Instructions revised and modified trebleapp is attached. NOTE: GSIs newer than 7/Feb/2022 will include this workaround by default.

Update 4: This guide is now unnecessary now that unofficial LineageOS is very close to release
 
Last edited:

SB3P

Member
Aug 11, 2021
27
4
Samsung Galaxy M12
Nokia 2.2

Achievement unlocked: flashed GSI with FBE enabled! :D

Screenshot_FBE_Working.png

In short, I've successfully done flashing of @phhusson's latest version of Android 12 GSI (which is v402 as of today). To do this, I needed to modify the multidisabler script so it won't disable FBE, format the userdata using the stock recovery, flash TWRP, resize tmpfs to proper size, push GSI image into tmpfs and flash it using TWRP. I used the securized image with vndklite variant, since there was no securized images for regular vndk releases (but it seemed that vndk was working better for me, at least I have no USB connection anymore where with VNDK I was able to have USB debugging). Maybe I'll try re-flashing it once I'll patch the regular images and securize them (since I'm on *nix, I can just mount them and modify their contents) and take an approach of finding how Samsung ROMs are working OK. For now, I need to take a break from all bootloops I had in the process of FBE flashing 😓.

Anyway, the goal of this experiment was to use GSI ROMs as a daily driver and having FBE disabled could otherwise cause a serious problem on device loss.

So, onto the list what's been tested (that wasn't noted before):
  • Screen locking – it seems that the workaround for the screen is not applied before unlocking the phone, probably because the app is not running yet. This might work with the script used as postfs module.

    EDIT: I've found some notes in the Magisk documentation that both post-fs data and late_start services are run after data is decrypted, which basically means applying this workaround using Magisk seems to be pointless for now (maybe not after PPH app will stop providing the workaround)... Probably the best option would be patching the ROM itself, either with flashable ZIPs or directly before flashing it (most GSIs can be mounted under Linux and tweaked).
  • Adaptive brightness – not working, since all virtual sensors are not working for now. Might be easy to fix through as I've found some stuff in the official ROM that I had an idea to experiment with putting them into GSIs (as a Magisk module, to avoid a breakage).

  • USB – as I said, a data transfer via USB is not working for me for some reason. It worked for me once I had VNDK Android 12 GSI installed (same version).

  • Booting with stock kernel – I had some successful attempts doing that, but it further was a cause of a bootloop, at least once I had installed Magisk. Therefore, I'll recommend patching the Magisk the way as in tutorial (after patching the kernel) to have everything working for now.
For people who wants to play with stock images but don't know how: you can use simg2img, lpunpack and Linux to extract and mount the official ROM image in approach of finding there some tips like in initrc services why some stuff is working fine on Samsung while it doesn't on GSIs. Maybe I would tinker with it a bit, trying to export a few services and libraries in an approach to create a Magisk module with all stuff needed to have a fully functional GSI, but I'm tired of modding for now, especially when this is my first Samsung phone I had to deal with.

Edit: Typo fixes, added additional text formatting.
 
Last edited:

ap4ss3rby

Senior Member
Sep 9, 2015
156
45
Amazing work. If you need testers feel free to PM me. As a sidenote, poking in sysfs led me to believe that android is sending the info needed to read the proximity but the kernel is sending garbage which gets interpreted as the sensor not being triggered. Also phh should have added the workaround into his trebleapp starting from phh AOSP 12 v401, so aside from installing magisk no post install workarounds should be needed.
Attached is a photo of what cmd_result reads when a whatsapp voice message is played which reads proximity to play the message in the earpiece and turn screen off when proximity is triggered
 

Attachments

  • Screenshot_20220210_224920.png
    Screenshot_20220210_224920.png
    21.3 KB · Views: 119
Last edited:

SB3P

Member
Aug 11, 2021
27
4
Samsung Galaxy M12
Nokia 2.2
Also phh should have added the workaround into his trebleapp starting from phh AOSP 12 v401, so aside from installing magisk no post install workarounds should be needed.
Unfortunately, the commit was reverted as of master branch, so we should prepare for it to stop to work unless phh will work on it before releasing an another version. Also I wrote that the workaround didn't seem to apply itself before unlocking the phone (FBE encrypted) the first time and therefore decrypting sensitive data after boot. For now this makes it an requirement when using PHH app to unlock the phone before it sleeps so the touch is going to be responsive.

Anyway, it seems that even Magisk (v24.1) is not capable of running the services before data is decrypted, so now I have no idea how to bypass that in other way than patching the ROM itself and creating the `initrc` service... Anyway, this is also a hint that what samsung is doing starts before basically everything, so no APK file nor script is going to really fix it since they are meant to start after data is decrypted...
 
Last edited:

ap4ss3rby

Senior Member
Sep 9, 2015
156
45
Unfortunately, the commit was reverted as of master repo, so we should prepare for it to stop to work unless phh will work on it before releasing an another version. Also I wrote that the workaround didn't seem to apply itself before unlocking the phone (FBE encrypted) the first time and therefore decrypting sensitive data after boot. For now this makes it an requirement when using PHH app to unlock the phone before it sleeps so the touch is going to be responsive.

Anyway, it seems that even Magisk (v24.1) is not capable of running the services before data is decrypted, so now I have no idea how to bypass that in other way than patching the ROM itself and creating the `initrc` service... Anyway, this is also a hint that what samsung is doing starts before basically everything, so no APK file nor script is going to really fix it since they are meant to start after data is decrypted...
I guess for now we have two options:
A: Build custom kernel/vendor specifically for GSIs that correctly reports sensors as GSIs expect them to
B: Fix GSI issues through Magisk services implementing various workarounds in scripts. (an example is the touchscreen sleep/wake issue)
 

SB3P

Member
Aug 11, 2021
27
4
Samsung Galaxy M12
Nokia 2.2
Attached is a photo of what cmd_result reads when a whatsapp voice message is played which reads proximity to play the message in the earpiece and turn screen off when proximity is triggered
Also that's interesting those virtual sensors are still present, I personally thought that Samsung made it the way there's an virtual device create as on Linux and there's their proprietary software running somewhere in the system that uses the camera as an input and calculates it to provide the data... On the other hand, when I think about that logic, even some (if not all) virtual devices on Linux (e.g. v4l2loopback) needs to have their module loaded with the kernel to work. I'm glad at least there's no need to reinvent the wheel and no one really needs to recreate the entire algorithm for it if it's going to be in the kernel sources...

I guess for now we have two options (...)
I feel like the B option is worse than patching the GSI ROMs, either via flashable ZIPs or on your own... This is because I couldn't find anything in docs that would let me run services before /data is going to be decrypted... Personally, I've made myself a such service using the statically-compiled Linux ARM binary (non-NDK, using GNU libs – yes, it is still runnable on Android as well) – it applies the workaround for now both when screen is turned on and off (I had no idea on which event it should really run, so I made it to run on both just to be safe) by watching the file changes based on (AFAIK) filesystem events – so it has a major advantage over your script, as it won't run in endless loop, yet watch the file responsible for brightness to change and then do its job. But even with that, TSP doesn't seem to make touch available immediately and it is still expected to be revived after 1-2 seconds.

Also, as of the methods of applying these workarounds, the other way could be modifying the ramdisk (maybe with the help of Magisk, which I believe has documented how it's actually doing it itself and how others could modify the root and init as Magisk does to load files before the OS will properly initalize itself. Yet I don't like an idea of messing myself with the boot partition, at least for now...
 

ap4ss3rby

Senior Member
Sep 9, 2015
156
45
Debug info: I tried flashing stock to grab logs from the touchscreen driver. The logs attached here do not appear at all on an unpatched GSI (I.E flashing the GSI as is without any touch workaround).
 

Attachments

  • sec_input_dmesg_stock.txt
    5.2 KB · Views: 26

physwizz

Senior Member
Sep 16, 2013
3,594
800
Sydney
Hi, I installed LineageOS 18.1 GSI on my M127F. I want to share my guide to installing this GSI.

Code:
DISCLAIMER:
By following this guide you accept that you
 may do irreversible damage to your phone.
 If something breaks the responsibility is
 yours only. If you want stable software that
 is guaranteed to work 100% don't follow
this guide.

I assume you are running a fully stock system and and locked bootloader and firmware U3/U4.

Installing TWRP and custom kernel
  1. Enable Developer Options by tapping on software information > build number 7 times
  2. Enter developer options then toggle OEM Unlocking on.
  3. Power off your phone.
  4. Hold Vol Up + Vol Down then plug in your phone to enter download mode
  5. THIS WILL ERASE ALL YOUR DATA AND VOID YOUR WARRANTY. Follow on screen instructions to unlock your bootloader. THIS WILL ERASE ALL YOUR DATA AND VOID YOUR WARRANTY
  6. After this you want to download and install attached Orangefox recovery using odin. After odin is done flashing enter recovery
  7. Format data (not wipe) in recovery
  8. Enter terminal and type multidisabler twice
  9. Reboot to system and verify that under security encryption is disabled
  10. Download TWRP and custom kernel for your phone
  11. Reboot into recovery and locate the downloaded twrp image
  12. Select recovery.
  13. Reboot into recovery
  14. Install kernel, then wipe cache and reboot. You should now see that it is complaining about some internal issue. This is normal.
Installing the GSI
  1. Download your favorite ROM from the list provided below. You want to install an arm64 a/b image.
  2. Extract the image file
  3. Reboot to recovery.
  4. Select install then install image
  5. Locate the GSI image
  6. Select install system
  7. After that is done return to recovery and select factory reset.
  8. Reboot then do setup (if applicable) then download attached magisk and phh trebleapp. If your phone is stuck on bootanimation check under to fix it.
  9. IMPORTANT: DO NOT LET THE SCREEN TURN OFF OR YOU WILL HAVE TO REBOOT TO MAKE TOUCH WORK AGAIN.
  10. Install attached magisk
  11. Open magisk and click on install then direct install
  12. Download and install the attached phh-treble app apk.
  13. Touch should now work. Enjoy your GSI.
Extras

  1. Magisk 24.1
    1. Open Magisk
    2. Go to settings
    3. Update Magisk Manager app to version 24.1
    4. Relaunch Magisk then install magisk
    5. Choose direct instal
  2. Migrating to patched trebleapp
    1. Download and install attached trebleapp
    2. Open your root file manager
    3. go to /data/adb/service.d
    4. Delete the script you added earlier

Tips in case things don't work

In case after rebooting to the GSI the phone bootloops:
  1. Download stock image from wherever you download your firmware (I use a python program called samloader)
    • Extract the AP of the downloaded firmware
  2. Find userdata.img.lz4 and create a .tar archive only containing this file
  3. Reboot to download mode
  4. In odin select AP then locate the newly created .tar archive Then click on flash
  5. Reboot
  6. Continue from step 7 under the "Installing the GSI" portion of the guide

To revive the touchscreen using ADB:
  1. In case you didn't grant adb root access but installed magisk, run adb shell then su. A root access for the app shell will appear. Grant root permission
  2. Plug in phone to a computer with ADB
  3. adb shell
  4. su
  5. cat /sys/class/sec/tsp/cmd_result
  6. echo check_connection > /sys/class/sec/tsp/cmd
What works:
  • Boots
  • RIL
  • Fingerprint
  • Main rear camera
  • Front camera
  • Sleep/Wake (workaround in steps above, may need to sleep wake several times before it works)
  • WiFi
  • Flashlight
  • Rotation
  • Magisk 24
  • 90Hz (M12 only. A12 doesn't have 90Hz refresh rate)
  • LineageOS 18.1
  • LineageOS 19
  • CAOS (GApps variant available)
  • phh AOSP 11 v313
  • phh AOSP 12 v400h
Untested
  • GPS
  • Flashing GApps. (I use fdroid and aurora store on LineageOS and CAOS has built in GApps)
  • USB-OTG
  • A127F
  • M127G
  • If I didn't list it under broken or working I didn't try it or forgot to test it.
Broken
  • Double tap to wake. Touchscreen turns off and I have no idea how to keep it alive while lcd is off
  • MTP
  • Virtual Proximity. Screen will stay on in phone calls and WhatsApp will always play voice messages through speaker
  • Flashlight brightness. Flashlight will always stay on weakest brightness with no way to adjust.
  • Adaptive refresh. The framerate you set in phh addons is what you get. Be prepared for slightly reduced battery.
  • You tell me (even though I probably don't have the solution)
Bugs
  • You may need to wait a little bit before touchscreen responds or sleep/wake several times before screen responds after turning the screen off
Credits
@physwizz for kernel, TWRP and orangefox
@phhusson for implementing workaround in trebleapp as well as GSI list
me for touch workaround

Links
Kernels and recoveries: https://t.me/a127f_res/113
GSIs: https://github.com/phhusson/treble_experimentations/wiki/Generic-System-Image-(GSI)-list
Great guide.
Well done
 
  • Like
Reactions: Srssiam

matahbeyz

Member
Apr 16, 2020
22
8
Thanks for the great guide. Unfortunately, I don't know how to resize tmpfs. Can anybody tell me how to do that? I only have 4 GB or less on my Samsung Galaxy A12 with 64 GB of Storage (it should have, it only shows something like 3 or 4 gigabytes like I mentioned)
 

SB3P

Member
Aug 11, 2021
27
4
Samsung Galaxy M12
Nokia 2.2
Thanks for the great guide. Unfortunately, I don't know how to resize tmpfs. Can anybody tell me how to do that? I only have 4 GB or less on my Samsung Galaxy A12 with 64 GB of Storage (it should have, it only shows something like 3 or 4 gigabytes like I mentioned)
You don't have to resize TMPFS if you don't want to have FBE encryption or have the external SD card (you can use microSD for flashing, which might be a better choice if you need to flash a larger devices). Also you can't resize TMPFS to 64 GB, it uses your RAM to store regular data instead of storage (this is basically the concept of TMPFS). What I was mentioning is that /data won't work under FBE and custom recoveries for now, so you need to use your RAM instead if you don't have any external storage device to save images somewhere via ADB.

As of resizing the TMPFS, you should be able to find some Linux tutorial how to do that, on Android this is works basically the same (even on both Linux and Android you have /tmp directory with TMPFS by default).

Anyway, I've decided to share some stuff that you may need for that. Here's the multidisabler script I was using for flashing GSIs with FBE encryption preserved. I was also working on the native binary that would work as the workaround for the touchscreen so it can be used instead of the script. The advantages are that it actually listens to filesystem events and therefore does not need to read file in loop in order to get the information if brightness has changed. Maybe I'll share it with you once I find it to be ready, right now I'll just share my multidisabler script with patches.

BTW, I've tested LineageOS GSIs (both 11 and 12) and noticed they behave completely different, no matter of variant (the USB actually uses some driver, which is not fully compatible with M12 but close enough to provide basic communication through ADB). I guess pphusson just changed something and now these drivers aren't applied by default, yet I think I've noticed the issues with Bluetooth's HSP/HFP profiles which as I remember was not the case with latest stable pphusson's vanilla Android 12 GSIs. Now I just hope these problems are going to be resolved in the next builds of Android's GSIs with phhusson's patches and with the knowledge that MTP just worked fine on TWRP I used, there's a little hope that we will gain the proper combination of drivers/firmware to have both USB and Bluetooth functional at the same time someday.

I've also approached patching the kernel under newer kernel base 4.19.112, yet I gave up on properly resolving its conflicts. I may work on that as well in order to patch some vulnerabilities, with a hope that I'll succeed updating kernel as closest to the latest patch as possible. The 4.19.112 is going to be just a test if Samsung is capable of actually booting from it and if I may be able to use git with common human logic and my limited programming skills to actually patch it the way it would do so (without much understanding about the code itself, yet basic knowledge about C syntax). For now I've only succeed reproducing the upstream Linux kernel commit structure from 4.19.111, with a single additional commit for Samsung changes and another one for physwizz ones.
 

Attachments

  • multidisabler_noencrypt.sh.xz
    1.5 KB · Views: 33
Dec 16, 2013
14
0
mumbai

Achievement unlocked: flashed GSI with FBE enabled! :D

View attachment 5533799

In short, I've successfully done flashing of @phhusson's latest version of Android 12 GSI (which is v402 as of today). To do this, I needed to modify the multidisabler script so it won't disable FBE, format the userdata using the stock recovery, flash TWRP, resize tmpfs to proper size, push GSI image into tmpfs and flash it using TWRP. I used the securized image with vndklite variant, since there was no securized images for regular vndk releases (but it seemed that vndk was working better for me, at least I have no USB connection anymore where with VNDK I was able to have USB debugging). Maybe I'll try re-flashing it once I'll patch the regular images and securize them (since I'm on *nix, I can just mount them and modify their contents) and take an approach of finding how Samsung ROMs are working OK. For now, I need to take a break from all bootloops I had in the process of FBE flashing 😓.

Anyway, the goal of this experiment was to use GSI ROMs as a daily driver and having FBE disabled could otherwise cause a serious problem on device loss.

So, onto the list what's been tested (that wasn't noted before):
  • Screen locking – it seems that the workaround for the screen is not applied before unlocking the phone, probably because the app is not running yet. This might work with the script used as postfs module.

    EDIT: I've found some notes in the Magisk documentation that both post-fs data and late_start services are run after data is decrypted, which basically means applying this workaround using Magisk seems to be pointless for now (maybe not after PPH app will stop providing the workaround)... Probably the best option would be patching the ROM itself, either with flashable ZIPs or directly before flashing it (most GSIs can be mounted under Linux and tweaked).
  • Adaptive brightness – not working, since all virtual sensors are not working for now. Might be easy to fix through as I've found some stuff in the official ROM that I had an idea to experiment with putting them into GSIs (as a Magisk module, to avoid a breakage).

  • USB – as I said, a data transfer via USB is not working for me for some reason. It worked for me once I had VNDK Android 12 GSI installed (same version).

  • Booting with stock kernel – I had some successful attempts doing that, but it further was a cause of a bootloop, at least once I had installed Magisk. Therefore, I'll recommend patching the Magisk the way as in tutorial (after patching the kernel) to have everything working for now.
For people who wants to play with stock images but don't know how: you can use simg2img, lpunpack and Linux to extract and mount the official ROM image in approach of finding there some tips like in initrc services why some stuff is working fine on Samsung while it doesn't on GSIs. Maybe I would tinker with it a bit, trying to export a few services and libraries in an approach to create a Magisk module with all stuff needed to have a fully functional GSI, but I'm tired of modding for now, especially when this is my first Samsung phone I had to deal with.

Edit: Typo fixes, added additional text formatting.
Could you explain how you done this.... i mean please explain step by step... i am using Galaxy M12G Varient....thanks in advance
 

SB3P

Member
Aug 11, 2021
27
4
Samsung Galaxy M12
Nokia 2.2
Could you explain how you done this.... i mean please explain step by step... i am using Galaxy M12G Varient....thanks in advance
If you would see the *untested* section at the initial post of this thread, it is unknown whetever this works or not for M127G phones (if it bootloops it might not work at all). Anyway, here's how I did it on M127F (at least how I remember this):

1. I did steps from 1-6, I believe I skipped 7 since I was aware it will mess something up with the data partition.

2. I modified the multidisabler script and pushed it to my phone via the ADB (to TMPFS). You can find this script pushed as xz compressed file. Before executing multidisabler script I have done a backup of the recovery and system partitions (using dd tool) which I am going to reflash later.

3. I rebooted to download mode and flashed TWRP image.

4. After TWRP ended flashing, I booted into the recovery. I flashed the physwizz kernel and then my own GSI image as it was described in the instructions at the initial post. Just remember that /data partition is not functional with FBE and TWRP so you need to push your images somewhere else like microSD card or TMPFS partition. OTG might work here as well, this is something I haven't tested yet through...

5. Once you are done with flashing you need to restore the original recovery partition via the download mode. TWRP won't boot the GSIs with FBE encryption enabled actually it does boot now for me, yet I still recommend switching to stock recovery if your phone bootloops or you need to format/wipe userdata partition. You can then safely format your /data partition with the stock recovery.
 
Last edited:
Dec 16, 2013
14
0
mumbai
Hi, I installed LineageOS 18.1 GSI on my M127F. I want to share my guide to installing this GSI.

Code:
DISCLAIMER:
By following this guide you accept that you
 may do irreversible damage to your phone.
 If something breaks the responsibility is
 yours only. If you want stable software that
 is guaranteed to work 100% don't follow
this guide.

I assume you are running a fully stock system and and locked bootloader and firmware U3/U4.

Installing TWRP and custom kernel
  1. Enable Developer Options by tapping on software information > build number 7 times
  2. Enter developer options then toggle OEM Unlocking on.
  3. Power off your phone.
  4. Hold Vol Up + Vol Down then plug in your phone to enter download mode
  5. THIS WILL ERASE ALL YOUR DATA AND VOID YOUR WARRANTY. Follow on screen instructions to unlock your bootloader. THIS WILL ERASE ALL YOUR DATA AND VOID YOUR WARRANTY
  6. After this you want to download and install attached Orangefox recovery using odin. After odin is done flashing enter recovery
  7. Format data (not wipe) in recovery
  8. Enter terminal and type multidisabler twice
  9. Reboot to system and verify that under security encryption is disabled
  10. Download TWRP and custom kernel for your phone
  11. Reboot into recovery and locate the downloaded twrp image
  12. Select recovery.
  13. Reboot into recovery
  14. Install kernel, then wipe cache and reboot. You should now see that it is complaining about some internal issue. This is normal.
Installing the GSI
  1. Download your favorite ROM from the list provided below. You want to install an arm64 a/b image.
  2. Extract the image file
  3. Reboot to recovery.
  4. Select install then install image
  5. Locate the GSI image
  6. Select install system
  7. After that is done return to recovery and select factory reset.
  8. Reboot then do setup (if applicable) then download attached magisk and phh trebleapp. If your phone is stuck on bootanimation check under to fix it.
  9. IMPORTANT: DO NOT LET THE SCREEN TURN OFF OR YOU WILL HAVE TO REBOOT TO MAKE TOUCH WORK AGAIN.
  10. Install attached magisk
  11. Open magisk and click on install then direct install
  12. Download and install the attached phh-treble app apk.
  13. Touch should now work. Enjoy your GSI.
Extras

  1. Magisk 24.1
    1. Open Magisk
    2. Go to settings
    3. Update Magisk Manager app to version 24.1
    4. Relaunch Magisk then install magisk
    5. Choose direct instal
  2. Migrating to patched trebleapp
    1. Download and install attached trebleapp
    2. Open your root file manager
    3. go to /data/adb/service.d
    4. Delete the script you added earlier

Tips in case things don't work

In case after rebooting to the GSI the phone bootloops:
  1. Download stock image from wherever you download your firmware (I use a python program called samloader)
    • Extract the AP of the downloaded firmware
  2. Find userdata.img.lz4 and create a .tar archive only containing this file
  3. Reboot to download mode
  4. In odin select AP then locate the newly created .tar archive Then click on flash
  5. Reboot
  6. Continue from step 7 under the "Installing the GSI" portion of the guide

To revive the touchscreen using ADB:
  1. In case you didn't grant adb root access but installed magisk, run adb shell then su. A root access for the app shell will appear. Grant root permission
  2. Plug in phone to a computer with ADB
  3. adb shell
  4. su
  5. cat /sys/class/sec/tsp/cmd_result
  6. echo check_connection > /sys/class/sec/tsp/cmd
What works:
  • Boots
  • RIL
  • Fingerprint
  • Main rear camera
  • Front camera
  • Sleep/Wake (workaround in steps above, may need to sleep wake several times before it works)
  • WiFi
  • Flashlight
  • Rotation
  • Magisk 24
  • 90Hz (M12 only. A12 doesn't have 90Hz refresh rate)
  • LineageOS 18.1
  • LineageOS 19
  • CAOS (GApps variant available)
  • phh AOSP 11 v313
  • phh AOSP 12 v400h
Untested
  • GPS
  • Flashing GApps. (I use fdroid and aurora store on LineageOS and CAOS has built in GApps)
  • USB-OTG
  • A127F
  • M127G
  • If I didn't list it under broken or working I didn't try it or forgot to test it.
Broken
  • Double tap to wake. Touchscreen turns off and I have no idea how to keep it alive while lcd is off
  • MTP
  • Virtual Proximity. Screen will stay on in phone calls and WhatsApp will always play voice messages through speaker
  • Flashlight brightness. Flashlight will always stay on weakest brightness with no way to adjust.
  • Adaptive refresh. The framerate you set in phh addons is what you get. Be prepared for slightly reduced battery.
  • You tell me (even though I probably don't have the solution)
Bugs
  • You may need to wait a little bit before touchscreen responds or sleep/wake several times before screen responds after turning the screen off
Credits
@physwizz for kernel, TWRP and orangefox
@phhusson for implementing workaround in trebleapp as well as GSI list
me for touch workaround

Links
Kernels and recoveries: https://t.me/a127f_res/113
GSIs: https://github.com/phhusson/treble_experimentations/wiki/Generic-System-Image-(GSI)-list
try to install @phhusson (system-squeak-arm64-ab-vndklite-gapps-secure.img) GSI using above method on Samsung Galaxy M12G (SM-M127G) BUT failed to boot up

facing following issue:
1) unable to boot in OrangeFox Recovery
2) boot in TWRP Recovery but not detected MicroSD Card
3) samehow manage to push Kernal.zip, SystemGSI.img by adb push file_name_with_extension /sdcard BUT not flash properly as TWRP reboot again and again in 2-3 minutes

so friends, don't try this method on Samsung Galaxy M12G (SM-M127G) unless Senior member come up with this specific model
 

ap4ss3rby

Senior Member
Sep 9, 2015
156
45
For anyone who has starred this thread, I and other devs have released a proper build of LineageOS with /vendor. Aside from VoLTE (which I don't think worked in GSIs anyways) everything should work. Moderators, please close this thread
 
Last edited:

SB3P

Member
Aug 11, 2021
27
4
Samsung Galaxy M12
Nokia 2.2
For anyone who has starred this thread, I and other devs have released a proper build of LineageOS with /vendor. Aside from VoLTE (which I don't think worked in GSIs anyways) everything should work. Moderators, please close this thread
LineageOS is not only GSI available, I think someone might still find it useful if they want to flash another ROMs. Also Phhuson's GSI also contains some features that unofficial GSI release don't have (i.e. flashlight control in Phhusson's app), so they still might be useful for someone.

This is why I think it is better to not close this thread and maybe revive original guide.
 

ap4ss3rby

Senior Member
Sep 9, 2015
156
45
LineageOS is not only GSI available, I think someone might still find it useful if they want to flash another ROMs. Also Phhuson's GSI also contains some features that unofficial GSI release don't have (i.e. flashlight control in Phhusson's app), so they still might be useful for someone.

This is why I think it is better to not close this thread and maybe revive original guide.
Our rom is built completely from source, not a GSI, and it is more or less a complete replacement of stock firmware. If you want you can use a GSI over that instead, and it should function much better than just replacing stock firmware
 
Last edited:

SB3P

Member
Aug 11, 2021
27
4
Samsung Galaxy M12
Nokia 2.2
Our rom is built completely from source, not a GSI, and it is more or less a complete replacement of stock firmware. If you want you can use a GSI over that instead, and it should function much better than just replacing stock firmware
I haven't said GSI are better, I personally use this unofficial LineageOS build. But what I've said, GSI brings much more variety of picking the OS you can install. Even Linux can be installed on phones nowadays using GSI with only Halium-patched kernel as an requirement. This is why I think leaving this tutorial archived (no updates, interest on fixing bugs etc.) is better than removing it.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 4
    I am deleting this guide since M12 will soon recieve an unofficial build of LineageOS 19.1. Don't ask when, as I'm not the lead developer but I helped with it
    2
    Update 1: I figured out how to make script run on boot. Instructions revised. If you followed earlier check them again
    Update 2: Magisk 24.1 is now stable. Instructions revised.
    Update 3: I contacted phh and he implemented the script inside his trebleapp. Instructions revised and modified trebleapp is attached. NOTE: GSIs newer than 7/Feb/2022 will include this workaround by default.

    Update 4: This guide is now unnecessary now that unofficial LineageOS is very close to release
    2

    Achievement unlocked: flashed GSI with FBE enabled! :D

    Screenshot_FBE_Working.png

    In short, I've successfully done flashing of @phhusson's latest version of Android 12 GSI (which is v402 as of today). To do this, I needed to modify the multidisabler script so it won't disable FBE, format the userdata using the stock recovery, flash TWRP, resize tmpfs to proper size, push GSI image into tmpfs and flash it using TWRP. I used the securized image with vndklite variant, since there was no securized images for regular vndk releases (but it seemed that vndk was working better for me, at least I have no USB connection anymore where with VNDK I was able to have USB debugging). Maybe I'll try re-flashing it once I'll patch the regular images and securize them (since I'm on *nix, I can just mount them and modify their contents) and take an approach of finding how Samsung ROMs are working OK. For now, I need to take a break from all bootloops I had in the process of FBE flashing 😓.

    Anyway, the goal of this experiment was to use GSI ROMs as a daily driver and having FBE disabled could otherwise cause a serious problem on device loss.

    So, onto the list what's been tested (that wasn't noted before):
    • Screen locking – it seems that the workaround for the screen is not applied before unlocking the phone, probably because the app is not running yet. This might work with the script used as postfs module.

      EDIT: I've found some notes in the Magisk documentation that both post-fs data and late_start services are run after data is decrypted, which basically means applying this workaround using Magisk seems to be pointless for now (maybe not after PPH app will stop providing the workaround)... Probably the best option would be patching the ROM itself, either with flashable ZIPs or directly before flashing it (most GSIs can be mounted under Linux and tweaked).
    • Adaptive brightness – not working, since all virtual sensors are not working for now. Might be easy to fix through as I've found some stuff in the official ROM that I had an idea to experiment with putting them into GSIs (as a Magisk module, to avoid a breakage).

    • USB – as I said, a data transfer via USB is not working for me for some reason. It worked for me once I had VNDK Android 12 GSI installed (same version).

    • Booting with stock kernel – I had some successful attempts doing that, but it further was a cause of a bootloop, at least once I had installed Magisk. Therefore, I'll recommend patching the Magisk the way as in tutorial (after patching the kernel) to have everything working for now.
    For people who wants to play with stock images but don't know how: you can use simg2img, lpunpack and Linux to extract and mount the official ROM image in approach of finding there some tips like in initrc services why some stuff is working fine on Samsung while it doesn't on GSIs. Maybe I would tinker with it a bit, trying to export a few services and libraries in an approach to create a Magisk module with all stuff needed to have a fully functional GSI, but I'm tired of modding for now, especially when this is my first Samsung phone I had to deal with.

    Edit: Typo fixes, added additional text formatting.
    1
    Hi, I installed LineageOS 18.1 GSI on my M127F. I want to share my guide to installing this GSI.

    Code:
    DISCLAIMER:
    By following this guide you accept that you
     may do irreversible damage to your phone.
     If something breaks the responsibility is
     yours only. If you want stable software that
     is guaranteed to work 100% don't follow
    this guide.

    I assume you are running a fully stock system and and locked bootloader and firmware U3/U4.

    Installing TWRP and custom kernel
    1. Enable Developer Options by tapping on software information > build number 7 times
    2. Enter developer options then toggle OEM Unlocking on.
    3. Power off your phone.
    4. Hold Vol Up + Vol Down then plug in your phone to enter download mode
    5. THIS WILL ERASE ALL YOUR DATA AND VOID YOUR WARRANTY. Follow on screen instructions to unlock your bootloader. THIS WILL ERASE ALL YOUR DATA AND VOID YOUR WARRANTY
    6. After this you want to download and install attached Orangefox recovery using odin. After odin is done flashing enter recovery
    7. Format data (not wipe) in recovery
    8. Enter terminal and type multidisabler twice
    9. Reboot to system and verify that under security encryption is disabled
    10. Download TWRP and custom kernel for your phone
    11. Reboot into recovery and locate the downloaded twrp image
    12. Select recovery.
    13. Reboot into recovery
    14. Install kernel, then wipe cache and reboot. You should now see that it is complaining about some internal issue. This is normal.
    Installing the GSI
    1. Download your favorite ROM from the list provided below. You want to install an arm64 a/b image.
    2. Extract the image file
    3. Reboot to recovery.
    4. Select install then install image
    5. Locate the GSI image
    6. Select install system
    7. After that is done return to recovery and select factory reset.
    8. Reboot then do setup (if applicable) then download attached magisk and phh trebleapp. If your phone is stuck on bootanimation check under to fix it.
    9. IMPORTANT: DO NOT LET THE SCREEN TURN OFF OR YOU WILL HAVE TO REBOOT TO MAKE TOUCH WORK AGAIN.
    10. Install attached magisk
    11. Open magisk and click on install then direct install
    12. Download and install the attached phh-treble app apk.
    13. Touch should now work. Enjoy your GSI.
    Extras

    1. Magisk 24.1
      1. Open Magisk
      2. Go to settings
      3. Update Magisk Manager app to version 24.1
      4. Relaunch Magisk then install magisk
      5. Choose direct instal
    2. Migrating to patched trebleapp
      1. Download and install attached trebleapp
      2. Open your root file manager
      3. go to /data/adb/service.d
      4. Delete the script you added earlier

    Tips in case things don't work

    In case after rebooting to the GSI the phone bootloops:
    1. Download stock image from wherever you download your firmware (I use a python program called samloader)
      • Extract the AP of the downloaded firmware
    2. Find userdata.img.lz4 and create a .tar archive only containing this file
    3. Reboot to download mode
    4. In odin select AP then locate the newly created .tar archive Then click on flash
    5. Reboot
    6. Continue from step 7 under the "Installing the GSI" portion of the guide

    To revive the touchscreen using ADB:
    1. In case you didn't grant adb root access but installed magisk, run adb shell then su. A root access for the app shell will appear. Grant root permission
    2. Plug in phone to a computer with ADB
    3. adb shell
    4. su
    5. cat /sys/class/sec/tsp/cmd_result
    6. echo check_connection > /sys/class/sec/tsp/cmd
    What works:
    • Boots
    • RIL
    • Fingerprint
    • Main rear camera
    • Front camera
    • Sleep/Wake (workaround in steps above, may need to sleep wake several times before it works)
    • WiFi
    • Flashlight
    • Rotation
    • Magisk 24
    • 90Hz (M12 only. A12 doesn't have 90Hz refresh rate)
    • LineageOS 18.1
    • LineageOS 19
    • CAOS (GApps variant available)
    • phh AOSP 11 v313
    • phh AOSP 12 v400h
    Untested
    • GPS
    • Flashing GApps. (I use fdroid and aurora store on LineageOS and CAOS has built in GApps)
    • USB-OTG
    • A127F
    • M127G
    • If I didn't list it under broken or working I didn't try it or forgot to test it.
    Broken
    • Double tap to wake. Touchscreen turns off and I have no idea how to keep it alive while lcd is off
    • MTP
    • Virtual Proximity. Screen will stay on in phone calls and WhatsApp will always play voice messages through speaker
    • Flashlight brightness. Flashlight will always stay on weakest brightness with no way to adjust.
    • Adaptive refresh. The framerate you set in phh addons is what you get. Be prepared for slightly reduced battery.
    • You tell me (even though I probably don't have the solution)
    Bugs
    • You may need to wait a little bit before touchscreen responds or sleep/wake several times before screen responds after turning the screen off
    Credits
    @physwizz for kernel, TWRP and orangefox
    @phhusson for implementing workaround in trebleapp as well as GSI list
    me for touch workaround

    Links
    Kernels and recoveries: https://t.me/a127f_res/113
    GSIs: https://github.com/phhusson/treble_experimentations/wiki/Generic-System-Image-(GSI)-list
    Great guide.
    Well done