English

✏ Porting TWRP recovery

I have a new build of TWRP (compiled with omnirom 6.0 sources) - version 3.0.3+ (git hash cc19c6f) available! Download link: https://private.z3ntu.xyz/fairphone/TWRP_3.0.3-0/ (look at the readme.txt file for info what is what).

If there are any problems you notice, please report them to me!

EDIT: Updated the build to include crypto support. This should hopefully enable you to decrypt /data if you have it encrypted.

EDIT 2: Apparently flashing images doesn’t work right now because the product is set to fp2 instead of FP2 and the Fairphone zips check that… Will try to fix that next.

EDIT 3: Fixed that :slight_smile: If you have encrypted /data please report back if it works for you :thumbsup:

EDIT 4: Encrypted /data doesn’t work but I was working most of my Sunday to get this to work (still doesn’t unfortunately).

3 Likes

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

2 Likes

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

1 Like

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.

1 Like

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.

20 Likes

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

Fantastic!

Thank you so much! Very well done!

Cheers!

2 Likes

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

1 Like

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

2 Likes

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.

7 Likes

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.

5 Likes

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 2.8.7.0 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 2.8.7.0 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.

1 Like

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.