[Samsung Galaxy Fold ROMs, Kernels, Recoveries, & O] ianmacd:
TWRP 3.4.0 for the Samsung Galaxy Fold

​

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.

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)

twrp-winnerx-3.5.0_9-1_ianmacd.img

twrp-winnerx-3.5.0_9-1L_ianmacd.img (landscape)

Latest release for F900F (BTH2 firmware)

twrp-winner-3.5.0_9-1_ianmacd.img

twrp-winner-3.5.0_9-1L_ianmacd.img (landscape)

Android 9

Latest release for F907B (ATA1 firmware)

twrp-winnerx-3.3.1-23_ianmacd.img

twrp-winnerx-3.3.1-23L_ianmacd.img (landscape)

Latest release for F900F (ATA3 firmware)

twrp-winner-3.3.1-23_ianmacd.img

twrp-winner-3.3.1-23L_ianmacd.img (landscape)

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 bootable recovery

TWRP device trees

Galaxy Fold a.ka. winner (F900F)

Galaxy Fold 5G a.ka. winnerx (F907B)

Kernel source code

Galaxy Fold a.ka. winner (F900F)

Galaxy Fold 5G a.k.a. winnerx (F907B)

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