2018-12-18 09:26:22 +01:00
|
|
|
#!/bin/sh
|
2017-04-06 03:42:16 -10:00
|
|
|
# Un comment and use set +e to ignore and set -e to enable 'exit on error control'
|
2017-06-09 09:17:07 +02:00
|
|
|
set +e
|
2017-04-06 03:42:16 -10:00
|
|
|
# Un comment the line below to help debug scripts by printing a trace of the script commands
|
|
|
|
|
#set -x
|
2012-08-04 15:12:36 -07:00
|
|
|
# PX4FMU startup script.
|
2014-12-13 15:57:38 +01:00
|
|
|
#
|
2016-12-23 09:06:49 +01:00
|
|
|
# NOTE: environment variable references:
|
|
|
|
|
# If the dollar sign ('$') is followed by a left bracket ('{') then the
|
|
|
|
|
# variable name is terminated with the right bracket character ('}').
|
|
|
|
|
# Otherwise, the variable name goes to the end of the argument.
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# NOTE: COMMENT LINES ARE REMOVED BEFORE STORED IN ROMFS.
|
2014-12-13 15:57:38 +01:00
|
|
|
#
|
2018-07-20 11:19:12 -06:00
|
|
|
#------------------------------------------------------------------------------
|
2018-07-04 18:46:13 -06:00
|
|
|
|
|
|
|
|
#
|
2018-07-26 18:18:53 -06:00
|
|
|
# Set default paramter values.
|
2018-08-16 14:43:13 -07:00
|
|
|
# Do not add intra word spaces
|
|
|
|
|
# it wastes flash
|
2018-07-04 18:46:13 -06:00
|
|
|
#
|
2020-10-14 13:15:02 -07:00
|
|
|
set R /
|
2019-07-16 08:48:25 -06:00
|
|
|
set AUTOCNF no
|
2018-08-04 11:15:50 -06:00
|
|
|
set AUX_MODE pwm
|
|
|
|
|
set DATAMAN_OPT ""
|
|
|
|
|
set FCONFIG /fs/microsd/etc/config.txt
|
|
|
|
|
set FEXTRAS /fs/microsd/etc/extras.txt
|
|
|
|
|
set FMU_MODE pwm
|
2018-12-14 12:36:32 -05:00
|
|
|
set FRC /fs/microsd/etc/rc.txt
|
2018-11-21 23:27:21 -05:00
|
|
|
set IOFW "/etc/extras/px4_io-v2_default.bin"
|
2018-08-04 11:15:50 -06:00
|
|
|
set IO_PRESENT no
|
2018-11-30 14:32:50 -05:00
|
|
|
set LOGGER_ARGS ""
|
2018-11-30 13:46:41 -05:00
|
|
|
set LOGGER_BUF 14
|
2018-08-04 11:15:50 -06:00
|
|
|
set MAV_TYPE none
|
|
|
|
|
set MIXER none
|
|
|
|
|
set MIXER_AUX none
|
|
|
|
|
set MIXER_FILE none
|
2020-12-17 13:54:57 +01:00
|
|
|
set MIXER_EXTRA none
|
2018-08-04 11:15:50 -06:00
|
|
|
set MK_MODE none
|
|
|
|
|
set MKBLCTRL_ARG ""
|
|
|
|
|
set OUTPUT_MODE none
|
|
|
|
|
set PARAM_FILE /fs/microsd/params
|
|
|
|
|
set PWM_DISARMED p:PWM_DISARMED
|
|
|
|
|
set PWM_MAX p:PWM_MAX
|
|
|
|
|
set PWM_MIN p:PWM_MIN
|
|
|
|
|
set PWM_OUT none
|
|
|
|
|
set PWM_RATE p:PWM_RATE
|
2020-12-17 13:54:57 +01:00
|
|
|
set PWM_AUX_DISARMED p:PWM_AUX_DISARMED
|
|
|
|
|
set PWM_AUX_MAX p:PWM_AUX_MAX
|
|
|
|
|
set PWM_AUX_MIN p:PWM_AUX_MIN
|
|
|
|
|
set PWM_AUX_OUT none
|
|
|
|
|
set PWM_AUX_RATE p:PWM_AUX_RATE
|
|
|
|
|
set PWM_EXTRA_DISARMED p:PWM_EXTRA_DISARMED
|
|
|
|
|
set PWM_EXTRA_MAX p:PWM_EXTRA_MAX
|
|
|
|
|
set PWM_EXTRA_MIN p:PWM_EXTRA_MIN
|
|
|
|
|
set PWM_EXTRA_OUT none
|
|
|
|
|
set PWM_EXTRA_RATE p:PWM_EXTRA_RATE
|
|
|
|
|
set EXTRA_MIXER_MODE none
|
2019-07-05 14:13:58 +02:00
|
|
|
set RC_INPUT_ARGS ""
|
2018-08-04 11:15:50 -06:00
|
|
|
set SDCARD_MIXERS_PATH /fs/microsd/etc/mixers
|
2019-07-06 17:24:22 +02:00
|
|
|
set STARTUP_TUNE 1
|
2018-08-04 11:15:50 -06:00
|
|
|
set USE_IO no
|
|
|
|
|
set VEHICLE_TYPE none
|
2018-08-16 14:43:13 -07:00
|
|
|
|
2019-04-02 10:13:56 +02:00
|
|
|
# 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
|
|
|
|
|
|
2016-12-12 12:53:12 -10:00
|
|
|
#
|
|
|
|
|
# Mount the procfs.
|
|
|
|
|
#
|
|
|
|
|
mount -t procfs /proc
|
|
|
|
|
|
2015-01-26 08:59:19 +01:00
|
|
|
#
|
2018-07-13 17:05:10 -06:00
|
|
|
# Start CDC/ACM serial driver.
|
2015-01-26 08:59:19 +01:00
|
|
|
#
|
2017-09-20 00:04:23 -04:00
|
|
|
sercon
|
2015-01-26 08:59:19 +01:00
|
|
|
|
2018-07-13 17:05:10 -06:00
|
|
|
#
|
|
|
|
|
# Print full system version.
|
|
|
|
|
#
|
2017-09-24 13:36:13 -04:00
|
|
|
ver all
|
|
|
|
|
|
2018-08-16 14:43:13 -07:00
|
|
|
#
|
|
|
|
|
# Start the ORB (first app to start)
|
|
|
|
|
# tone_alarm and tune_control
|
|
|
|
|
# is dependent.
|
|
|
|
|
#
|
|
|
|
|
uorb start
|
|
|
|
|
|
2012-08-04 15:12:36 -07:00
|
|
|
#
|
|
|
|
|
# Try to mount the microSD card.
|
|
|
|
|
#
|
2018-07-13 17:05:10 -06:00
|
|
|
# REBOOTWORK this needs to start after the flight control loop.
|
2012-08-04 15:12:36 -07:00
|
|
|
if mount -t vfat /dev/mmcsd0 /fs/microsd
|
|
|
|
|
then
|
2016-12-12 12:53:12 -10:00
|
|
|
if hardfault_log check
|
|
|
|
|
then
|
2018-07-20 11:19:12 -06:00
|
|
|
# Error tune.
|
2019-07-06 17:24:22 +02:00
|
|
|
set STARTUP_TUNE 2
|
2016-12-12 12:53:12 -10:00
|
|
|
if hardfault_log commit
|
|
|
|
|
then
|
|
|
|
|
hardfault_log reset
|
|
|
|
|
fi
|
2017-09-20 00:04:23 -04:00
|
|
|
fi
|
2020-06-08 16:57:28 -04:00
|
|
|
|
|
|
|
|
# Prevent MacOS and Ubuntu from creating unnecessary temporary files on the microSD card
|
|
|
|
|
|
|
|
|
|
# block MacOS Spotlight indexing (.Spotlight-V100 folder)
|
|
|
|
|
if [ ! -f "/fs/microsd/.metadata_never_index" ]; then
|
|
|
|
|
cat > /fs/microsd/.metadata_never_index
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# block MacOS trashes
|
|
|
|
|
if [ ! -f "/fs/microsd/.Trashes" ]; then
|
|
|
|
|
cat > /fs/microsd/.Trashes
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# block MacOS logging of filesystem events
|
|
|
|
|
if [ ! -d "/fs/microsd/.fseventsd" ]; then
|
|
|
|
|
mkdir /fs/microsd/.fseventsd
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ ! -f "/fs/microsd/.fseventsd/no_log" ]; then
|
|
|
|
|
cat > /fs/microsd/.fseventsd/no_log
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# block Ubuntu trash
|
|
|
|
|
if [ ! -f "/fs/microsd/.Trash-1000" ]; then
|
|
|
|
|
cat > /fs/microsd/.Trash-1000
|
|
|
|
|
fi
|
|
|
|
|
|
2012-08-04 15:12:36 -07:00
|
|
|
else
|
2018-08-16 14:43:13 -07:00
|
|
|
# tune SD_INIT
|
2020-10-05 21:39:26 -04:00
|
|
|
set STARTUP_TUNE 14 # tune 14 = SD_INIT
|
2015-04-11 01:02:21 +02:00
|
|
|
if mkfatfs /dev/mmcsd0
|
|
|
|
|
then
|
|
|
|
|
if mount -t vfat /dev/mmcsd0 /fs/microsd
|
|
|
|
|
then
|
2018-07-18 11:39:45 -06:00
|
|
|
echo "INFO [init] card formatted"
|
2015-04-11 01:02:21 +02:00
|
|
|
else
|
2020-10-05 21:39:26 -04:00
|
|
|
set STARTUP_TUNE 15 # tune 15 = SD_ERROR
|
2018-01-05 22:45:12 +01:00
|
|
|
echo "ERROR [init] format failed"
|
2015-04-11 01:02:21 +02:00
|
|
|
fi
|
|
|
|
|
fi
|
2012-08-04 15:12:36 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Look for an init script on the microSD card.
|
2014-01-10 23:14:29 +01:00
|
|
|
# Disable autostart if the script found.
|
2012-08-04 15:12:36 -07:00
|
|
|
#
|
2014-11-17 14:58:29 +01:00
|
|
|
if [ -f $FRC ]
|
2012-12-27 13:17:43 +01:00
|
|
|
then
|
2020-06-22 13:53:01 -07:00
|
|
|
. $FRC
|
2018-07-13 17:05:10 -06:00
|
|
|
else
|
2018-07-18 11:39:45 -06:00
|
|
|
|
2013-08-25 19:27:11 +02:00
|
|
|
#
|
2020-11-20 11:43:51 -08:00
|
|
|
# Set the parameter file the board supports params on
|
|
|
|
|
# MTD device.
|
2013-08-25 19:27:11 +02:00
|
|
|
#
|
2020-11-20 11:43:51 -08:00
|
|
|
if mft query -q -k MTD -s MTD_PARAMETERS -v /fs/mtd_params
|
2014-01-12 16:33:23 +01:00
|
|
|
then
|
2014-01-17 23:14:24 +01:00
|
|
|
set PARAM_FILE /fs/mtd_params
|
2014-01-15 00:02:57 +01:00
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2018-07-13 17:05:10 -06:00
|
|
|
#
|
|
|
|
|
# Load parameters.
|
|
|
|
|
#
|
2020-11-20 11:43:51 -08:00
|
|
|
# if the board has a storage for (factory) calibration data
|
|
|
|
|
if mft query -q -k MTD -s MTD_CALDATA -v /fs/mtd_caldata
|
2020-09-04 15:24:44 +02:00
|
|
|
then
|
2020-11-20 11:43:51 -08:00
|
|
|
param load /fs/mtd_caldata
|
2020-09-04 15:24:44 +02:00
|
|
|
fi
|
|
|
|
|
|
2014-01-15 00:02:57 +01:00
|
|
|
param select $PARAM_FILE
|
2020-09-04 15:24:44 +02:00
|
|
|
if ! param import
|
2014-01-15 00:02:57 +01:00
|
|
|
then
|
2020-08-26 16:05:56 +02:00
|
|
|
param reset_all
|
2014-01-12 17:43:33 +01:00
|
|
|
fi
|
2020-09-22 15:30:47 -07:00
|
|
|
if ver hwtypecmp V5X00 V5X90 V5Xa0
|
|
|
|
|
then
|
|
|
|
|
netman update -i eth0
|
|
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2016-03-28 14:48:14 +02:00
|
|
|
#
|
2018-07-13 17:05:10 -06:00
|
|
|
# Set AUTOCNF flag to use it in AUTOSTART scripts.
|
2016-03-28 14:48:14 +02:00
|
|
|
#
|
2019-07-16 08:48:25 -06:00
|
|
|
if param greater SYS_AUTOCONFIG 0
|
2016-03-28 14:48:14 +02:00
|
|
|
then
|
2019-07-16 08:48:25 -06:00
|
|
|
if param compare SYS_AUTOCONFIG 1
|
2019-04-02 10:13:56 +02:00
|
|
|
then
|
2021-01-14 13:22:18 +01:00
|
|
|
# Wipe out params except RC*, flight modes, total flight time, calibration parameters, next flight UUID
|
|
|
|
|
param reset_all SYS_AUTO* RC* COM_FLTMODE* LND_FLIGHT* TC_* CAL_ACC* CAL_GYRO* COM_FLIGHT* SYS_PARAM_VER
|
2019-04-02 10:13:56 +02:00
|
|
|
fi
|
2019-07-16 08:48:25 -06:00
|
|
|
|
|
|
|
|
set AUTOCNF yes
|
2018-12-14 12:36:32 -05:00
|
|
|
fi
|
|
|
|
|
|
2019-01-18 10:47:39 -05:00
|
|
|
#
|
|
|
|
|
# Optional board defaults: rc.board_defaults
|
|
|
|
|
#
|
2020-10-14 13:15:02 -07:00
|
|
|
set BOARD_RC_DEFAULTS ${R}etc/init.d/rc.board_defaults
|
2019-01-18 10:47:39 -05:00
|
|
|
if [ -f $BOARD_RC_DEFAULTS ]
|
|
|
|
|
then
|
|
|
|
|
echo "Board defaults: ${BOARD_RC_DEFAULTS}"
|
2020-06-22 13:53:01 -07:00
|
|
|
. $BOARD_RC_DEFAULTS
|
2019-01-18 10:47:39 -05:00
|
|
|
fi
|
|
|
|
|
unset BOARD_RC_DEFAULTS
|
|
|
|
|
|
2020-10-05 21:39:26 -04:00
|
|
|
#
|
|
|
|
|
# Start the tone_alarm driver.
|
|
|
|
|
# Needs to be started after the parameters are loaded (for CBRK_BUZZER).
|
|
|
|
|
#
|
|
|
|
|
tone_alarm start
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Play the startup tune (if not disabled or there is an error)
|
|
|
|
|
#
|
|
|
|
|
param compare CBRK_BUZZER 782090
|
|
|
|
|
if [ $? != 0 -o $STARTUP_TUNE != 1 ]
|
|
|
|
|
then
|
|
|
|
|
tune_control play -t $STARTUP_TUNE
|
|
|
|
|
fi
|
|
|
|
|
|
2018-12-14 12:36:32 -05:00
|
|
|
#
|
|
|
|
|
# Waypoint storage.
|
|
|
|
|
# REBOOTWORK this needs to start in parallel.
|
|
|
|
|
#
|
|
|
|
|
dataman start $DATAMAN_OPT
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Start the socket communication send_event handler.
|
|
|
|
|
#
|
|
|
|
|
send_event start
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Start the resource load monitor.
|
|
|
|
|
#
|
|
|
|
|
load_mon start
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Start system state indicator.
|
|
|
|
|
#
|
2020-08-26 08:46:35 +02:00
|
|
|
rgbled start -X -q
|
|
|
|
|
rgbled_ncp5623c start -X -q
|
2018-12-14 12:36:32 -05:00
|
|
|
|
2020-11-11 01:11:18 -05:00
|
|
|
if param greater -s LIGHT_EN_BLINKM 0
|
2019-03-08 14:40:31 -08:00
|
|
|
then
|
2020-03-10 13:25:37 +01:00
|
|
|
if blinkm start -X
|
2019-09-02 21:55:24 +03:00
|
|
|
then
|
|
|
|
|
blinkm systemstate
|
|
|
|
|
fi
|
2016-03-28 14:48:14 +02:00
|
|
|
fi
|
|
|
|
|
|
2013-08-25 19:27:11 +02:00
|
|
|
#
|
2018-07-13 17:05:10 -06:00
|
|
|
# Set parameters and env variables for selected AUTOSTART.
|
2013-08-25 19:27:11 +02:00
|
|
|
#
|
2018-08-11 10:33:43 +02:00
|
|
|
if ! param compare SYS_AUTOSTART 0
|
2013-10-15 17:54:57 +02:00
|
|
|
then
|
2020-10-14 13:15:02 -07:00
|
|
|
. ${R}etc/init.d/rc.autostart
|
2013-10-15 17:54:57 +02:00
|
|
|
fi
|
|
|
|
|
|
2013-08-25 19:27:11 +02:00
|
|
|
#
|
2018-07-13 17:05:10 -06:00
|
|
|
# Override parameters from user configuration file.
|
2013-08-25 19:27:11 +02:00
|
|
|
#
|
2014-11-17 14:58:29 +01:00
|
|
|
if [ -f $FCONFIG ]
|
2013-12-14 15:08:56 +01:00
|
|
|
then
|
2016-12-23 09:06:49 +01:00
|
|
|
echo "Custom: ${FCONFIG}"
|
2020-06-22 13:53:01 -07:00
|
|
|
. $FCONFIG
|
2013-12-14 15:08:56 +01:00
|
|
|
fi
|
|
|
|
|
|
2014-01-10 23:14:29 +01:00
|
|
|
#
|
2018-07-13 17:05:10 -06:00
|
|
|
# If autoconfig parameter was set, reset it and save parameters.
|
2014-01-10 23:14:29 +01:00
|
|
|
#
|
2018-09-27 11:11:12 +02:00
|
|
|
if [ $AUTOCNF = yes ]
|
2013-08-02 15:47:04 +02:00
|
|
|
then
|
2014-01-10 23:14:29 +01:00
|
|
|
param set SYS_AUTOCONFIG 0
|
2013-12-14 15:08:56 +01:00
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2020-12-28 12:40:45 -05:00
|
|
|
#
|
|
|
|
|
# Set USE_IO flag.
|
|
|
|
|
#
|
|
|
|
|
if param compare -s SYS_USE_IO 1
|
|
|
|
|
then
|
|
|
|
|
set USE_IO yes
|
|
|
|
|
fi
|
|
|
|
|
|
2018-08-03 15:06:00 +02:00
|
|
|
#
|
|
|
|
|
# Check if PX4IO present and update firmware if needed.
|
2018-11-16 12:52:37 -05:00
|
|
|
# Assumption IOFW set to firmware file and IO_PRESENT = no
|
2018-08-03 15:06:00 +02:00
|
|
|
#
|
|
|
|
|
|
2020-12-28 12:40:45 -05:00
|
|
|
if [ -f $IOFW -a $USE_IO = yes ]
|
2018-08-16 14:43:13 -07:00
|
|
|
then
|
2020-12-28 12:40:45 -05:00
|
|
|
if px4io checkcrc ${IOFW}
|
2018-08-03 15:06:00 +02:00
|
|
|
then
|
2020-12-28 12:40:45 -05:00
|
|
|
set IO_PRESENT yes
|
2018-09-26 13:15:31 -07:00
|
|
|
else
|
2020-12-28 12:40:45 -05:00
|
|
|
# tune Program PX4IO
|
|
|
|
|
tune_control play -t 16 # tune 16 = PROG_PX4IO
|
2018-08-16 14:43:13 -07:00
|
|
|
|
2020-12-28 12:40:45 -05:00
|
|
|
if px4io start
|
|
|
|
|
then
|
|
|
|
|
# Try to safety px4 io so motor outputs don't go crazy.
|
|
|
|
|
if ! px4io safety_on
|
2018-08-03 15:06:00 +02:00
|
|
|
then
|
2020-12-28 12:40:45 -05:00
|
|
|
# px4io did not respond to the safety command.
|
|
|
|
|
px4io stop
|
2018-08-03 15:06:00 +02:00
|
|
|
fi
|
2020-12-28 12:40:45 -05:00
|
|
|
fi
|
2018-08-03 15:06:00 +02:00
|
|
|
|
2020-12-28 12:40:45 -05:00
|
|
|
if px4io forceupdate 14662 ${IOFW}
|
|
|
|
|
then
|
|
|
|
|
usleep 10000
|
|
|
|
|
tune_control stop
|
|
|
|
|
if px4io checkcrc ${IOFW}
|
2018-08-03 15:06:00 +02:00
|
|
|
then
|
2020-12-28 12:40:45 -05:00
|
|
|
echo "PX4IO CRC OK after updating"
|
|
|
|
|
tune_control play -t 17 # tune 17 = PROG_PX4IO_OK
|
|
|
|
|
set IO_PRESENT yes
|
2018-08-16 14:43:13 -07:00
|
|
|
fi
|
2020-12-28 12:40:45 -05:00
|
|
|
fi
|
2018-08-03 15:06:00 +02:00
|
|
|
|
2020-12-28 12:40:45 -05:00
|
|
|
if [ $IO_PRESENT = no ]
|
|
|
|
|
then
|
|
|
|
|
echo "PX4IO update failed"
|
|
|
|
|
tune_control play -t 18 # tune 18 = PROG_PX4IO_ERR
|
2018-08-03 15:06:00 +02:00
|
|
|
fi
|
|
|
|
|
fi
|
2014-06-01 10:59:11 +02:00
|
|
|
|
2020-12-28 12:40:45 -05:00
|
|
|
if [ $USE_IO = yes -a $IO_PRESENT = no ]
|
|
|
|
|
then
|
|
|
|
|
echo "PX4IO not found"
|
|
|
|
|
tune_control play error
|
|
|
|
|
fi
|
2018-08-03 15:06:00 +02:00
|
|
|
fi
|
|
|
|
|
|
2019-11-24 13:25:11 -05:00
|
|
|
#
|
|
|
|
|
# RC update (map raw RC input to calibrate manual control)
|
|
|
|
|
# start before commander
|
|
|
|
|
#
|
|
|
|
|
rc_update start
|
|
|
|
|
|
2015-03-08 14:55:51 +01:00
|
|
|
#
|
2018-07-13 17:05:10 -06:00
|
|
|
# Sensors System (start before Commander so Preflight checks are properly run).
|
2018-07-26 18:18:53 -06:00
|
|
|
# Commander needs to be this early for in-air-restarts.
|
2018-07-04 18:46:13 -06:00
|
|
|
#
|
2019-03-18 10:39:56 -04:00
|
|
|
if param greater SYS_HITL 0
|
2017-03-03 17:40:02 +01:00
|
|
|
then
|
2017-09-20 00:04:23 -04:00
|
|
|
set OUTPUT_MODE hil
|
2017-05-05 15:20:49 +02:00
|
|
|
sensors start -h
|
2019-08-16 11:51:04 +02:00
|
|
|
commander start -h
|
2018-09-05 17:01:11 +02:00
|
|
|
# disable GPS
|
|
|
|
|
param set GPS_1_CONFIG 0
|
2018-12-14 12:36:32 -05:00
|
|
|
|
2019-03-18 10:39:56 -04:00
|
|
|
# start the simulator in hardware if needed
|
2019-04-11 10:42:58 +02:00
|
|
|
if param compare SYS_HITL 2
|
2019-04-11 10:38:49 +02:00
|
|
|
then
|
|
|
|
|
sih start
|
|
|
|
|
fi
|
|
|
|
|
|
2017-03-03 17:40:02 +01:00
|
|
|
else
|
2018-12-14 12:36:32 -05:00
|
|
|
#
|
|
|
|
|
# board sensors: rc.sensors
|
|
|
|
|
#
|
2020-10-14 13:15:02 -07:00
|
|
|
set BOARD_RC_SENSORS ${R}etc/init.d/rc.board_sensors
|
2018-12-14 12:36:32 -05:00
|
|
|
if [ -f $BOARD_RC_SENSORS ]
|
|
|
|
|
then
|
|
|
|
|
echo "Board sensors: ${BOARD_RC_SENSORS}"
|
2020-06-22 13:53:01 -07:00
|
|
|
. $BOARD_RC_SENSORS
|
2018-12-14 12:36:32 -05:00
|
|
|
fi
|
|
|
|
|
unset BOARD_RC_SENSORS
|
|
|
|
|
|
2020-10-14 13:15:02 -07:00
|
|
|
. ${R}etc/init.d/rc.sensors
|
2019-11-11 15:35:59 -05:00
|
|
|
|
2020-03-23 09:30:52 +01:00
|
|
|
if param compare -s BAT1_SOURCE 2
|
|
|
|
|
then
|
|
|
|
|
esc_battery start
|
|
|
|
|
fi
|
|
|
|
|
|
2020-04-06 19:09:02 -06:00
|
|
|
if ! param compare BAT1_SOURCE 1
|
|
|
|
|
then
|
|
|
|
|
battery_status start
|
|
|
|
|
fi
|
|
|
|
|
|
2017-09-20 00:04:23 -04:00
|
|
|
commander start
|
2017-03-03 17:40:02 +01:00
|
|
|
fi
|
2018-07-04 18:46:13 -06:00
|
|
|
|
2018-07-13 17:05:10 -06:00
|
|
|
# Sensors on the PWM interface bank.
|
2019-10-07 10:50:12 +03:00
|
|
|
if param compare -s SENS_EN_LL40LS 1
|
2017-04-23 22:53:33 +03:00
|
|
|
then
|
2018-07-13 17:05:10 -06:00
|
|
|
# Clear pins 5 and 6.
|
2017-09-17 08:53:04 -10:00
|
|
|
set FMU_MODE pwm4
|
|
|
|
|
set AUX_MODE pwm4
|
|
|
|
|
fi
|
2018-07-17 21:51:40 -06:00
|
|
|
|
2020-01-06 18:14:06 -07:00
|
|
|
|
|
|
|
|
# Check if ATS is enabled
|
|
|
|
|
if param compare FD_EXT_ATS_EN 1
|
|
|
|
|
then
|
|
|
|
|
# Clear pins 5 and 6.
|
|
|
|
|
set FMU_MODE pwm4
|
|
|
|
|
set AUX_MODE pwm4
|
|
|
|
|
fi
|
|
|
|
|
|
2020-11-11 01:11:18 -05:00
|
|
|
if param greater -s TRIG_MODE 0
|
2017-09-17 08:53:04 -10:00
|
|
|
then
|
2020-08-03 18:11:50 +02:00
|
|
|
# We ONLY support trigger on pins 5+6 or 7+8 when simultanously using AUX for actuator output.
|
2017-09-17 08:53:04 -10:00
|
|
|
if param compare TRIG_PINS 56
|
2017-04-03 18:06:46 +02:00
|
|
|
then
|
|
|
|
|
# clear pins 5 and 6
|
|
|
|
|
set FMU_MODE pwm4
|
|
|
|
|
set AUX_MODE pwm4
|
2017-09-17 08:53:04 -10:00
|
|
|
else
|
2020-08-03 18:11:50 +02:00
|
|
|
if param compare TRIG_PINS 78
|
|
|
|
|
then
|
|
|
|
|
# clear pins 7 and 8
|
|
|
|
|
set FMU_MODE pwm6
|
|
|
|
|
set AUX_MODE pwm6
|
|
|
|
|
else
|
|
|
|
|
set FMU_MODE none
|
|
|
|
|
set AUX_MODE none
|
|
|
|
|
fi
|
2017-04-03 18:06:46 +02:00
|
|
|
fi
|
2017-05-08 12:08:53 +02:00
|
|
|
|
2018-07-17 21:51:40 -06:00
|
|
|
camera_trigger start
|
2017-09-17 08:53:04 -10:00
|
|
|
camera_feedback start
|
2016-10-28 17:19:42 +02:00
|
|
|
fi
|
|
|
|
|
|
2018-07-19 22:32:11 -06:00
|
|
|
#
|
|
|
|
|
# Check if UAVCAN is enabled, default to it for ESCs.
|
|
|
|
|
#
|
2019-10-07 10:50:12 +03:00
|
|
|
if param greater -s UAVCAN_ENABLE 0
|
2018-07-19 22:32:11 -06:00
|
|
|
then
|
|
|
|
|
# Start core UAVCAN module.
|
|
|
|
|
if uavcan start
|
|
|
|
|
then
|
|
|
|
|
if param greater UAVCAN_ENABLE 1
|
|
|
|
|
then
|
|
|
|
|
# Start UAVCAN firmware update server and dynamic node ID allocation server.
|
|
|
|
|
uavcan start fw
|
2020-11-26 17:36:03 +08:00
|
|
|
tune_control play -t 1
|
2018-07-19 22:32:11 -06:00
|
|
|
if param greater UAVCAN_ENABLE 2
|
|
|
|
|
then
|
|
|
|
|
set OUTPUT_MODE uavcan_esc
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
else
|
2020-10-05 21:39:26 -04:00
|
|
|
tune_control play error
|
2018-07-19 22:32:11 -06:00
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2018-07-17 21:51:40 -06:00
|
|
|
#
|
2019-09-19 01:47:32 -07:00
|
|
|
# Optional board mavlink streams: rc.board_mavlink
|
2018-07-17 21:51:40 -06:00
|
|
|
#
|
2020-10-14 13:15:02 -07:00
|
|
|
set BOARD_RC_MAVLINK ${R}etc/init.d/rc.board_mavlink
|
2019-09-19 01:47:32 -07:00
|
|
|
if [ -f $BOARD_RC_MAVLINK ]
|
|
|
|
|
then
|
|
|
|
|
echo "Board extras: ${BOARD_RC_MAVLINK}"
|
2020-06-22 13:53:01 -07:00
|
|
|
. $BOARD_RC_MAVLINK
|
2019-09-19 01:47:32 -07:00
|
|
|
fi
|
|
|
|
|
unset BOARD_RC_MAVLINK
|
2016-04-14 18:14:22 -04:00
|
|
|
|
2018-09-05 17:01:11 +02:00
|
|
|
#
|
|
|
|
|
# Start UART/Serial device drivers.
|
|
|
|
|
# Note: rc.serial is auto-generated from Tools/serial/generate_config.py
|
|
|
|
|
#
|
2020-10-14 13:15:02 -07:00
|
|
|
. ${R}etc/init.d/rc.serial
|
2018-09-05 17:01:11 +02:00
|
|
|
|
2020-03-26 13:53:24 +01:00
|
|
|
if [ $IO_PRESENT = no ]
|
2019-07-05 14:13:58 +02:00
|
|
|
then
|
|
|
|
|
# Must be started after the serial config is read
|
|
|
|
|
rc_input start $RC_INPUT_ARGS
|
|
|
|
|
fi
|
|
|
|
|
|
2014-01-10 23:14:29 +01:00
|
|
|
#
|
2018-07-12 12:50:47 -06:00
|
|
|
# Configure vehicle type specific parameters.
|
|
|
|
|
# Note: rc.vehicle_setup is the entry point for rc.interface,
|
2019-05-02 10:26:42 +02:00
|
|
|
# rc.fw_apps, rc.mc_apps, rc.rover_apps, and rc.vtol_apps.
|
2014-01-10 23:14:29 +01:00
|
|
|
#
|
2020-10-14 13:15:02 -07:00
|
|
|
. ${R}etc/init.d/rc.vehicle_setup
|
2015-02-19 21:50:54 +01:00
|
|
|
|
2018-10-23 10:34:02 +02:00
|
|
|
# Camera capture driver
|
2019-10-07 10:50:12 +03:00
|
|
|
if param greater -s CAM_CAP_FBACK 0
|
2018-10-23 10:34:02 +02:00
|
|
|
then
|
|
|
|
|
if camera_capture start
|
|
|
|
|
then
|
|
|
|
|
camera_capture on
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2014-05-13 08:03:01 +02:00
|
|
|
#
|
2018-07-10 19:37:05 -06:00
|
|
|
# Start the navigator.
|
2014-05-13 08:03:01 +02:00
|
|
|
#
|
|
|
|
|
navigator start
|
|
|
|
|
|
2017-02-02 20:34:15 +11:00
|
|
|
#
|
2018-07-04 18:46:13 -06:00
|
|
|
# Start a thermal calibration if required.
|
2017-02-02 20:34:15 +11:00
|
|
|
#
|
2020-10-14 13:15:02 -07:00
|
|
|
. ${R}etc/init.d/rc.thermal_cal
|
2017-02-02 20:34:15 +11:00
|
|
|
|
2018-07-18 11:39:45 -06:00
|
|
|
#
|
|
|
|
|
# Start vmount to control mounts such as gimbals, disabled by default.
|
|
|
|
|
#
|
2020-11-11 01:11:18 -05:00
|
|
|
if param greater -s MNT_MODE_IN -1
|
2018-07-18 11:39:45 -06:00
|
|
|
then
|
2018-08-11 10:33:43 +02:00
|
|
|
vmount start
|
2018-07-18 11:39:45 -06:00
|
|
|
fi
|
|
|
|
|
|
2020-03-11 18:49:18 +01:00
|
|
|
# Check for flow sensor
|
2020-11-11 01:11:18 -05:00
|
|
|
if param compare -s SENS_EN_PX4FLOW 1
|
2019-08-05 15:48:24 -04:00
|
|
|
then
|
2020-03-11 18:49:18 +01:00
|
|
|
px4flow start -X
|
2019-08-05 15:48:24 -04:00
|
|
|
fi
|
2019-03-27 10:43:01 +01:00
|
|
|
|
2019-07-08 23:30:22 +03:00
|
|
|
# Blacksheep telemetry
|
2020-11-11 01:11:18 -05:00
|
|
|
if param compare -s TEL_BST_EN 1
|
2019-07-08 23:30:22 +03:00
|
|
|
then
|
2020-03-11 18:54:40 +01:00
|
|
|
bst start -X
|
2019-07-08 23:30:22 +03:00
|
|
|
fi
|
|
|
|
|
|
2020-11-11 01:11:18 -05:00
|
|
|
if param compare -s IMU_GYRO_FFT_EN 1
|
2020-10-25 23:48:21 -04:00
|
|
|
then
|
|
|
|
|
gyro_fft start
|
|
|
|
|
fi
|
|
|
|
|
|
2018-07-10 19:37:05 -06:00
|
|
|
#
|
2018-12-14 12:36:32 -05:00
|
|
|
# Optional board supplied extras: rc.board_extras
|
|
|
|
|
#
|
2020-10-14 13:15:02 -07:00
|
|
|
set BOARD_RC_EXTRAS ${R}etc/init.d/rc.board_extras
|
2018-12-14 12:36:32 -05:00
|
|
|
if [ -f $BOARD_RC_EXTRAS ]
|
|
|
|
|
then
|
|
|
|
|
echo "Board extras: ${BOARD_RC_EXTRAS}"
|
2020-06-22 13:53:01 -07:00
|
|
|
. $BOARD_RC_EXTRAS
|
2018-12-14 12:36:32 -05:00
|
|
|
fi
|
|
|
|
|
unset BOARD_RC_EXTRAS
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Start any custom addons from the sdcard.
|
2018-07-10 19:37:05 -06:00
|
|
|
#
|
2018-07-17 21:51:40 -06:00
|
|
|
if [ -f $FEXTRAS ]
|
|
|
|
|
then
|
|
|
|
|
echo "Addons script: ${FEXTRAS}"
|
2020-06-22 13:53:01 -07:00
|
|
|
. $FEXTRAS
|
2018-07-17 21:51:40 -06:00
|
|
|
fi
|
2018-12-14 12:36:32 -05:00
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Start the logger.
|
|
|
|
|
#
|
2020-10-14 13:15:02 -07:00
|
|
|
. ${R}etc/init.d/rc.logging
|
2018-12-14 12:36:32 -05:00
|
|
|
|
2019-07-20 20:09:42 +02:00
|
|
|
#
|
|
|
|
|
# Set additional parameters and env variables for selected AUTOSTART.
|
|
|
|
|
#
|
|
|
|
|
if ! param compare SYS_AUTOSTART 0
|
|
|
|
|
then
|
2020-10-14 13:15:02 -07:00
|
|
|
. ${R}etc/init.d/rc.autostart.post
|
2019-07-20 20:09:42 +02:00
|
|
|
fi
|
2019-04-02 10:13:56 +02:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
2018-07-26 18:18:53 -06:00
|
|
|
#
|
2018-07-10 19:37:05 -06:00
|
|
|
# End of autostart.
|
2018-07-26 18:18:53 -06:00
|
|
|
#
|
2015-08-08 00:10:01 +02:00
|
|
|
fi
|
2015-07-22 10:04:13 +02:00
|
|
|
|
2018-07-26 18:18:53 -06:00
|
|
|
#
|
|
|
|
|
# Unset all script parameters to free RAM.
|
|
|
|
|
#
|
2020-10-14 13:15:02 -07:00
|
|
|
unset R
|
2018-12-14 12:36:32 -05:00
|
|
|
unset AUTOCNF
|
2018-07-04 18:46:13 -06:00
|
|
|
unset AUX_MODE
|
|
|
|
|
unset DATAMAN_OPT
|
|
|
|
|
unset FCONFIG
|
|
|
|
|
unset FEXTRAS
|
|
|
|
|
unset FMU_MODE
|
2018-12-14 12:36:32 -05:00
|
|
|
unset FRC
|
2018-07-04 18:46:13 -06:00
|
|
|
unset IO_PRESENT
|
2018-12-14 12:36:32 -05:00
|
|
|
unset IOFW
|
2018-11-30 14:32:50 -05:00
|
|
|
unset LOGGER_ARGS
|
2018-11-30 13:46:41 -05:00
|
|
|
unset LOGGER_BUF
|
2018-07-04 18:46:13 -06:00
|
|
|
unset MAV_TYPE
|
|
|
|
|
unset MIXER
|
|
|
|
|
unset MIXER_AUX
|
2018-08-11 17:59:24 +02:00
|
|
|
unset MIXER_FILE
|
2018-07-04 18:46:13 -06:00
|
|
|
unset MK_MODE
|
|
|
|
|
unset MKBLCTRL_ARG
|
|
|
|
|
unset OUTPUT_MODE
|
2019-04-02 10:13:56 +02:00
|
|
|
unset PARAM_DEFAULTS_VER
|
2018-07-04 18:46:13 -06:00
|
|
|
unset PARAM_FILE
|
2018-07-17 04:24:02 -06:00
|
|
|
unset PWM_AUX_DISARMED
|
|
|
|
|
unset PWM_AUX_MAX
|
|
|
|
|
unset PWM_AUX_MIN
|
|
|
|
|
unset PWM_AUX_OUT
|
|
|
|
|
unset PWM_AUX_RATE
|
2018-07-04 18:46:13 -06:00
|
|
|
unset PWM_DISARMED
|
|
|
|
|
unset PWM_MAX
|
2018-07-17 04:24:02 -06:00
|
|
|
unset PWM_MIN
|
2018-12-14 12:36:32 -05:00
|
|
|
unset PWM_OUT
|
|
|
|
|
unset PWM_RATE
|
2019-07-05 14:13:58 +02:00
|
|
|
unset RC_INPUT_ARGS
|
2018-08-11 10:54:44 +02:00
|
|
|
unset SDCARD_MIXERS_PATH
|
2019-07-06 17:24:22 +02:00
|
|
|
unset STARTUP_TUNE
|
2018-07-04 18:46:13 -06:00
|
|
|
unset USE_IO
|
|
|
|
|
unset VEHICLE_TYPE
|
|
|
|
|
|
2018-07-26 18:18:53 -06:00
|
|
|
#
|
2018-07-13 17:05:10 -06:00
|
|
|
# Boot is complete, inform MAVLink app(s) that the system is now fully up and running.
|
2018-07-26 18:18:53 -06:00
|
|
|
#
|
2015-08-08 00:10:01 +02:00
|
|
|
mavlink boot_complete
|