posix: add support for ROMFSROOT

- add missing ROMFS files to CMakeLists.txt
- rename genromfs to etc, so that it's clearer for SITL use
This commit is contained in:
Beat Küng 2020-09-10 13:24:46 +02:00
parent 28a6e82698
commit 809d05053b
11 changed files with 165 additions and 27 deletions

View File

@ -34,7 +34,7 @@
message(STATUS "ROMFS: ${config_romfs_root}")
set(romfs_src_dir ${PX4_SOURCE_DIR}/ROMFS/${config_romfs_root})
set(romfs_gen_root_dir ${PX4_BINARY_DIR}/genromfs)
set(romfs_gen_root_dir ${PX4_BINARY_DIR}/etc)
set_property(GLOBAL PROPERTY PX4_ROMFS_FILES)
set_property(GLOBAL PROPERTY PX4_ROMFS_CMAKE_FILES)
@ -81,21 +81,35 @@ file(GLOB jinja_templates ${PX4_SOURCE_DIR}/Tools/serial/*.jinja)
if (px4_constrained_flash_build)
set(added_arguments --constrained-flash)
endif()
# create list of relative romfs file names
set(romfs_copy_files_relative)
foreach(romfs_file IN LISTS romfs_copy_files)
string(REPLACE "${romfs_src_dir}/" "" romfs_file_rel ${romfs_file})
list(APPEND romfs_copy_files_relative ${romfs_file_rel})
endforeach()
# copy the ROMFS files by creating a tar and extracting it to the build
# directory (which preserves the directory structure)
file(MAKE_DIRECTORY ${romfs_gen_root_dir})
set(romfs_tar_file ${PX4_BINARY_DIR}/romfs_files.tar)
add_custom_command(
OUTPUT ${romfs_tar_file}
COMMAND ${CMAKE_COMMAND} -E tar cf ${romfs_tar_file} ${romfs_copy_files_relative}
WORKING_DIRECTORY ${romfs_src_dir}
DEPENDS ${romfs_copy_files}
)
add_custom_command(
OUTPUT ${romfs_gen_root_dir}/init.d/rcS
COMMAND ${CMAKE_COMMAND} -E tar xf ${romfs_tar_file}
WORKING_DIRECTORY ${romfs_gen_root_dir}
DEPENDS ${romfs_tar_file}
)
add_custom_command(
OUTPUT
${romfs_gen_root_dir}/init.d/rcS
${romfs_gen_root_dir}/init.d/rc.serial
${romfs_gen_root_dir}/init.d/rc.autostart
${romfs_gen_root_dir}/init.d/rc.autostart.post
romfs_copy.stamp
COMMAND ${CMAKE_COMMAND} -E remove_directory ${romfs_gen_root_dir}
# TODO: we should only copy the files in ${romfs_copy_files}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${romfs_src_dir} ${romfs_gen_root_dir}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${romfs_gen_root_dir}/init.d-posix
COMMAND ${CMAKE_COMMAND} -E remove_directory ${romfs_gen_root_dir}/mixers-sitl
COMMAND ${CMAKE_COMMAND} -E remove ${romfs_gen_root_dir}/mixers/CMakeLists.txt
COMMAND ${CMAKE_COMMAND} -E remove ${romfs_gen_root_dir}/init.d/CMakeLists.txt
COMMAND ${CMAKE_COMMAND} -E remove ${romfs_gen_root_dir}/init.d/airframes/CMakeLists.txt
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py
--airframes-path ${romfs_gen_root_dir}/init.d
--start-script ${romfs_gen_root_dir}/init.d/rc.autostart
@ -106,10 +120,10 @@ add_custom_command(
--config-files ${module_config_files} #--verbose
COMMAND ${CMAKE_COMMAND} -E touch romfs_copy.stamp
DEPENDS
${romfs_gen_root_dir}/init.d/rcS
${jinja_templates}
${module_config_files}
${romfs_cmake_files}
${romfs_copy_files}
${PX4_SOURCE_DIR}/Tools/px_process_airframes.py
${PX4_SOURCE_DIR}/Tools/px4airframes/markdownout.py
${PX4_SOURCE_DIR}/Tools/px4airframes/rcout.py
@ -190,6 +204,13 @@ add_custom_command(OUTPUT romfs_extras.stamp
COMMENT "ROMFS: copying extras"
)
add_custom_target(romfs_gen_files_target
DEPENDS
${romfs_gen_root_dir}/init.d/rcS
${romfs_gen_root_dir}/init.d/rc.serial
romfs_extras.stamp
)
add_custom_command(
OUTPUT romfs_pruned.stamp
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_romfs_pruner.py --folder ${romfs_gen_root_dir} --board ${PX4_BOARD}
@ -220,7 +241,11 @@ if("${CONFIG_FS_CROMFS}" STREQUAL "y")
COMMENT "ROMFS: generating image"
)
else()
add_library(romfs STATIC nsh_romfsimg.c)
add_dependencies(romfs prebuild_targets)
set_target_properties(romfs PROPERTIES LINKER_LANGUAGE C)
elseif("${CONFIG_FS_ROMFS}" STREQUAL "y")
# create romfs.img
find_program(GENROMFS genromfs)
if(NOT GENROMFS)
@ -255,13 +280,13 @@ else()
COMMAND ${SED} 's/unsigned/const unsigned/g' nsh_romfsimg.c > nsh_romfsimg.c.tmp && ${CMAKE_COMMAND} -E rename nsh_romfsimg.c.tmp nsh_romfsimg.c
DEPENDS romfs.img
)
add_library(romfs STATIC nsh_romfsimg.c)
add_dependencies(romfs prebuild_targets)
set_target_properties(romfs PROPERTIES LINKER_LANGUAGE C)
endif()
add_library(romfs STATIC nsh_romfsimg.c)
add_dependencies(romfs prebuild_targets)
set_target_properties(romfs PROPERTIES LINKER_LANGUAGE C)
# shellcheck
find_program(SHELLCHECK_PATH shellcheck)

View File

@ -33,3 +33,8 @@
add_subdirectory(init.d)
add_subdirectory(mixers)
# TODO: make this configurable from the board config, or better combine
if("${PX4_BOARD}" MATCHES "sitl")
add_subdirectory(mixers-sitl)
add_subdirectory(init.d-posix)
endif()

View File

@ -0,0 +1,73 @@
############################################################################
#
# Copyright (c) 2020 PX4 Development Team. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name PX4 nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
px4_add_romfs_files(
10016_iris
10020_if750a
10030_px4vision
1010_iris_opt_flow
1010_iris_opt_flow.post
1011_iris_irlock
1012_iris_rplidar
1013_iris_vision
1013_iris_vision.post
1014_solo
1015_iris_obs_avoid
1015_iris_obs_avoid.post
1016_iris_rtps
1016_iris_rtps.post
1017_iris_opt_flow_mockup
1018_iris_vision_velocity
1019_iris_dual_gps
1020_uuv_generic
1021_uuv_hippocampus
1030_plane
1031_plane_cam
1032_plane_catapult
1033_plane_lidar
1033_rascal
1034_rascal-electric
1040_standard_vtol
1041_tailsitter
1042_tiltrotor
1060_rover
1061_r1_rover
1062_tf-r1
1070_boat
17001_tf-g1
2507_cloudship
6011_typhoon_h480
6011_typhoon_h480.post
rc.replay
rcS
)

View File

@ -34,6 +34,8 @@
add_subdirectory(airframes)
px4_add_romfs_files(
rc.airship_apps
rc.airship_defaults
rc.fw_apps
rc.fw_defaults
rc.interface

View File

@ -5,8 +5,6 @@
# @type VTOL Octoplane
# @class VTOL
#
# @maintainer
#
# @output MAIN1 motor 1
# @output MAIN2 motor 2
# @output MAIN3 motor 3
@ -21,6 +19,7 @@
# @output AUX4 Rudder
# @output AUX5 Throttle
#
# @board px4_fmu-v2 exclude
# @board intel_aerofc-v1 exclude
# @board bitcraze_crazyflie exclude
#

View File

@ -8,6 +8,11 @@
# @output MAIN2 port thruster
# @output MAIN3 thrust tilt
# @output MAIN4 tail thruster
#
# @board px4_fmu-v2 exclude
# @board intel_aerofc-v1 exclude
# @board bitcraze_crazyflie exclude
#
sh /etc/init.d/rc.airship_defaults

View File

@ -46,6 +46,8 @@ px4_add_romfs_files(
2106_albatross
2200_mini_talon
2507_cloudship
# [3000, 3999] Flying wing"
3000_generic_wing
3030_io_camflyer
@ -131,6 +133,8 @@ px4_add_romfs_files(
13010_claire
13012_convergence
13013_deltaquad
13014_vtol_babyshark
13050_generic_vtol_octo
13200_generic_vtol_tailsitter
# [14000, 14999] Tri Y
@ -141,6 +145,8 @@ px4_add_romfs_files(
16001_helicopter
17002_TF-AutoG2
24001_dodeca_cox
50000_generic_ground_vehicle

View File

@ -32,8 +32,11 @@
############################################################################
px4_add_romfs_files(
autogyro_sitl.main.mix
boat_sitl.main.mix
delta_wing_sitl.main.mix
plane_sitl.main.mix
quad_x_vtol.main.mix
rover_ackermann_sitl.main.mix
rover_diff_sitl.main.mix
standard_vtol_sitl.main.mix

View File

@ -34,13 +34,16 @@
px4_add_romfs_files(
AAERTWF.main.mix
AAVVTWFF.main.mix
AAVVTWFF_vtail.main.mix
AERT.main.mix
AETRFG.main.mix
babyshark.main.mix
blade130.main.mix
caipi.main.mix
CCPM.main.mix
claire.aux.mix
claire.main.mix
cloudship.main.mix
coax.main.mix
delta.main.mix
deltaquad.main.mix
@ -69,20 +72,24 @@ px4_add_romfs_files(
quad_s250aq.main.mix
quad_+_vtol.main.mix
quad_w.main.mix
quad_x.main.mix
quad_x_cw.main.mix
quad_x.main.mix
quad_x_vtol.main.mix
stampede.main.mix
tri_y_yaw-.main.mix
tri_y_yaw+.main.mix
rover_generic.main.mix
rover_diff_and_servo.main.mix
rover_generic.main.mix
stampede.main.mix
standard_vtol_hitl.main.mix
TF-AutoG2.main.mix
tilt_quad.aux.mix
tilt_quad.main.mix
tri_y_yaw+.main.mix
tri_y_yaw-.main.mix
uuv_x.main.mix
Viper.main.mix
vtol_AAERT.aux.mix
vtol_AAVVT.aux.mix
vtol_convergence.main.mix
vtol_delta.aux.mix
vtol_tailsitter_duo.main.mix
wingwing.main.mix
TF-AutoG2.main.mix
uuv_x.main.mix
)

View File

@ -67,7 +67,7 @@
# LABEL : optional label, set to default if not specified
# TOOLCHAIN : cmake toolchain
# ARCHITECTURE : name of the CPU CMake is building for (used by the toolchain)
# ROMFSROOT : relative path to the ROMFS root directory (currently NuttX only)
# ROMFSROOT : relative path to the ROMFS root directory
# BUILD_BOOTLOADER : flag to enable building and including the bootloader config
# IO : name of IO board to be built and included in the ROMFS (requires a valid ROMFSROOT)
# BOOTLOADER : bootloader file to include for flashing via bl_update (currently NuttX only)

View File

@ -80,8 +80,8 @@ else()
install(
DIRECTORY
${PROJECT_SOURCE_DIR}/posix-configs
${PROJECT_SOURCE_DIR}/ROMFS
${PROJECT_SOURCE_DIR}/test
${CMAKE_BINARY_DIR}/etc
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
DESTINATION
${PROJECT_NAME}
@ -97,6 +97,11 @@ px4_posix_generate_symlinks(
TARGET px4
)
if (config_romfs_root)
add_subdirectory(${PX4_SOURCE_DIR}/ROMFS ${PX4_BINARY_DIR}/ROMFS)
add_dependencies(px4 romfs_gen_files_target)
endif()
# board defined upload helper
if(EXISTS "${PX4_BOARD_DIR}/cmake/upload.cmake")
@ -157,6 +162,14 @@ elseif("${PX4_BOARD}" MATCHES "sitl")
${PROJECT_NAME}/Tools
)
# ROMFS files
install(
DIRECTORY
${PROJECT_SOURCE_DIR}/build/px4_sitl_default/etc
DESTINATION
${PROJECT_NAME}/build/px4_sitl_default
)
# sitl_gazebo built plugins
install(
DIRECTORY