✏ Porting TWRP recovery

Tags: #<Tag:0x00007fefbd84c290> #<Tag:0x00007fefbd947f28> #<Tag:0x00007fefbd947cd0>


Thanks a lot for your work on porting TWRP, very much appreciated!

Just fyi: I just downloaded & tried the available build. I couldn’t decrypt /data, TWRP always replied failed to decrypt /data.
Though, it seems to recognize the encryption, as it prompts for a password when opening TWRP.


Could you send me the recovery.log file? There should be a button in TWRP to copy that to the sdcard


Just tried it with transient TWRP (fastboot boot xxx.img). Two tries, first, trying to decrypt as presented, then I switched to German language, to no avail. Tried to copy the logfile, but it wants to copy to /data/media, which is not available, as nothing’s mounted on /data.
Second try, immediately switching to German, and getting the logfile out of TWRP directly with adb.
I will try to send it to you via PM


Same with me (though I flashed your TWRP port beforehand).

Exported the log via adb, (see PM for the whole recovery.log).

I guess the critical part is this here:

I:Set page: 'decrypt’
I:operation_end - status=1
I:Set page: 'trydecrypt’
I:operation_start: 'Decrypt’
crypt_ftr->fs_size = 54386623
Using scrypt with keymaster for cryptfs KDF
Trying to convert ascii string of odd length
Failed to convert passwd from hex, using passwd instead
could not find any keystore module
Failed to init keymaster
Signing failed
kdf failed
failure decrypting master key
Failed to decrypt master key
crypt_ftr->fs_size = 54386623
Using scrypt with keymaster for cryptfs KDF
could not find any keystore module
Failed to init keymaster
Signing failed
kdf failed
failure decrypting master key
Failed to decrypt master key
Failed to decrypt data.


I am proud to present a TWRP build with working crypto! That means, that you can access your data partition even if it is encrypted from Android!

Decryption is confirmed to work with a 3x3 pattern and with a passcode.

Download link: https://private.z3ntu.xyz/fairphone/TWRP_3.0.3-1/

Take a look at the readme.txt file for info what file is what.

Mounting encypted system with TWRP possible meanwhile?
:pencil2: Update Guide for a modified FP Open OS (with Gapps, Xposed and more)
How to upgrade Fairphone open OS, with xposed/xprivacy?
Updating TWRP wipes data - why?
Fairphone OS 18.04.1 is now available
On data backup attempt with TWRP, error "Failed to mount '/data'"

Here a short extract from my recovery.log:

Enabling support for allow_discards in dmcrypt.
load_crypto_mapping_table: target_type = crypt
load_crypto_mapping_table: real_blk_name = /dev/block/mmcblk0p20, extra_params = 1 allow_discards
Password matches
Data successfully decrypted


Thank you so much! Very well done!



Same here, verified with a text-passphrase set with snooperstopper.


Works great for me, too! You deserve a very prominent place for your work, here!


Great work, my phone is finally encryted and i can back up my system with TWRP. Incredible! I am so happy!


A new version of TWRP was released yesterday and here’s a build (with decryption support as the last build).

Download link: https://private.z3ntu.xyz/fairphone/TWRP_3.1.0-0/

Changelog: https://twrp.me/site/update/2017/03/10/twrp-3.1.0-0-released.html (a bit less as the previous builds were already with changes from 3.1.0-0)

Take a look at the readme.txt file for info what file is what.

Fairphone Open 17.03.0 is now available
Replace standard Android emojis with EmojiOne (three methods) [root/flashable zip]

Just in case that this is not known by everybody. If you’re using TWRP already, it’s possible to flash the newer TWRP recovery images straight out of TWRP without ADB. Just use the “flash img” instead of “flash zip” button and flash the recovery image only.


I couldn’t flash TWRP_3.1.0-0. Via fastboot I get this:
fastboot flash recovery TWRP_3.1.0-0.img
target reported max download size of 536870912 bytes
sending ‘recovery’ (12240 KB)…
OKAY [ 0.385s]
writing ‘recovery’…
OKAY [ 0.163s]
finished. total time: 0.549s
But it didn’t change anything.

Trying to flash out of TWRP with the image on an external not encrypted sd card it fails saying unable to mount ‘/data’. So I suppose the second way only works for a crypto version of TWRP.


What exactly do you mean with that? What happens if you try to enter recovery mode after you’ve flashed it via fastboot?


I mean that afterwards there still is TWRP instead of 3.1.0.


That’s weird. But if you just boot into TWRP 3.1.0 via
fastboot boot TWRP_3.1.0-0_signed.img
(the signed version) it starts it, right?


That’s extremely weird… Did you try the suggestion from @Volker ?


Not yet, but I’ll do this as soon as I have backed up my freshly installed system via TWRP. (I had some problems with a new opengapp pico version an the last OS update as well.) After this I’ll be here again.


Ok ‘fastboot boot TWRP_3.1.0-0_signed.img’ works fine.

I found out that I don’t have any permissions via adb: ‘failed to copy ‘test’ to ‘/device’: Read-only file system’

Could this be the reason why I cannot flash? I haven’t got a clue how I can get those permissions back.


The root filesystem / comes the ramdisk embedded in the boot image. You cannot write that by default because it’s mounted read-only (ro). If you really want to write to that filesystem (you probably don’t want to), you can remount it as read-write with mount -o rw,remount /.

And you probably want to flash updates either with adb sideload (find the button in TWRP for that), just copying the zip to the phone storage and apply it from that or use fastboot.


Thanks for the explanations. This stuff is still quite new to me. I have just discovered the image installing button in TWRP and I successfully installed TWRP_3.1.0-0. Great, now I can encrypt my system and have backups as well.

As far as the adb permissions are concerned I have opened up a new thread here: