px4-firmware/ROMFS/px4fmu_test/init.d/rcS

155 lines
2.6 KiB
Plaintext
Raw Normal View History

#!nsh
#
# PX4FMU startup script for test hackery.
#
2015-02-05 07:44:16 -04:00
set unit_test_failure 0
2014-01-04 12:05:52 -04:00
uorb start
2013-12-20 09:25:35 -04:00
if sercon
then
echo "[i] USB interface connected"
2013-12-20 09:25:35 -04:00
# Try to get an USB console
nshterm /dev/ttyACM0 &
fi
#
# Try to mount the microSD card.
#
2015-02-08 11:44:10 -04:00
mount -t vfat /dev/mmcsd0 /fs/microsd
if [ $? == 0 ]
then
echo "[i] card mounted at /fs/microsd"
# Start playing the startup tune
tone_alarm start
else
echo "[i] no microSD card found"
# Play SOS
tone_alarm error
fi
2014-01-04 12:05:52 -04:00
#
# Start a minimal system
#
if [ -f /etc/extras/px4io-v2_default.bin ]
then
set io_file /etc/extras/px4io-v2_default.bin
else
set io_file /etc/extras/px4io-v1_default.bin
fi
2015-02-08 11:44:10 -04:00
px4io start
if [ $? == 0 ]
2014-01-04 12:05:52 -04:00
then
echo "PX4IO OK"
2015-02-05 07:44:16 -04:00
else
set unit_test_failure 1
set unit_test_failure_list "${unit_test_failure_list} px4io_start"
2014-01-04 12:05:52 -04:00
fi
2015-02-08 11:44:10 -04:00
px4io checkcrc $io_file
if [ $? == 0 ]
2014-01-04 12:05:52 -04:00
then
echo "PX4IO CRC OK"
else
echo "PX4IO CRC failure"
tone_alarm MBABGP
if px4io forceupdate 14662 $io_file
then
if px4io start
then
echo "PX4IO restart OK"
tone_alarm MSPAA
else
echo "PX4IO restart failed"
tone_alarm MNGGG
2015-02-05 07:44:16 -04:00
set unit_test_failure 1
set unit_test_failure_list "${unit_test_failure_list} px4io_flash"
2014-01-04 12:05:52 -04:00
fi
else
echo "PX4IO update failed"
tone_alarm MNGGG
2015-02-05 07:44:16 -04:00
set unit_test_failure 1
set unit_test_failure_list "${unit_test_failure_list} px4io_flash"
2014-01-04 12:05:52 -04:00
fi
fi
#
# The presence of this file suggests we're running a mount stress test
#
2014-01-04 12:05:52 -04:00
if [ -f /fs/microsd/mount_test_cmds.txt ]
then
tests mount
fi
2014-09-13 23:59:44 -03:00
#
# Run unit tests at board boot, reporting failure as needed.
# Add new unit tests using the same pattern as below.
#
2015-02-08 11:44:10 -04:00
mavlink_tests
if [ $? != 0 ]
2014-09-13 23:59:44 -03:00
then
set unit_test_failure 1
set unit_test_failure_list "${unit_test_failure_list} mavlink_tests"
fi
2015-02-08 11:44:10 -04:00
commander_tests
if [ $? != 0 ]
2014-09-13 23:59:44 -03:00
then
set unit_test_failure 1
set unit_test_failure_list "${unit_test_failure_list} commander_tests"
fi
2015-02-08 11:44:10 -04:00
uorb test
if [ $? != 0 ]
then
set unit_test_failure 1
set unit_test_failure_list "${unit_test_failure_list} uorb_tests"
fi
2015-02-08 11:44:10 -04:00
adc start
2015-02-08 18:08:06 -04:00
# XXX this syntax is not quite right, but if takes no flags (yet)
2015-02-08 18:24:50 -04:00
if hmc5883 -I -S start
then
fi
if [ $? != 0 ]
2015-01-03 12:47:58 -04:00
then
2015-02-08 11:44:10 -04:00
# This is an FMUv1 or FMUv2
echo "FMUv2 (or FMUv3 where 'hmc5883 -I -S start' failed)"
2015-01-03 12:47:58 -04:00
ms5611 start
2015-02-08 11:44:10 -04:00
mpu6000 start
lsm303d start
l3gd20 start
else
# This is a FMUv3
echo "FMUv3"
2015-01-03 12:47:58 -04:00
mpu6000 -X start
mpu6000 start
lsm303d -X start
l3gd20 -X start
ms5611 start
2015-02-08 11:44:10 -04:00
fi
2015-02-08 18:24:50 -04:00
if tests all
then
fi
2015-02-08 11:44:10 -04:00
if [ $? != 0 ]
then
set unit_test_failure 1
set unit_test_failure_list "${unit_test_failure_list} system_tests"
2015-01-03 12:47:58 -04:00
fi
2014-09-13 23:59:44 -03:00
if [ $unit_test_failure == 0 ]
then
echo
echo "All Unit Tests PASSED"
else
echo
echo "Some Unit Tests FAILED:${unit_test_failure_list}"
fi
2015-02-08 11:44:10 -04:00
ver all