From a5b2270292364e64a6dd7162413f479751398a75 Mon Sep 17 00:00:00 2001 From: Jacob Dahl <37091262+dakejahl@users.noreply.github.com> Date: Sun, 14 Jun 2026 16:24:09 -0600 Subject: [PATCH] fix(parameters): save resets synchronously and scope caldata repair (#27658) * fix(commander): save parameters synchronously after parameter reset ParamResetAll and ParamResetAllConfig relied on the deferred autosave (300 ms delay, 2 s rate limit) to persist the reset, so a reboot or power cycle right after the command ack could leave the old parameters in storage. Save synchronously like ParamResetSensorFactory already does. Signed-off-by: Jacob Dahl * fix(rcS): only run caldata BSON size repair on boards with caldata The bsondump docsize block from #23088 repairs a zeroed BSON document size field in /fs/mtd_caldata, but it ran unconditionally with a comment claiming it checks /fs/mtd_params, producing failed-bsondump boot noise on every board without a caldata partition. Move it inside the MTD_CALDATA gate next to the param load it exists to protect. Signed-off-by: Jacob Dahl --------- Signed-off-by: Jacob Dahl --- ROMFS/px4fmu_common/init.d/rcS | 14 +++++++------- src/modules/commander/worker_thread.cpp | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS index 2d655e1208f..93b5bfe2e70 100644 --- a/ROMFS/px4fmu_common/init.d/rcS +++ b/ROMFS/px4fmu_common/init.d/rcS @@ -179,19 +179,19 @@ else # Load param file location from kconfig . ${R}etc/init.d/rc.filepaths - # Check if /fs/mtd_params is a valid BSON file - if ! bsondump docsize /fs/mtd_caldata - then - echo "New /fs/mtd_caldata size is:" - bsondump docsize /fs/mtd_caldata - fi - # # Load parameters. # # if the board has a storage for (factory) calibration data if mft query -q -k MTD -s MTD_CALDATA -v /fs/mtd_caldata then + # repair the caldata BSON document size field if it was left zeroed + if ! bsondump docsize /fs/mtd_caldata + then + echo "New /fs/mtd_caldata size is:" + bsondump docsize /fs/mtd_caldata + fi + param load /fs/mtd_caldata fi diff --git a/src/modules/commander/worker_thread.cpp b/src/modules/commander/worker_thread.cpp index bccbc635be0..fc8b0bc1f61 100644 --- a/src/modules/commander/worker_thread.cpp +++ b/src/modules/commander/worker_thread.cpp @@ -176,7 +176,7 @@ void WorkerThread::threadEntry() case Request::ParamResetAll: param_reset_all(); - _ret_value = 0; + _ret_value = param_save_default(true); break; case Request::ParamResetSensorFactory: { @@ -196,7 +196,7 @@ void WorkerThread::threadEntry() "COM_FLIGHT_UUID" }; param_reset_excludes(exclude_list, sizeof(exclude_list) / sizeof(exclude_list[0])); - _ret_value = 0; + _ret_value = param_save_default(true); break; } }