Can't flash stock FP4 ROM

Hey, when i try to go from LineageOS 20 back to stock FP4OS i always get this error when trying to flash my device with the provided script from the official download. I tried Android 11 and 12 but both have the same issue. That’s the error message:
terminate called after throwing an instance of ‘std::out_of_range’
what(): basic_string::compare: __pos (which is 464) > this->size() (which is 0)
/home/devil/Downloads/OS/SPOS/FP4/FP4OS (Android 12)/flash_fp4_factory.sh: line 214: 60745 Aborted (core dumped) ( ${FASTBOOT_BIN} -s “${1}” flash “${2}” “${3}” )
I would love to get some help :slight_smile:

Not sure if the information is required, but what OS exactly is running on your PC?

My first guess is that maybe the parentheses as part of the path are the problem, so you could try to rename the folder and try again.

I’m running Manjaro, but i already flashed my dads FP3 and even my 4 from the same PC with Manjaro and the same folder names, but sure i will try.

Alright I tried it with the folder name changed to fp4os and I put it in Downloads, I don’t think that’s the problem here…
terminate called after throwing an instance of ‘std::out_of_range’
what(): basic_string::compare: __pos (which is 464) > this->size() (which is 0)
/home/devil/Downloads/fp4os/flash_fp4_factory.sh: line 214: 16313 Aborted (core dumped) ( ${FASTBOOT_BIN} -s “${1}” flash “${2}” “${3}” )
The 16313 is a different number almost every time I try it. When i look into the .sh file on line 214 it says:

flash_image_or_abort() {
  (${FASTBOOT_BIN} -s "${1}" flash "${2}" "${3}") ||
    {
      echo -en "$RED"
      echo "ERROR: Could not flash the ${2} partition on device ${1}."
      echo ""
      echo "ERROR: Please unplug the phone, take the battery out, boot the device into"
      echo "ERROR: fastboot mode, and start this script again."
      echo "ERROR: (To get to fastboot mode, press Volume-Down and plug in the USB-C)"
      echo "ERROR: (cable until the fastboot menu appears.)"
      abort_now
    }
}

I just had a look at the flash script, for Linux it takes fastboot that’s already installed on the PC. The FP3 script used fastboot that was part of the downloaded ZIP file.
So maybe your fastboot has a “wrong” version?

What’s your output of

fastboot --version

For me it’s

fastboot version 30.0.3-6597393
Installed as /x03/platform-tools/fastboot

I installed mine from https://dl.google.com/android/repository/platform-tools-latest-linux.zip at some point in the past.

For me it says

fastboot version 34.0.4-android-tools
Installed as /usr/bin/fastboot

That’s the very newest version of the android tools. Googling around shows a few bugs here and there with the 34.0.x versions.

Maybe you can give the latest 33.0.x version a try: https://dl.google.com/android/repository/platform-tools_r33.0.3-linux.zip

How can i “replace” the fastboot version?

Quickest way to test if this helps would be the following (assuming you unpacked the ZIP with fastboot to /home/devil/Downloads/platform-tools):

export PATH="/home/devil/Downloads/platform-tools:$PATH"
cd /home/devil/Downloads/fp4os
./flash_fp4_factory.sh
2 Likes

That worked :open_mouth: thank you very much.
Can you also tell me if it’s safe to relock the bootloader?

I can’t really tell, but IIRC correctly one should always make sure the phone can be unlocked again in case things go sideways.

2 Likes

Definitely check fastboot flashing get_unlock_ability immediately before locking.
And don’t boot into Android after flashing it, the first boot resets it to 0 (The reason being that’s how you get your phone delivered and there are apps that check for that).

Flash → Check → Lock :slightly_smiling_face:

3 Likes

Oh that’s unfortunate, i already booted up. Can i just reflash it? If i reflash, do i have to lock_critical and lock or only lock?

Yeah, just flash it again :slightly_smiling_face:

You can lock critical, but there’s no access to the critical partitions if the bootloader is locked so you don’t gain any security advantage.
Not sure if there are apps that check for that :thinking:
If you are worried something might not work, lock it, that’s how it’s supposed to be on stock.

2 Likes

I guess that worked :smiley: thank you and @Ingo so much for the help :slight_smile:

2 Likes

Hello,
I have a Fairphone 4 which currently has LineageOS installed on it. I want to revert this phone back to FairphoneOS, and have tried to follow the official guide for it. However, I keep running into this issue without being able to tell why:

Writing 'recovery_b'                               OKAY [  0.518s]
Finished. Total time: 3.588s
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::compare: __pos (which is 464) > this->size() (which is 0)
./flash_fp4_factory.sh: line 214: 179385 Aborted                 (core dumped) ( ${FASTBOOT_BIN} -s "${1}" flash "${2}" "${3}" )
ERROR: Could not flash the super partition on device 1f153ff7.

ERROR: Please unplug the phone, take the battery out, boot the device into
ERROR: fastboot mode, and start this script again.
ERROR: (To get to fastboot mode, press Volume-Down and plug in the USB-C)
ERROR: (cable until the fastboot menu appears.)
ERROR: Aborting now (press Enter to terminate).

I’ve tried following the steps provided in the error message with zero success. I do not know enough about how this script works in order to troubleshoot it myself.

System info and what I’ve tried so far

  • I’m running the .sh-script from an install of EndeavourOS, a Linux distribution based on Arch Linux. I’ve made sure to unlock my bootloader, and can see that my device is connected properly using fastboot devices.
  • I’ve made sure the android-tools-package is installed and at the latest version available in the Arch repository.
  • I’ve tried running the script using sudo to make sure that it isn’t a permission issue from my computer.

I did not have an issue when sideloading LineageOS. If it’s possible to sideload Fairphone using the same method as Lineage (installing a recovery image and using adb -d sideload filename.zip), please do let me know.

The only thing I can think of which could possibly cause this, is the super.img-file being corrupted somehow. However, this really shouldn’t be the case since the sha256sum checks out.

Any and all help is greatly appreciated.

Have moved your post here as I hope you’ll find some ideas and help above.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.