After writing a bash code that automatically installs LineageOS on the Fair Phone 2 (FP2), I am also implementing the "reverse" OS installation, from LineageOS to Fairphone Open OS. From Fairphone Open OS to LineageOS works flawlessly, however the other way round does not yield the expected behaviour.
I would expect the FP2 to successfully boot up into a new instance of Fairphone Open OS after executing:
sudo adb shell twrp sideload sudo adb sideload 19.11.2-sibon-24df0be9-ota.zip # terminate/end the sideloading modus sudo adb sideload /dev/null adb reboot
That does not work, as the phone gets stuck in an infinite boot until the usb connection with the host is disconnected. In that case,
- the phone starts the new Fairphone Open OS installation for about half a second,
- then displays the "power off" message,
- and reboots into the
Android Recoverymenu whilst displaying:
**Android Recovery** Fairphone/FP2/FP2 9/21.03.0-rel.2-sibon-3cb25d6c userdebug/release-keys Use volume up/down and power. Can't load Android system. Your data may be corrupt. If you continue to get this message you may need to perform a factory data reset and erase all data stored on this device. **Try Again** **Factory data reset**
If the option Try Again is selected, the phone reboots, and then repeats itself coming back at this menu. However, if
Factory data reset is selected, the factory data reset is executed successfully and the phone successfully boots into Fairphone Open OS.
Error Mitigation Strategy I
Since the factory reset "solves the problem", I tried to automate this. However, I am experiencing some difficulties doing so. The main issue is that I do not have control over the phone anymore as soon as I reboot it after sideloading the Fairphone Open OS in TWRP. This is because throughout the booting (up to failure/reboot into Android Recovery mode), the adb is unauthorized:
List of devices attached somedeviceid unauthorized
So I tried to erase the data after sideloading in TWRP, but before rebooting, using:
adb shell twrp wipe data adb shell twrp wipe cache adb shell twrp wipe dalvik
However, that also leads to the observed behaviour as described above.
Error Mitigation Strategy II
Since erasing the data from the TWRP system did not equal a factory reset in/of the Fairphone Open OS, I thought I might reboot into fastboot and do a factory reset from there, as is explained here, using the code:
adb reboot bootloader fastboot erase userdata fastboot erase cache fastboot reboot
However, that soft-bricked the device. I think this soft-bricked it because, Fairphone Open OS replaces the TWRP recovery system with its own
Android Recovery system, which corrupts the TWRP recovery system, and then the Fairphone Open OS tried to fail into its recovery mode, but that still was set to the TWRP because it was not removed due to the use of
fastboot in between, yet the TWRP was corrupted. However, after some of trial and error and some improperly documented actions, I did manage to unbrick the TWRP somehow, which brings me back to trying to the observed behaviour.
Error mitigation strategy III
I tried the reset functionality as described here, from twrp after sideloading, before rebooting:
adb shell recovery --wipe_data
I:Lun file '/sys/class/android_usb/android0/f_mass_storage/lun0/file' does not exist, USB storage mode disabled TW_INCLUDE_CRYPTO := true I:Found brightness file at '/sys/class/leds/lcd-backlight/brightness' I:Got max brightness 255 from '/sys/class/leds/lcd-backlight/max_brightness' I:TWFunc::Set_Brightness: Setting brightness control to 255 I:LANG: en I:TW_NO_LEGACY_PROPS := true
However, it resulted in the same described observed behaviour, needing a manual factory reset before Fairphone Open OS would boot successfully.
What could I do to successfully sideload and boot into the Fairphone Open OS coming from a LineageOS system without the user having to perform a manually factory reset?