TWRP for Fairphone 5

This is the patchset that seems to work but I need to test it in-depth again because it was depending on a patchset which was only semi-recently merged into TWRP.

https://gerrit.twrp.me/c/android_device_fairphone_FP5/+/6952

The general approach would be the same for FP4 but I couldn’t make it work last time I tried.

3 Likes

Thanks for all your efforts into bringing TWRP to the FP5, Luca!

I’m currently trying to get a working build of LineageOS and wanted to use TWRP to do some backups beforehand.

Unfortunately I haven’t managed to disable AVB using fastboot yet and couldn’t boot the TWRP image file. Both fastboot commands seem to be stuck at “Sending xyz.img”. I’ve already tried to use different USB cables. I do not get an error message, it just seems to be somehow stuck. “fastboot devices” correctly lists my FP5 when connected.

Do I have to sign the TWRP image before booting?

EDIT:
The solution was to put an old USB hub between the pc and the phone… That’s so stupid. Found here: https://xdaforums.com/t/yet-again-fastboot-is-stuck-on-sending-boot-img.4166479/
TWRP is booting fine using “fastboot boot” now.

2 Likes

Hi llluuuzzziii,
did you manage to install TWRP permanently ? Or did you just boot from it ? Or did you do something else ?

@All : I did not manage to install TWRP permanently on my FP5 but I managed to fastboot boot into TWRP . Is this sufficient for me to install Magisk or to do a backup of my phone from TWRP ?

Thanks Luca and everyone for their efforts. I spent a long time getting this recovery to work – after the unlocked bootloader warning, the phone remained on the Fairphone logo. The issue was that my A/B boot slot was set to ‘b’. One fastboot set_active other later, the recovery booted right up! Sadly, I bricked my phone shortly after, so I cannot test any further for now…

I managed to fastboot boot into TWRP . Is this sufficient for me to install Magisk or to do a backup of my phone from TWRP ?

I’d also be interested in the answer. If I unlock the bootloader, can I use “fastboot boot twrp.img” to create a backup (as it used to work with my FP2) ?

Hey.

the compiled version of TWRP is only 12.0 which is quite useless at least to me. There is however a uncompiled version of TWRP based on 12.1 in the device repository, which points to behing able to decrypt userdata. Is there a compiled img of that version or do we have to compile it ourself.

You can use the installer to install TWRP like a module in magisk. This will unroot your phone so do not restart your phone. Instead just reinstall magisk and then restart. This will keep TWRP and Magisk.

1 Like

I am as curious as you, and I tried to compile it this weekend on my linux laptop. I added the additional flags (*) and started the compilation, but it failed because I have too low RAM memory (I have 8Gig) :frowning:

Killed 19:13:57 soong bootstrap failed with: exit status 1
[ 4084.844609] Out of memory: Killed process 20950 (soong_build)

I started again with -j1 as advised, but it didn’t solve anything…

(*) I added the following flags as suggested here:

BOARD_USES_QCOM_FBE_DECRYPTION := true

in /home/oli/twrp-fp5/device/fairphone/FP5/BoardConfig.mk
and

setprop prepdecrypt.loglevel 2 
setprop prepdecrypt.setpatch true 

“on init” in /home/oli/twrp-fp5/device/fairphone/FP5/recovery/root/init.recovery.qcom.rc

My laptop has 64 Gigs of ram but my technical knowhow isnt sufficent. :pensive:

Let’s collaborate then! I give you step-by step instructions (maybe in private msg to not overflow this topic?) and you share the resulting file :smiley:

EDIT: do you have already a Linux OS installed on your computer? Ubuntu will be ideal so we can copy and paste the instructions from my own computer :wink:

1 Like

I dont have ubuntu on this pc. I tried it on my Ubuntu laptop with 16 gigs of ram. Its a trivial task to swap hard drives however so yeah why not.

Ok so here are the instructions step by step. (clic to expand)
  1. Install repo from Google
mkdir -p ~/.bin

PATH="${HOME}/.bin:${PATH}"

curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo

chmod a+rx ~/.bin/repo
  1. create a new directory
mkdir twrp-fp5

cd ~/twrp-fp5
  1. initialize your local repository

repo init --depth=1 -u https://github.com/minimal-manifest-twrp/platform_manifest_twrp_aosp.git -b twrp-12.1

If you have an error message go to step 5 then try step 3 again

  1. Add this device repository to a new local manifest
cd .repo

mkdir local_manifests

cd local_manifests

touch roomservice.xml

nano ~/.repo/local_manifests/roomservice.xml

and paste this inside:
(right clic + Paste to paste; Ctrl+O to save the file; Ctrl+X to leave nano text editor)

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <project name="Fairphone/android_device_fairphone_FP5" path="device/fairphone/FP5" remote="github" revision="android-12.1" />
</manifest>
  1. fix the git identity
nano ~/.repo/manifests.git/config

and write this inside:
(right clic + Paste to paste; Ctrl+O to save the file; Ctrl+X to leave nano text editor)

[user]
        email = user@yourdomain.com
        name = User Name
  1. to sync up:
cd  ~/twrp-fp5/

repo sync
  1. edit the first of the two files I mentioned above
nano ~/twrp-fp5/device/fairphone/FP5/BoardConfig.mk

Paste this inside:

BOARD_USES_QCOM_FBE_DECRYPTION := true
  1. edit the second file
nano ~/twrp-fp5/device/fairphone/FP5/recovery/root/init.recovery.qcom.rc

And paste this in the “on init” section

setprop prepdecrypt.loglevel 2 
setprop prepdecrypt.setpatch true 
  1. and finally compile it:
export ALLOW_MISSING_DEPENDENCIES=true

. build/envsetup.sh

lunch twrp_FP5-eng

m bootimage
  1. have a look if there is a generated twrp file (send it to me so I can test it :slight_smile: )

It should be in ~/twrp-fp5/out/target/product/FP5/boot.img

If you have specific questions send me a private message, and I’ll update this tutorial instead of posting it again and again :slight_smile:

1 Like

Hi @Ice_Fire !
Thanks for sharing your file :slight_smile:
I tested it (fastboot boot boot.img) and it booted to TWRP 3.7.1_12-0-a28a9f38 :smiley:
However the decryption is not successful :frowning:

Looking at the logs (adb pull /tmp/recovery.log) I guess we are missing one module:

E:Unable to override 'ro.crypto.dm_default_key.options_format.version' due to missing libresetprop
E:Unable to override 'ro.crypto.volume.metadata.method' due to missing libresetprop
E:Unable to override 'external_storage.projid.enabled' due to missing libresetprop
E:Unable to override 'external_storage.casefold.enabled' due to missing libresetprop
E:Unable to override 'external_storage.sdcardfs.enabled' due to missing libresetprop

Some of you might find it worth subscribing to https://xdaforums.com/t/questions-about-avb-and-twrp-on-the-fp5.4687024/#post-89661725 if you’re considering using this.

Hi everyone, I’ve tried to install TWRP and have run into a few blocks.

First, I followed the instructions on twrp.me to deactivate Android verified boot by running fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img after copying vbmeta.img from the fp os factory install, after first having unlocked the bootloader with a fastboot command. This resulted in some boot loop before I started up, and I did a factory reset on my otherwise fresh phone.

Second, I tried to compile TWRP following the instructions but tried to run the instructions on WSL on a family member’s computer.

setting up the environment printed nothing to the screen, and the lunch command printed /usr/bin/env: ‘python’: No such file or directory. After patching that with a simple cp /usr/bin/python3 /usr/bin/python (alias didn’t seem to work), the following output didn’t change After this the build command resulted in an exit 1. (yes, i did remove the extra python link in /usr/bin)

Does anyone have any built images of twrp 12.1? Maybe there is some information about disabling AVB as well, and whether it is necessary. Thanks. For extra context, my plan is to install TWRP but keep standard FP OS. I want to have TWRP for the extra backup options but don’t want the extra hassles and extra maintenance with going full open source/degoogle.

You can go into fastboot and use fastboot boot twrp.img to temporarily boot twrp. Afterwards you can go to Advanced > Flash current TWRP. Now twrp will be permanently installed without replacing your OS.

Thanks! Since then I was able to install TWRP on my os, which I later learned I didn’t quite want. But After going through the rabbit hole that was TWRP I decided to use extra free time to explore installing other OS, why not try LineageOS out and see if I can find a solution that makes me more confident, backup-wise, that I can do a factory reset if something ever requires me to, heaven forbid.

Some things I learned, for other fearless novices who like myself, want to continue down the road:

(1) Installing TWRP on the phone can have some advantages but when installing on some OS which relies on e.g. continual updates, may not be the best idea. The stock recovery partition helps in the updates, and temporarily flashing into TWRP suffices for many purposes.

(2) The version of TWRP supplied already compiled (3.7.1 on Android 12.0) can’t mount the partitions of FPOS because of encryption and so TWRP for backup with that is probably not well suited. Also, if you’re looking for a solution to backup the data/settings that you otherwise have no backup for, you first have to unlock the bootloader which wipes your system.

(3) ChatGPT is somewhat knowledgeable about Android tools, although obviously is not to be trusted as a sole source of information. Can help to build some vocabulary or learn potential consequences of doing things a certain way.

Hello everyone.

I seek to install TWRP in order for me to have a reliable recovery that would allow me to install and maintain LineageOS for MicroG and back up my partitions for security purposes.

@punyidea , i went through your messages, but last time i went and did such manipulations was with my redmi not 5 plus… i guess things have changed.

So i have questions, hoping you could help me there if that’s okay for you?

Firstly the twrp website provides a zip installer and an img file for tbe FP5.

You mentionned that you wouldn’t recommend using the img file with FPOS. Is it still the case for LineageOS for MicroG?

the TWRP page also mentions the usage of

fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img

Should i use the one provided by FPOS (that should be downloadable somewhere) or the one from LineageOS for MicroG ? and should it be before loading TWRP ?

Then, if i take a look at the regular LineageOS, it talks about a certain boot.img and dtbo.img, should i still consider flashing these with fastboot or does the lineageos zip can flash those with TWRP ?

Best Regards - Spid

I would still not recommend it, lineageos has its own recovery that you wouldn’t access if you install twrp.

For Backup of app data I still haven’t gotten a working good solution but the built in sailfish of lineageos goes a fair bit of the way there.

Hey, thank you for your answer !

So you do recommend LineageOS’ default recovery ?

I might stick with that, since it’s officially supported, for now.
What’s your experience like with LOS on the FP5 ?

Would it be safe for a production phone ? (i do understand there are risks while using these kind of roms but i’m not really sure of the current status there)

1 Like