Flashing script wrongfully claims the phone is still locked

I also ran into this issue yesterday and today with my new Fairphone 5 and the flash_FP5_factory.sh script (eOS image 2.4.1 (stable)). I had the bootloader unlocked, but the flash-fp5-script complained falsely about the phone still being locked.

In my opinion, the script defines the fastboot-binary correctly in the function ‘os_checks()’.
However the function ‘check_unlock_status()’ uses a plain “fastboot” instead of the variable “${FASTBOOT_BIN}” (where the correct binary is stored). This probably has been forgotten to be adjusted in the script.

I replaced the “fastboot” commands inside ‘check_unlock_status()’ with the variable “${FASTBOOT_BIN}” and afterwards the script passes the check, detects the correct fastboot mode and does not complain anymore about the phone still being locked.

The changed function ‘check_unlock_status()’ looks like this after the modification:

# Check if the device is properly unlocked
check_unlock_status() {
  PHONE_IS_READY=true
  if ("${FASTBOOT_BIN}" getvar is-userspace 2>&1 | grep -q yes); then
    echo "Info: Your phone is in fastbootD mode."
    if ("${FASTBOOT_BIN}" getvar unlocked 2>&1 | grep -q no); then
      echo "Error: Your phone is still locked."
      echo "Did you execute 'fastboot flashing unlock'?"
      PHONE_IS_READY=false
    fi
  else
    echo "Info: Your phone is in regular bootloader mode."
    if ("${FASTBOOT_BIN}" getvar unlocked 2>&1 | grep -q no); then
      echo "Error: Your phone is still locked."
      echo "Did you execute 'fastboot flashing unlock'?"
      PHONE_IS_READY=false
    fi
    if ("${FASTBOOT_BIN}" oem device-info 2>&1 | grep -q "critical unlocked: false"); then
      echo "Error: Critical partitions are still locked."
      echo "Did you execute 'fastboot flashing unlock_critical'?"
      PHONE_IS_READY=false
    fi
  fi

  if [ "$PHONE_IS_READY" = "false" ]; then
    echo "Error: Your phone is not ready for flashing yet (see above), aborting..."
    exit 1
  fi
}

I will also ping the developer of the script (mentioned inside the script) about this thread so that this issue can be addressed properly.

5 Likes