2018-12-18 09:26:22 +01:00
|
|
|
#!/bin/sh
|
2013-07-07 12:13:40 -07:00
|
|
|
#
|
|
|
|
|
# PX4FMU startup script for test hackery.
|
|
|
|
|
#
|
2018-04-07 21:45:09 -04:00
|
|
|
set +e
|
2020-10-14 13:15:02 -07:00
|
|
|
set R /
|
2015-02-05 12:44:16 +01:00
|
|
|
set unit_test_failure 0
|
|
|
|
|
|
2020-10-14 13:15:02 -07:00
|
|
|
set BOARD_RC ${R}etc/init.d/rc.board
|
2018-11-30 14:13:54 -05:00
|
|
|
|
2020-03-10 13:25:37 +01:00
|
|
|
if rgbled start -X
|
2015-02-21 12:45:50 +01:00
|
|
|
then
|
2017-02-24 10:22:43 +01:00
|
|
|
led_control on -c blue
|
2015-02-21 12:45:50 +01:00
|
|
|
fi
|
|
|
|
|
|
2013-12-20 14:25:35 +01:00
|
|
|
if sercon
|
|
|
|
|
then
|
2014-12-14 11:28:25 +01:00
|
|
|
echo "[i] USB interface connected"
|
2013-12-20 14:25:35 +01:00
|
|
|
|
|
|
|
|
# Try to get an USB console
|
|
|
|
|
nshterm /dev/ttyACM0 &
|
2014-01-04 13:54:14 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Try to mount the microSD card.
|
|
|
|
|
#
|
2015-02-08 16:44:10 +01:00
|
|
|
mount -t vfat /dev/mmcsd0 /fs/microsd
|
2018-09-27 11:11:12 +02:00
|
|
|
if [ $? = 0 ]
|
2014-01-04 13:54:14 +01:00
|
|
|
then
|
2014-12-14 11:28:25 +01:00
|
|
|
echo "[i] card mounted at /fs/microsd"
|
2014-01-04 13:54:14 +01:00
|
|
|
# Start playing the startup tune
|
2020-10-05 21:39:26 -04:00
|
|
|
tune_control play -t 1 # tune 1 = STARTUP
|
2014-01-04 13:54:14 +01:00
|
|
|
else
|
2014-12-14 11:28:25 +01:00
|
|
|
echo "[i] no microSD card found"
|
2020-10-05 21:39:26 -04:00
|
|
|
tune_control play error
|
2014-01-04 13:54:14 +01:00
|
|
|
fi
|
|
|
|
|
|
2014-01-04 17:05:52 +01:00
|
|
|
#
|
|
|
|
|
# Start a minimal system
|
|
|
|
|
#
|
|
|
|
|
|
2015-02-09 18:42:52 +01:00
|
|
|
#
|
|
|
|
|
# Load parameters
|
|
|
|
|
#
|
|
|
|
|
set PARAM_FILE /fs/microsd/params
|
|
|
|
|
if mtd start
|
|
|
|
|
then
|
|
|
|
|
set PARAM_FILE /fs/mtd_params
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
param select $PARAM_FILE
|
2015-02-09 23:27:10 +01:00
|
|
|
if param load
|
|
|
|
|
then
|
|
|
|
|
echo "[param] Loaded: $PARAM_FILE"
|
|
|
|
|
else
|
|
|
|
|
echo "[param] FAILED loading $PARAM_FILE"
|
|
|
|
|
fi
|
2015-02-09 18:42:52 +01:00
|
|
|
|
2018-11-30 14:13:54 -05:00
|
|
|
#
|
|
|
|
|
# run boards rc.board if available
|
|
|
|
|
#
|
|
|
|
|
if [ -f $BOARD_RC ]
|
|
|
|
|
then
|
|
|
|
|
echo "Board init: ${BOARD_RC}"
|
2020-06-22 13:53:01 -07:00
|
|
|
. $BOARD_RC
|
2018-11-30 14:13:54 -05:00
|
|
|
fi
|
|
|
|
|
|
2018-11-22 03:48:19 -08:00
|
|
|
if [ -f /etc/extras/px4_io-v2_default.bin ]
|
2014-01-04 17:05:52 +01:00
|
|
|
then
|
2018-11-22 03:48:19 -08:00
|
|
|
set io_file /etc/extras/px4_io-v2_default.bin
|
2014-01-04 17:05:52 +01:00
|
|
|
fi
|
|
|
|
|
|
2015-02-09 17:15:28 +01:00
|
|
|
if px4io start
|
2014-01-04 17:05:52 +01:00
|
|
|
then
|
|
|
|
|
echo "PX4IO OK"
|
2015-02-05 12:44:16 +01:00
|
|
|
else
|
|
|
|
|
set unit_test_failure 1
|
|
|
|
|
set unit_test_failure_list "${unit_test_failure_list} px4io_start"
|
2014-01-04 17:05:52 +01:00
|
|
|
fi
|
|
|
|
|
|
2015-02-09 17:15:28 +01:00
|
|
|
if px4io checkcrc $io_file
|
2014-01-04 17:05:52 +01:00
|
|
|
then
|
|
|
|
|
echo "PX4IO CRC OK"
|
|
|
|
|
else
|
|
|
|
|
echo "PX4IO CRC failure"
|
2020-10-05 21:39:26 -04:00
|
|
|
tune_control play -t 16 # tune 16 = PROG_PX4IO
|
2021-02-21 22:39:52 +01:00
|
|
|
if px4io update $io_file
|
2014-01-04 17:05:52 +01:00
|
|
|
then
|
|
|
|
|
if px4io start
|
|
|
|
|
then
|
|
|
|
|
echo "PX4IO restart OK"
|
2020-10-05 21:39:26 -04:00
|
|
|
tune_control play-t 17 # tune 17 = PROG_PX4IO_OK
|
2014-01-04 17:05:52 +01:00
|
|
|
else
|
|
|
|
|
echo "PX4IO restart failed"
|
2020-10-05 21:39:26 -04:00
|
|
|
tune_control play -t 18 # tune 18 = PROG_PX4IO_ERR
|
2015-02-05 12:44:16 +01:00
|
|
|
set unit_test_failure 1
|
|
|
|
|
set unit_test_failure_list "${unit_test_failure_list} px4io_flash"
|
2014-01-04 17:05:52 +01:00
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
echo "PX4IO update failed"
|
2020-10-05 21:39:26 -04:00
|
|
|
tune_control play -t 18 # tune 18 = PROG_PX4IO_ERR
|
2015-02-05 12:44:16 +01:00
|
|
|
set unit_test_failure 1
|
|
|
|
|
set unit_test_failure_list "${unit_test_failure_list} px4io_flash"
|
2014-01-04 17:05:52 +01:00
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2014-01-04 13:54:14 +01:00
|
|
|
#
|
|
|
|
|
# The presence of this file suggests we're running a mount stress test
|
|
|
|
|
#
|
2014-01-04 17:05:52 +01:00
|
|
|
if [ -f /fs/microsd/mount_test_cmds.txt ]
|
2014-01-04 13:54:14 +01:00
|
|
|
then
|
|
|
|
|
tests mount
|
|
|
|
|
fi
|
2014-09-13 19:59:44 -07:00
|
|
|
|
2020-10-14 13:15:02 -07:00
|
|
|
. ${R}etc/init.d/rc.sensors
|
2016-04-24 13:26:27 -04:00
|
|
|
|
2016-07-29 13:27:58 +02:00
|
|
|
ver all
|
2016-04-24 13:26:27 -04:00
|
|
|
|
2014-09-13 19:59:44 -07:00
|
|
|
#
|
|
|
|
|
# Run unit tests at board boot, reporting failure as needed.
|
|
|
|
|
# Add new unit tests using the same pattern as below.
|
|
|
|
|
#
|
|
|
|
|
|
2015-02-08 23:24:50 +01:00
|
|
|
if tests all
|
2014-09-13 19:59:44 -07:00
|
|
|
then
|
|
|
|
|
echo
|
|
|
|
|
echo "All Unit Tests PASSED"
|
2017-02-24 10:22:43 +01:00
|
|
|
led_control on -c green
|
2014-09-13 19:59:44 -07:00
|
|
|
else
|
|
|
|
|
echo
|
2016-07-29 13:27:58 +02:00
|
|
|
echo "Some Unit Tests FAILED"
|
2017-02-24 10:22:43 +01:00
|
|
|
led_control on -c red
|
2014-12-14 11:28:25 +01:00
|
|
|
fi
|
2015-02-08 16:44:10 +01:00
|
|
|
|
2015-03-08 08:35:10 +01:00
|
|
|
free
|