Skip to content

fix: remount the SD card read-only before poweroff - #239

Open
dime-online wants to merge 1 commit into
spruceUI:developmentfrom
dime-online:agent/fix-mini-flip-clean-shutdown
Open

fix: remount the SD card read-only before poweroff#239
dime-online wants to merge 1 commit into
spruceUI:developmentfrom
dime-online:agent/fix-mini-flip-clean-shutdown

Conversation

@dime-online

@dime-online dime-online commented Aug 5, 2026

Copy link
Copy Markdown

Summary

  • preserves SprigUI's existing autoresume capture and app/emulator shutdown sequence
  • after the final stock sync, closes inherited standard streams and uses a system-only PATH
  • makes one exact read-only remount attempt for /dev/mmcblk0p1 at /mnt/SDCARD
  • verifies the base vfat mount is read-only, then uses the same stock /sbin/poweroff action whether the remount succeeded or failed

Scope

This is for SprigUI's supported Miyoo Mini Flip target. The Mini OG reboot path is unchanged.

SprigUI keeps SD-backed bind mounts active during shutdown. A direct adaptation of full spruceOS's RAM stage/unmount flow was tested on the Mini Flip and froze before the RAM stage started, so this change intentionally leaves those binds readable and remounts only the base FAT volume read-only.

Root cause

The normal software-shutdown path synced the filesystem and immediately called poweroff, but never transitioned the FAT volume out of its writable state. On a Miyoo Mini Flip, documented quick-save shutdowns could leave the card dirty even though save_poweroff.sh completed normally. A vfat read-only remount commits the FAT clean-state transition while leaving SprigUI's bind-mounted runtime files readable for the firmware handoff.

The failure path deliberately retains stock behavior: it still powers off rather than freezing the UI and forcing a hard cut. Everything through autoresume capture, process signaling/waits, and the original sync is byte-identical to the current development script. This does not add a second-stage shutdown script or import the different spruceOS shutdown topology.

Validation

  • sh -n and Git whitespace checks
  • nine-case inert equivalence/failure harness, including autoresume capture, an emulator wait, remount command failure, false-success verification, duplicate/wrong mount records, and the untouched Mini OG reboot path
  • three physical Mini Flip button shutdowns: main menu, in-game with autoresume capture, then in-game again after resume
  • confirmed autoresume, RetroArch auto-state, and SRAM behavior remained intact
  • after the patched shutdowns: Windows reported NOT Dirty and Healthy/OK; read-only CHKDSK found no filesystem errors

Fixes #236

@dime-online
dime-online marked this pull request as ready for review August 5, 2026 22:24
@dime-online dime-online closed this Aug 7, 2026
@dime-online
dime-online deleted the agent/fix-mini-flip-clean-shutdown branch August 7, 2026 07:16
@dime-online
dime-online restored the agent/fix-mini-flip-clean-shutdown branch August 7, 2026 07:17
@dime-online dime-online reopened this Aug 7, 2026
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.

SD Card Corruption During Write Interrupted by Shutdown

1 participant