Skip to content

chksysconfig: merge missing settings instead of overwriting user config#2372

Open
aenertia wants to merge 1 commit intoROCKNIX:nextfrom
aenertia:failsafe-corrupt-fix
Open

chksysconfig: merge missing settings instead of overwriting user config#2372
aenertia wants to merge 1 commit intoROCKNIX:nextfrom
aenertia:failsafe-corrupt-fix

Conversation

@aenertia
Copy link
Copy Markdown
Contributor

@aenertia aenertia commented Mar 4, 2026

The verify function checks for a missing system.hostname to detect a corrupt or truncated system.cfg. I believe the intent is to restore defaults so the system boots correctly. However, the current implementation runs rsync -a /usr/config/ /storage/.config which overwrites the entire user config tree — WiFi credentials, SSH settings, emulator preferences and per-game overrides are all replaced with factory defaults.

This creates a cycle: the full rsync restores system.hostname, but EmulationStation's save logic strips settings that match its internal defaults (including system.hostname). On the next hard crash, the hostname is missing again, triggering another full overwrite.

Replace the destructive rsync with a merge that adds keys present in the reference config but missing from the user config. Existing user settings are preserved. Retroarch config restoration is separated to only run when those specific files are actually missing.

Observed on RK3566 (RGB30/353P) during thermal shutdown and on Retroid Pocket 5 previous during hard crashes from stress testing.

@loki666
Copy link
Copy Markdown
Contributor

loki666 commented Mar 4, 2026

wondering if a simple copy wouldn't be enough...
ie: the user system.cfg contains valid key with invalid value... that will be hard to detect
ultimately, if the system.cfg is screwed... I'm not sure it's worth trying to salvage anything from it...

but doing a full rsync is probably too much indeed.

@aenertia
Copy link
Copy Markdown
Contributor Author

aenertia commented Mar 4, 2026

Yeah simple copy would be ok ; but it does introduce the potential for loosing expected state more often than not; maybe just looking for a subset of 'safe' keys as part of the merge? .More generally I think we need to flag more aggressively to the user that the machine is in degraded state i.e a 'Recovery mode' style banner or similar in ES.

@aenertia
Copy link
Copy Markdown
Contributor Author

aenertia commented Mar 4, 2026

Yeah simple copy would be ok ; but it does introduce the potential for loosing expected state more often than not; maybe just looking for a subset of 'safe' keys as part of the merge? .More generally I think we need to flag more aggressively to the user that the machine is in degraded state i.e a 'Recovery mode' style banner or similar in ES.

--- Just as a follow up thought to this ; since the hostname falls through to a hard-default provided by ES in this mode (which currently confusingly is a Batocera string). We can probably change that in ES to ROCKNIX-RECOVERY or something and use that ?

…onfig

After a hard crash (thermal shutdown, power loss), system.cfg can be
truncated to only the most recently written settings. The existing
verify function detects this via a missing system.hostname check, but
responds by rsyncing the entire reference config tree over the user's
config — destroying WiFi credentials, SSH settings, and per-game
emulator preferences.

Replace the destructive rsync with a targeted restore of only the
settings required for basic system functionality:

  ssh.enabled root.password wifi.enabled boot system.language
  system.timezone audio.volume audio.device system.hostname

The remaining 200+ emulator defaults (integerscale, ratio, autosave)
are managed internally by EmulationStation and do not need to be
present in system.cfg for the system to function.

The hostname is set to <DEVICE>-RECOVERED (e.g. RK3566-RECOVERED)
to signal to the user that recovery occurred. This is visible in ES
system info, the network hostname, and SSH banner without requiring
any EmulationStation code changes. A boot console message and journal
log entry are also emitted.

TODO: Add ES startup dialog triggered by a flag file check in
emulationstation-next for a more visible recovery notification.

Observed on RGB30 (RK3566) during DMC devfreq thermal testing and
Retroid Pocket 5 during stress testing.
@aenertia aenertia force-pushed the failsafe-corrupt-fix branch from 77df91c to b8c8076 Compare March 9, 2026 19:17
@aenertia
Copy link
Copy Markdown
Contributor Author

aenertia commented Mar 9, 2026

Updated to reflect discussion.

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.

2 participants