This is a wiki post. Everyone can improve it, by clicking the green pencil above. It grew out of this topic about porting TWRP to the Fairphone.
If you have questions or want to share experiences you can do this here.
TWRP is a dic:customrecovery image, that provides a better user interface and additional features over the stock recovery image.
You can use the recovery image to replace the OS on your phone if it somehow gets broken, manually install updates or system apps (sideloading), apply a factor reset, etc. If you somehow mess up the recovery image itself, you can still use fastboot mode (as described below) to reinstall the recovery image or the OS itself.
This post is about the Fairphone 2, for info on TWRP on the FP1, see this post.
Older versions of the FP Open OS (note that the Open OS does not include any Google-applications and services), you get a (typically) include an older version of TWRP already, which might be sufficient. See below on how to use this older TWRP version to install a newer version (if desired). Since OS version 19.11.2 (december 2019), a stock android recovery is included instead.
Updating your FP (Open) OS using the OTA upgrader application will overwrite the recovery image as well. See below for how to prevent this.
Getting TWRP
Since April 2017, support for the FP2 was integrated into TWRP and official precompiled versions are available from their website. Before that, custom images were offered on this forum, which should not longer be needed now.
The easiest way to install TWRP is probably to use the TWRP app to flash it (which requires root). I have not tested this, though. The rest of this post details the manual installation process.
To download a TWRP image file, head over to the TWRP website and look up the FP2 in their device list. You can find the images under “Download links”. Primary (Europe) or Primary (Americas) whichever is preferred and available.
All versions available from the TWRP website support an encrypted data partition.
Upgrading TWRP using TWRP
Once you have TWRP installed you can use it to update itself to a newer version. Doing so is fairly straightforward, but here’s a breakdown just in case:
- Put the TWRP .img file you want to install on the internal storage or SD card.
- Start TWRP by keeping volume up and power pressed for 10s or so during power on. If you boot it for the first time, it asks to enable write permission for the system partition, which is not needed for updating TWRP.
- Select
Install
- Touch
Install Image
(orImages...
in older versions) in the lower right to allow selecting images files instead of zip files. - Find the .img file you want to install and touch it.
- Select the
Recovery
partition - Swipe to confirm the flash
Installing or upgrading TWRP using adb and fastboot
Fastboot mode should always be available, regardless of what OS or recovery image is currently installed.
We are following similar procedure as for rooting, for which you have to install all software and drivers stated there under step 3a-c and continue as follows:
1. First of all to make things easy, download the pre-compiled TWRP recovery.img (see above under Getting TWRP and copy it directly to your C:\ drive (C:\recovery.img)
2. Start up your minimal ADB and Fastboot by double clicking the shortcut on your desktop/program folder. A command promt will appear. Your FP2 should be switched on and connected via USB.
3. First we will start the FP2 into Fastboot mode by entering:
adb reboot bootloader
Your phone should reboot but instead of starting normally it will just display the black Fairphone logo and the led will blink blue.
If you have errors: see here or here
4. Make sure, you still have connection to the phone by entering:
fastboot devices
This should output something like: f8b4f663 fastboot
If you have errors: see here or here. If your phone displays a prompt to authorize your PC to connect via ADB, allow it.
5. Next we will flash the image to the FP2 by typing:
fastboot flash recovery c:\recovery.img
The flashing only takes some seconds and should not produce any errors.
6. At last we will restart our FP2 by typing:
fastboot reboot
Your phone should start normally and flashing is complete.
6.b Verify that TWRP was permanently installed:
Sometimes, when booting into the Android system normally right after flashing the TWRP recovery image, the system restores the previous default recovery image. Verify which recovery is active:
- Switch off your FP2
- Boot into recovery mode (by pressing VOLUME UP and ON in parallel until you see the recovery screen, this takes about ~10 seconds)
If you see the TWRP logo followed by a “graphical” user interface, everything worked fine.
If, on the other hand, you see a miniature text-based interface, saying something like “Android system recovery…” in the first line, you need to flash TWRP again and boot into recovery mode as the very first step right after flashing the image (instead of booting into Android system normally):
- Flash the TWPR image again as described above
- type
fastboot reboot
→ but do not press ENTER yet! - press the VOLUME UP button on your FP2 (and keep it pressed)
- hit ENTER key to execute reboot and take you directly into the TWRP recovery
After this, TWRP should be flashed permamantly.
7. If you want to continue to install XPosed Framework + GravityBox:
-
Install the Xposed framework (these need to repeated after every OS update):
-
Download the xposed framework zip (manually, or using the “Xposed Downloader” app). The current version is xposed-v89-sdk25-arm.zip. Note that the “sdk” version depens on the Android version, see the list on Wikipedia, look for “API version”).
This zip can just be stored in your Downloads folder of your phone memory, TWRP can read it from there.
-
Switch off your FP2
-
boot into TWRP recovery (by pressing VOLUME UP and ON in parallel until you see the TWRP screen, this takes about ~10 seconds)
-
install the downloaded XPosed ZIP
-
-
To manage the modules you still need to install the “XPosed Installer” from the XDA-site (*)
-
You have to enable the XPosed Framework and restart your phone
-
After one of the reboots your Android maybe will show “Optimizing Apps # from #”.
-
If you want to install GravityBox, download the module within the XPosedInstaller and be happy to tweak your FP2
(*) In case this does not work for you out of the box, you may need to rename /system/vendor/lib/libart.so (and perhaps /system/vendor/lib/libart-compiler.so as well), e.g. by appending .bak to the file(s) (/system/vendor/lib/libart.so.bak). At least, this did the trick for me on a rooted FP Open OS. Afterwards, I tried to install the XposedInstaller, Amaze told me it did not work, but on rebooting I saw the optimising apps message. I then "re"installed the XposedInstaller after the reboot and this worked. But as @fp1_wo_sw_updates rightfully put it:
It looks like proprietary libs from qualcomm are in the way. On rooted phones running the google-free FP Open OS, people seem to have success by renaming /system/vendor/lib/libart.so and /system/vendor/lib/libart-compiler.so so the system uses the libs installed by the xposed installer. (This is just a guess, please read the corresponding posts]! Don’t brick your phone! Also this will remove the optimized QC libs from the running system).
Updating Fairphone (Open) OS without overwriting TWRP
If you update FP (Open) OS using the builtin updater, or flash.bat or flash.sh script, it will overwrite the recovery image with the stock Android bootloader (FPOS) or an older version of TWRP (FPOOS). To prevent that, use TWRP to apply the update instead:
-
Download the “Manual installation” zipfile version (for FP OS, the link is in this support article, for FP Open OS, the link is on the releases page), save it on SD card or internal storage
IMPORTANT: As of FP Open OS 17.12.1 use the OTA file! -
Start phone in TWRP (Power+VolUp > 10s) and install the image via ZIP
-
If desired, without reboot also (re-)flash XPosed ZIP with TWRP.
-
I you want to (re-)gain superuser/root access flash newest version of boot.img (FP OS) or re-enable it it the developer options (FP Open OS). See this post for details on both.
-
Then reboot into fastboot mode (by choosing “Restart” and “bootloader” in TWRP).
-
Reboot (
fastboot reboot
) and let your phone “optimize apps” (since this takes quite a while).
History
- 2016-01-20:
- Fixed color of gui (orange → blue).
- Removed note regarding Xposed (here
for this topic). - Added screenshot.
- Added list of tested things.
- 2016-01-22:
- Updated list of tested things
- 2016-01-25:
- Added known issue.
- 2016-02-13
- Updated the installation guide for the compiled recovery.img (@therob)
- 2016-03-03
- Updated the installation guide for the compiled recovery.img by adding a side note on the installation of the XposedInstaller on rooted FP Open OS. (@merci)
- 2016-04-10
- Added procedure to install FPOS updates, when TWRP is installed (@therob)
- 2016-12-xx
- Added description on (sometimes) necessary steps to have TWRP be installed permanently
- 2017-03-04
- Manual system updates: add link to Fairphone’s official support article for latest FPOS images
- 2017-03-13
- Versions: Add link to images of @z3ntu
- Installation guide: Short hint for flashing images direct from TWRP
- Known Issues: Delete data encryption issue
- 2017-06-11
- Restructure post to serve as a reference and move it into a new topic.
- 2019-05-05
- Mention the TWRP app for installing TWRP
- Remove the TWRP version number included with FP Open, since different versions are now included.
- 2020-02-29
- Mention that OS 19.11.2 includes AOSP recovery again
- Clarify Xposed installer instructions (in particular, explain sdk versions).
- Fix some markdown layout issues
- 2021-06-07
- Remove note about TWRP no longer being available which broke formatting. (This is already mentioned further up.)