Phone won't stay off

I have a Fairphone 2 running Lineage OS 15.1. When I power down the phone (not plugged in) it immediately boots up again. Removing the battery does not prevent this: the phone powers up immediately the battery is inserted.

Probably relevant: if I enable Developer Options -> Advanced Restart, and choose (for example) to reboot to recovery, the phone ignores the choice and reboots to system.

Presumably, these functions work by communicating with some sort of low-level power management hardware. I suspect this isn’t working. Is there a way I can diagnose and fix this?

Can anyone point me at the source code in either Lineage or Fairphone Open that does this communication, or tell me where I might see an error log?

Many thanks!

Edit: “adb reboot recovery” is also ignored and just reboots to system.


Could it be your power button is stuck?
Try turning off with the cover removed.

1 Like

Thanks for the suggestion.

The power button clicks when pressed, and the system responds to it correctly, so I don’t believe it is stuck down.

I’m investigating where the fault might be. Here’s a bit of insight into how low-level this magic is

Digging through the source code, I found that reboot is caused by setting the sys.powerctl property to, for example, “reboot,recovery”. This causes the kernel to reboot the system, and presumably stash some instructions for the bootloader to pick up.

Issuing adb shell setprop sys.powerctl reboot,recovery worked just now, but now it doesn’t. There’s something quite flaky going on.

1 Like

For your phone to automatically boot up when inserting the battery, the power button must be being depressed.

Did you try with both the back cover and the rim removed?

Removing the rim does not make a difference. The button is not physically stuck down. Without the rim, it clicks, and the running system responds correctly to it.

The charger makes a difference. Here’s how.

With the charger plugged in, shutting down from software sometimes works – which is to say, the phone reboots into its low-level battery display software. But usually the phone just boots back in to the system. If you remove the battery and replace it, the phone boots back in to the system.

With the charger unplugged, shutting down from sofware sometimes works – which is to say the phone turns off completely. In this case, if you remove the battery and replace it, the phone does nothing. If you remove the battery and replace it, then plug in the charger, the phone boots into the battery display software. At this point, to get to the system, you must hold down the power button for 10 seconds. Short presses only toggle the display.

For what it’s worth, I had some similar looking problems on a Xioami Mi4 LTE running Lineage OS. On that phone, I couldn’t pull out the battery!

1 Like

A TWRP wipe of system, cache, data and a clean install of Lineage OS ( does not fix this problem.

Could there be corruption of the boot partition? (This is /dev/block/mmcblk0p8 on my phone.) Presumably this is a FP2-specific binary. Where could I get the default image to compare it to?

1 Like

Do you have the new camera modules? It seems that ist a bug that is discussed here in a few threads.


No, I have the original FP2 camera module.

Concerning the boot partition, I unpacked and then compared it with the boot partition (just in case):

$ adb pull /dev/block/mmcblk0p8
$ cmp mmcblk0p8 lineage-15.1-20180910-nightly-FP2-signed/boot.img 
cmp: EOF on lineage-15.1-20180910-nightly-FP2-signed/boot.img after byte 7614464, in line 28614

So that checks out. That doesn’t mean there isn’t a bug in Lineage’s boot.img though!

1 Like

More evidence. If I boot into TWRP (holding the volume up) and then use its reboot, and tell it to reboot into recovery, fastboot, system, or power off, then everything works properly.

That is evidence that there is a bug in Lineage OS setting the magic boot variable properly. The boot loader itself is probably not to blame.

The sun has come out here, so it’s time to go outside and stop debugging my phone for now :slight_smile:

1 Like

To power off the main processor (or restart) the kernel appears to talk to the Qualcomm power management chip on the Snapdragon SOC. The interface is described in PMIC APSS Interface Specification and Operational Description and you can see it being from the kernel in arch/arm/mach-msm/restart.c. I haven’t yet found out how the parameter is passed through this restart to determine what to boot.

Incidentally, this same interface is the part that detects the power key. I suspect the PMIC is “on” whenever there’s a power source, whether or not the power button has been pressed.

We can see in msm_restart_prepare in restart.c that commands like setprop sys.powerctl restart,recovery are eventually translated into hex codes (recovery to 0x77665502) that are passed through a warm restart to the bootloader. The code appears to be poked in to a particular address MSM_IMEM_BASE + RESTART_REASON_ADDR.

So my guess is that Lineage is not reaching this code correctly, and the reason code is not being poked. TWRP manages it successfully on the same phone, so it’s probably not a hardware or bootloader problem. The next step will be to try to trace the chain of events up to this restart code.


I’ve made a post in r/LineageOS to see if they have any pointers. It also points them to this thread.

1 Like

Even if it sounds a little bit stupid. I hope you have no alarm clock set. I found out, that as long as an active alarm is set, the phone powers up automatically again, when switched off. :alarm_clock: = :repeat:

Thanks for the suggestion. I think the PMIC is responsible for that as well, but I haven’t read the code.

I don’t have any alarms set though.

I have the same problem. I am not at all technical, so I’m not really following the conversation above but if there is a fix that is easily applied, I’d really appreciate it if you posted it here.

Sure - your wish is my command, master.

I have a solution which everyone should easily be able to perform and also the tool should be at everyone’s hand. I fully guarantee success - the phone will surely stay off. An extra plus - no more alarms will disturb you.
If it against anyone’s expectations does not stay off, I will give you 100% refund for a completely new FP2, promise.



So I applied the fix and now it won’t turn back on again, any ideas?


Now what - look at the topic title.
Wasn’t that what you wanted to have? Did I get something wrong here?

You should decide for the one or the other - you can’t have both. I could not read anywhere that you wanted to switch it back on again…:roll_eyes:

So as it reads you have applied the fix properly as now the phone seems to be off, only…for ever…cold…flatline, target reached and I have kept my promise.
I think now I deserve a like from you, or not? :smile:

Honestly, some users here dug quite deep into code to hopefully find the cause. But this even makes it more strange. There are only a few users with this phenomenon while there are a lot more using LineageOS not facing this unusual behavior. I am curious if the installed OS revision is the same or if something was not properly done while being flashed. Reading through these posts don’t give me any idea where to investigate. Again this turns out to be one of the very few tricky cases.
Anyway good luck.


I’m not using the hammer, but something a bit similar: taking out the battery to force the phone off!

I do hope to debug this properly, but I can’t go further without setting up some development kit. So far I’ve just been reading code on my phone.

If I figure it out I’ll post.


Although here we have many LineageOS users, I assume there is something similar to our FP forum for that OS?
How about the developers, are you in touch with them too? I guess they would not have ported and regularly updated the OS if there were only 5 FP2 users or so.

Since they are strictly at the point for programming and dealing with the source code, maybe they have an idea what can be done.

As LineageOS is at last Linux based your immediate power up (actually it is reboot) behavior to me looks like the runlevel variable or option is not set properly or not changed anymore being stuck in runlevel 6.

ATM I only have limited knowledge of these specific processes going on and they are related to conventional x86/x64 Linux versions.
For the runlevel and boot state there is a init process or more advanced the sysvinit available.
With sysvinit there are single user mode and multi user mode runlevels available.
Any init process follows an init script usually at /etc/inittab.
The initdefault value here sets the runlevel. Afaik this value is provided by the boot loader at power up and/or stored in some place depending on your choice when having long pressed the power button.

As your phone boots up at any time even after inserting the battery I assume this could be a root to investigate.
Generally Linux is the most detailed documented OS available, that’s a major benefit as I think.