Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROMFS split rc.board into defaults, sensors, and extras #11044

Merged
merged 2 commits into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions ROMFS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,32 @@ if(config_bl_file)
)
endif()

if(EXISTS "${PX4_BOARD_DIR}/init/rc.board")
add_custom_command(OUTPUT ${romfs_gen_root_dir}/init.d/rc.board
COMMAND ${CMAKE_COMMAND} -E copy ${PX4_BOARD_DIR}/init/rc.board ${romfs_gen_root_dir}/init.d/rc.board
DEPENDS
${PX4_BOARD_DIR}/init/rc.board
${romfs_gen_root_dir}/init.d/rcS
COMMENT "ROMFS: copying rc.board"
set(OPTIONAL_BOARD_RC)
list(APPEND OPTIONAL_BOARD_RC
rc.board_defaults
rc.board_sensors
rc.board_extras
)

foreach(board_rc_file ${OPTIONAL_BOARD_RC})

if(EXISTS "${PX4_BOARD_DIR}/init/${board_rc_file}")
message(STATUS "ROMFS: Adding ${board_rc_file}")

add_custom_command(OUTPUT ${romfs_gen_root_dir}/init.d/${board_rc_file}
COMMAND ${CMAKE_COMMAND} -E copy ${PX4_BOARD_DIR}/init/${board_rc_file} ${romfs_gen_root_dir}/init.d/${board_rc_file}
DEPENDS
${PX4_BOARD_DIR}/init/${board_rc_file}
${romfs_gen_root_dir}/init.d/rcS
COMMENT "ROMFS: copying ${board_rc_file}"
)

list(APPEND extras_dependencies
${romfs_gen_root_dir}/init.d/rc.board
)
endif()
list(APPEND extras_dependencies
${romfs_gen_root_dir}/init.d/${board_rc_file}
)
endif()

endforeach()

add_custom_command(OUTPUT romfs_extras.stamp
COMMAND ${CMAKE_COMMAND} -E make_directory ${romfs_gen_root_dir}/extras/
Expand Down
2 changes: 0 additions & 2 deletions ROMFS/px4fmu_common/init.d/airframes/4900_crazyflie
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ then

param set SENS_FLOW_MINRNG 0.05

param set SYS_FMU_TASK 1

fi

set PWM_DISARMED none
Expand Down
149 changes: 80 additions & 69 deletions ROMFS/px4fmu_common/init.d/rcS
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ set +e
# it wastes flash
#
set AUX_MODE pwm
set BOARD_RC /etc/init.d/rc.board
set DATAMAN_OPT ""
set FAILSAFE none
set FAILSAFE_AUX none
set FCONFIG /fs/microsd/etc/config.txt
set FEXTRAS /fs/microsd/etc/extras.txt
set FRC /fs/microsd/etc/rc.txt
set FMU_ARGS ""
set FMU_MODE pwm
set FRC /fs/microsd/etc/rc.txt
set IO_PRESENT no
set IOFW "/etc/extras/px4_io-v2_default.bin"
set IO_PRESENT no
set LOG_FILE /fs/microsd/bootlog.txt
Expand Down Expand Up @@ -134,22 +134,6 @@ if [ -f $FRC ]
then
sh $FRC
else
#
# Waypoint storage.
# REBOOTWORK this needs to start in parallel.
#
# TODO: fix board override $DATAMAN_OPT
dataman start $DATAMAN_OPT

#
# Start the socket communication send_event handler.
#
send_event start

#
# Start the resource load monitor.
#
load_mon start

#
# Set the parameter file if mtd starts successfully.
Expand All @@ -169,67 +153,69 @@ else
fi

#
# Start the tone_alarm driver.
# Needs to be started after the parameters are loaded (for CBRK_BUZZER).
# Note that this will still play the already published startup tone.
#
tone_alarm start

#
# Start system state indicator.
# Optional board defaults: rc.board_defaults
#
if ! rgbled start
set BOARD_RC_DEFAULTS /etc/init.d/rc.board_defaults
if [ -f $BOARD_RC_DEFAULTS ]
then
if blinkm start
then
blinkm systemstate
fi
echo "Board defaults: ${BOARD_RC_DEFAULTS}"
sh $BOARD_RC_DEFAULTS
fi

rgbled_ncp5623c start

#
# FMUv5 may have both PWM I2C RGB LED support.
#
rgbled_pwm start
unset BOARD_RC_DEFAULTS

#
# Set AUTOCNF flag to use it in AUTOSTART scripts.
#
if param compare SYS_AUTOCONFIG 1
then
# Wipe out params except RC*, flight modes and total flight time.
# Wipe out params except RC*, flight modes, total flight time, accel cal, gyro cal
param reset_nostart RC* COM_FLTMODE* LND_FLIGHT_T_* TC_* CAL_ACC* CAL_GYRO*
set AUTOCNF yes
else
set AUTOCNF no
fi

#
# Waypoint storage.
# REBOOTWORK this needs to start in parallel.
#
dataman start $DATAMAN_OPT

#
# Start the socket communication send_event handler.
#
send_event start

#
# Start the resource load monitor.
#
load_mon start

#
# Start system state indicator.
#
if ! rgbled start
then

rgbled_ncp5623c start

#
# Release 1.4.0 transitional support: set to old default if unconfigured,
# this preserves the previous behaviour.
# FMUv5 may have both PWM I2C RGB LED support.
#
if param compare BAT_N_CELLS 0
rgbled_pwm start

if blinkm start
then
param set BAT_N_CELLS 3
blinkm systemstate
fi
fi

###############################################################################
# Begin setup for board specific configurations. #
###############################################################################

#
# run boards rc.board if available
# Start the tone_alarm driver.
# Needs to be started after the parameters are loaded (for CBRK_BUZZER).
# Note that this will still play the already published startup tone.
#
if [ -f $BOARD_RC ]
then
echo "Board init: ${BOARD_RC}"
sh $BOARD_RC
fi

###############################################################################
# End Setup for board specific configurations. #
###############################################################################
tone_alarm start

if param compare SYS_FMU_TASK 1
then
Expand Down Expand Up @@ -343,9 +329,23 @@ else
set OUTPUT_MODE hil
sensors start -h
commander start --hil

# disable GPS
param set GPS_1_CONFIG 0

else
#
# board sensors: rc.sensors
#
set BOARD_RC_SENSORS /etc/init.d/rc.board_sensors
if [ -f $BOARD_RC_SENSORS ]
then
echo "Board sensors: ${BOARD_RC_SENSORS}"
sh $BOARD_RC_SENSORS
fi
unset BOARD_RC_SENSORS


sh /etc/init.d/rc.sensors
commander start
fi
Expand Down Expand Up @@ -436,11 +436,6 @@ else
#
sh /etc/init.d/rc.thermal_cal

#
# Start the logger.
#
sh /etc/init.d/rc.logging

#
# Start vmount to control mounts such as gimbals, disabled by default.
#
Expand All @@ -450,13 +445,30 @@ else
fi

#
# Start any custom addons.
# Optional board supplied extras: rc.board_extras
#
set BOARD_RC_EXTRAS /etc/init.d/rc.board_extras
if [ -f $BOARD_RC_EXTRAS ]
then
echo "Board extras: ${BOARD_RC_EXTRAS}"
sh $BOARD_RC_EXTRAS
fi
unset BOARD_RC_EXTRAS

#
# Start any custom addons from the sdcard.
#
if [ -f $FEXTRAS ]
then
echo "Addons script: ${FEXTRAS}"
sh $FEXTRAS
fi

#
# Start the logger.
#
sh /etc/init.d/rc.logging

#
# End of autostart.
#
Expand All @@ -465,17 +477,18 @@ fi
#
# Unset all script parameters to free RAM.
#
unset AUTOCNF
unset AUX_MODE
unset DATAMAN_OPT
unset FAILSAFE
unset FAILSAFE_AUX
unset FCONFIG
unset FEXTRAS
unset FRC
unset FMU_ARGS
unset FMU_MODE
unset IOFW
unset FRC
unset IO_PRESENT
unset IOFW
unset LOG_FILE
unset LOGGER_ARGS
unset LOGGER_BUF
Expand All @@ -492,16 +505,14 @@ unset PWM_AUX_MAX
unset PWM_AUX_MIN
unset PWM_AUX_OUT
unset PWM_AUX_RATE
unset PWM_OUT
unset PWM_RATE
unset PWM_DISARMED
unset PWM_MAX
unset PWM_MIN
unset PWM_OUT
unset PWM_RATE
unset SDCARD_MIXERS_PATH
unset USE_IO
unset VEHICLE_TYPE
unset BOARD_RC
unset AUTOCNF

#
# Boot is complete, inform MAVLink app(s) that the system is now fully up and running.
Expand Down
47 changes: 0 additions & 47 deletions boards/airmind/mindpx-v2/init/rc.board

This file was deleted.

14 changes: 14 additions & 0 deletions boards/airmind/mindpx-v2/init/rc.board_defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
#
# Airmind Mindpx-v2 specific board defaults
#------------------------------------------------------------------------------


if [ $AUTOCNF = yes ]
then
# Disable safety switch by default
param set CBRK_IO_SAFETY 22027

fi

set MIXER_AUX none
15 changes: 15 additions & 0 deletions boards/airmind/mindpx-v2/init/rc.board_sensors
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
#
# Airmind Mindpx-v2 specific board sensors init
#------------------------------------------------------------------------------

# External I2C bus
hmc5883 -C -T -X start

# Internal I2C bus
hmc5883 -C -T -I -R 12 start

mpu6000 -s -R 8 start
mpu9250 -s -R 8 start
lsm303d -R 10 start
l3gd20 -R 14 start
Loading