mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 19:07:45 +08:00
autostart scripts: Reintroduce SYS_PARAM_VER (#22813)
The case where the airframe maintainer wants to enforce a reset to airframe is not covered anymore with the `param set-default` mechanism. For products based on PX4 this is still required to ensure proper functionality after a major update.
This commit is contained in:
@@ -36,6 +36,12 @@ set SDCARD_FORMAT no
|
|||||||
set STARTUP_TUNE 1
|
set STARTUP_TUNE 1
|
||||||
set VEHICLE_TYPE none
|
set VEHICLE_TYPE none
|
||||||
|
|
||||||
|
# Airframe parameter versioning
|
||||||
|
# Value set to 1 by default but can optionally be overridden in the airframe configuration startup script.
|
||||||
|
# Airframe maintainers can ensure a reset to the airframe defaults during an update by increasing by one.
|
||||||
|
# e.g. add line "set PARAM_DEFAULTS_VER 2" in your airframe file to build the first update that enfoces a reset.
|
||||||
|
set PARAM_DEFAULTS_VER 1
|
||||||
|
|
||||||
#
|
#
|
||||||
# Print full system version.
|
# Print full system version.
|
||||||
#
|
#
|
||||||
@@ -182,13 +188,11 @@ else
|
|||||||
netman update -i eth0
|
netman update -i eth0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
# To trigger a parameter reset during boot SYS_AUTCONFIG was set to 1 before
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
if param greater SYS_AUTOCONFIG 0
|
if param greater SYS_AUTOCONFIG 0
|
||||||
then
|
then
|
||||||
# Reset params except Airframe, RC calibration, sensor calibration, flight modes, total flight time, and next flight UUID.
|
# Reset parameters except airframe, parameter version, RC calibration, sensor calibration, flight modes, total flight time, flight UUID
|
||||||
param reset_all SYS_AUTOSTART RC* CAL_* COM_FLTMODE* LND_FLIGHT* TC_* COM_FLIGHT*
|
param reset_all SYS_AUTOSTART SYS_PARAM_VER RC* CAL_* COM_FLTMODE* LND_FLIGHT* TC_* COM_FLIGHT*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -233,6 +237,17 @@ else
|
|||||||
fi
|
fi
|
||||||
unset AUTOSTART_PATH
|
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.
|
# Start the tone_alarm driver.
|
||||||
# Needs to be started after the parameters are loaded (for CBRK_BUZZER).
|
# Needs to be started after the parameters are loaded (for CBRK_BUZZER).
|
||||||
@@ -598,6 +613,7 @@ unset LOGGER_ARGS
|
|||||||
unset LOGGER_BUF
|
unset LOGGER_BUF
|
||||||
unset PARAM_FILE
|
unset PARAM_FILE
|
||||||
unset PARAM_BACKUP_FILE
|
unset PARAM_BACKUP_FILE
|
||||||
|
unset PARAM_DEFAULTS_VER
|
||||||
unset RC_INPUT_ARGS
|
unset RC_INPUT_ARGS
|
||||||
unset SDCARD_AVAILABLE
|
unset SDCARD_AVAILABLE
|
||||||
unset SDCARD_EXT_PATH
|
unset SDCARD_EXT_PATH
|
||||||
|
|||||||
@@ -83,6 +83,19 @@ PARAM_DEFINE_INT32(SYS_AUTOCONFIG, 0);
|
|||||||
*/
|
*/
|
||||||
PARAM_DEFINE_INT32(SYS_HITL, 0);
|
PARAM_DEFINE_INT32(SYS_HITL, 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 are reset and
|
||||||
|
* reloaded from the airframe configuration.
|
||||||
|
*
|
||||||
|
* @min 0
|
||||||
|
* @group System
|
||||||
|
*/
|
||||||
|
PARAM_DEFINE_INT32(SYS_PARAM_VER, 1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable auto start of rate gyro thermal calibration at the next power up.
|
* Enable auto start of rate gyro thermal calibration at the next power up.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -310,6 +310,9 @@ MavlinkParametersManager::send()
|
|||||||
param_find("TRIG_MODE");
|
param_find("TRIG_MODE");
|
||||||
param_find("UAVCAN_ENABLE");
|
param_find("UAVCAN_ENABLE");
|
||||||
|
|
||||||
|
// parameter only used in startup script but should show on ground station
|
||||||
|
param_find("SYS_PARAM_VER");
|
||||||
|
|
||||||
_first_send = true;
|
_first_send = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user