Skip to content

fix: initialize complete backup checksum image - #165

Merged
erikkaashoek merged 1 commit into
erikkaashoek:mainfrom
PhysicistJohn:fix/deterministic-backup-checksum
Aug 4, 2026
Merged

fix: initialize complete backup checksum image#165
erikkaashoek merged 1 commit into
erikkaashoek:mainfrom
PhysicistJohn:fix/deterministic-backup-checksum

Conversation

@PhysicistJohn

Copy link
Copy Markdown

Problem

The RTC backup checksum covers every byte of backup_t except the checksum byte itself. That range includes the packed dummy2 reserved byte, but the stack-local structure is populated field-by-field and never initializes it.

The checksum can therefore incorporate indeterminate stack data and cause otherwise valid analyzer settings to be rejected after reset.

Change

Zero-initialize the complete packed backup image before assigning its persisted fields. This makes the reserved byte and resulting checksum deterministic without changing the backup layout or checksum algorithm.

Verification

  • F072 and F303 firmware targets build successfully with Arm GNU 11.3.Rel1.
  • The implementation was exercised in the ChibiOS RC5 candidate with a deterministic reserved byte.
  • On STM32F303 hardware, configured frequency and attenuation sentinels survived the tested warm-reset path and the post-reset checksum was accepted.

Scope and limitations

  • No storage layout, field encoding, RF, UI, or protocol behavior changes.
  • Physical warm-reset retention is proven.
  • Retention of a before/after sentinel across complete removal of power was not measured and is not claimed by this PR.

The RTC backup checksum covers every byte except the checksum itself, including a reserved packed byte that was never assigned. Its stack value could therefore make otherwise valid state fail verification after reset.

Zero-initialize the complete backup image before assigning persisted fields so the checksum and reserved byte are deterministic.
@erikkaashoek
erikkaashoek merged commit d12696d into erikkaashoek:main Aug 4, 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.

2 participants