mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-04 21:23:57 +08:00
config: add dynamic init file
Build all targets / Scan for Board Targets (push) Has been cancelled
Build all targets / Build Group [${{ matrix.group }}][${{ matrix.arch == 'nuttx' && 'x86' || 'arm64' }}] (push) Has been cancelled
Build all targets / Upload Artifacts to S3 (push) Has been cancelled
Build all targets / Create Release and Upload Artifacts (push) Has been cancelled
Checks / build (NO_NINJA_BUILD=1 px4_fmu-v5_default) (push) Has been cancelled
Checks / build (NO_NINJA_BUILD=1 px4_sitl_default) (push) Has been cancelled
Checks / build (check_format) (push) Has been cancelled
Checks / build (check_newlines) (push) Has been cancelled
Checks / build (module_documentation) (push) Has been cancelled
Checks / build (px4_fmu-v2_default stack_check) (push) Has been cancelled
Checks / build (px4_sitl_allyes) (push) Has been cancelled
Checks / build (shellcheck_all) (push) Has been cancelled
Checks / build (tests) (push) Has been cancelled
Checks / build (tests_coverage) (push) Has been cancelled
Checks / build (validate_module_configs) (push) Has been cancelled
Clang Tidy / build (push) Has been cancelled
MacOS build / build (px4_fmu-v5_default) (push) Has been cancelled
MacOS build / build (px4_sitl) (push) Has been cancelled
Ubuntu environment build / Build and Test (ubuntu:22.04) (push) Has been cancelled
Ubuntu environment build / Build and Test (ubuntu:24.04) (push) Has been cancelled
Container build / Set Tags and Variables (push) Has been cancelled
Container build / Build Container (amd64) (push) Has been cancelled
Container build / Build Container (arm64) (push) Has been cancelled
Container build / Deploy To Registry (push) Has been cancelled
EKF Update Change Indicator / unit_tests (push) Has been cancelled
Failsafe Simulator Build / build (failsafe_web) (push) Has been cancelled
FLASH usage analysis / Analyzing px4_fmu-v5x (push) Has been cancelled
FLASH usage analysis / Analyzing px4_fmu-v6x (push) Has been cancelled
FLASH usage analysis / Publish Results (push) Has been cancelled
ITCM check / Checking nxp_tropic-community (push) Has been cancelled
ITCM check / Checking px4_fmu-v5x (push) Has been cancelled
ITCM check / Checking px4_fmu-v6xrt (push) Has been cancelled
MAVROS Mission Tests / build (map[mission:MC_mission_box vehicle:iris]) (push) Has been cancelled
MAVROS Offboard Tests / build (map[test_file:mavros_posix_tests_offboard_posctl.test vehicle:iris]) (push) Has been cancelled
Nuttx Target with extra env config / build (px4_fmu-v5_default) (push) Has been cancelled
Python CI Checks / build (push) Has been cancelled
ROS Integration Tests / build (push) Has been cancelled
ROS Translation Node Tests / Build and test (map[ros_version:humble ubuntu:jammy]) (push) Has been cancelled
ROS Translation Node Tests / Build and test (map[ros_version:jazzy ubuntu:noble]) (push) Has been cancelled
SITL Tests / Testing PX4 tailsitter (push) Has been cancelled
SITL Tests / Testing PX4 iris (push) Has been cancelled
SITL Tests / Testing PX4 standard_vtol (push) Has been cancelled
Docs - Crowdin - Upload Guide sources (en) / upload-to-crowdin (push) Has been cancelled
Docs - Deploy PX4 User Guide / build (push) Has been cancelled
Docs - Deploy PX4 User Guide to AWS / build (push) Has been cancelled
Docs - Deploy PX4 User Guide / deploy (push) Has been cancelled
Docs - Deploy PX4 User Guide to AWS / deploy (push) Has been cancelled
Handle stale issues and PRs / stale (push) Has been cancelled
Fuzzing / Fuzzing (push) Has been cancelled
Build all targets / Scan for Board Targets (push) Has been cancelled
Build all targets / Build Group [${{ matrix.group }}][${{ matrix.arch == 'nuttx' && 'x86' || 'arm64' }}] (push) Has been cancelled
Build all targets / Upload Artifacts to S3 (push) Has been cancelled
Build all targets / Create Release and Upload Artifacts (push) Has been cancelled
Checks / build (NO_NINJA_BUILD=1 px4_fmu-v5_default) (push) Has been cancelled
Checks / build (NO_NINJA_BUILD=1 px4_sitl_default) (push) Has been cancelled
Checks / build (check_format) (push) Has been cancelled
Checks / build (check_newlines) (push) Has been cancelled
Checks / build (module_documentation) (push) Has been cancelled
Checks / build (px4_fmu-v2_default stack_check) (push) Has been cancelled
Checks / build (px4_sitl_allyes) (push) Has been cancelled
Checks / build (shellcheck_all) (push) Has been cancelled
Checks / build (tests) (push) Has been cancelled
Checks / build (tests_coverage) (push) Has been cancelled
Checks / build (validate_module_configs) (push) Has been cancelled
Clang Tidy / build (push) Has been cancelled
MacOS build / build (px4_fmu-v5_default) (push) Has been cancelled
MacOS build / build (px4_sitl) (push) Has been cancelled
Ubuntu environment build / Build and Test (ubuntu:22.04) (push) Has been cancelled
Ubuntu environment build / Build and Test (ubuntu:24.04) (push) Has been cancelled
Container build / Set Tags and Variables (push) Has been cancelled
Container build / Build Container (amd64) (push) Has been cancelled
Container build / Build Container (arm64) (push) Has been cancelled
Container build / Deploy To Registry (push) Has been cancelled
EKF Update Change Indicator / unit_tests (push) Has been cancelled
Failsafe Simulator Build / build (failsafe_web) (push) Has been cancelled
FLASH usage analysis / Analyzing px4_fmu-v5x (push) Has been cancelled
FLASH usage analysis / Analyzing px4_fmu-v6x (push) Has been cancelled
FLASH usage analysis / Publish Results (push) Has been cancelled
ITCM check / Checking nxp_tropic-community (push) Has been cancelled
ITCM check / Checking px4_fmu-v5x (push) Has been cancelled
ITCM check / Checking px4_fmu-v6xrt (push) Has been cancelled
MAVROS Mission Tests / build (map[mission:MC_mission_box vehicle:iris]) (push) Has been cancelled
MAVROS Offboard Tests / build (map[test_file:mavros_posix_tests_offboard_posctl.test vehicle:iris]) (push) Has been cancelled
Nuttx Target with extra env config / build (px4_fmu-v5_default) (push) Has been cancelled
Python CI Checks / build (push) Has been cancelled
ROS Integration Tests / build (push) Has been cancelled
ROS Translation Node Tests / Build and test (map[ros_version:humble ubuntu:jammy]) (push) Has been cancelled
ROS Translation Node Tests / Build and test (map[ros_version:jazzy ubuntu:noble]) (push) Has been cancelled
SITL Tests / Testing PX4 tailsitter (push) Has been cancelled
SITL Tests / Testing PX4 iris (push) Has been cancelled
SITL Tests / Testing PX4 standard_vtol (push) Has been cancelled
Docs - Crowdin - Upload Guide sources (en) / upload-to-crowdin (push) Has been cancelled
Docs - Deploy PX4 User Guide / build (push) Has been cancelled
Docs - Deploy PX4 User Guide to AWS / build (push) Has been cancelled
Docs - Deploy PX4 User Guide / deploy (push) Has been cancelled
Docs - Deploy PX4 User Guide to AWS / deploy (push) Has been cancelled
Handle stale issues and PRs / stale (push) Has been cancelled
Fuzzing / Fuzzing (push) Has been cancelled
* config: add dynamic init file * added review feedback * added docs
This commit is contained in:
@@ -73,6 +73,11 @@ menu "Toolchain"
|
|||||||
help
|
help
|
||||||
relative path to the ROMFS root directory
|
relative path to the ROMFS root directory
|
||||||
|
|
||||||
|
config BOARD_ADDITIONAL_INIT
|
||||||
|
string "Additional init file"
|
||||||
|
help
|
||||||
|
additional configurable init file to include in the ROMFS
|
||||||
|
|
||||||
config BOARD_IO
|
config BOARD_IO
|
||||||
string "IO board name"
|
string "IO board name"
|
||||||
default "px4_io-v2_default"
|
default "px4_io-v2_default"
|
||||||
|
|||||||
@@ -202,6 +202,31 @@ foreach(board_rc_file ${OPTIONAL_BOARD_RC})
|
|||||||
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
if(config_additional_init)
|
||||||
|
if(EXISTS "${PX4_BOARD_DIR}/init/${config_additional_init}")
|
||||||
|
file(RELATIVE_PATH rc_file_relative ${PX4_SOURCE_DIR} ${PX4_BOARD_DIR}/init/${config_additional_init})
|
||||||
|
message(STATUS "ROMFS: Adding ${rc_file_relative} -> /etc/init.d/rc.additional_init")
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT
|
||||||
|
${romfs_gen_root_dir}/init.d/rc.additional_init
|
||||||
|
${config_additional_init}.stamp
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PX4_BOARD_DIR}/init/${config_additional_init} ${romfs_gen_root_dir}/init.d/rc.additional_init
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E touch ${config_additional_init}.stamp
|
||||||
|
DEPENDS
|
||||||
|
${PX4_BOARD_DIR}/init/${config_additional_init}
|
||||||
|
romfs_copy.stamp
|
||||||
|
COMMENT "ROMFS: copying ${config_additional_init}"
|
||||||
|
)
|
||||||
|
|
||||||
|
list(APPEND extras_dependencies
|
||||||
|
${config_additional_init}.stamp
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "BOARD_ADDITIONAL_INIT file not found at: ${PX4_BOARD_DIR}/init/${config_additional_init}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# board extras
|
# board extras
|
||||||
set(OPTIONAL_BOARD_EXTRAS)
|
set(OPTIONAL_BOARD_EXTRAS)
|
||||||
|
|||||||
@@ -56,6 +56,17 @@ then
|
|||||||
fi
|
fi
|
||||||
unset BOARD_RC_DEFAULTS
|
unset BOARD_RC_DEFAULTS
|
||||||
|
|
||||||
|
#
|
||||||
|
# Optional additional init file: rc.additional_init
|
||||||
|
#
|
||||||
|
set BOARD_RC_ADDITIONAL_INIT ${R}etc/init.d/rc.additional_init
|
||||||
|
if [ -f $BOARD_RC_ADDITIONAL_INIT ]
|
||||||
|
then
|
||||||
|
echo "Board additional init: ${BOARD_RC_ADDITIONAL_INIT}"
|
||||||
|
. $BOARD_RC_ADDITIONAL_INIT
|
||||||
|
fi
|
||||||
|
unset BOARD_RC_ADDITIONAL_INIT
|
||||||
|
|
||||||
#
|
#
|
||||||
# Start system state indicator.
|
# Start system state indicator.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -217,6 +217,17 @@ else
|
|||||||
fi
|
fi
|
||||||
unset BOARD_RC_DEFAULTS
|
unset BOARD_RC_DEFAULTS
|
||||||
|
|
||||||
|
#
|
||||||
|
# Optional additional init file: rc.additional_init
|
||||||
|
#
|
||||||
|
set BOARD_RC_ADDITIONAL_INIT ${R}etc/init.d/rc.additional_init
|
||||||
|
if [ -f $BOARD_RC_ADDITIONAL_INIT ]
|
||||||
|
then
|
||||||
|
echo "Board additional init: ${BOARD_RC_ADDITIONAL_INIT}"
|
||||||
|
. $BOARD_RC_ADDITIONAL_INIT
|
||||||
|
fi
|
||||||
|
unset BOARD_RC_ADDITIONAL_INIT
|
||||||
|
|
||||||
# Load airframe configuration based on SYS_AUTOSTART parameter
|
# Load airframe configuration based on SYS_AUTOSTART parameter
|
||||||
if ! param compare SYS_AUTOSTART 0
|
if ! param compare SYS_AUTOSTART 0
|
||||||
then
|
then
|
||||||
|
|||||||
@@ -339,6 +339,11 @@ if(EXISTS ${BOARD_DEFCONFIG})
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# ADDITIONAL INIT
|
||||||
|
if(ADDITIONAL_INIT)
|
||||||
|
set(config_additional_init ${ADDITIONAL_INIT} CACHE INTERNAL "additional init" FORCE)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(UAVCAN_INTERFACES)
|
if(UAVCAN_INTERFACES)
|
||||||
set(config_uavcan_num_ifaces ${UAVCAN_INTERFACES} CACHE INTERNAL "UAVCAN interfaces" FORCE)
|
set(config_uavcan_num_ifaces ${UAVCAN_INTERFACES} CACHE INTERNAL "UAVCAN interfaces" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ This is documented below.
|
|||||||
The best way to customize the system startup is to introduce a [new frame configuration](../dev_airframes/adding_a_new_frame.md).
|
The best way to customize the system startup is to introduce a [new frame configuration](../dev_airframes/adding_a_new_frame.md).
|
||||||
The frame configuration file can be included in the firmware or on an SD Card.
|
The frame configuration file can be included in the firmware or on an SD Card.
|
||||||
|
|
||||||
|
#### Dynamic customization
|
||||||
|
|
||||||
If you only need to "tweak" the existing configuration, such as starting one more application or setting the value of a few parameters, you can specify these by creating two files in the `/etc/` directory of the SD Card:
|
If you only need to "tweak" the existing configuration, such as starting one more application or setting the value of a few parameters, you can specify these by creating two files in the `/etc/` directory of the SD Card:
|
||||||
|
|
||||||
- [/etc/config.txt](#customizing-the-configuration-config-txt): modify parameter values
|
- [/etc/config.txt](#customizing-the-configuration-config-txt): modify parameter values
|
||||||
@@ -106,7 +108,7 @@ If editing on Windows use a suitable editor.
|
|||||||
These files are referenced in PX4 code as `/fs/microsd/etc/config.txt` and `/fs/microsd/etc/extras.txt`, where the root folder of the microsd card is identified by the path `/fs/microsd`.
|
These files are referenced in PX4 code as `/fs/microsd/etc/config.txt` and `/fs/microsd/etc/extras.txt`, where the root folder of the microsd card is identified by the path `/fs/microsd`.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
#### Customizing the Configuration (config.txt)
|
##### Customizing the Configuration (config.txt)
|
||||||
|
|
||||||
The `config.txt` file can be used to modify parameters.
|
The `config.txt` file can be used to modify parameters.
|
||||||
It is loaded after the main system has been configured and _before_ it is booted.
|
It is loaded after the main system has been configured and _before_ it is booted.
|
||||||
@@ -118,7 +120,7 @@ param set-default PWM_MAIN_DIS3 1000
|
|||||||
param set-default PWM_MAIN_MIN3 1120
|
param set-default PWM_MAIN_MIN3 1120
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Starting Additional Applications (extras.txt)
|
##### Starting Additional Applications (extras.txt)
|
||||||
|
|
||||||
The `extras.txt` can be used to start additional applications after the main system boot.
|
The `extras.txt` can be used to start additional applications after the main system boot.
|
||||||
Typically these would be payload controllers or similar optional custom components.
|
Typically these would be payload controllers or similar optional custom components.
|
||||||
@@ -145,3 +147,28 @@ The following example shows how to start custom applications:
|
|||||||
|
|
||||||
mandatory_app start # Will abort boot if mandatory_app is unknown or fails
|
mandatory_app start # Will abort boot if mandatory_app is unknown or fails
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Additional customization
|
||||||
|
|
||||||
|
In rare cases where the desired setup cannot be achieved through frame configuration or dynamic customization,
|
||||||
|
you can add a script that will be contained in the binary.
|
||||||
|
|
||||||
|
**Note**: In almost all cases, you should use a frame configuration. This method should only be used for
|
||||||
|
edge-cases such as customizing `cannode` based boards.
|
||||||
|
|
||||||
|
- Add a new init script in `boards/<vendor>/<board>/init` that will run during board startup. For example:
|
||||||
|
```sh
|
||||||
|
# File: boards/<vendor>/<board>/init/rc.additional
|
||||||
|
param set-default <param> <value>
|
||||||
|
```
|
||||||
|
|
||||||
|
- Add a new board variant in `boards/<vendor>/<board>/<variant>.px4board` that includes the additional script. For example:
|
||||||
|
```sh
|
||||||
|
# File: boards/<vendor>/<board>/var.px4board
|
||||||
|
CONFIG_BOARD_ADDITIONAL_INIT="rc.additional"
|
||||||
|
```
|
||||||
|
|
||||||
|
- Compile the firmware with your new variant by appending the variant name to the compile target. For example:
|
||||||
|
```sh
|
||||||
|
make <target>_var
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user