1

I have a samsung SMG531f Grand Prime. I accidentially deleted my OS in Team Win by selecting the System option coming under Wipe option in the main menu. Now when I switch on the phone it will show only the startup screen. I can only go to the TeamWin by pressing Volume up Home and power button. But when I try to go to odin mode by clicking on volume down power and home button it doesn't work. How can I overcome this problem and reinstall os to this phone.

Volume up key doesn't work in this phone.

Prefer a solution which can be configured in Windows environment as I don't have access to an open source OS.

ChathurawinD
  • 151
  • 8
  • 1
    on newer samsung devices system.img is lz4 compressed. yours should be simg2img sparse image – alecxs Jan 22 '22 at 21:17
  • @alecxs Could you elaborate on how can I do it step by step? – ChathurawinD Jan 22 '22 at 21:24
  • this is the origin of simg2img.exe but I recommend more recent version for linux https://forum.xda-developers.com/showthread.php?t=1054836&page=3 – alecxs Feb 22 '22 at 21:46

1 Answers1

1
  1. download and extract ROM from samloader

    cd /media/xubuntu/1234567890ABCDEF
    sudo apt update
    sudo apt install android-sdk-ext4-utils android-sdk-libsparse-utils android-sdk-platform-tools-common android-tools-adb android-tools-fastboot f2fs-tools git python3.8 python3-pip
    

    git clone https://github.com/nlscc/samloader

    cd samloader pip3 install . cd .. sudo cp -av ~/.local/bin/samloader /usr/local/bin

    mkdir Android cd Android

    samloader -m SM-G531F -r SLK checkupdate samloader -m SM-G531F -r SLK download -v G531FDDU1APJ2/G531FODD1APJ2/G531FDDU1APJ2/G531FDDU1APJ2 -O . samloader -m SM-G531F -r SLK decrypt -v G531FDDU1APJ2/G531FODD1APJ2/G531FDDU1APJ2/G531FDDU1APJ2 -V 4 -i SM-G531F_1_20161116150254_w0xdzpk60j_fac.zip.enc4 -o SM-G531F_1_20161116150254_w0xdzpk60j_fac.zip

    unzip SM-G531F.zip tar -vxf AP_G531F.tar*

  2. convert system.img into mountable disk image

    mv -v system.img system.sparse.img
    file system.sparse.img
    simg2img system.sparse.img system.img
    file system.img
    

    (optional) check if mountable

    mkdir system
    sudo mount -vo loop,ro,noexec,noload,noatime -t ext4 system.img system
    ls -a system
    sudo umount -v system
    
  3. copy file to MicroSD Card

    adb push system.img /external_sd
    

    (optional) compare digest

    md5sum system.img
    adb shell md5sum /external_sd/system.img
    
  4. write disk image from terminal dd

    adb shell
    find /dev/block -name by-name
    ls -l /dev/block/bootdevice/by-name/system
    dd if=/external_sd/system.img of=/dev/block/bootdevice/by-name/system
    reboot recovery
    
  5. disable dm-verity and recovery-from-boot.p (necessary for TWRP)

    adb disable-verity
    adb shell
    mount -w /system
    mv -v /system/recovery-from-boot.p /system/recovery-from-boot.bak
    
alecxs
  • 4,034
  • 3
  • 16
  • 34
  • How can I do this in Windows? – ChathurawinD Feb 12 '22 at 11:38
  • Can you explain how can I do the whole process in Windows? – ChathurawinD Feb 12 '22 at 20:21
  • EVERYTHING in the above answer, most of the commands are to run in Linux environment when I Googled. Could you please give me a way how on doing these in Windows? – ChathurawinD Feb 13 '22 at 01:54
  • @alexcs I tried those before too. It shows downloading in MINGW64 but it never shows whether the download succeeded or not. And I have no idea about how can I find the downloaded file. Please understand how a person who has never used Linux feels like executing your commands and translating those to Windows environment. – ChathurawinD Feb 13 '22 at 11:12
  • I am sorry with the resources I have moving to Linux is not an option for me. – ChathurawinD Feb 13 '22 at 11:57
  • @alexcs Even though I have a flash drive, configuring Linux on it and getting to know the commands to get this done on it is a hassle for me at the moment. There can be a lot of issues as in other app configurations which should be done as I do not have used Linux before. – ChathurawinD Feb 13 '22 at 12:09
  • @alexcs chathura@chathura-VirtualBox:~/Android$ simg2img system.sparse.img system.img error: file_write: write: No space left on device Cannot write output file This error message shows up. What can I do? – ChathurawinD Feb 16 '22 at 09:10
  • Note: step 5 is probably most important to avoid losing TWRP (as the file name reveals system will overwrite recovery from boot otherwise). dm-verity can disabled by installing Magisk (rename apk to zip) or by installing no-verity-opt-encrypt.zip – alecxs Feb 16 '22 at 11:43
  • @alexcs I tried with the live usb, I selected the Windows hard disk, Now i get below error.

    "open your windows hard drive, right mouse click, "open terminal here""

    W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease Error writing to output file - write (28: No space left on device) [IP: 91.189.91.39 80

    – ChathurawinD Feb 16 '22 at 16:00
  • @alexcs Last attempt was made in a live iso. Can this be a reason like the OS doesn't have access right to read or write anything to my C drive as it is the only drive that I have in my PC. – ChathurawinD Feb 20 '22 at 15:37