diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS index 49b062909d..dee36a53c3 100644 --- a/ROMFS/px4fmu_common/init.d/rcS +++ b/ROMFS/px4fmu_common/init.d/rcS @@ -36,6 +36,11 @@ set SDCARD_FORMAT no set STARTUP_TUNE 1 set VEHICLE_TYPE none +# Airframe parameter versioning: airframe maintainers can optionally set this in the +# airframe startup script, and then increase it by one whenever they want to ensure +# that parameters are reset to the airframe defaults for an update. +set PARAM_DEFAULTS_VER 1 + # # Print full system version. # @@ -175,13 +180,11 @@ else netman update -i eth0 fi - # - # If the airframe has been previously reset SYS_AUTCONFIG will have been set to 1 and other params will be reset on the next boot. - # + # To trigger a parameter reset during boot SYS_AUTCONFIG was set to 1 before if param greater SYS_AUTOCONFIG 0 then - # Reset params except Airframe, RC calibration, sensor calibration, flight modes, total flight time, and next flight UUID. - param reset_all SYS_AUTOSTART RC* CAL_* COM_FLTMODE* LND_FLIGHT* TC_* COM_FLIGHT* + # Reset parameters except airframe, parameter version, RC calibration + flight modes, sensor + airspeed calibration, total flight time, flight UUID + param reset_all SYS_AUTOS* SYS_PA* RC* COM_FLTMODE* CAL_* ASPD_S* LND_FLIGHT* TC_* COM_FLIGHT* fi # @@ -226,6 +229,17 @@ else fi unset AUTOSTART_PATH + # Check parameter version and reset upon airframe configuration version mismatch + # reboot required because "param reset_all" would reset all "param set" lines from airframe + if ! param compare SYS_PARAM_VER ${PARAM_DEFAULTS_VER} + then + echo "Switched to different parameter version. Resetting parameters." + param set SYS_PARAM_VER ${PARAM_DEFAULTS_VER} + param set SYS_AUTOCONFIG 1 + param save + reboot + fi + # # Start the tone_alarm driver. # Needs to be started after the parameters are loaded (for CBRK_BUZZER). @@ -556,6 +570,7 @@ unset LOGGER_ARGS unset LOGGER_BUF unset PARAM_FILE unset PARAM_BACKUP_FILE +unset PARAM_DEFAULTS_VER unset RC_INPUT_ARGS unset SDCARD_AVAILABLE unset SDCARD_EXT_PATH diff --git a/src/lib/systemlib/system_params.c b/src/lib/systemlib/system_params.c index 1417cd37b4..86dbba3b77 100644 --- a/src/lib/systemlib/system_params.c +++ b/src/lib/systemlib/system_params.c @@ -97,6 +97,19 @@ PARAM_DEFINE_INT32(SYS_HITL, 0); */ PARAM_DEFINE_INT32(SYS_MC_EST_GROUP, 2); +/** + * Parameter version + * + * This is used internally only: an airframe configuration might set an expected + * parameter version value via PARAM_DEFAULTS_VER. This is checked on bootup + * against SYS_PARAM_VER, and if they do not match, parameters from the airframe + * configuration are reloaded. + * + * @min 0 + * @group System + */ +PARAM_DEFINE_INT32(SYS_PARAM_VER, 1); + /** * Enable auto start of rate gyro thermal calibration at the next power up. * diff --git a/src/modules/mavlink/mavlink_parameters.cpp b/src/modules/mavlink/mavlink_parameters.cpp index c7332bff7b..cf6a17ff10 100644 --- a/src/modules/mavlink/mavlink_parameters.cpp +++ b/src/modules/mavlink/mavlink_parameters.cpp @@ -311,6 +311,7 @@ MavlinkParametersManager::send() param_find("SENS_BOARD_Y_OFF"); param_find("SENS_BOARD_Z_OFF"); param_find("SENS_DPRES_OFF"); + param_find("SYS_PARAM_VER"); param_find("TRIG_MODE"); param_find("UAVCAN_ENABLE");