aboutsummaryrefslogtreecommitdiff
path: root/ROMFS/px4fmu_test/init.d/rcS
blob: 6d72ecc6c74c9122c459d9a10672496e8299dde4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#!nsh
#
# PX4FMU startup script for test hackery.
#
set unit_test_failure 0

uorb start

if rgbled start
then
	rgbled rgb 20 20 255
fi

if sercon
then
	echo "[i] USB interface connected"

	# Try to get an USB console
	nshterm /dev/ttyACM0 &
fi

#
# Try to mount the microSD card.
#
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

#
# Start a minimal system
#

#
# Load parameters
#
set PARAM_FILE /fs/microsd/params
if mtd start
then
	set PARAM_FILE /fs/mtd_params
fi

param select $PARAM_FILE
if param load
then
	echo "[param] Loaded: $PARAM_FILE"
else
	echo "[param] FAILED loading $PARAM_FILE"
fi

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

if px4io start
then
	echo "PX4IO OK"
else
	set unit_test_failure 1
	set unit_test_failure_list "${unit_test_failure_list} px4io_start"
fi

if px4io checkcrc $io_file
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
			set unit_test_failure 1
			set unit_test_failure_list "${unit_test_failure_list} px4io_flash"
		fi
	else
		echo "PX4IO update failed"
		tone_alarm MNGGG
		set unit_test_failure 1
		set unit_test_failure_list "${unit_test_failure_list} px4io_flash"
	fi
fi

#
# The presence of this file suggests we're running a mount stress test
#
if [ -f /fs/microsd/mount_test_cmds.txt ]
then
	tests mount
fi

#
# Run unit tests at board boot, reporting failure as needed.
# Add new unit tests using the same pattern as below.
#

if mavlink_tests
then
else
	set unit_test_failure 1
	set unit_test_failure_list "${unit_test_failure_list} mavlink_tests"
fi

if commander_tests
then
else
	set unit_test_failure 1
	set unit_test_failure_list "${unit_test_failure_list} commander_tests"
fi

if uorb test
then
else
	set unit_test_failure 1
	set unit_test_failure_list "${unit_test_failure_list} uorb_tests"
fi

# Start all sensors on all boards
ms5611 start
adc start

if mpu6000 -X start
then
fi

if mpu6000 start
then
fi

if l3gd20 -X start
then
fi

if l3gd20 start
then
fi

# MAG selection
if param compare SENS_EXT_MAG 2
then
	if hmc5883 -I start
	then
	fi
else
	# Use only external as primary
	if param compare SENS_EXT_MAG 1
	then
		if hmc5883 -X start
		then
		fi
	else
	# auto-detect the primary, prefer external
		if hmc5883 start
		then
		fi
	fi
fi

if ver hwcmp PX4FMU_V2
then
	if lsm303d -X start
	then
	fi

	if lsm303d start
	then
	fi

	if ms5611 -X start
	then
	fi
fi

if meas_airspeed start
then
else
	if ets_airspeed start
	then
	else
		if ets_airspeed start -b 1
		then
		fi
	fi
fi

if sensors start
then
fi

# Check for flow sensor
if px4flow start
then
fi

if ll40ls start
then
fi

if tests all
then
else
	set unit_test_failure 1
	set unit_test_failure_list "${unit_test_failure_list} system_tests"
fi

if [ $unit_test_failure == 0 ]
then
	echo
	echo "All Unit Tests PASSED"
	rgbled rgb 20 255 20
else
	echo
	echo "Some Unit Tests FAILED:${unit_test_failure_list}"
	rgbled rgb 255 20 20
fi

ver all

free