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

Development [ROOT] [TWRP] [KERNEL] [GSI] for SM-A127f (a12s)

Search This thread

physwizz

Senior Member
Sep 16, 2013
3,311
730
Sydney
If you're still using twrp you must mount system from terminal every time you use it.
Otherwise go to post 22 and use Method 1
 

uluruman

Senior Member
Oct 23, 2021
83
8
Success! I have finally made it to LineageOS on my (Russian Vietnam-made) SM-A127F/DSN! I tried it quickly and it looks like it works fine: no problems with the lock screen or camera. Unfortunately no "easy" way worked for me, so I had to go the hard way: completely repacking the super.img, replacing the stock system.img with LineageOS.img. To my immense surprise that worked! Although it first required a lot of searching for the correct tools (for Linux + a bit of Windows in a VM) and then learning how to unpack and repack everything back.

Basically, here are my steps (mostly Linux):
  1. Downloaded the stock firmware (I used the Fijian version as it's the smallest of all)
  2. Flashed it using Odin. That is the only Windows tool I had to use (Heimdall does not work for me, probably it's too outdated)
  3. Gone through the Android setup, enabled the Developer mode, unlocked the bootloader (OEM Unlock), rebooted
  4. Gone through the setup once again, installed Magisk, patched the AP image, flashed it (I think all that is unnecessary)
  5. Unpacked the AP[..].tar.md5 from the stock firmware files: tar xf AP[..].tar.md5
  6. Uncompressed super.img: unlz4 super.img.lz4
  7. Converted from sparse image format to non-sparse (raw): simg2img super.img super.raw
  8. Downloaded and compiled the LonelyFool's lpunpack_and_lpmake
  9. mkdir super, then unpack the super.raw into that dir: lpunpack super.raw super
  10. Downloaded LineageOS GSI
  11. Unpacked it: unxz lineage-[..]-treble_arm64_bvS.img.xz
  12. Converted to raw system image: simg2img lineage-18.1-20211010-UNOFFICIAL-treble_arm64_bvS.img system.img
  13. Renamed the original system.img to system_orig.img
  14. Put the LineageOS system.img into the super dir
  15. Converted the system_orig.img into the raw image format: simg2img system_orig.img system_orig.raw
  16. Dumped (displayed) the system_orig.raw metadata: lpdump system_orig.raw
  17. (here comes the hardest part) Repacked super.img back together using the dumped metadata info:
    lpmake \
    --metadata-size 65536 --super-name super --metadata-slots 2 --device super:5679087616 --group group_basic:5674893312 \
    --partition system:readonly:1852809216:group_basic --image system=./super/system.img \
    --partition vendor:readonly:441614336:group_basic --image vendor=./super/vendor.img \
    --partition product:readonly:948908032:group_basic --image product=./super/product.img \
    --partition odm:readonly:4349952:group_basic --image odm=./super/odm.img \
    --sparse --output ./super_custom.img
  18. Flashed Orange Fox using Odin
  19. Booted into Recovery (vol up + power) and flashed the super_custom.img into the Super partition
  20. Rebooted and got LineageOS loading
 
Last edited:

physwizz

Senior Member
Sep 16, 2013
3,311
730
Sydney
Success! I have finally made it to LineageOS on my (Russian Vietnam-made) SM-A127F/DSN! I tried it quickly and it looks like it works fine: no problems with the lock screen or camera. Unfortunately no "easy" way worked for me, so I had to go the hard way: completely repacking the super.img, replacing the stock system.img with LineageOS.img. To my immense surprise that worked! Although it first required a lot of searching for the correct tools (for Linux + a bit of Windows in a VM) and then learning how to unpack and repack everything back.

Basically, here are my steps (mostly Linux):
  1. Downloaded the stock firmware (I used the Fijian version as it's the smallest of all)
  2. Flashed it using Odin. That is the only Windows tool I had to use (Heimdall does not work for me, probably it's too outdated)
  3. Gone through the Android setup, enabled the Developer mode, unlocked the bootloader (OEM Unlock), rebooted
  4. Gone through the setup once again, installed Magisk, patched the AP image, flashed it (I think all that is unnecessary)
  5. Unpacked the AP[..].tar.md5: tar xf AP[..].tar.md5
  6. Uncompressed super.img: unlz4 super.img.lz4
  7. Converted from sparse image format to non-sparse (raw): simg2img super.img super.raw
  8. Downloaded and compiled the LonelyFool's lpunpack_and_lpmake.
  9. mkdir super && lpunpack super.raw super
  10. Downloaded LineageOS GSI
  11. Unpacked it: unxz lineage-[..]-treble_arm64_bvS.img.xz
  12. Converted to raw system image: simg2img lineage-18.1-20211010-UNOFFICIAL-treble_arm64_bvS.img system.img
  13. Renamed the original system.img to system_orig.img
  14. Put the LineageOS system.img into the super dir instead of the stock one
  15. Converted the system_orig.img into the raw image format: simg2img system_orig.img system_orig.raw
  16. Dumped (displayed) the system_orig.raw metadata: lpdump system_orig.raw
  17. (here comes the hardest part) Repacked super.img back together using the dumped metadata info:
    lpmake \
    --metadata-size 65536 --super-name super --metadata-slots 2 --device super:5679087616 --group group_basic:5674893312 \
    --partition system:readonly:1852809216:group_basic --image system=./super/system.img \
    --partition vendor:readonly:441614336:group_basic --image vendor=./super/vendor.img \
    --partition product:readonly:948908032:group_basic --image product=./super/product.img \
    --partition odm:readonly:4349952:group_basic --image odm=./super/odm.img \
    --sparse --output ./super_custom.img
  18. Flashed Orange Fox using Odin
  19. Booted into Recovery (vol up + power) and flashed the customized super.img into the Super partition
  20. Rebooted and got LineageOS loading
Great work.
I flashed lineage and pixel experience from twrp

Why is DSN so much different?

post#3
 
Last edited:
  • Like
Reactions: uluruman
Feb 3, 2016
32
10
Great work.
I flashed lineage and pixel experience from twrp

Why is DSN so much different?

post#3
Wow, and you called my modest 7 steps a "mammoth effort". Uluruman, thats the mammoth. Maybe, leave a mention about unclear state for DSN in original #1.
Although root, twrp, lineage.... are for those, who can at least read a bit, its not a necessary to invent wheel again.
 
  • Like
Reactions: uluruman

physwizz

Senior Member
Sep 16, 2013
3,311
730
Sydney
Success! I have finally made it to LineageOS on my (Russian Vietnam-made) SM-A127F/DSN! I tried it quickly and it looks like it works fine: no problems with the lock screen or camera. Unfortunately no "easy" way worked for me, so I had to go the hard way: completely repacking the super.img, replacing the stock system.img with LineageOS.img. To my immense surprise that worked! Although it first required a lot of searching for the correct tools (for Linux + a bit of Windows in a VM) and then learning how to unpack and repack everything back.

Basically, here are my steps (mostly Linux):
  1. Downloaded the stock firmware (I used the Fijian version as it's the smallest of all)
  2. Flashed it using Odin. That is the only Windows tool I had to use (Heimdall does not work for me, probably it's too outdated)
  3. Gone through the Android setup, enabled the Developer mode, unlocked the bootloader (OEM Unlock), rebooted
  4. Gone through the setup once again, installed Magisk, patched the AP image, flashed it (I think all that is unnecessary)
  5. Unpacked the AP[..].tar.md5 from the stock firmware files: tar xf AP[..].tar.md5
  6. Uncompressed super.img: unlz4 super.img.lz4
  7. Converted from sparse image format to non-sparse (raw): simg2img super.img super.raw
  8. Downloaded and compiled the LonelyFool's lpunpack_and_lpmake
  9. mkdir super, then unpack the super.raw into that dir: lpunpack super.raw super
  10. Downloaded LineageOS GSI
  11. Unpacked it: unxz lineage-[..]-treble_arm64_bvS.img.xz
  12. Converted to raw system image: simg2img lineage-18.1-20211010-UNOFFICIAL-treble_arm64_bvS.img system.img
  13. Renamed the original system.img to system_orig.img
  14. Put the LineageOS system.img into the super dir
  15. Converted the system_orig.img into the raw image format: simg2img system_orig.img system_orig.raw
  16. Dumped (displayed) the system_orig.raw metadata: lpdump system_orig.raw
  17. (here comes the hardest part) Repacked super.img back together using the dumped metadata info:
    lpmake \
    --metadata-size 65536 --super-name super --metadata-slots 2 --device super:5679087616 --group group_basic:5674893312 \
    --partition system:readonly:1852809216:group_basic --image system=./super/system.img \
    --partition vendor:readonly:441614336:group_basic --image vendor=./super/vendor.img \
    --partition product:readonly:948908032:group_basic --image product=./super/product.img \
    --partition odm:readonly:4349952:group_basic --image odm=./super/odm.img \
    --sparse --output ./super_custom.img
  18. Flashed Orange Fox using Odin
  19. Booted into Recovery (vol up + power) and flashed the super_custom.img into the Super partition
  20. Rebooted and got LineageOS loading
Everything is a learning experience, even when you're 67 years old.
 

physwizz

Senior Member
Sep 16, 2013
3,311
730
Sydney
Root and TWRP

1. Download firmware
2. Extract ap file.
3. Patch with magisk
4. Flash with Odin
5. Download recovery.img (you might need to extract from tar)
6. Install TWRP app
7. Install TWRP
8. Choose file to flash.(don't select device)
9. Select recovery.img.
Done
 

uluruman

Senior Member
Oct 23, 2021
83
8
@uluruman , @honzazkrumlova ,

Perhaps you guys should get together and make a thread for the a127f/DSN
I am still clarifying some things. First of all there seems to be some problem with boot.img: LineageOS hangs forever on the animated loading screen after a reboot. I used the Magisk-patched boot.img and vbmeta.img as the base of my experiments, but probably they should either remain stock or I should magisk-patch them again right on the first boot of LineageOS. Either way I want to find the cleanest and the shortest way of doing it all for those who just want to swap to LineageOS.
 

physwizz

Senior Member
Sep 16, 2013
3,311
730
Sydney
I am still clarifying some things. First of all there seems to be some problem with boot.img: LineageOS hangs forever on the animated loading screen after a reboot. I used the Magisk-patched boot.img and vbmeta.img as the base of my experiments, but probably they should either remain stock or I should magisk-patch them again right on the first boot of LineageOS. Either way I want to find the cleanest and the shortest way of doing it all for those who just want to swap to LineageOS.
You don't need them if you rooted with patched ap file.
Also make sure you wipe data.
GSIs can't use OneUI data
 

physwizz

Senior Member
Sep 16, 2013
3,311
730
Sydney
Just tried to install U3 firmware on my a127f with u2 baseband.


Installation Method


Patch u3 ap file using special magisk

Boot into recovery
Backup boot, data, dtbo, super
Mount system etc
Wipe data.
Install patched boot.img
Install super.img
Reboot to recovery
Mount system etc
Install multidisabler
Reboot to recovery
Mount system etc
Install multidisabler again
Reboot

This bootlooped. So I restored my u2 backup
 

TheWorldYT

Member
Oct 23, 2021
48
4
Root Method for all Exynos 850 devices.

A. Root part 1 - Preparing the file


I accept no responsibility for bricked phones but I will help you to recover.

1. Download the exact firmware (including upgrade date) for your device from https://samfrew.com or https://www.samfirmware.net/ or https://www.full-repair-firmware.com/search?q=A20 or
2. Download patched magisk
3. Use zarchiver to extract the apxxxxxx....md5 section from the firmware.
4. Use patched magisk to patch the ap section. Allow the extra files.
Click on install and select patch file.
The output will be a patched tar file.

B. To Unlock Bootloader
1. Activate developer options by going to settings, about phone, software information and tapping on build number 7 times.
On phone developer options in settings allow OEM unlocking and enable usb debugging by moving both
sliders RIGHT
If you don't see the OEM unlock
-Disable Auto System Update
-Then disable Automatic date and time (Found in General Management) > then set the time back 14 days
- Connect to the internet
-Go to software update then check for update and wait a long time till it registers the device on server
-Once it's registered the OEM Unlock should be visible in the Developer Options
then connect phone to PC
2. Reboot into download mode by holding down both Vol up and Vol down
(You might need to long press vol up to unlock bootloader)
then press vol up to continue
Reboot and skip through the setup process.


C. Root part 2

Reboot into download mode again
6. Flash the patched ap tar file using special Odin.
(Click on the ap button and choose the patched tar file. Press start)
7. Reboot.
8. Skip all the way through the set-up process.




D. TWRP installation for a127f and m127f (may not work for a127f/DSN)

Make sure your system has fully completed the installation process and all apps have been installed

1. Download the afaneh92 zip file.Unzip the tar from the zip.
2. Extract the recovery.img
3. Install TWRP app form the playstore
4. Choose Install TWRP
5. Choose file to flash.(don't select device)
6. Select recovery.img.
7. Reboot to recovery.
8. Mount system (Press mount then choose system)
9. Tap on Wipe, tap on format data, type YES. (Not just wipe data)
10. Tap on Advanced then terminal.
11. Type multidisabler. Wait for it to finish. Type multidisabler again. Go to main menu
Reboot to recovery (tap on reboot, tap on recovery)
Ignore the keyrefuge error message.
12. Reboot and go completely through the setup process. Wait for downloading to finish. This may take up to an hour. You can see the progress by pulling down from the top.
13. Reboot into recovery and Backup boot, data, super and dtbo


@physwizz
i extracted the file and i don't get what to do next
 

TheWorldYT

Member
Oct 23, 2021
48
4
and i can't reflash it back to stock firmware and i can't boot to anything except twrp.

please help!
 

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    Thanks physwizz! With these new recoveries I finally got TWRP booting! I've formatted data okay, have the sdcard accessible after that and a reboot, but now the next problem: a lot of "Unable to find partition for path '/system_root'" messages. And indeed, there is no "system_root" partition entry in fstab. Also the "Mount system partition read-only" checkbox in the Mount section is unresponsive and remains always checked. Any ideas?
    Agh, finally, I found combination, that works for me.
    I have spent days and physwizz hours PMing with me to double, triple check, if I missed some point. It still remain mysterious, why steps leads to different results, as a novice, I can just speculate, if there is some tiny important difference between A127F/DS and A127F/DSN. Or, well.... what about starting "Stock ROM" we are different.

    But there have been some clues.
    Afaneh92's TWRP, it can boot for me, but there has been two things that stink for me. Select Storage - shown Internal storage 0MB capacity and unmountable Data partition, that even if it reports 0MB size, cannot as an empty be backuped, for example. Reboots after proper steps (Format data) leads to slow bootlooping (10mins, I guess Android factory reset trying to finish with some bug in the end).

    Newest TWRP - that one reported lasttime, Srilanka user, it can in some point (physwizz remount command) starts to report Storage size, even Data partition, but installing multidisabler didnt worked for me, leads to Cannot install zip file error. So, not surprise, after data format and reboot, it lead to nothing, well I can just speculate it that un-disabled encryption. Physwizz advice to remount solves part of red colors anout system root.

    I combine those TWRP, using both for part of the job.
    1. Rebooted to Afaneh92 TWRP,
    2. run remount command
    3. run multidisable twice
    4. Reboot directly to download mode
    5. flash SriLankas TWPR, and boot it
    6. Remount command, Format data
    7. Reboot

    voila, system starts, initiate standard default process. Srilankas TWRP can backup all partition I want (including /data). All done.

    I have no idea, if this procedure will help others and will work in other conditions, thats the task for you guys, much much advanced than me. I have just some unclear imagination, whats those steps are about, but there has to be something unfinished with afanehs twrp, that prevent it to work OK in some conditions (hardware, original but regional stock rom)

    Let others know, if it worked for ya.
    HzK
    1
    I can now totally confirm that the afaneh92's TWRP image, as well as edward0181's, does not work on the Vietnam-made SM-A127F/DSN: I've rooted it, installed TWRP app, flashed the recovery.img from the app and rebooted into recovery using adb. I'm still getting just endless reboots. So this time the experiment was clean and the "wrong key pressed at wrong time" factor was completely excluded. I'm just curious why any stock firmware and the stock recovery tools works just fine? I've already tried many different country-specific versions from that list and they all flash and work perfectly.

    P.S.: By the way, I've built the latest Magisk from the git master and it works great, so no patched version needed.
    1
    Orange Fox
    From @(Sri Lanka)

    (MTP not working)

    Installation
    Unzip files
    Extract recovery.img

    Method 1.
    If you have already installed afaneh92 TWRP and decrypted.
    1. Boot to recovery.
    2. Install recovery.img
    3. Choose recovery partition
    4. Reboot to recovery

    Method 2.
    From the start

    1. Download firmware
    2. Extract ap file.
    3. Patch with magisk
    4. Flash with Odin
    5. Download recovery.img
    6. Install TWRP app
    7. Install TWRP
    8. Choose file to flash.(don't select device)
    9. Select recovery.img.
    10. Reboot to recovery.
    11. Format data
    12. Install multidisabler zip
    Or dmverity
    13. Reboot to recovery
    Done


    @physwizz
    1
    Agh, finally, I found combination, that works for me.
    I have spent days and physwizz hours PMing with me to double, triple check, if I missed some point. It still remain mysterious, why steps leads to different results, as a novice, I can just speculate, if there is some tiny important difference between A127F/DS and A127F/DSN. Or, well.... what about starting "Stock ROM" we are different.

    But there have been some clues.
    Afaneh92's TWRP, it can boot for me, but there has been two things that stink for me. Select Storage - shown Internal storage 0MB capacity and unmountable Data partition, that even if it reports 0MB size, cannot as an empty be backuped, for example. Reboots after proper steps (Format data) leads to slow bootlooping (10mins, I guess Android factory reset trying to finish with some bug in the end).

    Newest TWRP - that one reported lasttime, Srilanka user, it can in some point (physwizz remount command) starts to report Storage size, even Data partition, but installing multidisabler didnt worked for me, leads to Cannot install zip file error. So, not surprise, after data format and reboot, it lead to nothing, well I can just speculate it that un-disabled encryption. Physwizz advice to remount solves part of red colors anout system root.

    I combine those TWRP, using both for part of the job.
    1. Rebooted to Afaneh92 TWRP,
    2. run remount command
    3. run multidisable twice
    4. Reboot directly to download mode
    5. flash SriLankas TWPR, and boot it
    6. Remount command, Format data
    7. Reboot

    voila, system starts, initiate standard default process. Srilankas TWRP can backup all partition I want (including /data). All done.

    I have no idea, if this procedure will help others and will work in other conditions, thats the task for you guys, much much advanced than me. I have just some unclear imagination, whats those steps are about, but there has to be something unfinished with afanehs twrp, that prevent it to work OK in some conditions (hardware, original but regional stock rom)

    Let others know, if it worked for ya.
    HzK
    Glad it now works.
    What a mammoth effort.
    The a127f/DSN is different in some way from a127f (I have a single Sim)

    Now see if you can install my kernel v4
    1
    I'll try the honzazkrumlova method. But I can't use the Afaneh92's TWRP anyway.