Skip to content

Commit f4a85fa

Browse files
ThomasDebrunnerdagar
authored andcommitted
rcS: Allow startup files to be located on SD card
1 parent 6daa579 commit f4a85fa

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
#
3+
# External airframe startup script (on SD card)
4+
#
5+
set SDCARD_MIXERS_PATH ${SDCARD_EXT_PATH}/mixers
6+
7+
if [ -e ${SDCARD_EXT_PATH}/rc.autostart ]
8+
then
9+
. ${SDCARD_EXT_PATH}/rc.autostart
10+
else
11+
echo "Error: ${SDCARD_EXT_PATH}/rc.autostart does not exist"
12+
fi

ROMFS/px4fmu_common/init.d/rcS

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ set PWM_EXTRA_OUT none
4444
set PWM_EXTRA_RATE p:PWM_EXTRA_RATE
4545
set EXTRA_MIXER_MODE none
4646
set RC_INPUT_ARGS ""
47+
set SDCARD_AVAILABLE no
48+
set SDCARD_EXT_PATH /fs/microsd/ext_autostart
4749
set SDCARD_MIXERS_PATH /fs/microsd/etc/mixers
4850
set STARTUP_TUNE 1
4951
set USE_IO no
@@ -57,7 +59,6 @@ ver all
5759
#
5860
# Try to mount the microSD card.
5961
#
60-
set SDCARD_AVAILABLE no
6162
# REBOOTWORK this needs to start after the flight control loop.
6263
if mount -t vfat /dev/mmcsd0 /fs/microsd
6364
then
@@ -104,7 +105,6 @@ then
104105
fi
105106
fi
106107
fi
107-
unset SDCARD_AVAILABLE
108108

109109
#
110110
# Look for an init script on the microSD card.
@@ -206,10 +206,22 @@ else
206206
#
207207
# Set parameters and env variables for selected AUTOSTART.
208208
#
209+
set AUTOSTART_PATH etc/init.d/rc.autostart
209210
if ! param compare SYS_AUTOSTART 0
210211
then
211-
. ${R}etc/init.d/rc.autostart
212+
if param greater SYS_AUTOSTART 1000000
213+
then
214+
# Use external startup file
215+
if [ $SDCARD_AVAILABLE = yes ]
216+
then
217+
set AUTOSTART_PATH etc/init.d/rc.autostart_ext
218+
else
219+
echo "ERROR [init] SD card not mounted - trying to load airframe from ROMFS"
220+
fi
221+
fi
222+
. ${R}$AUTOSTART_PATH
212223
fi
224+
unset AUTOSTART_PATH
213225

214226
#
215227
# Override parameters from user configuration file.
@@ -540,6 +552,8 @@ unset PWM_OUT
540552
unset PWM_EXTRA_OUT
541553
unset PWM_EXTRA_RATE
542554
unset RC_INPUT_ARGS
555+
unset SDCARD_AVAILABLE
556+
unset SDCARD_EXT_PATH
543557
unset SDCARD_MIXERS_PATH
544558
unset STARTUP_TUNE
545559
unset USE_IO

0 commit comments

Comments
 (0)