Skip to content

firmware: GeoRAM preload falls back to georam.tmp or .bak when georam.ram is missing - #73

Merged
SensoriumEmbedded merged 2 commits into
SensoriumEmbedded:mainfrom
kfox:georam-preload-fallback
Oct 26, 2026
Merged

SensoriumEmbedded merged 2 commits into
SensoriumEmbedded:mainfrom
kfox:georam-preload-fallback

Conversation

@kfox

@kfox kfox commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Builds on #72 (the GEOS 64 user guide); merge that first. Until then this PR also shows its commit.

Saving GeoRAM (SaveRAMBanksReplacing) writes georam.tmp, renames georam.ram to georam.bak, then renames georam.tmp to georam.ram. If power drops between the two renames, there is no georam.ram on the card, and GEOS starts with empty GeoRAM even though the new save (.tmp) and the previous one (.bak) are both there.

With this change, the GeoRAM preload (LoadRAMBanksReplaced in RAMBanks.c, next to the save) falls back when georam.ram is missing:

  1. georam.tmp, but only if its size is exactly the full GeoRAM image. Any other size is a torn write and is skipped.
  2. otherwise georam.bak.
  3. otherwise the same behaviour as before (not found, empty GeoRAM).

The GEOS 64 user guide says that the next launch after a power loss during a save loads the newest complete save. Serial logs which file was loaded. Nothing is renamed or repaired at load time: the next save already handles a missing georam.ram. The .tmp/.bak extensions are now shared constants, so save and load use the same names. The REU preload is unchanged, because the REU saves to numbered files rather than replacing one.

Verification

  • npm run build:tr and npm run build:tr-plus: both build.
  • npm test: 258 pass, 0 fail.
  • No host test harness reaches RAMBanks.c, so the fallback has no automated test.
  • Not hardware-tested.

Review

One single-pass code review at medium effort found no defects. It traced every point where power could drop during the save against the new load order. It also noted one limitation: if the GeoRAM size changes between boots (it depends on free RAM), a complete .tmp is skipped and .bak is loaded instead. That is the intended conservative choice.

@kfox
kfox force-pushed the georam-preload-fallback branch from 843d0ac to 3b726db Compare October 26, 2026 20:22
@SensoriumEmbedded

Copy link
Copy Markdown
Owner

Thank you Kelly!
Hardware testing: what I ran

Four card states on a TR+ with this merged onto main, using 512K images whose every page carries a tag so the saved georam.ram shows which file was loaded. All four passed:

  • georam.ram missing, complete .tmp plus .bak: serial Not found, loading: /georam.tmp, 512K read; after an Alt save georam.ram held the .tmp image and .bak was untouched.
  • georam.ram missing, a 100,000-byte .tmp plus .bak: Skipping /georam.tmp: 100000 Bytes, then the .bak loaded; the save wrote the .bak image to georam.ram.
  • georam.ram missing, a .tmp one page too long, no .bak: Skipping /georam.tmp: 524544 Bytes, Not found!, GEOS still started; the save produced a fresh 512K georam.ram.
  • georam.ram present plus a stale complete .tmp: georam.ram loaded with no fallback line; the save rotated it to .bak and the .tmp was consumed.

@SensoriumEmbedded
SensoriumEmbedded marked this pull request as ready for review October 26, 2026 22:05
@SensoriumEmbedded
SensoriumEmbedded merged commit 5728ddc into SensoriumEmbedded:main Oct 26, 2026
4 checks passed
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