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

Autostart: load all airframes IDs with priority ROMFS -> SD card #23332

Merged
merged 1 commit into from
Jul 3, 2024
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
26 changes: 16 additions & 10 deletions ROMFS/px4fmu_common/init.d/rcS
Original file line number Diff line number Diff line change
Expand Up @@ -217,25 +217,31 @@ else
fi
unset BOARD_RC_DEFAULTS

#
# Set parameters and env variables for selected SYS_AUTOSTART.
#
set AUTOSTART_PATH etc/init.d/rc.autostart
# Load airframe configuration based on SYS_AUTOSTART parameter
if ! param compare SYS_AUTOSTART 0
then
if param greater SYS_AUTOSTART 1000000
# rc.autostart directly run the right airframe script which sets the VEHICLE_TYPE
# Look for airframe in ROMFS
. ${R}etc/init.d/rc.autostart

if [ ${VEHICLE_TYPE} == none ]
then
# Use external startup file
# Look for airframe on SD card
if [ $SDCARD_AVAILABLE = yes ]
then
set AUTOSTART_PATH etc/init.d/rc.autostart_ext
. ${R}etc/init.d/rc.autostart_ext
else
echo "ERROR [init] SD card not mounted - trying to load airframe from ROMFS"
echo "ERROR [init] SD card not mounted - can't load external airframe"
fi
fi
. ${R}$AUTOSTART_PATH

if [ ${VEHICLE_TYPE} == none ]
then
echo "ERROR [init] No airframe file found for SYS_AUTOSTART value"
param set SYS_AUTOSTART 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does resetting SYS_AUTOSTART to 0 actually accomplish anything or should we just leave it alone to keep things simple (development workflows, avoiding unnecessary resets jumping between versions, etc)?

Copy link
Member Author

@MaEtUgR MaEtUgR Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resetting it to zero flags that the autostart wasn't loaded. When I talked to @bkueng he was stressing that this should be retained for the case someone updates but the airframe he used is gone from the new version. I remember I was once glad that I saw the ID go to zero in one of my tests. Not sure if that couldn't be solved even more user friendly e.g. by messageing the user that there's no airframe with the ID but not changing the parameter.

For reference this was introduced here: https://github.com/PX4/PX4-Autopilot/pull/13772/files#diff-c0c83e328e28cbd2f7c7ad46bbb6369024ed63daa3f9dc8cf89ac79125183e1dR82
I did not change it but am open to discussion. I feel it's more accessible to change now.

tune_control play error
fi
fi
unset AUTOSTART_PATH

# Check parameter version and reset upon airframe configuration version mismatch.
# Reboot required because "param reset_all" would reset all "param set" lines from airframe.
Expand Down
6 changes: 0 additions & 6 deletions Tools/px4airframes/rcout.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ def __init__(self, groups, board, post_start=False):
result += "then\n"
result += "\techo \"Loading airframe: /etc/init.d/airframes/${AIRFRAME}\"\n"
result += "\t. /etc/init.d/airframes/${AIRFRAME}\n"
if not post_start:
result += "else\n"
result += "\techo \"ERROR [init] No file matches SYS_AUTOSTART value found in : /etc/init.d/airframes\"\n"
# Reset the configuration
result += "\tparam set SYS_AUTOSTART 0\n"
result += "\ttone_alarm ${TUNE_ERR}\n"
result += "fi\n"
result += "unset AIRFRAME"
self.output = result
Expand Down
Loading