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
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.

The verify function checks for a missing system.hostname to detect a
corrupt or truncated system.cfg. 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) during thermal shutdown and on Retroid
Pocket 5 during hard crashes from stress testing.
@loki666
Copy link
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
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
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 ?

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