Occasionally my headless Raspberry Pi becomes unresponsive.
I have configured the watchdog, but it doesn't always kick in.
So I have added a reset button which does a hard reset by connecting the GLOBAL_EN to GND.
Another solution would be to just cut off the power.
Is there a difference between those two solutions with respect to SD corruption?
2 Answers
Connecting GLOBAL_EN to GND is not a safe shutdown. Removing power from the RPi while it's running is also not a safe shutdown. A safe shutdown is one in which any pending writes to the SD card are completed before stopping the processor.
The simplest solution to your problem may be the "one-button ON-OFF" switch. It's described in this answer. If that doesn't do it for you, follow up here in the comments & I'll come up with something else.
-
From my understanding, using the GPIO overlay creates an interrupt which means that the kernel still needs to be responsive to interrupts, which may not always be the case with a hanging system. As my system only hangs occasionally, I cannot tell, if the GPIO overlay will solve my issue. Nonetheless, I will give it a try and accept your answer as a solution. Commented Sep 27, 2023 at 14:51
-
@user333869: The overlay signals the processor to issue a
shutdown
, so yes - if your system cannot issue theshutdown
, then this will not help. That said, it seems far more likely to me that the "hang" you see is due to the communications link between your terminal and your RPi. If you can measure the current being drawn by your RPi, you should be able to detect a significant reduction after theshutdown
is issued. Hope that's clear...– SeamusCommented Sep 27, 2023 at 15:27
It will make no difference.
Cutting power will actually take a short time for capacitors to discharge vs instantaneous PMIC reset.
I would install a button and activate the shutdown overlay to see if this works.
-
I think that any operation that forcibly interrupts SD card writes can lead to data corruption. A hard reset of the CPU can do that, as well as a power cut. But what about wear leveling operations of the SD card itself? These will be interrupted hard by power off but possibly soft by a CPU reset. Commented Sep 25, 2023 at 5:32
-
That wasn't the question you asked. I was not recommending either. Commented Sep 25, 2023 at 6:13