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.

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