HAL_PX4: perform automatic update of px4io firmware

This commit is contained in:
Andrew Tridgell 2013-02-18 13:55:58 +11:00
parent 8e2a20bea8
commit 8041768c67
1 changed files with 45 additions and 17 deletions

View File

@ -2,17 +2,26 @@
# APM startup script for NuttX on PX4 # APM startup script for NuttX on PX4
# To disable APM startup add a /fs/microsd/APM/nostart file
# To disable use of a PX4IO board add a file /fs/microsd/APM/fmu_only
set deviceA /dev/ttyACM0
set deviceC /dev/ttyS1
if [ -f /fs/microsd/APM/nostart ] if [ -f /fs/microsd/APM/nostart ]
then then
echo "APM/nostart found - skipping" echo "APM/nostart found - skipping"
else else
uorb start
# mount binfs so we can find the built-in apps # mount binfs so we can find the built-in apps
mount -t binfs /dev/null /bin if [ -f /bin/reboot ]
then
echo "binfs already mounted"
else
echo "Mounting binfs"
mount -t binfs /dev/null /bin
fi
set device /dev/ttyS1
set sketch NONE set sketch NONE
if [ -f /bin/ArduPlane ] if [ -f /bin/ArduPlane ]
@ -32,40 +41,59 @@ fi
if [ $sketch != NONE ] if [ $sketch != NONE ]
then then
if [ -f /fs/microsd/px4io.bin ]
then
echo "Checking for new px4io firmware"
if cmp /fs/microsd/px4io.bin /fs/microsd/px4io.bin.loaded
then
echo "No new px4io firmware"
else
echo "Loading /fs/microsd/px4io.bin"
px4io update /fs/microsd/px4io.bin > /fs/microsd/APM/px4io_update.log
cp /fs/microsd/px4io.bin /fs/microsd/px4io.bin.loaded
echo "Loaded /fs/microsd/px4io.bin OK" >> /fs/microsd/APM/px4io_update.log
fi
fi
echo "Starting APM sensors" echo "Starting APM sensors"
uorb start
mpu6000 start mpu6000 start
ms5611 start ms5611 start
hmc5883 start hmc5883 start
adc start adc start
echo Trying PX4IO start if [ -f /fs/microsd/APM/fmu_only ]
if px4io start
then then
echo Setting up PX4IO board echo "Setting up PX4FMU direct mode"
echo Loading FMU_pass mixer
mixer load /dev/pwm_output /etc/mixers/FMU_pass.mix
echo Setting FMU mode_serial
fmu mode_serial
else
echo Setting up PX4FMU direct mode
fmu start mode_pwm fmu start mode_pwm
if [ $device == /dev/ttyS1 ] if [ $deviceC == /dev/ttyS1 ]
then then
# ttyS1 is used for PWM output when there # ttyS1 is used for PWM output when there
# is no IO board # is no IO board
set device /dev/ttyS2 set deviceC /dev/ttyS2
fi fi
else
echo "Setting up PX4IO board"
px4io start
echo "Loading FMU_pass mixer"
mixer load /dev/pwm_output /etc/mixers/FMU_pass.mix
echo "Setting FMU mode_serial"
fmu mode_serial
fi fi
echo Starting $sketch echo Starting $sketch
$sketch -d $device start $sketch -d $deviceA -d2 $deviceC start
# if starting on the console, tell nsh to exit # if starting on the console, tell nsh to exit
# this prevents it from chewing bytes # this prevents it from chewing bytes
if [ $device == /dev/ttyS0 ] if [ $deviceC == /dev/ttyS0 ]
then then
echo "Exiting from nsh shell"
exit exit
fi fi
else else
echo "No APM sketch found" echo "No APM sketch found"
fi fi
fi fi
echo "rc.APM finished"