From 0bb5225370338fcc8df27ce590a91e85ba4d1cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Tue, 2 Apr 2019 10:13:56 +0200 Subject: [PATCH] rcS: add airframe parameter versioning and extend SYS_AUTOCONFIG --- ROMFS/px4fmu_common/init.d/rcS | 24 +++++++++++++++++++++++- src/lib/systemlib/system_params.c | 10 +++++----- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS index f162f72ed1..9dc58d3650 100644 --- a/ROMFS/px4fmu_common/init.d/rcS +++ b/ROMFS/px4fmu_common/init.d/rcS @@ -57,6 +57,12 @@ set SDCARD_MIXERS_PATH /fs/microsd/etc/mixers set USE_IO no set VEHICLE_TYPE none +# Airframe parameter versioning: airframe maintainers can set this in the +# airframe startup script, and then increase it by one whenever an airframe +# parameter is updated - it will ensure that these parameters will be updated +# when the firmware is flashed. +set PARAM_DEFAULTS_VER 1 + # # Mount the procfs. # @@ -161,7 +167,12 @@ else param reset_nostart RC* COM_FLTMODE* LND_FLIGHT_T_* TC_* CAL_ACC* CAL_GYRO* set AUTOCNF yes else - set AUTOCNF no + if param compare SYS_AUTOCONFIG 2 + then + set AUTOCNF yes + else + set AUTOCNF no + fi fi # @@ -473,6 +484,16 @@ else # sh /etc/init.d/rc.logging + + 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 2 + param save + reboot + fi + # # End of autostart. # @@ -503,6 +524,7 @@ unset MIXER_FILE unset MK_MODE unset MKBLCTRL_ARG unset OUTPUT_MODE +unset PARAM_DEFAULTS_VER unset PARAM_FILE unset PWM_AUX_DISARMED unset PWM_AUX_MAX diff --git a/src/lib/systemlib/system_params.c b/src/lib/systemlib/system_params.c index 764a751ce9..a066997c5f 100644 --- a/src/lib/systemlib/system_params.c +++ b/src/lib/systemlib/system_params.c @@ -56,10 +56,9 @@ PARAM_DEFINE_INT32(SYS_AUTOSTART, 0); * Platform-specific values are used if available. * RC* parameters are preserved. * - * @min 0 - * @max 1 * @value 0 Keep parameters * @value 1 Reset parameters + * @value 2 Reload airframe parameters * @group System */ PARAM_DEFINE_INT32(SYS_AUTOCONFIG, 0); @@ -144,9 +143,10 @@ PARAM_DEFINE_INT32(SYS_COMPANION, 0); /** * Parameter version * - * This monotonically increasing number encodes the parameter compatibility set. - * whenever it increases parameters might not be backwards compatible and - * ground control stations should suggest a fresh configuration. + * 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