Skip to content

Conversation

@DrFlarp
Copy link

@DrFlarp DrFlarp commented Jan 27, 2026

If kernel returns non-zero on suspend, handle the error properly and retry without exiting the script.

This avoids having to constantly restart network services. The user will not be able to wake the device in the time that it is retrying the deep sleep process (around 6 seconds on a Brick with Wifi turned on)

This addresses #594

@frysee
Copy link
Member

frysee commented Jan 28, 2026

We also have the retry mechanism on the caller side: https://github.com/LoveRetro/NextUI/blob/main/workspace/all/common/api.c#L3799
We probably wont need both. Should we just kill that one?

@DrFlarp
Copy link
Author

DrFlarp commented Jan 28, 2026

I mulled this one over, if we do that we should fix the fallback implementation PLAT_deepSleep so it doesn't cause the system to fully power off on a single failure.

@frysee
Copy link
Member

frysee commented Jan 28, 2026

I mulled this one over, if we do that we should fix the fallback implementation PLAT_deepSleep so it doesn't cause the system to fully power off on a single failure.

Yeah, sounds good - lets do it that way. PLAT_deepSleep already checks return value, just needs a loop.

@frysee
Copy link
Member

frysee commented Jan 29, 2026

Looks clean!

@DrFlarp
Copy link
Author

DrFlarp commented Feb 1, 2026

The fix as it had been initially designed had some unacceptable cases of non-responsiveness to user input.

4117654 introduces a new helper, waitforwake.elf, that works like sleep <x> but terminates early when it detects a power button press

Also fixed: a really frustrating, hard-to-debug edge case where the system goes to sleep normally but returns non-zero on wake. When the user presses the power button to wake, the script thinks that this was a failed sleep attempt and puts the system back to sleep. In my testing I've had cases where I've tried 4 times to wake the console and it failed 4 times in a row. I've wasted enough of my life trying to pin this one down so I'm just going to check how long the console was asleep for and assume it was successful if longer than 5 seconds.

This is a number of big changes so open to feedback as always.

@DrFlarp DrFlarp marked this pull request as ready for review February 1, 2026 14:05
@frysee
Copy link
Member

frysee commented Feb 1, 2026

For something that ideally should just be echo mem >/sys/power/state this is getting a bit out of control :)

@DrFlarp
Copy link
Author

DrFlarp commented Feb 1, 2026

Sure, the question is what to leave in...

I think some amount of power button unresponsiveness is ok but the bug where the system falls back asleep immediately after waking is unacceptable.

frysee and others added 18 commits February 1, 2026 20:24
… from other devices (LoveRetro#580)

* State_read: Dedupe unnecessary branch

rzfile already handles uncompressed files for us

* do not display stale errno here

* Save States: improve compatibility with save states imported from other devices
fix: nextui hanging when launching games from folder auto-launch
…Retro#615)

* Fix: improve PLAT_bluetooth* to cope with API changes between bluez versions

* Fix: Use MAC address as map key to prevent collisions with duplicate/empty device names
LoveRetro#616)

Fix: wifi fails to come up after reboot, if bluetooth is also enabled and inits at the same time
@DrFlarp DrFlarp force-pushed the recover-from-bad-suspend branch from 6f138ba to cfcb84f Compare February 2, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants