From d50a3c902a5a0b60dd0f820fa01a64fad48a0c3c Mon Sep 17 00:00:00 2001 From: PhysicistJohn <54456354+PhysicistJohn@users.noreply.github.com> Date: Tue, 14 Jul 2026 22:04:58 -0700 Subject: [PATCH] fix: initialize complete backup checksum image 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. --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 09fc658..745074a 100644 --- a/main.c +++ b/main.c @@ -161,7 +161,8 @@ static THD_FUNCTION(Thread1, arg) while (1) { // START_PROFILE if (sweep_mode&(SWEEP_ENABLE|SWEEP_ONCE)) { - backup_t b; + /* Initialize the reserved byte covered by the checksum too. */ + backup_t b = {0}; b.data.frequency0 = setting.frequency0; b.data.frequency1 = setting.frequency1; if (setting.auto_attenuation)