TWRP 3.4.0 for the Samsung Galaxy Fold

I own


  • Total voters
    63
Search This thread
TWRP 3.4.0 for the Samsung Galaxy Fold

twrp-fold.jpg

Introduction

It gives me great pleasure to present to you TWRP on the Samsung Galaxy Fold. Your foldable phone just became even more flexible.

This project picks up TWRP where Chris Williamson left off. Chris produced the initial release of TWRP for the Fold, which combined a custom kernel sporting some extra features with a pre-rooted TWRP image.

Chris asked me to take over the development of TWRP for the Fold to allow him to concentrate on kernel development for the device, and I was happy to oblige. My goal is to offer you the most functional build of TWRP that I possibly can, whilst making no assumptions about your desire to root the device or run a custom kernel. For that reason, the kernel I am supplying as part of this project is as close to stock as possible, with only the minimum number of changes required to allow TWRP to function, and with no added features. For the same reason, the images I provide have not been pre-rooted with Magisk.

Rooting Samsung system-as-root devices

How you root your Fold depends on whether you are running Android 9 (Pie) or Android 10. If, however, you have already upgraded your device to Android 10, you can root your device only in the boot partition. For reasons that are not yet clear, the Fold will not boot Android froma custom kernel that is rooted in recovery.

Rooting in the recovery partition

When the device is rooted in recovery, the TWRP image must be patched with Magisk (using the Magisk Manager app) to allow the same kernel to be shared between TWRP and Android. After patching, the user always boots the device from the recovery partition, and uses the device's hardware keys at boot time to select between Magisk-rooted Android and TWRP. A normal system boot from the boot partition brings the system up without root.

Rooting in the boot partition

When the device is rooted in the boot partition, the TWRP image is left untouched. Instead, the boot partition must be rooted with Magisk by flashing the Magisk zip file in TWRP. Rooted Android is booted via a normal system boot and the hardware keys play no special role. There is no option to boot Android unrooted.

Device preparation

Before doing anything else, back up your data now if you have any.

If you are installing TWRP on a brand new device, you must first unlock its bootloader. Select OEM Unlocking from Settings → Developer Options, then reboot to Device Unlock mode to actually unlock the bootloader. This will have the side-effect of resetting the device.

If you are installing TWRP on an unrooted device, it is crucial that you also flash the attached vbmeta.img file at the same time. Simply include this in a tar file with the TWRP image for your device (renamed recovery.img) and flash them together. You must reformat /data after doing this.

If you fail to neutralise the device's vbmeta protection before rebooting, the device's anti-tampering protection will be triggered and you will be unable to boot either Android or TWRP. A full reinstallation of stock firmware will be required and your device may be left in KG State Prenormal, requiring time-consuming extra steps to restore its ability to accept unofficial images again. Do not fail to neutralise vbmeta.

If you have already rooted your device with Magisk, vbmeta has already been disarmed and you may proceed with installing TWRP.

Image preparation

Rooting in the recovery partition

As noted above, the TWRP images supplied here are not pre-patched with Magisk. If you wish to dual-boot TWRP and Android Pie, you must patch the recovery image with Magisk before flashing it. Version 20.2 of Magisk is recommended for this. Versions 20 and 20.1 contain a serious bug that will render the recovery partition unbootable after patching. Please see John Wu's excellent step-by-step instructions for rooting the 2019 generation of Samsung Pie devices with Magisk.

An altogether simpler way of working is to flash the TWRP image on demand, only when required. After finishing your work in TWRP, simply replace TWRP with a Magisk-rooted stock recovery image and reboot to Android. I personally recommend this swapping approach, as it frees both the TWRP maintainer and the user from constantly updating the TWRP image to ensure it contains a kernel that is compatible with the version of the firmware on the device.

Here is a basic sample script that will check whether the current environment is Android or TWRP, flash the appropriate recovery image for the other environment, then reboot to it. You can easily adapt it to fit your needs.

Code:
twrp_img=/sdcard/twrp/twrp-3.3.1.img
stock_img=/sdcard/twrp/recovery-ask2-magisk.img

if [ -f /sbin/magisk ]; then
  # We're in Android: Switch to TWRP.
  #
  infile=$twrp_img
else
  # We're in TWRP: Switch to Android.
  #
  infile=$stock_img
fi

dd if=$infile of=/dev/block/by-name/recovery bs=$(stat -c%s $infile) && reboot recovery

Rooting in the boot partition

No special image preparation is required for installation on Android 10 devices.

TWRP images

TWRP is offered here as an assortment of recovery image files. To use with Odin, first rename the appropriate file recovery.img and then tar it. Ready-made tar files are not supplied here, because it would double the number of files to be maintained, and because it's trivial to generate a tar archive on any modern computing platform, including on the Fold itself.

Post-installation

The Fold, like all 2019 Samsung devices, utilises file-based encryption (FBE) by default. The use of encryption in TWRP on Samsung devices is invariably problematic, however, and encryption is therefore routinely disabled by users wishing to use TWRP. If this is not done, your files will remain unreadable to TWRP.

To remove encryption from your device, please flash the Samsung multi-disabler after installing TWRP, and then reformat /data again. Do not skip this step, even if you have already formatted /data one or more times thus far. If installing TWRP on Android 10, you need at least v2.3 of the multi-disabler.

Compatibility

The images below are known to be compatible with the firmware revisions stated. Results on other revisions will vary.

The F907B images have been personally tested and verified by me on my own Fold 5G prior to release. The F900F images should be of comparable quality.

Download

Android 10

Latest release for F907B (BTH2 firmware)


Latest release for F900F (BTH2 firmware)


Android 9

Latest release for F907B (ATA1 firmware)


Latest release for F900F (ATA3 firmware)


Known problems

  • TWRP is currently displayed only on the device's main (inner) screen.
  • Haptic feedback is currently unavailable in TWRP.

Frequently Asked Questions

Q. Why do you offer a separate build for each device with landscape orientation?


A. The aspect ratio of the main (inner) screen 4.2:3 is such that TWRP on this device looks good in both portrait and landscape orientation. In portrait mode, the clock and battery meter are shifted to the left to avoid the camera notch. In portrait mode, the entire image is shifted to the right to avoid the notch.

See the gallery of images below, or simply try each version of TWRP on your device, to discover which orientation you prefer.

TWRP source code


TWRP device trees


Kernel source code


Real-time chat

For support or just to talk about the device amongst friends, please join our small Telegram group dedicated to the Galaxy Fold.

Credits

I am indebted to Chris Williamson (@chrisaw) for laying the foundations for TWRP on the Fold. And thanks in no small part to him and his contagious enthusiasm for the device, I'm now also indebted to Samsung for the purchase price of a Fold 5G.

Thanks to @osm0sis for AIK, a tool without which working with boot images would be far more tedious than it already is.

Thanks to Samsung for engineering this amazing device in the first place.

And last but not least, thanks to my wife, Sarah, for her tolerance of my expenditure on gadgetry.

XDA:DevDB Information
TWRP for the Samsung Galaxy Fold, Tool/Utility for the Samsung Galaxy Fold

Contributors
ianmacd, chrisw

Version Information
Status: Stable
Current Stable Version: 3.4.0-4_ianmacd
Stable Release Date: 2020-10-05

Created 2019-11-20
Last Updated 2021-01-19
 

Attachments

  • vbmeta.img
    256 bytes · Views: 425
Last edited:
Changelog

3.5.0_9-1_ianmacd

  • Update to TWRP 3.5.0.

3.4.0-4_ianmacd

  • Use latest F907BXXS4BTH2 and F900FXXS4BTH2 kernel source code.

3.4.0-1_ianmacd

  • TWRP updated to version 3.4.0.

3.3.1-101_ianmacd

  • Use latest F900FXXU3BTDD and F907BXXU3BTDD kernel source code.
  • Kernel now built using clang 8.0.11.

3.3.1-100_ianmacd

  • First release supporting Android 10.
  • Use latest F900FXXU3BTCD and F907BXXU3BTC9 kernel source code.

3.3.1-23_ianmacd

  • Use latest F900FXXS3ATA3 and F907BXXS3ATA1 kernel source code.

3.3.1-22_ianmacd (F907B only)

  • Build kernel from latest F907BXXS2ASL3 source code.

3.3.1-21_ianmacd (F907B only)

  • Build kernel from latest F907BXXU2ASK9 source code.

3.3.1-20_ianmacd

  • Use latest F900FXXS2ASKC and F907BXXS2ASK2 kernel source code.
  • Build without crypto code, as crypto is unsupported.
  • MInor fstab fix for /data.
  • Disable sundry irrelevant kernel features for a slightly leaner kernel.

3.3.1-17_ianmacd

  • First ianmacd release, using F900FXXU1ASJ4 and F907BXXS2ASK2 kernel source code.
 
Last edited:
Version 3.3.1-20_ianmacd released.

This release upgrades the kernel from the latest Samsung source code. In the case of the F900F, there are significant changes, whereas the F907B's kernel is hardly differs from the previous version.

The builds have also been stripped of superfluous crypto code, and a harmless bug in the fstab has been fixed.

3.3.1-20_ianmacd

  • Use latest F900FXXS2ASKC and F907BXXS2ASK2 kernel source code.
  • Build without crypto code, as crypto is unsupported.
  • MInor fstab fix for /data.
  • Disable sundry irrelevant kernel features for a slightly leaner kernel.
 

avetny

Senior Member
Jul 16, 2010
5,732
1,823
Private Island.
This release upgrades the kernel from the latest Samsung source code. In the case of the F900F, there are significant changes, whereas the F907B's kernel is hardly differs from the previous version.

The builds have also been stripped of superfluous crypto code, and a harmless bug in the fstab has been fixed.

3.3.1-20_ianmacd

  • Use latest F900FXXS2ASKC and F907BXXS2ASK2 kernel source code.
  • Build without crypto code, as crypto is unsupported.
  • MInor fstab fix for /data.
  • Disable sundry irrelevant kernel features for a slightly leaner kernel.


Thank you for all your work !!!
 

DTman22

New member
Oct 20, 2019
1
0
help me plz

hello, I can't flash with Odin because it gives me an error message: blocked from the OEM.
 

tranquility

Senior Member
Sep 30, 2007
243
49
Almaty
Hi ianmacd
I know this is off top, but couldn't private message you
On libsecure_storage companion for rooted Samsung devices ver. 2.0 I experienced strong connectivity issues with airpods 2 (on note 9), rolling back to 1.8 got working it ok. Just for your information
 

thmthoom

Member
Oct 18, 2019
12
0
hi I tried to use the method but something wrong happened, now my f900f stuck on starting android and it won't start up .
how can I go to download mode .?

Note: the VOL_UP + Power bottom it's not doing anything, even if putting the cable into the phone while starting up ..

any solutions .. ?
 

thmthoom

Member
Oct 18, 2019
12
0
I'M getting "custom binary blocked by OEM lock "
the OEM unlock in developer option is ON

model F900F
Any solution ?
 
I'M getting "custom binary blocked by OEM lock "
the OEM unlock in developer option is ON

model F900F
Any solution ?

All you have done by toggling that option under Developer Options is enable OEM-unlocking of the device. You haven't actually opened the lock yet.

Boot to Download Mode to actually open the lock.

See the OP for more details.

Sent from my SM-N975F using XDA Labs
 

thmthoom

Member
Oct 18, 2019
12
0
All you have done by toggling that option under Developer Options is enable OEM-unlocking of the device. You haven't actually opened the lock yet.

Boot to Download Mode to actually open the lock.

See the OP for more details.

Sent from my SM-N975F using XDA Labs

Thanks for your response brother..
Actually I’m booting to download mode using K 300 tool .. because I cannot boot using VOLUP + POWER bottom .. so my question is :
1- how to open the lock through the download mode , coz I’m not getting any options there.

2- what do u mean by “ see the op for more details “
 

thmthoom

Member
Oct 18, 2019
12
0
All you have done by toggling that option under Developer Options is enable OEM-unlocking of the device. You haven't actually opened the lock yet.

Boot to Download Mode to actually open the lock.

See the OP for more details.

Sent from my SM-N975F using XDA Labs

Brother , for Unlocking Bootloader these are the steps :

Allow bootloader unlocking in Developer options → OEM unlocking ( DONE )
Reboot your device to download mode. Either use adb reboot download, or use the key combo for your device. ( DONE )
Long press volume up to unlock the bootloader. This will wipe your data and automatically reboot. ( the volume up won't work in this step, only I can use Volume down+power to restart the phone )

So what to do in this case if you have any ideas ...
 

thmthoom

Member
Oct 18, 2019
12
0
I Followed " John Wu's excellent step-by-step instructions for rooting the 2019 generation of Samsung Pie devices with Magisk. " STEP-BY-STEP these was the resutls :

1- I won't able to use VOL_UP bottom , I skip this step " I think this step caused me a lot of problems "
2- all other steps I'm getting ( boot ) locked OEM or ( vbmeta ) locked OEM
3- I tried to flash recovery alone
4- I tried to flash vbmeta alone
5- I tried to flash both recovery + vbmeta together

The result : FAIL :(

I think my main problem is unlocking the bootloader using VOL_UP key ..... How to do this while I don't have an option to use VOL_UP key.
even if i'm pressing the VOL_UP key for 1 Minute nothing happens .

you kindness solution will be appreciated :(
 

Vahnyyz

Senior Member
@ianmacd

First I'd like to say thank you for the work that you've done, and your intro was very well put and super kind to Chris. I know you likely have your hands very full, however I was wondering if you knew of any plans for the F900U or F900U1. I would like to reformat my AT&T phone so that I can get access to unlocking bootloader and hopefully use your TWRP, but I'm not sure if it would work.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 10
    TWRP 3.4.0 for the Samsung Galaxy Fold

    twrp-fold.jpg

    Introduction

    It gives me great pleasure to present to you TWRP on the Samsung Galaxy Fold. Your foldable phone just became even more flexible.

    This project picks up TWRP where Chris Williamson left off. Chris produced the initial release of TWRP for the Fold, which combined a custom kernel sporting some extra features with a pre-rooted TWRP image.

    Chris asked me to take over the development of TWRP for the Fold to allow him to concentrate on kernel development for the device, and I was happy to oblige. My goal is to offer you the most functional build of TWRP that I possibly can, whilst making no assumptions about your desire to root the device or run a custom kernel. For that reason, the kernel I am supplying as part of this project is as close to stock as possible, with only the minimum number of changes required to allow TWRP to function, and with no added features. For the same reason, the images I provide have not been pre-rooted with Magisk.

    Rooting Samsung system-as-root devices

    How you root your Fold depends on whether you are running Android 9 (Pie) or Android 10. If, however, you have already upgraded your device to Android 10, you can root your device only in the boot partition. For reasons that are not yet clear, the Fold will not boot Android froma custom kernel that is rooted in recovery.

    Rooting in the recovery partition

    When the device is rooted in recovery, the TWRP image must be patched with Magisk (using the Magisk Manager app) to allow the same kernel to be shared between TWRP and Android. After patching, the user always boots the device from the recovery partition, and uses the device's hardware keys at boot time to select between Magisk-rooted Android and TWRP. A normal system boot from the boot partition brings the system up without root.

    Rooting in the boot partition

    When the device is rooted in the boot partition, the TWRP image is left untouched. Instead, the boot partition must be rooted with Magisk by flashing the Magisk zip file in TWRP. Rooted Android is booted via a normal system boot and the hardware keys play no special role. There is no option to boot Android unrooted.

    Device preparation

    Before doing anything else, back up your data now if you have any.

    If you are installing TWRP on a brand new device, you must first unlock its bootloader. Select OEM Unlocking from Settings → Developer Options, then reboot to Device Unlock mode to actually unlock the bootloader. This will have the side-effect of resetting the device.

    If you are installing TWRP on an unrooted device, it is crucial that you also flash the attached vbmeta.img file at the same time. Simply include this in a tar file with the TWRP image for your device (renamed recovery.img) and flash them together. You must reformat /data after doing this.

    If you fail to neutralise the device's vbmeta protection before rebooting, the device's anti-tampering protection will be triggered and you will be unable to boot either Android or TWRP. A full reinstallation of stock firmware will be required and your device may be left in KG State Prenormal, requiring time-consuming extra steps to restore its ability to accept unofficial images again. Do not fail to neutralise vbmeta.

    If you have already rooted your device with Magisk, vbmeta has already been disarmed and you may proceed with installing TWRP.

    Image preparation

    Rooting in the recovery partition

    As noted above, the TWRP images supplied here are not pre-patched with Magisk. If you wish to dual-boot TWRP and Android Pie, you must patch the recovery image with Magisk before flashing it. Version 20.2 of Magisk is recommended for this. Versions 20 and 20.1 contain a serious bug that will render the recovery partition unbootable after patching. Please see John Wu's excellent step-by-step instructions for rooting the 2019 generation of Samsung Pie devices with Magisk.

    An altogether simpler way of working is to flash the TWRP image on demand, only when required. After finishing your work in TWRP, simply replace TWRP with a Magisk-rooted stock recovery image and reboot to Android. I personally recommend this swapping approach, as it frees both the TWRP maintainer and the user from constantly updating the TWRP image to ensure it contains a kernel that is compatible with the version of the firmware on the device.

    Here is a basic sample script that will check whether the current environment is Android or TWRP, flash the appropriate recovery image for the other environment, then reboot to it. You can easily adapt it to fit your needs.

    Code:
    twrp_img=/sdcard/twrp/twrp-3.3.1.img
    stock_img=/sdcard/twrp/recovery-ask2-magisk.img
    
    if [ -f /sbin/magisk ]; then
      # We're in Android: Switch to TWRP.
      #
      infile=$twrp_img
    else
      # We're in TWRP: Switch to Android.
      #
      infile=$stock_img
    fi
    
    dd if=$infile of=/dev/block/by-name/recovery bs=$(stat -c%s $infile) && reboot recovery

    Rooting in the boot partition

    No special image preparation is required for installation on Android 10 devices.

    TWRP images

    TWRP is offered here as an assortment of recovery image files. To use with Odin, first rename the appropriate file recovery.img and then tar it. Ready-made tar files are not supplied here, because it would double the number of files to be maintained, and because it's trivial to generate a tar archive on any modern computing platform, including on the Fold itself.

    Post-installation

    The Fold, like all 2019 Samsung devices, utilises file-based encryption (FBE) by default. The use of encryption in TWRP on Samsung devices is invariably problematic, however, and encryption is therefore routinely disabled by users wishing to use TWRP. If this is not done, your files will remain unreadable to TWRP.

    To remove encryption from your device, please flash the Samsung multi-disabler after installing TWRP, and then reformat /data again. Do not skip this step, even if you have already formatted /data one or more times thus far. If installing TWRP on Android 10, you need at least v2.3 of the multi-disabler.

    Compatibility

    The images below are known to be compatible with the firmware revisions stated. Results on other revisions will vary.

    The F907B images have been personally tested and verified by me on my own Fold 5G prior to release. The F900F images should be of comparable quality.

    Download

    Android 10

    Latest release for F907B (BTH2 firmware)


    Latest release for F900F (BTH2 firmware)


    Android 9

    Latest release for F907B (ATA1 firmware)


    Latest release for F900F (ATA3 firmware)


    Known problems

    • TWRP is currently displayed only on the device's main (inner) screen.
    • Haptic feedback is currently unavailable in TWRP.

    Frequently Asked Questions

    Q. Why do you offer a separate build for each device with landscape orientation?


    A. The aspect ratio of the main (inner) screen 4.2:3 is such that TWRP on this device looks good in both portrait and landscape orientation. In portrait mode, the clock and battery meter are shifted to the left to avoid the camera notch. In portrait mode, the entire image is shifted to the right to avoid the notch.

    See the gallery of images below, or simply try each version of TWRP on your device, to discover which orientation you prefer.

    TWRP source code


    TWRP device trees


    Kernel source code


    Real-time chat

    For support or just to talk about the device amongst friends, please join our small Telegram group dedicated to the Galaxy Fold.

    Credits

    I am indebted to Chris Williamson (@chrisaw) for laying the foundations for TWRP on the Fold. And thanks in no small part to him and his contagious enthusiasm for the device, I'm now also indebted to Samsung for the purchase price of a Fold 5G.

    Thanks to @osm0sis for AIK, a tool without which working with boot images would be far more tedious than it already is.

    Thanks to Samsung for engineering this amazing device in the first place.

    And last but not least, thanks to my wife, Sarah, for her tolerance of my expenditure on gadgetry.

    XDA:DevDB Information
    TWRP for the Samsung Galaxy Fold, Tool/Utility for the Samsung Galaxy Fold

    Contributors
    ianmacd, chrisw

    Version Information
    Status: Stable
    Current Stable Version: 3.4.0-4_ianmacd
    Stable Release Date: 2020-10-05

    Created 2019-11-20
    Last Updated 2021-01-19
    4
    Version 3.3.1-20_ianmacd released.

    This release upgrades the kernel from the latest Samsung source code. In the case of the F900F, there are significant changes, whereas the F907B's kernel is hardly differs from the previous version.

    The builds have also been stripped of superfluous crypto code, and a harmless bug in the fstab has been fixed.

    3.3.1-20_ianmacd

    • Use latest F900FXXS2ASKC and F907BXXS2ASK2 kernel source code.
    • Build without crypto code, as crypto is unsupported.
    • MInor fstab fix for /data.
    • Disable sundry irrelevant kernel features for a slightly leaner kernel.
    1
    TWRP version 3.5.0 released.

    Changelog

    3.5.0_9-1_ianmacd

    • Update to TWRP 3.5.0.