diff --git a/CMakeLists.txt b/CMakeLists.txt index 346383d1ff..d0e3fcfe69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,12 +144,10 @@ include(px4_add_module) set(config_module_list) include(px4_config) -include(px4_add_board) -include(${PX4_CONFIG_FILE}) +include(kconfig) message(STATUS "PX4 config: ${PX4_CONFIG}") message(STATUS "PX4 platform: ${PX4_PLATFORM}") -include(kconfig) if(${PX4_PLATFORM} STREQUAL "posix") if(ENABLE_LOCKSTEP_SCHEDULER) diff --git a/Makefile b/Makefile index 5ea7149c20..61107208e9 100644 --- a/Makefile +++ b/Makefile @@ -213,8 +213,8 @@ define colorecho +@echo -e '${COLOR_BLUE}${1} ${NO_COLOR}' endef -# Get a list of all config targets boards/*/*.cmake -ALL_CONFIG_TARGETS := $(shell find boards -maxdepth 3 -mindepth 3 -name '*.cmake' -print | sed -e 's|boards\/||' | sed -e 's|\.cmake||' | sed -e 's|\/|_|g' | sort) +# Get a list of all config targets boards/*/*.px4board +ALL_CONFIG_TARGETS := $(shell find boards -maxdepth 3 -mindepth 3 -name '*.px4board' -print | sed -e 's|boards\/||' | sed -e 's|\.px4board||' | sed -e 's|\/|_|g' | sort) # ADD CONFIGS HERE # -------------------------------------------------------------------- diff --git a/boards/nxp/fmuk66-v3/socketcan.cmake b/boards/nxp/fmuk66-v3/socketcan.cmake deleted file mode 100644 index 84451ecf1a..0000000000 --- a/boards/nxp/fmuk66-v3/socketcan.cmake +++ /dev/null @@ -1,131 +0,0 @@ - -px4_add_board( - PLATFORM nuttx - TOOLCHAIN arm-none-eabi - ARCHITECTURE cortex-m4 - CONSTRAINED_MEMORY - ROMFSROOT px4fmu_common - UAVCAN_INTERFACES 2 - SERIAL_PORTS - GPS1:/dev/ttyS3 - TEL1:/dev/ttyS4 - TEL2:/dev/ttyS1 - DRIVERS - adc/ads1115 - adc/board_adc - barometer # all available barometer drivers - barometer/mpl3115a2 - batt_smbus - camera_capture - camera_trigger - differential_pressure # all available differential pressure drivers - distance_sensor # all available distance sensor drivers - distance_sensor/srf05 # Specific driver - gps - #imu # all available imu drivers - imu/fxas21002c - imu/fxos8701cq - imu/invensense/icm20948 # required for ak09916 mag - irlock - lights # all available light drivers - lights/rgbled_pwm - magnetometer # all available magnetometer drivers - optical_flow # all available optical flow drivers - osd - pca9685 - pca9685_pwm_out - power_monitor/ina226 - #protocol_splitter - pwm_out_sim - pwm_out - rc_input - roboclaw - rpm - safety_button - smart_battery/batmon - telemetry # all available telemetry drivers - tone_alarm - uavcan_v1 - MODULES - airspeed_selector - attitude_estimator_q - battery_status - camera_feedback - commander - dataman - ekf2 - esc_battery - events - flight_mode_manager - fw_att_control - fw_pos_control_l1 - gyro_calibration - gyro_fft - land_detector - landing_target_estimator - load_mon - local_position_estimator - logger - mag_bias_estimator - mavlink - mc_att_control - mc_autotune_attitude_control - mc_hover_thrust_estimator - mc_pos_control - mc_rate_control - #micrortps_bridge - navigator - rc_update - rover_pos_control - sensors - sih - temperature_compensation - #uuv_att_control - #uuv_pos_control - vmount - vtol_att_control - SYSTEMCMDS - #bl_update - #dmesg - dumpfile - esc_calib - #gpio - i2cdetect - led_control - mft - mixer - motor_ramp - motor_test - mtd - nshterm - param - perf - pwm - reboot - reflect - sd_bench - sd_stress - serial_test - system_time - tests # tests and test runner - top - topic_listener - tune_control - uorb - usb_connected - ver - work_queue - EXAMPLES - fake_gps - #fake_imu - #fake_magnetometer - #fixedwing_control # Tutorial code from https://px4.io/dev/example_fixedwing_control - #hello - #hwtest # Hardware test - #matlab_csv_serial - #px4_mavlink_debug # Tutorial code from http://dev.px4.io/en/debug/debug_values.html - #px4_simple_app # Tutorial code from http://dev.px4.io/en/apps/hello_sky.html - #rover_steering_control # Rover example app - #uuv_example_app - #work_item - ) diff --git a/boards/nxp/fmuk66-v3/socketcan.px4board b/boards/nxp/fmuk66-v3/socketcan.px4board new file mode 100644 index 0000000000..b3efd82e53 --- /dev/null +++ b/boards/nxp/fmuk66-v3/socketcan.px4board @@ -0,0 +1,101 @@ +CONFIG_ARCHITECTURE_CORTEX_M4=y +CONFIG_BOARD_BUILD_BOOTLOADER=y +CONFIG_BOARD_CONSTRAINED_MEMORY=y +CONFIG_BOARD_SERIAL_GPS1="/dev/ttyS3" +CONFIG_BOARD_SERIAL_TEL1="/dev/ttyS4" +CONFIG_BOARD_SERIAL_TEL2="/dev/ttyS1" +CONFIG_DRIVERS_ADC_ADS1115=y +CONFIG_DRIVERS_ADC_BOARD_ADC=y +CONFIG_DRIVERS_BAROMETER=y +CONFIG_DRIVERS_BAROMETER_MPL3115A2=y +CONFIG_DRIVERS_BATT_SMBUS=y +CONFIG_DRIVERS_CAMERA_CAPTURE=y +CONFIG_DRIVERS_CAMERA_TRIGGER=y +CONFIG_DRIVERS_DIFFERENTIAL_PRESSURE=y +CONFIG_DRIVERS_DISTANCE_SENSOR=y +CONFIG_DRIVERS_DISTANCE_SENSOR_SRF05=y +CONFIG_DRIVERS_GPS=y +CONFIG_DRIVERS_IMU_FXAS21002C=y +CONFIG_DRIVERS_IMU_FXOS8701CQ=y +CONFIG_DRIVERS_IMU_INVENSENSE_ICM20948=y +CONFIG_DRIVERS_IRLOCK=y +CONFIG_DRIVERS_LIGHTS_RGBLED=y +CONFIG_DRIVERS_LIGHTS_RGBLED_NCP5623C=y +CONFIG_DRIVERS_LIGHTS_RGBLED_PWM=y +CONFIG_DRIVERS_MAGNETOMETER=y +CONFIG_DRIVERS_OPTICAL_FLOW_PAW3902=y +CONFIG_DRIVERS_OPTICAL_FLOW_PMW3901=y +CONFIG_DRIVERS_OPTICAL_FLOW_PX4FLOW=y +CONFIG_DRIVERS_OPTICAL_FLOW_THONEFLOW=y +CONFIG_DRIVERS_OSD=y +CONFIG_DRIVERS_PCA9685=y +CONFIG_DRIVERS_PCA9685_PWM_OUT=y +CONFIG_DRIVERS_POWER_MONITOR_INA226=y +CONFIG_DRIVERS_PWM_OUT=y +CONFIG_DRIVERS_PWM_OUT_SIM=y +CONFIG_DRIVERS_RC_INPUT=y +CONFIG_DRIVERS_ROBOCLAW=y +CONFIG_DRIVERS_RPM=y +CONFIG_DRIVERS_SAFETY_BUTTON=y +CONFIG_DRIVERS_SMART_BATTERY_BATMON=y +CONFIG_DRIVERS_TELEMETRY=y +CONFIG_DRIVERS_TONE_ALARM=y +CONFIG_DRIVERS_UAVCAN_V1=y +CONFIG_MODULES_AIRSPEED_SELECTOR=y +CONFIG_MODULES_ATTITUDE_ESTIMATOR_Q=y +CONFIG_MODULES_BATTERY_STATUS=y +CONFIG_MODULES_CAMERA_FEEDBACK=y +CONFIG_MODULES_COMMANDER=y +CONFIG_MODULES_DATAMAN=y +CONFIG_MODULES_EKF2=y +CONFIG_MODULES_ESC_BATTERY=y +CONFIG_MODULES_EVENTS=y +CONFIG_MODULES_FLIGHT_MODE_MANAGER=y +CONFIG_MODULES_FW_ATT_CONTROL=y +CONFIG_MODULES_FW_POS_CONTROL_L1=y +CONFIG_MODULES_GYRO_CALIBRATION=y +CONFIG_MODULES_GYRO_FFT=y +CONFIG_MODULES_LAND_DETECTOR=y +CONFIG_MODULES_LANDING_TARGET_ESTIMATOR=y +CONFIG_MODULES_LOAD_MON=y +CONFIG_MODULES_LOCAL_POSITION_ESTIMATOR=y +CONFIG_MODULES_LOGGER=y +CONFIG_MODULES_MAVLINK=y +CONFIG_MODULES_MC_ATT_CONTROL=y +CONFIG_MODULES_MC_HOVER_THRUST_ESTIMATOR=y +CONFIG_MODULES_MC_POS_CONTROL=y +CONFIG_MODULES_MC_RATE_CONTROL=y +CONFIG_MODULES_NAVIGATOR=y +CONFIG_MODULES_RC_UPDATE=y +CONFIG_MODULES_ROVER_POS_CONTROL=y +CONFIG_MODULES_SENSORS=y +CONFIG_MODULES_SIH=y +CONFIG_MODULES_TEMPERATURE_COMPENSATION=y +CONFIG_MODULES_VMOUNT=y +CONFIG_MODULES_VTOL_ATT_CONTROL=y +CONFIG_SYSTEMCMDS_DUMPFILE=y +CONFIG_SYSTEMCMDS_ESC_CALIB=y +CONFIG_SYSTEMCMDS_I2CDETECT=y +CONFIG_SYSTEMCMDS_LED_CONTROL=y +CONFIG_SYSTEMCMDS_MFT=y +CONFIG_SYSTEMCMDS_MIXER=y +CONFIG_SYSTEMCMDS_MOTOR_RAMP=y +CONFIG_SYSTEMCMDS_MOTOR_TEST=y +CONFIG_SYSTEMCMDS_MTD=y +CONFIG_SYSTEMCMDS_NSHTERM=y +CONFIG_SYSTEMCMDS_PARAM=y +CONFIG_SYSTEMCMDS_PERF=y +CONFIG_SYSTEMCMDS_PWM=y +CONFIG_SYSTEMCMDS_REBOOT=y +CONFIG_SYSTEMCMDS_REFLECT=y +CONFIG_SYSTEMCMDS_SD_BENCH=y +CONFIG_SYSTEMCMDS_SERIAL_TEST=y +CONFIG_SYSTEMCMDS_SYSTEM_TIME=y +CONFIG_SYSTEMCMDS_TOP=y +CONFIG_SYSTEMCMDS_TOPIC_LISTENER=y +CONFIG_SYSTEMCMDS_TUNE_CONTROL=y +CONFIG_SYSTEMCMDS_UORB=y +CONFIG_SYSTEMCMDS_USB_CONNECTED=y +CONFIG_SYSTEMCMDS_VER=y +CONFIG_SYSTEMCMDS_WORK_QUEUE=y +CONFIG_EXAMPLES_FAKE_GPS=y diff --git a/cmake/kconfig.cmake b/cmake/kconfig.cmake index 79a96cae5b..cecb4a5067 100644 --- a/cmake/kconfig.cmake +++ b/cmake/kconfig.cmake @@ -1,4 +1,4 @@ -set(BOARD_DEFCONFIG ${PX4_BOARD_DIR}/${PX4_BOARD_LABEL}.px4board CACHE FILEPATH "path to defconfig" FORCE) +set(BOARD_DEFCONFIG ${PX4_CONFIG_FILE} CACHE FILEPATH "path to defconfig" FORCE) set(BOARD_CONFIG ${PX4_BINARY_DIR}/boardconfig CACHE FILEPATH "path to config" FORCE) find_program(MENUCONFIG_PATH menuconfig) @@ -10,6 +10,8 @@ if(NOT MENUCONFIG_PATH OR NOT GUICONFIG_PATH OR NOT DEFCONFIG_PATH OR NOT SAVEDE "please install using \"pip3 install kconfiglib\"\n") endif() + + set(COMMON_KCONFIG_ENV_SETTINGS PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} KCONFIG_CONFIG=${BOARD_CONFIG} @@ -24,29 +26,7 @@ set(COMMON_KCONFIG_ENV_SETTINGS ROMFSROOT=${config_romfs_root} ) -add_custom_target(boardconfig - ${CMAKE_COMMAND} -E env - ${COMMON_KCONFIG_ENV_SETTINGS} - ${MENUCONFIG_PATH} Kconfig - COMMAND ${CMAKE_COMMAND} -E env ${COMMON_KCONFIG_ENV_SETTINGS} ${SAVEDEFCONFIG_PATH} - COMMAND ${CMAKE_COMMAND} -E copy defconfig ${BOARD_DEFCONFIG} - COMMAND ${CMAKE_COMMAND} -E rm ${PX4_BINARY_DIR}/NuttX/apps_copy.stamp - WORKING_DIRECTORY ${PX4_SOURCE_DIR} - USES_TERMINAL - COMMAND_EXPAND_LISTS -) - -add_custom_target(boardguiconfig - ${CMAKE_COMMAND} -E env - ${COMMON_KCONFIG_ENV_SETTINGS} - ${GUICONFIG_PATH} Kconfig - COMMAND ${CMAKE_COMMAND} -E env ${COMMON_KCONFIG_ENV_SETTINGS} ${SAVEDEFCONFIG_PATH} - COMMAND ${CMAKE_COMMAND} -E copy defconfig ${BOARD_DEFCONFIG} - COMMAND ${CMAKE_COMMAND} -E rm ${PX4_BINARY_DIR}/NuttX/apps_copy.stamp - WORKING_DIRECTORY ${PX4_SOURCE_DIR} - USES_TERMINAL - COMMAND_EXPAND_LISTS -) +message(STATUS ${PX4_BINARY_DIR}) if(EXISTS ${BOARD_DEFCONFIG}) @@ -309,3 +289,27 @@ if(EXISTS ${BOARD_DEFCONFIG}) set(config_module_list ${config_module_list}) endif() + +add_custom_target(boardconfig + ${CMAKE_COMMAND} -E env + ${COMMON_KCONFIG_ENV_SETTINGS} + ${MENUCONFIG_PATH} Kconfig + COMMAND ${CMAKE_COMMAND} -E env ${COMMON_KCONFIG_ENV_SETTINGS} ${SAVEDEFCONFIG_PATH} + COMMAND ${CMAKE_COMMAND} -E copy defconfig ${BOARD_DEFCONFIG} + COMMAND ${CMAKE_COMMAND} -E rm ${PX4_BINARY_DIR}/NuttX/apps_copy.stamp + WORKING_DIRECTORY ${PX4_SOURCE_DIR} + USES_TERMINAL + COMMAND_EXPAND_LISTS +) + +add_custom_target(boardguiconfig + ${CMAKE_COMMAND} -E env + ${COMMON_KCONFIG_ENV_SETTINGS} + ${GUICONFIG_PATH} Kconfig + COMMAND ${CMAKE_COMMAND} -E env ${COMMON_KCONFIG_ENV_SETTINGS} ${SAVEDEFCONFIG_PATH} + COMMAND ${CMAKE_COMMAND} -E copy defconfig ${BOARD_DEFCONFIG} + COMMAND ${CMAKE_COMMAND} -E rm ${PX4_BINARY_DIR}/NuttX/apps_copy.stamp + WORKING_DIRECTORY ${PX4_SOURCE_DIR} + USES_TERMINAL + COMMAND_EXPAND_LISTS +) diff --git a/cmake/px4_add_board.cmake b/cmake/px4_add_board.cmake deleted file mode 100644 index 9fdb5dbbf4..0000000000 --- a/cmake/px4_add_board.cmake +++ /dev/null @@ -1,195 +0,0 @@ -############################################################################ -# -# Copyright (c) 2018 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_board -# -# This function creates a PX4 board. -# -# Usage: -# px4_add_board( -# PLATFORM -# [ TOOLCHAIN ] -# [ ARCHITECTURE ] -# [ ROMFSROOT ] -# [ BUILD_BOOTLOADER ] -# [ IO ] -# [ UAVCAN_INTERFACES ] -# [ UAVCAN_PERIPHERALS ] -# [ DRIVERS ] -# [ MODULES ] -# [ SYSTEMCMDS ] -# [ EXAMPLES ] -# [ SERIAL_PORTS ] -# [ CONSTRAINED_FLASH ] -# [ NO_HELP ] -# [ CONSTRAINED_MEMORY ] -# [ EXTERNAL_METADATA ] -# [ TESTING ] -# [ LINKER_PREFIX ] -# [ ETHERNET ] -# [ CRYPTO ] -# [ KEYSTORE ] -# ) -# -# Input: -# PLATFORM : PX4 platform name (posix, nuttx, qurt) -# TOOLCHAIN : cmake toolchain -# ARCHITECTURE : name of the CPU CMake is building for (used by the toolchain) -# 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) -# UAVCAN_INTERFACES : number of interfaces for UAVCAN -# UAVCAN_PERIPHERALS : list of UAVCAN peripheral firmware to build and embed -# DRIVERS : list of drivers to build for this board (relative to src/drivers) -# MODULES : list of modules to build for this board (relative to src/modules) -# SYSTEMCMDS : list of system commands to build for this board (relative to src/systemcmds) -# EXAMPLES : list of example modules to build for this board (relative to src/examples) -# SERIAL_PORTS : mapping of user configurable serial ports and param facing name -# CONSTRAINED_FLASH : flag to enable constrained flash options (eg limit init script status text) -# NO_HELP : optional condition flag to disable help text on constrained flash systems -# CONSTRAINED_MEMORY : flag to enable constrained memory options (eg limit maximum number of uORB publications) -# EXTERNAL_METADATA : flag to exclude metadata to reduce flash -# TESTING : flag to enable automatic inclusion of PX4 testing modules -# LINKER_PREFIX : optional to prefix on the Linker script. -# ETHERNET : flag to indicate that ethernet is enabled -# CRYPTO : Crypto implementation selection -# KEYSTORE : Keystore implememntation selection -# -# -# Example: -# px4_add_board( -# PLATFORM nuttx -# TOOLCHAIN arm-none-eabi -# ARCHITECTURE cortex-m7 -# ROMFSROOT px4fmu_common -# IO px4_io-v2_default -# SERIAL_PORTS -# GPS1:/dev/ttyS0 -# TEL1:/dev/ttyS1 -# TEL2:/dev/ttyS2 -# TEL4:/dev/ttyS3 -# DRIVERS -# barometer/ms5611 -# gps -# imu/bosch/bmi055 -# imu/invensense/mpu6000 -# magnetometer/isentek/ist8310 -# pwm_out -# px4io -# rgbled -# MODULES -# commander -# ekf2 -# land_detector -# mavlink -# mc_att_control -# mc_pos_control -# navigator -# sensors -# MODULES -# mixer -# mtd -# param -# perf -# pwm -# reboot -# shutdown -# top -# topic_listener -# tune_control -# ) -# -function(px4_add_board) - - px4_parse_function_args( - NAME px4_add_board - ONE_VALUE - PLATFORM - TOOLCHAIN - ARCHITECTURE - ROMFSROOT - IO - UAVCAN_INTERFACES - UAVCAN_TIMER_OVERRIDE - LINKER_PREFIX - CRYPTO - KEYSTORE - MULTI_VALUE - DRIVERS - MODULES - SYSTEMCMDS - EXAMPLES - SERIAL_PORTS - UAVCAN_PERIPHERALS - OPTIONS - BUILD_BOOTLOADER - CONSTRAINED_FLASH - NO_HELP - CONSTRAINED_MEMORY - EXTERNAL_METADATA - TESTING - ETHERNET - REQUIRED - PLATFORM - ARGN ${ARGN}) - - set(PX4_BOARD_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE STRING "PX4 board directory" FORCE) - include_directories(${PX4_BOARD_DIR}/src) - - # get the VENDOR & MODEL from the caller's directory names - get_filename_component(base_dir "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) - get_filename_component(MODEL "${base_dir}" NAME) - get_filename_component(base_dir "${base_dir}" DIRECTORY) - get_filename_component(VENDOR "${base_dir}" NAME) - - set(PX4_BOARD ${VENDOR}_${MODEL} CACHE STRING "PX4 board" FORCE) - - # board name is uppercase with no underscores when used as a define - string(TOUPPER ${PX4_BOARD} PX4_BOARD_NAME) - string(REPLACE "-" "_" PX4_BOARD_NAME ${PX4_BOARD_NAME}) - set(PX4_BOARD_NAME ${PX4_BOARD_NAME} CACHE STRING "PX4 board define" FORCE) - - set(PX4_BOARD_VENDOR ${VENDOR} CACHE STRING "PX4 board vendor" FORCE) - set(PX4_BOARD_MODEL ${MODEL} CACHE STRING "PX4 board model" FORCE) - - if(NOT LABEL) - get_filename_component(LABEL "${CMAKE_CURRENT_LIST_FILE}" NAME_WE) - endif() - set(PX4_BOARD_LABEL ${LABEL} CACHE STRING "PX4 board label" FORCE) - - set(PX4_CONFIG "${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_${PX4_BOARD_LABEL}" CACHE STRING "PX4 config" FORCE) - - -endfunction() diff --git a/cmake/px4_config.cmake b/cmake/px4_config.cmake index 58e3db8e6a..a834cd04ce 100644 --- a/cmake/px4_config.cmake +++ b/cmake/px4_config.cmake @@ -37,7 +37,7 @@ if(NOT PX4_CONFIG_FILE) file(GLOB_RECURSE board_configs RELATIVE "${PX4_SOURCE_DIR}/boards" - "boards/*.cmake" + "boards/*.px4board" ) set(PX4_CONFIGS ${board_configs} CACHE STRING "PX4 board configs" FORCE) @@ -45,7 +45,7 @@ if(NOT PX4_CONFIG_FILE) foreach(filename ${board_configs}) # parse input CONFIG into components to match with existing in tree configs # the platform prefix (eg nuttx_) is historical, and removed if present - string(REPLACE ".cmake" "" filename_stripped ${filename}) + string(REPLACE ".px4board" "" filename_stripped ${filename}) string(REPLACE "/" ";" config ${filename_stripped}) list(LENGTH config config_len) @@ -62,6 +62,10 @@ if(NOT PX4_CONFIG_FILE) ((${label} STREQUAL "default") AND (${CONFIG} STREQUAL "${vendor}_${model}")) # default label can be omitted ) set(PX4_CONFIG_FILE "${PX4_SOURCE_DIR}/boards/${filename}" CACHE FILEPATH "path to PX4 CONFIG file" FORCE) + set(PX4_BOARD_DIR "${PX4_SOURCE_DIR}/boards/${vendor}/${model}" CACHE STRING "PX4 board directory" FORCE) + set(MODEL "${model}" CACHE STRING "PX4 board model" FORCE) + set(VENDOR "${vendor}" CACHE STRING "PX4 board vendor" FORCE) + set(LABEL "${label}" CACHE STRING "PX4 board vendor" FORCE) break() endif() @@ -71,6 +75,10 @@ if(NOT PX4_CONFIG_FILE) ((${label} STREQUAL "default") AND (${CONFIG} STREQUAL "${board}")) # default label can be omitted ) set(PX4_CONFIG_FILE "${PX4_SOURCE_DIR}/boards/${filename}" CACHE FILEPATH "path to PX4 CONFIG file" FORCE) + set(PX4_BOARD_DIR "${PX4_SOURCE_DIR}/boards/${vendor}/${model}" CACHE STRING "PX4 board directory" FORCE) + set(MODEL "${model}" CACHE STRING "PX4 board model" FORCE) + set(VENDOR "${vendor}" CACHE STRING "PX4 board vendor" FORCE) + set(LABEL "${label}" CACHE STRING "PX4 board vendor" FORCE) break() endif() endif() @@ -82,3 +90,24 @@ if(NOT PX4_CONFIG_FILE) endif() message(STATUS "PX4 config file: ${PX4_CONFIG_FILE}") + + +include_directories(${PX4_BOARD_DIR}/src) + +set(PX4_BOARD ${VENDOR}_${MODEL} CACHE STRING "PX4 board" FORCE) + +# board name is uppercase with no underscores when used as a define +string(TOUPPER ${PX4_BOARD} PX4_BOARD_NAME) +string(REPLACE "-" "_" PX4_BOARD_NAME ${PX4_BOARD_NAME}) +set(PX4_BOARD_NAME ${PX4_BOARD_NAME} CACHE STRING "PX4 board define" FORCE) + +set(PX4_BOARD_VENDOR ${VENDOR} CACHE STRING "PX4 board vendor" FORCE) +set(PX4_BOARD_MODEL ${MODEL} CACHE STRING "PX4 board model" FORCE) + +message(STATUS "PX4 vendor: ${PX4_BOARD_VENDOR}") +message(STATUS "PX4 vendor: ${vendor}") +message(STATUS "PX4 label: ${LABEL}") + +set(PX4_BOARD_LABEL ${LABEL} CACHE STRING "PX4 board label" FORCE) + +set(PX4_CONFIG "${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_${PX4_BOARD_LABEL}" CACHE STRING "PX4 config" FORCE)