TWRP for Fairphone 3

Hi guys,
First of all, thanks a lot for all your work on porting TWRP to FP3.
I was so happy that I immediatly tried to flash a GSI (phhusson’s vanilla AOSP, following XDA’s guide), but it didn’t boot.
I made a full backup with TWRP before that, so I tried to restore it, but i didn’t boot either.
So now, I can’t even get to TWRP anymore, even by fastboot boot twrp.img
No matter what I try to do, the phone gets directly to fastboot mode.
My questions are, how could I completely restore the phone to its stock state ? Maybe by using k4y0z’s stock dump ? Is there a specific order to flash different partitions ?
Thanks for your help.

1 Like

fastboot boot should work regardless.
Are you getting any errors?
I’d first try just restoring system.img.

I don’t have any error when I try to fastboot boot.
But I got one when I try to fastboot flash system system.img using the img from your dump.
Here is the result :
Invalid sparse file format at header magic
Sending sparse 'system_a' 1/5 (522239 KB) FAILED (remote: 'data too large')
fastboot: error: Command failed

I had the same issue.
If you want to dig the treble func, please go there : FP3 custom rom development based on released source code :slight_smile:

This will bring back your phone :wink: :

Do one slot by one:

fastboot --set-active=a
fastboot flash product product.img -S 522239K || exit 1
fastboot flash keymaster keymaster.img -S 522239K || exit 1
fastboot flash cmnlib64 cmnlib64.img -S 522239K || exit 1
fastboot flash cmnlib cmnlib.img -S 522239K || exit 1
fastboot flash lksecapp lksecapp.img -S 522239K || exit 1
fastboot flash mdtp mdtp.img -S 522239K || exit 1
fastboot flash vendor vendor.img -S 522239K || exit 1
fastboot flash system system.img -S 522239K || exit 1
fastboot flash boot boot.img -S 522239K || exit 1
fastboot flash vbmeta vbmeta.img -S 522239K || exit 1
fastboot flash dtbo dtbo.img -S 522239K || exit 1
fastboot flash dsp dsp.img -S 522239K || exit 1
fastboot flash devcfg devcfg.img -S 522239K || exit 1
fastboot flash tz tz.img -S 522239K || exit 1
fastboot flash rpm rpm.img -S 522239K || exit 1
fastboot flash sbl1 sbl1.img -S 522239K || exit 1
fastboot flash modem modem.img -S 522239K || exit 1
fastboot flash aboot aboot.img -S 522239K || exit 1
fastboot reboot bootloader

Check If you’re still in slot a! fastboot getvar current-slot, else, try to boot on slot a.
Then slot b :

fastboot --set-active=b
fastboot flash product product.img -S 522239K || exit 1
fastboot flash keymaster keymaster.img -S 522239K || exit 1
fastboot flash cmnlib64 cmnlib64.img -S 522239K || exit 1
fastboot flash cmnlib cmnlib.img -S 522239K || exit 1
fastboot flash lksecapp lksecapp.img -S 522239K || exit 1
fastboot flash mdtp mdtp.img -S 522239K || exit 1
fastboot flash vendor vendor.img -S 522239K || exit 1
fastboot flash system system.img -S 522239K || exit 1
fastboot flash boot boot.img -S 522239K || exit 1
fastboot flash vbmeta vbmeta.img -S 522239K || exit 1
fastboot flash dtbo dtbo.img -S 522239K || exit 1
fastboot flash dsp dsp.img -S 522239K || exit 1
fastboot flash devcfg devcfg.img -S 522239K || exit 1
fastboot flash tz tz.img -S 522239K || exit 1
fastboot flash rpm rpm.img -S 522239K || exit 1
fastboot flash sbl1 sbl1.img -S 522239K || exit 1
fastboot flash modem modem.img -S 522239K || exit 1
fastboot flash aboot aboot.img -S 522239K || exit 1
fastboot reboot
12 Likes

Dude, you just saved my phone! Thanks a lot!
I guess I’ll just stick to rooted stock for the moment, waiting for the guys around here to successfully boot a GSI :wink:

9 Likes

I guess I should reupload the large images as sparse images, so you don’t have to specify the “-S” flag.
Also it’s probably safer not just flashing all the partitions (including the sbl1 and aboot) to both slots.
This could brick your device for good if something goes wrong during flashing, since there is no firehose programmer available for EDL-mode.
It would have probably been enough to flash just system (possibly also boot, vendor and vbmeta)

7 Likes

If you want to, only the system image is too big. Actually I did slot a then slot b.
Actually it is important to flash all partitions because he might have (As I had) an other version of the other partitions

2 Likes

That’s true, but I don’t think flashing sbl1 and aboot is really necessary.
And since that is what is needed to have fastboot it’s probably safer to first try flashing without these.

4 Likes

Gsi worked (lineage on the FP3, I will post in FP3 custom rom development based on released source code in few minutes)

3 Likes

Since this slot A/B stuff is a bit alien when coming from the Fairphone 2 …

Do I get this right that I can keep the now installed TWRP and OTA updates of the stock OS would still work because the recovery is not involved anymore in the updating process?

(I did a quick search and read this here … https://forum.xda-developers.com/oneplus-6/how-to/guide-noobs-guide-to-b-partitions-op6-t3816123)

2 Likes

I believe that the A/B partitions are alternated between updates so that the user doesnt have to wait for there phone to update. When you update it applies the update to the partition that is not in use, then after reboot you get switched to the partition that wasnt in use, for example B but now is, and now partition A is used for the next update and it cycles back and fourth.

2 Likes

Yeah, this is how it sounds in the guide, too.

On the Fairphone 2, when performing an automatic update instead of a manual one, update files were simply downloaded to a certain directory, then the phone got rebooted, and then the recovery took over and installed the update before rebooting into the updated OS.

Regarding the A/B mechanism (which is now used on the Fairphone 3), the guide doesn’t exactly say how the slots are switched to then boot the other slot which got updated in the background.
But my guess now is the recovery would have no role in this anymore, so keeping the installed TWRP shouldn’t break automatic updates of the stock OS. Or should it?

Well, if in doubt, I’ll just see when the next update comes around.

2 Likes

I think technically you could have two different systems running on the same phone that share the same data partition, it would probably break updates (or one partition would get overwritten.) This also means you could have a combo of rooted and unrooted, as long as they were both running the same systems. (I could be totally wrong though.)

2 Likes

If I understand correctly, TWRP (and Magisk) are gone after the OTA update, and need to be re-installed:

The key thing here is that it [the OTA update] installs a fresh, fully stock version. Your data gets pulled over, but none of your mods go with it. To get them back, you have to install them all again. There are various ways of doing this, and this isn’t the place to repeat the guides that are already posted on how. Just understand that you have to do it to keep root, twrp, and your other mods.

3 Likes

That’s when you are rooted, if I got that sorted right.
That’s certainly an effect to consider.

2 Likes

Actually, most of the OTA updates are diffs. Which can corrupted a custom boot/system (or other partitions)

2 Likes

Therefore it says in the article:

The update engine detects root and downloads the full update instead of the incremental update

But @AnotherElk is right, they only mention root - wouldn’t that be dangerous with other mods (like TWRP)?

2 Likes

The update_engine should actually check the partition checksums and either download a full update or refuse to update altogether if they don’t match.

4 Likes

Definitely tracking this thread.
As soon as all your mods, tweaks, twrp, root are stable, will check
Keep up the good works. Nice job folks :+1:

2 Likes

I have uploaded an installable ZIP-file for Stock-ROM here:
https://androidfilehost.com/?fid=4349826312261710557

If anyone wants to give that a try.

12 Likes