FORUMS

 View Poll Results: I own

a Galaxy Fold
 
10 Vote(s)
35.71%
a Galaxy Fold 5G
 
10 Vote(s)
35.71%
neither of the above
 
8 Vote(s)
28.57%

TWRP 3.3.1 for Galaxy Fold

2,150 posts
Thanks Meter: 3,415
 
By ianmacd, Senior Member on 20th November 2019, 07:41 PM
Post Reply Email Thread
A folding TWRP banner I whipped up in GIMP

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

All new devices launched with Android 9 are required to be factory-configured as system-as-root devices. The ramdisk image formerly found in boot.img is now merged with /system.

For Samsung devices such as the Galaxy Fold, this means that boot.img can no longer be used to root the device. Instead, Magisk is installed in the recovery partition and the user must subsequently always boot from that partition, regardless of whether TWRP or Android is desired. The device's hardware keys are used at boot time to select between Magisk-rooted Android and TWRP.

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.

As noted above, the TWRP images supplied here are not pre-patched with Magisk. If you wish to dual-boot TWRP and Android, you must patch the recovery image with Magisk before flashing it. Version 20.2 (or 19.4) 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
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 by me, because this would double the number of files to be maintained, and it is trivial to generate a tar archive on any modern computing platform, including on the Fold itself.

Post-installation

The Fold, like all 2019 Samsung Pie 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.

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

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 Samung Galaxy Fold, Tool/Utility for the Samsung Galaxy fold

Contributors
ianmacd, chrisw

Version Information
Status: Stable
Current Stable Version: 3.3.1-23_ianmacd
Stable Release Date: 2020-02-24

Created 2019-11-20
Last Updated 2020-02-24
Attached Files
File Type: img vbmeta.img - [Click for QR Code] (256 Bytes, 140 views)
The Following 7 Users Say Thank You to ianmacd For This Useful Post: [ View ] Gift ianmacd Ad-Free
20th November 2019, 07:41 PM |#2  
ianmacd's Avatar
OP Senior Member
Flag Amsterdam
Thanks Meter: 3,415
 
More
Changelog
3.3.1-23_ianmacd
  • Use latest F900FXXS3ATA3 and F907BXXS3ATA1 kernel source code.

F907B

F900F

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.

F907B

F900F

3.3.1-17_ianmacd
  • First ianmacd release, using F900FXXU1ASJ4 and F907BXXS2ASK2 kernel source code.


F907B


F900F
21st November 2019, 04:39 PM |#4  
thanhnvt194's Avatar
Senior Member
Flag Hanoi
Thanks Meter: 451
 
More
That was fast!
Sadly most of us can't afford this 2000$ phone lol
7th December 2019, 01:22 PM |#5  
avetny's Avatar
Senior Member
Flag Private Island.
Thanks Meter: 1,743
 
More
Selling my US version, time to get F900F
9th December 2019, 08:26 PM |#6  
ianmacd's Avatar
OP Senior Member
Flag Amsterdam
Thanks Meter: 3,415
 
More
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.
The Following 4 Users Say Thank You to ianmacd For This Useful Post: [ View ] Gift ianmacd Ad-Free
10th December 2019, 01:34 PM |#7  
avetny's Avatar
Senior Member
Flag Private Island.
Thanks Meter: 1,743
 
More
Quote:
Originally Posted by ianmacd

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 !!!
19th December 2019, 05:27 PM |#8  
Junior Member
Thanks Meter: 0
 
More
help me plz
hello, I can't flash with Odin because it gives me an error message: blocked from the OEM.
23rd December 2019, 05:32 PM |#9  
ianmacd's Avatar
OP Senior Member
Flag Amsterdam
Thanks Meter: 3,415
 
More
Version 3.3.1-21_ianmacd released for the F907B.
Changelog

3.3.1-21_ianmacd (F907B only)
  • Kernel built from latest F907BXXS2ASK9 source code.
The Following User Says Thank You to ianmacd For This Useful Post: [ View ] Gift ianmacd Ad-Free
25th December 2019, 02:38 PM |#10  
tranquility's Avatar
Senior Member
Flag Almaty
Thanks Meter: 53
 
More
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
13th January 2020, 09:49 AM |#11  
Junior Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by DTman22

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

Same here.. anyone can help ...?
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes