Skip to content

Instantly share code, notes, and snippets.

@Kabouik

Kabouik/README.adoc

Last active Dec 11, 2020
Embed
What would you like to do?
TWRP on F(x)tec Pro¹, an SFOS perspective

TWRP on F(x)tec Pro¹, an SFOS perspective

PHONE AND COMPUTER PREPARATION (REQUIRED)

Install fastboot

sudo eopkg it android-tools

eopkg is Solus' package manager and android-tools is the package with which fastboot is shipped in this distribution. Adapt the above depending on your distribution’s package manager and the name of the package containing fastboot. Alternatively, you may also install it using snap with sudo snap install android-studio --classic, in which case you should be able to execute it from ~/Android/Sdk/platform-tools.

Unlock Pro¹ bootloader

Pro¹ units shipped by F(x)tec after 2019/11/19 have their bootloader locked. You need to unlock it to use this guide.

Warning
Unlocking bootloader will factory reset your device! Backup anything you need first.
  1. Go to "Settings > About phone" and tap the build number at the bottom 7 times to enable Developer Mode. Then, go to "Settings > System > Advanced > Developer options" and enable "OEM unlocking" and "USB debugging".

  2. Reboot the phone into bootloader mode by holding Volume Down + Power.

  3. Connect it to a computer with USB and unlock the bootloader from command prompt:

    fastboot devices # The device should be listed
    fastboot flashing unlock
    fastboot reboot

FLASH, BACKUP OR RESTORE SAILFISH OS

Note
The following instructions are adjusted for use in the Solus distribution and my own backup folder structure, slight path changes may be required on other machines and distributions.

Flash SFOS on the Pro¹

  1. Download the latest SFOS CI image (download button on the right; prefer a "run-build-testing" version, the "run-build" is a devel version and may break things or kill kittens), extract artifacts.zip to save the other .zip file it contains to a vfat, ext3 or ext4 formatted micro SD card (other filesystems might work too, but those are confirmed to work). It was reported that copying the .zip file over to internal storage via USB/MTP while in TWRP works too after step 7 below.

  2. Insert the micro SD card in the Pro¹ unless you intend to transfer the SFOS archive to internal storage instead (see step 7), reboot in bootloader mode (Volume Down + Power) and connect through USB to the computer. Note that whether you use internal storage or SD card to flash the SFOS archive will have no influence on where the final OS will be installed, it will always be installed on internal storage in the end.

  3. Check that the device is properly connected:

    fastboot devices # The device should be listed
  4. Download the TWRP boot image for Pro¹ and save it to the computer (/media/stockage/Fxtec\ Pro1/TWRP\ flash\ SFOS,\ backup\ and\ restore/twrp-3.3.1-qx1000.img in my case).

  5. Flash the TWRP boot image:

    fastboot set_active a
    fastboot flash boot /media/stockage/Fxtec\ Pro1/TWRP\ flash\ SFOS,\ backup\ and\ restore/twrp-3.3.1-qx1000.img
    Note
    Adjust the path on the computer side to your preferences.
  6. When completed, reboot the phone in recovery mode using Volume buttons to select "Recovery" and confirm with the Power button.

  7. In the TWRP interface, go to "Wipe > Format data", and confirm. If format fails, follow these instructions to change the filesystem to ext2 and then back to ext4 (it is silly, but it does work). If you have no SD card, at this stage you should now be able to use USB/MTP while in TWRP to copy the .zip file to internal storage.

  8. When format is completed, go to "Reboot > Reboot in Recovery". Wait for reboot, then "Install zip firmware", navigate to the micro SD card or internal storage where the SFOS archive is, and select it. Make sure the signature verification is set to off. When the installation is completed, reboot and the phone should boot into SFOS.

Backup SFOS using TWRP — Beware: not tested on SFOS image with LVM encryption

It is not possible to go into recovery mode with the SFOS boot image because it overwrites the TWRP image. It is therefore necessary to reflash TWRP.

  1. Make a backup of the SFOS boot image when the phone is running SFOS and connected to the same WiFi as the computer (Developer mode and password set from "Settings > Developer mode"); and check that it indeed created the file in the target directory on the computer:

    devel-su cp /boot/hybris-boot.img /home/nemo/hybris-boot.img
    scp nemo@ip:/home/nemo/hybris-boot.img /media/stockage/Fxtec\ Pro1/TWRP\ flash\ SFOS,\ backup\ and\ restore/
    Note
    Adjust the path on the computer side to your preferences.
  2. Make sure a micro SD with enough space for a full backup is inserted in the Pro¹, reboot the phone in bootloader mode (Volume Down + Power) and connect through USB to the computer.

  3. Check device connection with computer:

    fastboot devices # The device should be listed
  4. Flash TWRP boot image (this will prevent SFOS from booting, but you should have a backup of the SFOS boot image already):

    fastboot set_active a
    fastboot flash boot /media/stockage/Fxtec\ Pro1/TWRP\ flash\ SFOS,\ backup\ and\ restore/twrp-3.3.1-qx1000.img
  5. When completed, reboot the phone in recovery mode using Volume buttons to select "Recovery" and confirm with the Power button.

  6. Go to "Backup", check "Data" and save to the micro SD card after making sure there is enough space available.

  7. When backup is completed, reboot in Bootloader mode by going back to the TWRP main menu, then "Reboot", and choose "Bootloader". You can then flash the SFOS boot image again to allow booting SFOS (alternatively, go the the Factory reset instructions if you want to restore stock Android to the phone):

    fastboot set_active a
    fastboot flash boot /media/stockage/Fxtec\ Pro1/TWRP\ flash\ SFOS,\ backup\ and\ restore/hybris-boot.img
    Note
    Adjust the path on the computer side to your preferences.

Restore SFOS using TWRP — Beware: not tested on SFOS image with LVM encryption

It is not possible to go into recovery mode with the SFOS boot image because it overwrote the TWRP image. It is therefore necessary to reflash TWRP.

  1. If not already done, make a backup of the SFOS boot image when the phone is running SFOS and connected to the same WiFi as the computer (Developer mode and password set from "Settings > Developer mode"); and check that it indeed created the file in the target directory on the computer:

    devel-su cp /boot/hybris-boot.img /home/nemo/hybris-boot.img
    scp nemo@ip:/home/nemo/hybris-boot.img /media/stockage/Fxtec\ Pro1/TWRP\ flash\ SFOS,\ backup\ and\ restore/
    Note
    Adjust the path on the computer side to your preferences.
  2. Insert the micro SD that contains a previous TWRP backup in the Pro¹, reboot the phone in bootloader mode (Volume Down + Power) and connect through USB to the computer.

  3. Check that the device is properly connected:

    fastboot devices # The device should be listed
  4. Flash TWRP boot image (this will prevent SFOS from booting, but you should have a backup of the SFOS boot image already):

    fastboot set_active a
    fastboot flash boot /media/stockage/Fxtec\ Pro1/TWRP\ flash\ SFOS,\ backup\ and\ restore/twrp-3.3.1-qx1000.img
    Note
    Adjust the path on the computer side to your preferences.
  5. When completed, reboot the phone in recovery mode using Volume buttons to select "Recovery" and confirm with the Power button.

  6. In the TWRP interface, go to "Wipe > Format data", and confirm. If format fails, follow these instructions to change the filesystem to ext2 and then back to ext4 (it is silly, but it does work).

  7. Go to "Restore", select the micro SD card, and start restoring from it (checking digests might not be necessary).

  8. When the restoration is completed, reboot in Bootloader mode by going back to the TWRP main menu, then "Reboot", and choose "Bootloader". You can then flash the SFOS boot image again to allow booting SFOS:

    fastboot flash boot /media/stockage/Fxtec\ Pro1/TWRP\ flash\ SFOS,\ backup\ and\ restore/hybris-boot.img
    Note
    Adjust the path on the computer side to your preferences.
    Note
    The first boot will be long, and the the SIM card won’t be detected before a second reboot. Don’t panic.

RESTORE STOCK ANDROID

  1. Reboot in bootloader mode (Volume Down + Power) and connect through USB to the computer.

  2. Check that the device is properly connected:

    fastboot devices # The device should be listed
  3. Download the restoration files and extract them into the current folder.

  4. Flash the device with the files:

    fastboot flash devcfg_a devcfg.mbn
    fastboot flash devcfg_b devcfg.mbn
    fastboot flash dsp_a adspso.bin
    fastboot flash dsp_b adspso.bin
    fastboot flash bluetooth_a BTFM.bin
    fastboot flash bluetooth_b BTFM.bin
    fastboot flash modem_a NON-HLOS.bin
    fastboot flash modem_b NON-HLOS.bin
    fastboot flash pmic_a pmic.elf
    fastboot flash pmic_b pmic.elf
    fastboot flash rpm_a rpm.mbn
    fastboot flash rpm_b rpm.mbn
    fastboot flash splash splash.img
    fastboot flash tz_a tz.mbn
    fastboot flash tz_b tz.mbn
    fastboot flash xbl_a xbl.elf
    fastboot flash xbl_b xbl.elf
    fastboot flash abl_a abl.elf
    fastboot flash abl_b abl.elf
    fastboot flash boot_a boot.img
    fastboot flash boot_b boot.img
    fastboot flash dtbo_a dtbo.img
    fastboot flash dtbo_b dtbo.img
    fastboot flash system_a system.img
    fastboot flash system_b system.img
    fastboot flash vendor_a vendor.img
    fastboot flash vendor_b vendor.img
    fastboot flash mdtp_a mdtp.img
    fastboot flash mdtp_b mdtp.img
    fastboot flash vbmeta_a vbmeta.img
    fastboot flash vbmeta_b vbmeta.img
    fastboot erase userdata
  5. Reboot the device:

    fastboot reboot
@m-kress

This comment has been minimized.

Copy link

@m-kress m-kress commented May 4, 2020

Very good read to install Sailfish! Thank you!
There could be one little improvement in both your and the description from Waxberry:
One has to download the artifact.zip file and UNZIP it in order to get to the zip archive file, that really should be stored on the SD card!
:-)

@enigma9o7

This comment has been minimized.

Copy link

@enigma9o7 enigma9o7 commented May 5, 2020

Also worth clarifying SDcard is not required. After wipe and reboot, I copied the sfos zip over to device internal storage before flashing (via usb/mtp while in twrp).

@Kabouik

This comment has been minimized.

Copy link
Owner Author

@Kabouik Kabouik commented May 19, 2020

Thanks a lot for the comments. It should be clearer now, but else let me know here please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment