From 01b3e6fd25adf427f29e27f8d57b31f7e54a376b Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Tue, 29 Aug 2017 17:22:05 -0400 Subject: [PATCH] NuttX upgrade cmake wrapper (#7873) * NuttX cmake * px4_macros:Pass the stringified predicate as second arg to static assert CC_ASSERT mapes to the c++ static_assert or provides the same funtionality for c via the other macros. The c++ static assert takes 2 argumants the prdicate and a message. This fixes the lacking second argument. * Updated nuttx and apps submodule to upstream nuttx 7.21+==master This is the latest uptake of upstream nuttx and apps. * ROMFS generate with xxd instead of objcopy * delete nuttx-patches * NuttX update submodules to latest px4_nuttx-master * fix nuttx apps and board dependency * docker_run update to latest container 2017-08-29 * cmake ROMFS portable sed usage * NuttX update submodules to latest px4_nuttx-master --- .gitmodules | 9 +- CMakeLists.txt | 70 +- Debug/poor-mans-profiler.sh | 2 +- Makefile | 42 +- NuttX | 1 - ROMFS/CMakeLists.txt | 45 ++ Tools/docker_run.sh | 10 +- Tools/fix_headers.sh | 8 +- Tools/new_nuttx_px_config.sh | 2 +- Tools/px4_snapflight_sanitytest.sh | 18 +- Tools/qgc_meta_sync.sh | 4 +- Tools/sitl_multiple_run.sh | 2 +- Tools/sitl_run.sh | 1 - cmake/common/px4_base.cmake | 46 +- cmake/common/px4_git.cmake | 68 +- cmake/common/px4_metadata.cmake | 8 +- cmake/configs/nuttx_aerocore2_default.cmake | 22 +- cmake/configs/nuttx_aerofc-v1_default.cmake | 10 +- cmake/configs/nuttx_auav-x21_default.cmake | 29 +- cmake/configs/nuttx_crazyflie_default.cmake | 24 +- cmake/configs/nuttx_esc35-v1_bootloader.cmake | 32 +- cmake/configs/nuttx_esc35-v1_default.cmake | 99 ++- cmake/configs/nuttx_mindpx-v2_default.cmake | 22 +- cmake/configs/nuttx_nxphlite-v3_default.cmake | 31 +- .../nuttx_px4-same70xplained-v1_default.cmake | 34 +- .../nuttx_px4-stm32f4discovery_default.cmake | 23 +- .../nuttx_px4cannode-v1_bootloader.cmake | 32 +- .../configs/nuttx_px4cannode-v1_default.cmake | 62 +- .../configs/nuttx_px4esc-v1_bootloader.cmake | 32 +- cmake/configs/nuttx_px4esc-v1_default.cmake | 100 ++- .../configs/nuttx_px4flow-v2_bootloader.cmake | 32 +- cmake/configs/nuttx_px4fmu-v2_default.cmake | 32 +- cmake/configs/nuttx_px4fmu-v2_test.cmake | 27 +- cmake/configs/nuttx_px4fmu-v3_default.cmake | 30 +- cmake/configs/nuttx_px4fmu-v4_default.cmake | 81 +-- .../configs/nuttx_px4fmu-v4pro_default.cmake | 29 +- cmake/configs/nuttx_px4fmu-v5_default.cmake | 23 +- cmake/configs/nuttx_px4io-v1_default.cmake | 12 + cmake/configs/nuttx_px4io-v2_default.cmake | 14 + .../nuttx_px4nucleoF767ZI-v1_default.cmake | 21 +- .../configs/nuttx_s2740vc-v1_bootloader.cmake | 32 +- cmake/configs/nuttx_s2740vc-v1_default.cmake | 12 +- cmake/configs/nuttx_tap-v1_default.cmake | 26 +- .../nuttx_zubaxgnss-v1_bootloader.cmake | 32 +- cmake/configs/posix_bebop_default.cmake | 2 - cmake/configs/posix_eagle_hil.cmake | 2 +- cmake/configs/posix_sdflight_default.cmake | 2 +- cmake/configs/posix_sdflight_legacy.cmake | 2 +- cmake/configs/posix_sitl_default.cmake | 7 +- cmake/configs/qurt_eagle_hil.cmake | 2 +- cmake/configs/qurt_eagle_travis.cmake | 2 +- cmake/nuttx/bin_to_obj.py | 98 --- cmake/nuttx/builtin_commands.c.in | 12 - cmake/nuttx/px4_impl_nuttx.cmake | 522 ++----------- cmake/nuttx/px4_uavcan_bootloader.cmake | 56 ++ cmake/posix/px4_impl_posix.cmake | 7 +- .../toolchains/Toolchain-arm-none-eabi.cmake | 22 +- eclipse.cproject | 2 +- eclipse.project | 6 +- nuttx-configs/aerocore2/nsh/defconfig | 2 +- nuttx-configs/aerofc-v1/nsh/defconfig | 2 +- nuttx-configs/auav-x21/nsh/defconfig | 2 +- nuttx-configs/px4esc-v1/bootloader/Make.defs | 10 +- nuttx-configs/px4esc-v1/nsh/defconfig | 6 +- nuttx-configs/px4fmu-v2/nsh/Make.defs | 1 - nuttx-configs/px4fmu-v3/include/board.h | 2 +- nuttx-configs/px4fmu-v3/nsh/Make.defs | 2 +- nuttx-configs/px4fmu-v3/nsh/defconfig | 4 +- nuttx-patches/00001-REJECTED-add-math.h.patch | 583 --------------- .../00002-REJECTED-fix-shadow-wanings.patch | 64 -- ...ECTED-add-var-expansion-in-nsh-parse.patch | 271 ------- ...avoid-export-copy-with-export-insitu.patch | 56 -- .../00006-REJECTED-cstdint-fix.patch | 24 - ...-REJECTED-silence-jobserver-warnings.patch | 40 - .../00008-REJECTED-static-assert-fix.patch | 13 - ...09-REJECTED-ctype-fix-shadow-wanings.patch | 20 - .../00010-REJECTED-no-irq-args.patch | 60 -- ...11-REJECTED-stm32_serial_no_irq_args.patch | 222 ------ ...000-PENDING-wip-inflight-to-upstream.patch | 0 platforms/nuttx/NuttX/CMakeLists.txt | 215 ++++++ platforms/nuttx/NuttX/apps | 1 + platforms/nuttx/NuttX/nuttx | 1 + src/drivers/airspeed/CMakeLists.txt | 3 +- src/drivers/batt_smbus/CMakeLists.txt | 1 - src/drivers/bmi160/bmi160.cpp | 4 - .../adc/module.mk => boards/CMakeLists.txt} | 17 +- src/drivers/boards/aerocore/CMakeLists.txt | 8 +- src/drivers/boards/aerocore2/CMakeLists.txt | 8 +- src/drivers/boards/aerofc-v1/CMakeLists.txt | 7 +- src/drivers/boards/aerofc-v1/aerofc_init.c | 7 - src/drivers/boards/aerofc-v1/board_config.h | 2 + src/drivers/boards/auav-x21/CMakeLists.txt | 9 +- .../drivers/boards/common}/CMakeLists.txt | 44 +- src/drivers/boards/common/board_crashdump.c | 8 + .../boards/common/kinetis/CMakeLists.txt | 39 + .../boards/common/samv7/CMakeLists.txt | 39 + .../boards/common/stm32/CMakeLists.txt | 46 ++ src/drivers/boards/crazyflie/CMakeLists.txt | 8 +- src/drivers/boards/eagle/CMakeLists.txt | 41 ++ src/drivers/boards/eagle/board_config.h | 8 +- src/drivers/boards/eagle/sitl_led.c | 81 +++ src/drivers/boards/esc35-v1/CMakeLists.txt | 32 +- .../boards/esc35-v1/bootloader/CMakeLists.txt | 28 +- src/drivers/boards/mindpx-v2/CMakeLists.txt | 9 +- src/drivers/boards/nxphlite-v3/CMakeLists.txt | 9 +- .../px4-same70xplained-v1/CMakeLists.txt | 7 - .../px4-stm32f4discovery/CMakeLists.txt | 6 +- .../px4-stm32f4discovery/px4discovery_init.c | 4 - .../boards/px4cannode-v1/CMakeLists.txt | 39 +- .../px4cannode-v1/bootloader/CMakeLists.txt | 27 +- src/drivers/boards/px4esc-v1/CMakeLists.txt | 35 +- .../px4esc-v1/bootloader/CMakeLists.txt | 28 +- src/drivers/boards/px4esc-v1/px4esc_init.c | 5 - src/drivers/boards/px4flow-v2/CMakeLists.txt | 33 +- .../px4flow-v2/bootloader/CMakeLists.txt | 28 +- src/drivers/boards/px4fmu-v2/CMakeLists.txt | 7 - src/drivers/boards/px4fmu-v2/px4fmu2_init.c | 154 ---- src/drivers/boards/px4fmu-v2/px4fmu_spi.c | 275 ------- src/drivers/boards/px4fmu-v3/CMakeLists.txt | 44 ++ src/drivers/boards/px4fmu-v3/px4fmu3_init.c | 687 ++++++++++++++++++ src/drivers/boards/px4fmu-v3/px4fmu3_led.c | 96 +++ src/drivers/boards/px4fmu-v3/px4fmu_can.c | 130 ++++ src/drivers/boards/px4fmu-v3/px4fmu_spi.c | 551 ++++++++++++++ .../boards/px4fmu-v3/px4fmu_timer_config.c | 126 ++++ src/drivers/boards/px4fmu-v3/px4fmu_usb.c | 107 +++ src/drivers/boards/px4fmu-v4/CMakeLists.txt | 9 +- .../boards/px4fmu-v4pro/CMakeLists.txt | 9 +- src/drivers/boards/px4fmu-v5/CMakeLists.txt | 9 +- src/drivers/boards/px4io-v2/CMakeLists.txt | 8 +- src/drivers/boards/px4io-v2/board_config.h | 2 + .../boards/px4nucleoF767ZI-v1/CMakeLists.txt | 8 +- src/drivers/boards/s2740vc-v1/CMakeLists.txt | 31 +- .../s2740vc-v1/bootloader/CMakeLists.txt | 28 +- src/drivers/boards/tap-v1/CMakeLists.txt | 9 +- .../boards/zubaxgnss-v1/CMakeLists.txt | 31 +- .../zubaxgnss-v1/bootloader/CMakeLists.txt | 28 +- src/drivers/bootloaders/CMakeLists.txt | 48 ++ src/drivers/bootloaders/include/uavcan.h | 2 +- .../src/arch/stm32/drivers/can/driver.c | 2 +- src/drivers/bootloaders/src/sched/timer.c | 2 +- src/drivers/device/CMakeLists.txt | 20 +- src/drivers/px4io/CMakeLists.txt | 26 +- src/firmware/nuttx/CMakeLists.txt | 280 ++++--- src/firmware/posix/CMakeLists.txt | 14 +- src/firmware/posix/sitl_target.cmake | 7 +- src/firmware/qurt/CMakeLists.txt | 11 +- src/lib/version/CMakeLists.txt | 32 + .../lib/version}/px_update_git_header.py | 20 +- src/lib/version/version.c | 2 +- .../micrortps_client/CMakeLists.txt | 145 ++-- .../microRTPS_client_main.cpp | 3 +- src/modules/px4iofirmware/CMakeLists.txt | 121 +-- src/modules/systemlib/px4_macros.h | 2 +- src/modules/uORB/CMakeLists.txt | 27 +- src/modules/uavcan/CMakeLists.txt | 4 + src/modules/uavcanesc/CMakeLists.txt | 26 +- src/modules/uavcannode/CMakeLists.txt | 23 +- src/platforms/common/CMakeLists.txt | 3 - .../posix/drivers/accelsim/CMakeLists.txt | 1 - 159 files changed, 3220 insertions(+), 4256 deletions(-) delete mode 160000 NuttX create mode 100644 ROMFS/CMakeLists.txt create mode 100644 cmake/configs/nuttx_px4io-v1_default.cmake create mode 100644 cmake/configs/nuttx_px4io-v2_default.cmake delete mode 100755 cmake/nuttx/bin_to_obj.py delete mode 100644 cmake/nuttx/builtin_commands.c.in create mode 100644 cmake/nuttx/px4_uavcan_bootloader.cmake delete mode 100644 nuttx-patches/00001-REJECTED-add-math.h.patch delete mode 100644 nuttx-patches/00002-REJECTED-fix-shadow-wanings.patch delete mode 100644 nuttx-patches/00003-REJECTED-add-var-expansion-in-nsh-parse.patch delete mode 100644 nuttx-patches/00004-REJECTED-avoid-export-copy-with-export-insitu.patch delete mode 100644 nuttx-patches/00006-REJECTED-cstdint-fix.patch delete mode 100644 nuttx-patches/00007-REJECTED-silence-jobserver-warnings.patch delete mode 100644 nuttx-patches/00008-REJECTED-static-assert-fix.patch delete mode 100644 nuttx-patches/00009-REJECTED-ctype-fix-shadow-wanings.patch delete mode 100644 nuttx-patches/00010-REJECTED-no-irq-args.patch delete mode 100644 nuttx-patches/00011-REJECTED-stm32_serial_no_irq_args.patch delete mode 100644 nuttx-patches/90000-PENDING-wip-inflight-to-upstream.patch create mode 100644 platforms/nuttx/NuttX/CMakeLists.txt create mode 160000 platforms/nuttx/NuttX/apps create mode 160000 platforms/nuttx/NuttX/nuttx rename src/drivers/{samv7/adc/module.mk => boards/CMakeLists.txt} (87%) rename {nuttx-patches => src/drivers/boards/common}/CMakeLists.txt (62%) create mode 100644 src/drivers/boards/common/kinetis/CMakeLists.txt create mode 100644 src/drivers/boards/common/samv7/CMakeLists.txt create mode 100644 src/drivers/boards/common/stm32/CMakeLists.txt create mode 100644 src/drivers/boards/eagle/CMakeLists.txt create mode 100644 src/drivers/boards/eagle/sitl_led.c create mode 100644 src/drivers/boards/px4fmu-v3/CMakeLists.txt create mode 100644 src/drivers/boards/px4fmu-v3/px4fmu3_init.c create mode 100644 src/drivers/boards/px4fmu-v3/px4fmu3_led.c create mode 100644 src/drivers/boards/px4fmu-v3/px4fmu_can.c create mode 100644 src/drivers/boards/px4fmu-v3/px4fmu_spi.c create mode 100644 src/drivers/boards/px4fmu-v3/px4fmu_timer_config.c create mode 100644 src/drivers/boards/px4fmu-v3/px4fmu_usb.c create mode 100644 src/drivers/bootloaders/CMakeLists.txt rename {Tools => src/lib/version}/px_update_git_header.py (75%) diff --git a/.gitmodules b/.gitmodules index 5f8d8ec431..3fe2eb801a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,9 +4,6 @@ [submodule "mavlink/include/mavlink/v2.0"] path = mavlink/include/mavlink/v2.0 url = https://github.com/mavlink/c_library_v2.git -[submodule "NuttX"] - path = NuttX - url = https://github.com/PX4/PX4NuttX.git [submodule "src/modules/uavcan/libuavcan"] path = src/modules/uavcan/libuavcan url = https://github.com/UAVCAN/libuavcan.git @@ -40,3 +37,9 @@ [submodule "src/lib/micro-CDR"] path = src/lib/micro-CDR url = https://github.com/eProsima/micro-CDR.git +[submodule "platforms/nuttx/NuttX/nuttx"] + path = platforms/nuttx/NuttX/nuttx + url = git@github.com:PX4-NuttX/nuttx.git +[submodule "platforms/nuttx/NuttX/apps"] + path = platforms/nuttx/NuttX/apps + url = git@github.com:PX4-NuttX/apps.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 356a8fd20e..5acead0d32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,14 +99,8 @@ # #============================================================================= -if (${CMAKE_VERSION} VERSION_LESS 3.1.0) - message("Not a valid CMake version") - message("On Ubuntu >= 16.04, install or upgrade via:") - message(" sudo apt-get install cmake") - message("") - message("Official website: https://cmake.org/download/") - message(FATAL_ERROR "Update CMake and try again" ) -endif() +# check submodules before we do anything +execute_process(COMMAND Tools/check_submodules.sh WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) # Warning: Changing this modifies CMake's internal workings # and leads to wrong toolchain detection @@ -115,15 +109,18 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) set(PX4_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(PX4_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") -execute_process( - COMMAND Tools/check_submodules.sh - WORKING_DIRECTORY ${PX4_SOURCE_DIR} - ) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PX4_BINARY_DIR}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PX4_BINARY_DIR}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PX4_BINARY_DIR}) + +define_property(GLOBAL PROPERTY PX4_LIBRARIES + BRIEF_DOCS "PX4 libs" + FULL_DOCS "List of all PX4 module libraries" + ) #============================================================================= # configuration # -# must come before project to set toolchain set(CONFIG "posix_sitl_default" CACHE STRING "desired configuration") @@ -145,7 +142,6 @@ if (NOT EXTERNAL_MODULES_LOCATION STREQUAL "") endif() list(APPEND CMAKE_MODULE_PATH "${PX4_SOURCE_DIR}/cmake") -message(STATUS "CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}") set(config_module "configs/${CONFIG}") include(${config_module}) @@ -176,16 +172,17 @@ message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}") # include(common/px4_git) +# version info from git execute_process( - COMMAND git describe --always --tags - OUTPUT_VARIABLE git_tag - OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND Tools/tag_to_version.py --root ${PX4_SOURCE_DIR} + OUTPUT_VARIABLE version WORKING_DIRECTORY ${PX4_SOURCE_DIR} ) execute_process( - COMMAND Tools/tag_to_version.py --root ${PX4_SOURCE_DIR} - OUTPUT_VARIABLE git_version + COMMAND git describe --always --tags + OUTPUT_VARIABLE git_tag + OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY ${PX4_SOURCE_DIR} ) @@ -202,12 +199,10 @@ px4_add_git_submodule(TARGET git_jmavsim PATH "Tools/jMAVSim") px4_add_git_submodule(TARGET git_matrix PATH "src/lib/matrix") px4_add_git_submodule(TARGET git_mavlink PATH "mavlink/include/mavlink/v1.0") px4_add_git_submodule(TARGET git_mavlink2 PATH "mavlink/include/mavlink/v2.0") -px4_add_git_submodule(TARGET git_nuttx PATH "NuttX") +px4_add_git_submodule(TARGET git_nuttx PATH "platforms/nuttx/NuttX") px4_add_git_submodule(TARGET git_uavcan PATH "src/modules/uavcan/libuavcan") px4_add_git_submodule(TARGET git_micro_cdr PATH "src/lib/micro-CDR") -px4_create_git_hash_header() - #============================================================================= message(STATUS "PX4 VERSION: ${git_tag}") @@ -225,18 +220,12 @@ add_definitions(-DBUILD_URI=${BUILD_URI}) # Define GNU standard installation directories include(GNUInstallDirs) -# Add support for external project building -include(ExternalProject) - # Setup install paths -if (NOT CMAKE_INSTALL_PREFIX) - if (${OS} STREQUAL "posix") +if (${OS} STREQUAL "posix") + if (NOT CMAKE_INSTALL_PREFIX) set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Install path prefix" FORCE) endif() endif() -if (CMAKE_INSTALL_PREFIX) - message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") -endif() #============================================================================= # require px4 module interface @@ -361,12 +350,11 @@ px4_os_add_flags( LINK_DIRS link_dirs DEFINITIONS definitions) -px4_join(OUT CMAKE_EXE_LINKER_FLAGS LIST "${exe_linker_flags}" GLUE " ") -px4_join(OUT CMAKE_C_FLAGS LIST "${c_flags};${optimization_flags}" GLUE " ") -px4_join(OUT CMAKE_CXX_FLAGS LIST "${cxx_flags};${optimization_flags}" GLUE " ") +px4_join(OUT CMAKE_EXE_LINKER_FLAGS LIST "${CMAKE_EXE_LINKER_FLAGS};${exe_linker_flags}" GLUE " ") +px4_join(OUT CMAKE_C_FLAGS LIST "${CMAKE_C_FLAGS};${c_flags};${optimization_flags}" GLUE " ") +px4_join(OUT CMAKE_CXX_FLAGS LIST "${CMAKE_CXX_FLAGS};${cxx_flags};${optimization_flags}" GLUE " ") include_directories(${include_dirs}) -#message("INCLUDE_DIRS=${include_dirs}") link_directories(${link_dirs}) add_definitions(${definitions}) @@ -381,10 +369,8 @@ px4_generate_messages(TARGET msg_gen MSG_FILES ${msg_files} OS ${OS} INCLUDES ${msg_include_paths} - DEPENDS git_genmsg git_gencpp git_micro_cdr prebuild_targets + DEPENDS prebuild_targets ) -include_directories("${PX4_SOURCE_DIR}/src/lib/micro-CDR/include" - "${PX4_BINARY_DIR}/src/lib/micro-CDR/include/microcdr") px4_generate_airframes_xml(BOARD ${BOARD}) @@ -439,7 +425,6 @@ endif() #============================================================================= # subdirectories # -set(module_libraries) foreach(module ${config_module_list}) string(REGEX MATCH "^[./]" external_module ${module}) if (external_module) @@ -449,19 +434,10 @@ foreach(module ${config_module_list}) else() add_subdirectory(src/${module}) endif() - px4_mangle_name(${module} mangled_name) - list(APPEND module_libraries ${mangled_name}) endforeach() -# Keep track of external shared libs required for modules -set(module_external_libraries "${module_external_libraries}" CACHE INTERNAL "module_external_libraries") - add_subdirectory(src/firmware/${OS}) -if (config_io_board) - add_subdirectory(src/modules/px4iofirmware) -endif() - #============================================================================= # generate custom target to print for all executable and module cmake targets # diff --git a/Debug/poor-mans-profiler.sh b/Debug/poor-mans-profiler.sh index 4b03e56310..1b1e4b272f 100755 --- a/Debug/poor-mans-profiler.sh +++ b/Debug/poor-mans-profiler.sh @@ -77,7 +77,7 @@ do shift done -[[ -z "$elf" ]] && die "Please specify the ELF file location, e.g.: build_px4fmu-v4_default/src/firmware/nuttx/firmware_nuttx" +[[ -z "$elf" ]] && die "Please specify the ELF file location, e.g.: build/px4fmu-v4_default/src/firmware/nuttx/firmware_nuttx" # # Temporary files diff --git a/Makefile b/Makefile index 40bb156de0..fd56d9bcfe 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ endif # make px4fmu-v2_default test (builds and tests) # # This tells cmake to build the nuttx px4fmu-v2 default config in the -# directory build_nuttx_px4fmu-v2_default and then call make +# directory build/nuttx_px4fmu-v2_default and then call make # in that directory with the target upload. # explicity set default build target @@ -132,7 +132,7 @@ endif # -------------------------------------------------------------------- # describe how to build a cmake config define cmake-build -+@$(eval BUILD_DIR = $(SRC_DIR)/build_$@$(BUILD_DIR_SUFFIX)) ++@$(eval BUILD_DIR = $(SRC_DIR)/build/$@$(BUILD_DIR_SUFFIX)) +@if [ $(PX4_CMAKE_GENERATOR) = "Ninja" ] && [ -e $(BUILD_DIR)/Makefile ]; then rm -rf $(BUILD_DIR); fi +@if [ ! -e $(BUILD_DIR)/CMakeCache.txt ]; then mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && cmake $(2) -G"$(PX4_CMAKE_GENERATOR)" -DCONFIG=$(1) $(CMAKE_ARGS) || (rm -rf $(BUILD_DIR)); fi +@(cd $(BUILD_DIR) && $(PX4_MAKE) $(PX4_MAKE_ARGS) $(ARGS)) @@ -191,6 +191,7 @@ qgc_firmware: px4fmu_firmware misc_qgc_extra_firmware sizes # px4fmu NuttX firmware px4fmu_firmware: \ + check_px4io-v2_default \ check_px4fmu-v2_default \ check_px4fmu-v3_default \ check_px4fmu-v4_default \ @@ -229,7 +230,7 @@ checks_bootloaders: \ sizes sizes: - @-find build_* -name firmware_nuttx -type f | xargs size 2> /dev/null || : + @-find build -name *.elf -type f | xargs size 2> /dev/null || : # All default targets that don't require a special build environment check: check_posix_sitl_default px4fmu_firmware misc_qgc_extra_firmware alt_firmware checks_bootloaders tests check_format @@ -277,25 +278,25 @@ s3put_firmware: Firmware.zip s3put_qgc_firmware: s3put_px4fmu_firmware s3put_misc_qgc_extra_firmware s3put_px4fmu_firmware: px4fmu_firmware - @find $(SRC_DIR)/build_* -name "*.px4" -exec $(SRC_DIR)/Tools/s3put.sh "{}" \; + @find $(SRC_DIR)/build -name "*.px4" -exec $(SRC_DIR)/Tools/s3put.sh "{}" \; s3put_misc_qgc_extra_firmware: misc_qgc_extra_firmware - @find $(SRC_DIR)/build_* -name "*.px4" -exec $(SRC_DIR)/Tools/s3put.sh "{}" \; + @find $(SRC_DIR)/build -name "*.px4" -exec $(SRC_DIR)/Tools/s3put.sh "{}" \; s3put_metadata: px4_metadata @$(SRC_DIR)/Tools/s3put.sh airframes.md @$(SRC_DIR)/Tools/s3put.sh airframes.xml - @$(SRC_DIR)/Tools/s3put.sh build_posix_sitl_default/parameters.xml + @$(SRC_DIR)/Tools/s3put.sh build/posix_sitl_default/parameters.xml @$(SRC_DIR)/Tools/s3put.sh parameters.md s3put_scan-build: scan-build - @cd $(SRC_DIR) && ./Tools/s3put.sh `find build_scan-build -mindepth 1 -maxdepth 1 -type d`/ + @cd $(SRC_DIR) && ./Tools/s3put.sh `find build/scan-build -mindepth 1 -maxdepth 1 -type d`/ s3put_cppcheck: cppcheck @cd $(SRC_DIR) && ./Tools/s3put.sh cppcheck/ s3put_coverage: tests_coverage - @cd $(SRC_DIR) && ./Tools/s3put.sh build_posix_sitl_default/coverage-html/ + @cd $(SRC_DIR) && ./Tools/s3put.sh build/posix_sitl_default/coverage-html/ # Astyle # -------------------------------------------------------------------- @@ -326,7 +327,7 @@ coveralls_upload: --exclude=src/lib/ecl \ --exclude=src/lib/Matrix \ --exclude=src/modules/uavcan/libuavcan \ - --root . --build-root build_posix_sitl_default/ --follow-symlinks + --root . --build-root build/posix_sitl_default/ --follow-symlinks codecov_upload: @/bin/bash -c "bash <(curl -s https://codecov.io/bash)" @@ -336,32 +337,32 @@ codecov_upload: .PHONY: posix_sitl_default-clang scan-build clang-tidy clang-tidy-fix clang-tidy-quiet cppcheck check_stack posix_sitl_default-clang: - @mkdir -p $(SRC_DIR)/build_posix_sitl_default-clang - @cd $(SRC_DIR)/build_posix_sitl_default-clang && cmake .. -GNinja -DCONFIG=posix_sitl_default -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ - @cd $(SRC_DIR)/build_posix_sitl_default-clang && ninja + @mkdir -p $(SRC_DIR)/build/posix_sitl_default-clang + @cd $(SRC_DIR)/build/posix_sitl_default-clang && cmake $(SRC_DIR) -GNinja -DCONFIG=posix_sitl_default -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ + @cd $(SRC_DIR)/build/posix_sitl_default-clang && ninja scan-build: @export CCC_CC=clang @export CCC_CXX=clang++ - @mkdir -p $(SRC_DIR)/build_posix_sitl_default-scan-build - @cd $(SRC_DIR)/build_posix_sitl_default-scan-build && scan-build cmake .. -GNinja -DCONFIG=posix_sitl_default - @scan-build -o $(SRC_DIR)/build_scan-build cmake --build $(SRC_DIR)/build_posix_sitl_default-scan-build + @mkdir -p $(SRC_DIR)/build/posix_sitl_default-scan-build + @cd $(SRC_DIR)/build/posix_sitl_default-scan-build && scan-build cmake .. -GNinja -DCONFIG=posix_sitl_default + @scan-build -o $(SRC_DIR)/build/scan-build cmake --build $(SRC_DIR)/build/posix_sitl_default-scan-build clang-tidy: posix_sitl_default-clang - @cd build_posix_sitl_default-clang && run-clang-tidy-4.0.py -header-filter=".*\.hpp" -j$(j) -p . + @cd build/posix_sitl_default-clang && run-clang-tidy-4.0.py -header-filter=".*\.hpp" -j$(j) -p . # to automatically fix a single check at a time, eg modernize-redundant-void-arg # % run-clang-tidy-4.0.py -fix -j4 -checks=-\*,modernize-redundant-void-arg -p . clang-tidy-fix: posix_sitl_default-clang - @cd build_posix_sitl_default-clang && run-clang-tidy-4.0.py -header-filter=".*\.hpp" -j$(j) -fix -p . + @cd build/posix_sitl_default-clang && run-clang-tidy-4.0.py -header-filter=".*\.hpp" -j$(j) -fix -p . # modified version of run-clang-tidy.py to return error codes and only output relevant results clang-tidy-quiet: posix_sitl_default-clang - @cd build_posix_sitl_default-clang && $(SRC_DIR)/Tools/run-clang-tidy.py -header-filter=".*\.hpp" -j$(j) -p . + @cd build/posix_sitl_default-clang && $(SRC_DIR)/Tools/run-clang-tidy.py -header-filter=".*\.hpp" -j$(j) -p . # TODO: Fix cppcheck errors then try --enable=warning,performance,portability,style,unusedFunction or --enable=all cppcheck: posix_sitl_default - @cppcheck -i$(SRC_DIR)/src/examples --std=c++11 --std=c99 --std=posix --project=build_posix_sitl_default/compile_commands.json --xml-version=2 2> cppcheck-result.xml + @cppcheck -i$(SRC_DIR)/src/examples --std=c++11 --std=c99 --std=posix --project=build/posix_sitl_default/compile_commands.json --xml-version=2 2> cppcheck-result.xml @cppcheck-htmlreport --source-encoding=ascii --file=cppcheck-result.xml --report-dir=cppcheck --source-dir=$(SRC_DIR)/src/ check_stack: px4fmu-v3_default @@ -384,8 +385,7 @@ check_stack: px4fmu-v3_default .PHONY: clean submodulesclean submodulesupdate gazeboclean distclean clean: - @rm -rf $(SRC_DIR)/build_*/ - -@$(MAKE) --no-print-directory -C NuttX/nuttx clean + @rm -rf $(SRC_DIR)/build submodulesclean: @git submodule foreach --quiet --recursive git clean -ff -x -d diff --git a/NuttX b/NuttX deleted file mode 160000 index ba18501226..0000000000 --- a/NuttX +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ba18501226ee264d21fd95348163d47847de3448 diff --git a/ROMFS/CMakeLists.txt b/ROMFS/CMakeLists.txt new file mode 100644 index 0000000000..1dacf69b99 --- /dev/null +++ b/ROMFS/CMakeLists.txt @@ -0,0 +1,45 @@ + +message(STATUS "ROMFS: ${config_romfs_root}") + +set(romfs_temp_dir ${PX4_BINARY_DIR}/ROMFS/${config_romfs_root}) +set(romfs_src_dir ${PX4_SOURCE_DIR}/ROMFS/${config_romfs_root}) + +# directory setup +# copy all romfs files, process airframes, prune comments +file(GLOB_RECURSE init_airframes ${PX4_SOURCE_DIR}/ROMFS/${config_romfs_root}/*/[1-9]*) +add_custom_command(OUTPUT ${romfs_temp_dir}/init.d/rcS ${romfs_temp_dir}/init.d/rc.autostart + COMMAND cmake -E copy_directory ${romfs_src_dir} ${romfs_temp_dir} + COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py + -a ${romfs_temp_dir}/init.d + -s ${romfs_temp_dir}/init.d/rc.autostart + --board ${BOARD} + COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_romfs_pruner.py + --folder ${romfs_temp_dir} --board ${BOARD} + DEPENDS + ${romfs_src_files} + ${init_airframes} + ${PX4_SOURCE_DIR}/ROMFS/${config_romfs_root}/init.d/rcS + ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py + ) + +set(romfs_dependencies) +list(APPEND romfs_dependencies + ${romfs_temp_dir}/init.d/rcS + ${romfs_temp_dir}/init.d/rc.autostart + ) + +# create romfs.bin +add_custom_command(OUTPUT romfs.img + COMMAND ${GENROMFS} -f romfs.img -d ${romfs_temp_dir} -V "NSHInitVol" -v > romfs.txt 2>&1 + DEPENDS ${romfs_dependencies} + ) + +# create romfs.o +add_custom_command(OUTPUT nsh_romfsimg.c + COMMAND xxd -i romfs.img nsh_romfsimg.c + COMMAND sed 's/unsigned/const unsigned/g' nsh_romfsimg.c > nsh_romfsimg.c.tmp && mv nsh_romfsimg.c.tmp nsh_romfsimg.c + DEPENDS romfs.img + ) + +add_library(romfs STATIC nsh_romfsimg.c) +set_target_properties(romfs PROPERTIES LINKER_LANGUAGE C) diff --git a/Tools/docker_run.sh b/Tools/docker_run.sh index 98432ef0d6..d508837e2c 100755 --- a/Tools/docker_run.sh +++ b/Tools/docker_run.sh @@ -4,23 +4,23 @@ if [ -z ${PX4_DOCKER_REPO+x} ]; then echo "guessing PX4_DOCKER_REPO based on input"; if [[ $@ =~ .*px4fmu.* ]]; then # nuttx-px4fmu-v{1,2,3,4,5} - PX4_DOCKER_REPO="px4io/px4-dev-nuttx:2017-07-27" + PX4_DOCKER_REPO="px4io/px4-dev-nuttx:2017-08-29" elif [[ $@ =~ .*rpi.* ]] || [[ $@ =~ .*bebop.* ]]; then # posix_rpi_cross, posix_bebop_default - PX4_DOCKER_REPO="px4io/px4-dev-raspi:2017-07-27" + PX4_DOCKER_REPO="px4io/px4-dev-raspi:2017-08-29" elif [[ $@ =~ .*eagle.* ]] || [[ $@ =~ .*excelsior.* ]]; then # eagle, excelsior PX4_DOCKER_REPO="lorenzmeier/px4-dev-snapdragon:2017-07-28" elif [[ $@ =~ .*clang.* ]] || [[ $@ =~ .*scan-build.* ]]; then # clang tools - PX4_DOCKER_REPO="px4io/px4-dev-clang:2017-07-27" + PX4_DOCKER_REPO="px4io/px4-dev-clang:2017-08-29" elif [[ $@ =~ .*cppcheck.* ]]; then # need Ubuntu 17.04 for cppcheck cmake support # TODO: remove this once px4io/px4-dev-base updates PX4_DOCKER_REPO=px4io/px4-dev-base:ubuntu17.04 elif [[ $@ =~ .*tests* ]]; then # run all tests with simulation - PX4_DOCKER_REPO="px4io/px4-dev-simulation:2017-07-27" + PX4_DOCKER_REPO="px4io/px4-dev-simulation:2017-08-29" fi else echo "PX4_DOCKER_REPO is set to '$PX4_DOCKER_REPO'"; @@ -28,7 +28,7 @@ fi # otherwise default to nuttx if [ -z ${PX4_DOCKER_REPO+x} ]; then - PX4_DOCKER_REPO="px4io/px4-dev-nuttx:2017-07-27" + PX4_DOCKER_REPO="px4io/px4-dev-nuttx:2017-08-29" fi # docker hygiene diff --git a/Tools/fix_headers.sh b/Tools/fix_headers.sh index fa43bd3938..e54d8d5fb5 100755 --- a/Tools/fix_headers.sh +++ b/Tools/fix_headers.sh @@ -79,7 +79,7 @@ fi # Find a reasonable tmp directory. # First make a list of all build directories by looking for a CMakeCache.txt in them. Sort them so the most recent one is first. -CMAKECACHE_FILES=$(find "$BASEDIR" -mindepth 2 -maxdepth 2 -type f -name CMakeCache.txt -wholename "$BASEDIR/build_*/CMakeCache.txt" | xargs /bin/ls -td) +CMAKECACHE_FILES=$(find "$BASEDIR" -mindepth 2 -maxdepth 2 -type f -name CMakeCache.txt -wholename "$BASEDIR/build/*/CMakeCache.txt" | xargs /bin/ls -td) # Make a list of all candidate tmp directories. TMPDIRS= for f in $CMAKECACHE_FILES; do @@ -195,7 +195,7 @@ for subm in $SUBMODULES; do done echo -n "Finding all source files with #include's (excluding submodules and build directory)... " -find $BASEDIR -mindepth 2 -type f ! \( -wholename $BASEDIR/build_* -o $EXCLUDE_ARGS -o $SUBMODULES_ARGS \) \( $INCLUDE_C_ARGS -o $INCLUDE_H_ARGS \) > $TMPDIR/fix_headers_sources +find $BASEDIR -mindepth 2 -type f ! \( -wholename $BASEDIR/build/* -o $EXCLUDE_ARGS -o $SUBMODULES_ARGS \) \( $INCLUDE_C_ARGS -o $INCLUDE_H_ARGS \) > $TMPDIR/fix_headers_sources cat "$TMPDIR/fix_headers_sources" | xargs grep -l "$INCLUDE_RE" > $TMPDIR/fix_headers_sources_with_includes echo "done" number_of_files=$(sed -n '$=' "$TMPDIR/fix_headers_sources_with_includes") @@ -206,7 +206,7 @@ find $BASEDIR -type f ! \( $EXCLUDE_ARGS \) \( $SUBMODULES_ARGS \) \( $INCLUDE_H echo "done" echo -n "Finding all header files (excluding stdc++ headers)... " -find $BASEDIR -type f ! \( $EXCLUDE_ARGS \) -wholename $BASEDIR/build_* \( $INCLUDE_H_ARGS \) > $TMPDIR/fix_headers_HEADERS +find $BASEDIR -type f ! \( $EXCLUDE_ARGS \) -wholename $BASEDIR/build/* \( $INCLUDE_H_ARGS \) > $TMPDIR/fix_headers_HEADERS grep -E "$HEADER_RE" $TMPDIR/fix_headers_sources >> $TMPDIR/fix_headers_HEADERS cat $TMPDIR/fix_headers_SUBMODULE_HEADERS >> $TMPDIR/fix_headers_HEADERS echo "done" @@ -233,7 +233,7 @@ function include_path() foo=0 for includedir in $(grep "/$PATH_RE\$" $TMPDIR/fix_headers_HEADERS | cut -c $striplen-); do # If the include directory is NuttX header that was copied to the build directory, then it's still a system file. - if [[ $includedir/ =~ ^build_.*/NuttX/ ]]; then + if [[ $includedir/ =~ ^build/.*/NuttX/ ]]; then issubmodule=1 # If the include directory is a submodule, then treat it as a system file. elif [[ $includedir/ =~ ^$SUBMODULES_RE/ ]]; then diff --git a/Tools/new_nuttx_px_config.sh b/Tools/new_nuttx_px_config.sh index 034de8a9fe..d382714601 100755 --- a/Tools/new_nuttx_px_config.sh +++ b/Tools/new_nuttx_px_config.sh @@ -168,6 +168,6 @@ fi sed -i -r -e 's%("(magic|description|summary)": ")([^"]*)(",).*%\1FIXME (was: \3)\4%' "Images/${newname}.prototype" echo "*** The following files contain a reference to $oldconfig (this might take a while):" -find . -path './build_*' -o -path './.git' -o -name 'defconfig' -prune -o -type f -exec grep -l -- "$oldconfig" {} \; +find . -path './build/*' -o -path './.git' -o -name 'defconfig' -prune -o -type f -exec grep -l -- "$oldconfig" {} \; echo "*** Run 'git diff' to check the changes that this script already made relative to the copied prototype files." echo "*** Use 'git status' to see other (added) files, that likely need fixing." diff --git a/Tools/px4_snapflight_sanitytest.sh b/Tools/px4_snapflight_sanitytest.sh index 1cbd117393..d62ca20e78 100755 --- a/Tools/px4_snapflight_sanitytest.sh +++ b/Tools/px4_snapflight_sanitytest.sh @@ -156,24 +156,24 @@ installpx4() { if [ $mode == 0 ]; then # copy default binaries echo -e "Copying the PX4 binaries from the eagle_default build tree..." - adb push $workspace/build_qurt_eagle_default/src/firmware/qurt/libpx4.so /usr/share/data/adsp - adb push $workspace/build_qurt_eagle_default/src/firmware/qurt/libpx4muorb_skel.so /usr/share/data/adsp - adb push $workspace/build_posix_eagle_default/src/firmware/posix/px4 /home/linaro + adb push $workspace/build/qurt_eagle_default/src/firmware/qurt/libpx4.so /usr/share/data/adsp + adb push $workspace/build/qurt_eagle_default/src/firmware/qurt/libpx4muorb_skel.so /usr/share/data/adsp + adb push $workspace/build/posix_eagle_default/src/firmware/posix/px4 /home/linaro adb push $workspace/posix-configs/eagle/flight/px4.config /usr/share/data/adsp adb push $workspace/posix-configs/eagle/flight/mainapp.config /home/linaro elif [ $mode == 1 ]; then # copy legacy binaries echo -e "Copying the PX4 binaries from the eagle_legacy build tree..." - adb push $workspace/build_qurt_eagle_legacy/src/firmware/qurt/libpx4.so /usr/share/data/adsp - adb push $workspace/build_qurt_eagle_legacy/src/firmware/qurt/libpx4muorb_skel.so /usr/share/data/adsp - adb push $workspace/build_posix_eagle_legacy/src/firmware/posix/px4 /home/linaro + adb push $workspace/build/qurt_eagle_legacy/src/firmware/qurt/libpx4.so /usr/share/data/adsp + adb push $workspace/build/qurt_eagle_legacy/src/firmware/qurt/libpx4muorb_skel.so /usr/share/data/adsp + adb push $workspace/build/posix_eagle_legacy/src/firmware/posix/px4 /home/linaro adb push $workspace/posix-configs/eagle/200qx/px4.config /usr/share/data/adsp adb push $workspace/posix-configs/eagle/200qx/mainapp.config /home/linaro else echo -e "Copying the PX4 binaries from the excelsior_legacy build tree..." - adb push $workspace/build_qurt_excelsior_legacy/src/firmware/qurt/libpx4.so /usr/lib/rfsa/adsp - adb push $workspace/build_qurt_excelsior_legacy/src/firmware/qurt/libpx4muorb_skel.so /usr/lib/rfsa/adsp - adb push $workspace/build_posix_excelsior_legacy/src/firmware/posix/px4 /home/root + adb push $workspace/build/qurt_excelsior_legacy/src/firmware/qurt/libpx4.so /usr/lib/rfsa/adsp + adb push $workspace/build/qurt_excelsior_legacy/src/firmware/qurt/libpx4muorb_skel.so /usr/lib/rfsa/adsp + adb push $workspace/build/posix_excelsior_legacy/src/firmware/posix/px4 /home/root adb push $workspace/posix-configs/excelsior/px4.config /usr/lib/rfsa/adsp adb push $workspace/posix-configs/excelsior/mainapp.config /home/root fi diff --git a/Tools/qgc_meta_sync.sh b/Tools/qgc_meta_sync.sh index 8ebcbdb3e5..ad66c63885 100755 --- a/Tools/qgc_meta_sync.sh +++ b/Tools/qgc_meta_sync.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash make px4fmu-v4_default -cp build_px4fmu-v4_default/parameters.xml ../qgroundcontrol/src/FirmwarePlugin/PX4/PX4ParameterFactMetaData.xml -cp build_px4fmu-v4_default/airframes.xml ../qgroundcontrol/src/AutoPilotPlugins/PX4/AirframeFactMetaData.xml +cp build/px4fmu-v4_default/parameters.xml ../qgroundcontrol/src/FirmwarePlugin/PX4/PX4ParameterFactMetaData.xml +cp build/px4fmu-v4_default/airframes.xml ../qgroundcontrol/src/AutoPilotPlugins/PX4/AirframeFactMetaData.xml diff --git a/Tools/sitl_multiple_run.sh b/Tools/sitl_multiple_run.sh index 82bf79f0d0..7f590d87cb 100755 --- a/Tools/sitl_multiple_run.sh +++ b/Tools/sitl_multiple_run.sh @@ -17,7 +17,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" src_path="$SCRIPT_DIR/.." rc_script="posix-configs/SITL/init/ekf2/multiple_iris" -build_path=${src_path}/build_posix_sitl_default +build_path=${src_path}/build/posix_sitl_default echo "killing running instances" pkill -x px4 || true diff --git a/Tools/sitl_run.sh b/Tools/sitl_run.sh index d089b1a628..d887be0f9e 100755 --- a/Tools/sitl_run.sh +++ b/Tools/sitl_run.sh @@ -23,7 +23,6 @@ echo src_path: $src_path echo build_path: $build_path working_dir=`pwd` -sitl_bin=$build_path/src/firmware/posix/px4 rootfs=$build_path/tmp/rootfs if [ "$chroot" == "1" ] diff --git a/cmake/common/px4_base.cmake b/cmake/common/px4_base.cmake index 778e195d47..f334372853 100644 --- a/cmake/common/px4_base.cmake +++ b/cmake/common/px4_base.cmake @@ -198,10 +198,6 @@ function(px4_add_module) REQUIRED MODULE ARGN ${ARGN}) - if (EXTERNAL) - px4_mangle_name("${EXTERNAL_MODULES_LOCATION}/src/${MODULE}" MODULE) - endif() - px4_add_library(${MODULE} STATIC EXCLUDE_FROM_ALL ${SRCS}) # set defaults if not set @@ -219,16 +215,14 @@ function(px4_add_module) if(NOT ${property}) set(${property} ${${property}_DEFAULT}) endif() - set_target_properties(${MODULE} PROPERTIES ${property} - ${${property}}) + set_target_properties(${MODULE} PROPERTIES ${property} ${${property}}) endforeach() # default stack max to stack main if(NOT STACK_MAX) set(STACK_MAX ${STACK_MAIN}) endif() - set_target_properties(${MODULE} PROPERTIES STACK_MAX - ${STACK_MAX}) + set_target_properties(${MODULE} PROPERTIES STACK_MAX ${STACK_MAX}) if(${OS} STREQUAL "qurt" ) set_property(TARGET ${MODULE} PROPERTY POSITION_INDEPENDENT_CODE TRUE) @@ -270,7 +264,6 @@ function(px4_add_module) set_target_properties(${MODULE} PROPERTIES ${prop} ${${prop}}) endif() endforeach() - endfunction() #============================================================================= @@ -479,14 +472,6 @@ function(px4_add_common_flags) -D__STDC_FORMAT_MACROS ) - if (NOT (APPLE AND (${CMAKE_C_COMPILER_ID} MATCHES ".*Clang.*"))) - set(added_exe_linker_flags - -Wl,--warn-common - -Wl,--gc-sections - #,--print-gc-sections - ) - endif() - # output foreach(var ${inout_vars}) string(TOLOWER ${var} lower_var) @@ -496,31 +481,6 @@ function(px4_add_common_flags) endfunction() -#============================================================================= -# -# px4_mangle_name -# -# Convert a path name to a module name -# -# Usage: -# px4_mangle_name(dirname newname) -# -# Input: -# dirname : path to module dir -# -# Output: -# newname : module name -# -# Example: -# px4_mangle_name(${dirpath} mangled_name) -# message(STATUS "module name is ${mangled_name}") -# -function(px4_mangle_name dirname newname) - set(tmp) - string(REPLACE "/" "__" tmp ${dirname}) - set(${newname} ${tmp} PARENT_SCOPE) -endfunction() - #============================================================================= # # px4_strip_optimization @@ -588,6 +548,8 @@ function(px4_add_library target) px4_add_optimization_flags_for_target(${target}) # Pass variable to the parent px4_add_module. set(_no_optimization_for_target ${_no_optimization_for_target} PARENT_SCOPE) + + set_property(GLOBAL APPEND PROPERTY PX4_LIBRARIES ${target}) endfunction() #============================================================================= diff --git a/cmake/common/px4_git.cmake b/cmake/common/px4_git.cmake index 88a179709c..c6edd76fc3 100644 --- a/cmake/common/px4_git.cmake +++ b/cmake/common/px4_git.cmake @@ -68,71 +68,15 @@ function(px4_add_git_submodule) ONE_VALUE TARGET PATH REQUIRED TARGET PATH ARGN ${ARGN}) + string(REPLACE "/" "_" NAME ${PATH}) + add_custom_command(OUTPUT ${PX4_BINARY_DIR}/git_init_${NAME}.stamp - WORKING_DIRECTORY ${PX4_SOURCE_DIR} - COMMAND touch ${PX4_BINARY_DIR}/git_init_${NAME}.stamp + COMMAND Tools/check_submodules.sh ${PATH} + COMMAND cmake -E touch ${PX4_BINARY_DIR}/git_init_${NAME}.stamp DEPENDS ${PX4_SOURCE_DIR}/.gitmodules - ) - add_custom_target(${TARGET} WORKING_DIRECTORY ${PX4_SOURCE_DIR} -# todo:Not have 2 list of submodules one (see the end of Tools/check_submodules.sh and Firmware/CMakeLists.txt) -# using the list of submodules from the CMake file to drive the test -# COMMAND Tools/check_submodules.sh ${PATH} - DEPENDS ${PX4_BINARY_DIR}/git_init_${NAME}.stamp ) -endfunction() - -#============================================================================= -# -# px4_create_git_hash_header -# -# Create a header file containing the git hash of the current tree -# -# Usage: -# px4_create_git_hash_header() -# -# Example: -# px4_create_git_hash_header() -# -function(px4_create_git_hash_header) - px4_parse_function_args( - NAME px4_create_git_hash_header - ARGN ${ARGN}) - - set(px4_git_ver_header ${PX4_BINARY_DIR}/build_git_version.h) - - # check if px4 source is a git repo - if(EXISTS ${PX4_SOURCE_DIR}/.git) - if (IS_DIRECTORY ${PX4_SOURCE_DIR}/.git) - # standard git repo - set(git_dir_path ${PX4_SOURCE_DIR}/.git) - else() - # git submodule - file(READ ${PX4_SOURCE_DIR}/.git git_dir_path) - string(STRIP ${git_dir_path} git_dir_path) - string(REPLACE "gitdir: " "" git_dir_path ${git_dir_path}) - get_filename_component(git_dir_path ${git_dir_path} ABSOLUTE) - endif() - else() - message(FATAL_ERROR "is not a git repository") - endif() - if(NOT IS_DIRECTORY "${git_dir_path}") - message(FATAL_ERROR "${git_dir_path} is not a directory") - endif() - - set(deps - ${PX4_SOURCE_DIR}/Tools/px_update_git_header.py - ${git_dir_path}/index - ${git_dir_path}/HEAD) - - add_custom_command( - OUTPUT ${px4_git_ver_header} - COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_update_git_header.py ${px4_git_ver_header} > ${PX4_BINARY_DIR}/git_header.log - DEPENDS ${deps} - WORKING_DIRECTORY ${PX4_SOURCE_DIR} - COMMENT "Generating git hash header" - ) - set_source_files_properties(${px4_git_ver_header} PROPERTIES GENERATED TRUE) - add_custom_target(ver_gen ALL DEPENDS ${px4_git_ver_header}) + + add_custom_target(${TARGET} DEPENDS ${PX4_BINARY_DIR}/git_init_${NAME}.stamp) endfunction() diff --git a/cmake/common/px4_metadata.cmake b/cmake/common/px4_metadata.cmake index 2ab92ec5c6..f07a6364ec 100644 --- a/cmake/common/px4_metadata.cmake +++ b/cmake/common/px4_metadata.cmake @@ -73,7 +73,7 @@ function(px4_generate_messages) REQUIRED MSG_FILES OS TARGET ARGN ${ARGN}) - if("${config_nuttx_config}" STREQUAL "bootloader") + if("${nuttx_config_type}" STREQUAL "bootloader") # do nothing for bootloaders else() @@ -162,6 +162,12 @@ function(px4_generate_messages) ${msg_multi_files_out} ${msg_files_out} ) + + target_include_directories(${TARGET} + PRIVATE ${PX4_SOURCE_DIR}/src/lib/micro-CDR/include + PRIVATE ${PX4_BINARY_DIR}/src/lib/micro-CDR/include/microcdr + ) + target_link_libraries(${TARGET} PRIVATE lib__micro-CDR) endif() endfunction() diff --git a/cmake/configs/nuttx_aerocore2_default.cmake b/cmake/configs/nuttx_aerocore2_default.cmake index 836c049b8a..cdd136869b 100644 --- a/cmake/configs/nuttx_aerocore2_default.cmake +++ b/cmake/configs/nuttx_aerocore2_default.cmake @@ -2,8 +2,6 @@ include(nuttx/px4_impl_nuttx) px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - set(config_uavcan_num_ifaces 2) set(config_module_list @@ -16,7 +14,7 @@ set(config_module_list drivers/stm32/tone_alarm drivers/led drivers/px4fmu - drivers/boards/aerocore2 + drivers/boards drivers/lsm303d drivers/l3gd20 drivers/ms5611 @@ -63,6 +61,7 @@ set(config_module_list #modules/commander/commander_tests #lib/controllib/controllib_test #modules/mavlink/mavlink_tests + #modules/unit_test #modules/uORB/uORB_tests #systemcmds/tests @@ -169,20 +168,3 @@ set(config_module_list # Hardware test #examples/hwtest ) - -set(config_extra_builtin_cmds - serdis - sercon - ) - -add_custom_target(sercon) -set_target_properties(sercon PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "sercon" STACK_MAIN "2048" - COMPILE_FLAGS "-Os") - -add_custom_target(serdis) -set_target_properties(serdis PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "serdis" STACK_MAIN "2048" - COMPILE_FLAGS "-Os") diff --git a/cmake/configs/nuttx_aerofc-v1_default.cmake b/cmake/configs/nuttx_aerofc-v1_default.cmake index 523a938bcd..ce1f44e144 100644 --- a/cmake/configs/nuttx_aerofc-v1_default.cmake +++ b/cmake/configs/nuttx_aerofc-v1_default.cmake @@ -2,8 +2,6 @@ include(nuttx/px4_impl_nuttx) px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - set(config_uavcan_num_ifaces 2) set(config_module_list @@ -14,7 +12,7 @@ set(config_module_list drivers/stm32 drivers/led drivers/px4fmu - drivers/boards/aerofc-v1 + drivers/boards drivers/tap_esc drivers/mpu9250 drivers/ms5611 @@ -95,9 +93,3 @@ set(config_module_list platforms/common platforms/nuttx/px4_layer ) - -set(config_extra_builtin_cmds - ) - -set(config_io_board - ) diff --git a/cmake/configs/nuttx_auav-x21_default.cmake b/cmake/configs/nuttx_auav-x21_default.cmake index 89aca889b1..c0180bfe81 100644 --- a/cmake/configs/nuttx_auav-x21_default.cmake +++ b/cmake/configs/nuttx_auav-x21_default.cmake @@ -1,8 +1,6 @@ include(nuttx/px4_impl_nuttx) -px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common) - -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) +px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common IO px4io-v2) set(config_uavcan_num_ifaces 1) @@ -17,7 +15,7 @@ set(config_module_list drivers/led drivers/px4fmu drivers/px4io - drivers/boards/auav-x21 + drivers/boards drivers/rgbled drivers/mpu6000 drivers/mpu9250 @@ -190,26 +188,3 @@ set(config_module_list # Hardware test #examples/hwtest ) - -set(config_extra_builtin_cmds - serdis - sercon - ) - -set(config_io_board - px4io-v2 - ) - -add_custom_target(sercon) -set_target_properties(sercon PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "sercon" - STACK_MAIN "2048" - COMPILE_FLAGS "-Os") - -add_custom_target(serdis) -set_target_properties(serdis PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "serdis" - STACK_MAIN "2048" - COMPILE_FLAGS "-Os") diff --git a/cmake/configs/nuttx_crazyflie_default.cmake b/cmake/configs/nuttx_crazyflie_default.cmake index afb2b75568..f876bcaa0f 100644 --- a/cmake/configs/nuttx_crazyflie_default.cmake +++ b/cmake/configs/nuttx_crazyflie_default.cmake @@ -2,8 +2,6 @@ include(nuttx/px4_impl_nuttx) px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - set(config_module_list # # Board support modules @@ -12,7 +10,7 @@ set(config_module_list drivers/stm32 drivers/led drivers/px4fmu - drivers/boards/crazyflie + drivers/boards drivers/mpu9250 drivers/lps25h drivers/gps @@ -45,7 +43,6 @@ set(config_module_list modules/mavlink #modules/gpio_led modules/land_detector - modules/syslink # @@ -138,22 +135,3 @@ set(config_module_list # Hardware test #examples/hwtest ) - -set(config_extra_builtin_cmds - serdis - sercon - ) - -add_custom_target(sercon) -set_target_properties(sercon PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "sercon" - STACK_MAIN "2048" - COMPILE_FLAGS "-Os") - -add_custom_target(serdis) -set_target_properties(serdis PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "serdis" - STACK_MAIN "2048" - COMPILE_FLAGS "-Os") diff --git a/cmake/configs/nuttx_esc35-v1_bootloader.cmake b/cmake/configs/nuttx_esc35-v1_bootloader.cmake index 9967758a66..6f44573bdd 100644 --- a/cmake/configs/nuttx_esc35-v1_bootloader.cmake +++ b/cmake/configs/nuttx_esc35-v1_bootloader.cmake @@ -1,30 +1,2 @@ -include(nuttx/px4_impl_nuttx) - -px4_nuttx_configure(HWCLASS m4 CONFIG bootloader) - -set(px4_src_base ${CMAKE_SOURCE_DIR}/src/) -set(px4_bootloader_base ${px4_src_base}drivers/bootloaders/) -set(px4_module_base ${px4_src_base}modules/) - -# -# UAVCAN boot loadable Module ID - -# -# Bring in common uavcan hardware identity definitions -# - -include(configs/uavcan_board_ident/esc35-v1) - -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - -set(config_module_list - - drivers/boards/esc35-v1/bootloader - -) - -# -# Bootloaders use a compact vector table not -# from the lib, but exported in startup -# -set(nuttx_startup_files stm32_vectors.o) +include(nuttx/px4_uavcan_bootloader) +px4_nuttx_configure(HWCLASS m4 CONFIG bootloader) \ No newline at end of file diff --git a/cmake/configs/nuttx_esc35-v1_default.cmake b/cmake/configs/nuttx_esc35-v1_default.cmake index 2961b41264..5528f163db 100644 --- a/cmake/configs/nuttx_esc35-v1_default.cmake +++ b/cmake/configs/nuttx_esc35-v1_default.cmake @@ -1,97 +1,80 @@ include(nuttx/px4_impl_nuttx) add_definitions( - -DFLASH_BASED_PARAMS - -DPARAM_NO_ORB - -DPARAM_NO_AUTOSAVE - -DPARAMETER_BUFFER_SIZE=1024 + -DFLASH_BASED_PARAMS + -DPARAM_NO_ORB + -DPARAM_NO_AUTOSAVE + -DPARAMETER_BUFFER_SIZE=1024 ) px4_nuttx_configure(HWCLASS m4 CONFIG nsh) -# # UAVCAN boot loadable Module ID - set(uavcanblid_sw_version_major 0) set(uavcanblid_sw_version_minor 1) +add_definitions( + -DAPP_VERSION_MAJOR=${uavcanblid_sw_version_major} + -DAPP_VERSION_MINOR=${uavcanblid_sw_version_minor} + ) -# # Bring in common uavcan hardware identity definitions -# - include(configs/uavcan_board_ident/esc35-v1) +add_definitions( + -DHW_UAVCAN_NAME=${uavcanblid_name} + -DHW_VERSION_MAJOR=${uavcanblid_hw_version_major} + -DHW_VERSION_MINOR=${uavcanblid_hw_version_minor} +) px4_nuttx_make_uavcan_bootloadable(BOARD ${BOARD} - BIN ${CMAKE_CURRENT_BINARY_DIR}/src/firmware/nuttx/firmware_nuttx.bin - HWNAME ${uavcanblid_name} - HW_MAJOR ${uavcanblid_hw_version_major} - HW_MINOR ${uavcanblid_hw_version_minor} - SW_MAJOR ${uavcanblid_sw_version_major} - SW_MINOR ${uavcanblid_sw_version_minor}) + BIN ${CMAKE_CURRENT_BINARY_DIR}/src/firmware/nuttx/esc35-v1.bin + HWNAME ${uavcanblid_name} + HW_MAJOR ${uavcanblid_hw_version_major} + HW_MINOR ${uavcanblid_hw_version_minor} + SW_MAJOR ${uavcanblid_sw_version_major} + SW_MINOR ${uavcanblid_sw_version_minor} +) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) +include_directories(${PX4_SOURCE_DIR}/src/drivers/boards/esc35-v1/bootloader) set(config_module_list - # # Board support modules # - - drivers/stm32 + drivers/boards + drivers/bootloaders + drivers/device drivers/led - drivers/boards/esc35-v1 + drivers/stm32 # # System commands # + systemcmds/config systemcmds/reboot systemcmds/top - systemcmds/config + systemcmds/param systemcmds/ver - systemcmds/param # # General system control # - modules/uavcanesc - modules/uavcanesc/nshterm - modules/uavcanesc/commands/cfg - modules/uavcanesc/commands/selftest - modules/uavcanesc/commands/dc - modules/uavcanesc/commands/rpm - modules/uavcanesc/commands/stat + modules/uavcanesc + modules/uavcanesc/nshterm + modules/uavcanesc/commands/cfg + modules/uavcanesc/commands/selftest + modules/uavcanesc/commands/dc + modules/uavcanesc/commands/rpm + modules/uavcanesc/commands/stat # # Library modules # - modules/systemlib/param - modules/systemlib - modules/uORB - lib/version - - # - # Libraries - # - # had to add for cmake, not sure why wasn't in original config - platforms/nuttx - platforms/common - platforms/nuttx/px4_layer lib/micro-CDR - - + lib/version + modules/systemlib + modules/systemlib/param + modules/uORB + platforms/common + platforms/nuttx + platforms/nuttx/px4_layer ) - -set(config_extra_builtin_cmds - serdis - sercon - ) - -add_custom_target(sercon) -set_target_properties(sercon PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "sercon" STACK_MAIN "2048") - -add_custom_target(serdis) -set_target_properties(serdis PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "serdis" STACK_MAIN "2048") diff --git a/cmake/configs/nuttx_mindpx-v2_default.cmake b/cmake/configs/nuttx_mindpx-v2_default.cmake index e2f1c6ddad..8da71c258a 100644 --- a/cmake/configs/nuttx_mindpx-v2_default.cmake +++ b/cmake/configs/nuttx_mindpx-v2_default.cmake @@ -2,8 +2,6 @@ include(nuttx/px4_impl_nuttx) px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - set(config_uavcan_num_ifaces 1) set(config_module_list @@ -16,8 +14,9 @@ set(config_module_list drivers/stm32/tone_alarm drivers/led drivers/px4fmu - drivers/boards/mindpx-v2 + drivers/boards drivers/rgbled + #drivers/rgbled_pwm drivers/mpu6000 drivers/mpu9250 drivers/lsm303d @@ -208,20 +207,3 @@ set(config_rtps_send_topics set(config_rtps_receive_topics sensor_baro ) - -set(config_extra_builtin_cmds - serdis - sercon - ) - -add_custom_target(sercon) -set_target_properties(sercon PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "sercon" - STACK_MAIN "2048") - -add_custom_target(serdis) -set_target_properties(serdis PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "serdis" - STACK_MAIN "2048") diff --git a/cmake/configs/nuttx_nxphlite-v3_default.cmake b/cmake/configs/nuttx_nxphlite-v3_default.cmake index 3e18b188b4..2deabec29b 100644 --- a/cmake/configs/nuttx_nxphlite-v3_default.cmake +++ b/cmake/configs/nuttx_nxphlite-v3_default.cmake @@ -2,8 +2,6 @@ include(nuttx/px4_impl_nuttx) px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - set(config_uavcan_num_ifaces 1) set(config_module_list @@ -15,7 +13,7 @@ set(config_module_list #NOT Supported drivers/bma180 #NOT Supported drivers/bmi160 drivers/bmp280 - drivers/boards/nxphlite-v3 + drivers/boards drivers/bst drivers/camera_trigger drivers/device @@ -212,30 +210,3 @@ set(config_module_list # EKF examples/ekf_att_pos_estimator ) - -set(config_extra_builtin_cmds - serdis - sercon - ) - -set(config_extra_libs -##NO CAN YET uavcan -##NO CAN YET uavcan_stm32_driver - ) - -set(config_io_extra_libs - ) - -add_custom_target(sercon) -set_target_properties(sercon PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "sercon" - STACK_MAIN "2048" - COMPILE_FLAGS "-Os") - -add_custom_target(serdis) -set_target_properties(serdis PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "serdis" - STACK_MAIN "2048" - COMPILE_FLAGS "-Os") diff --git a/cmake/configs/nuttx_px4-same70xplained-v1_default.cmake b/cmake/configs/nuttx_px4-same70xplained-v1_default.cmake index 4ba3c8d879..6ad629ad22 100644 --- a/cmake/configs/nuttx_px4-same70xplained-v1_default.cmake +++ b/cmake/configs/nuttx_px4-same70xplained-v1_default.cmake @@ -2,8 +2,6 @@ include(nuttx/px4_impl_nuttx) px4_nuttx_configure(HWCLASS m7 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - ##set(config_uavcan_num_ifaces 2) set(config_module_list @@ -16,8 +14,7 @@ set(config_module_list drivers/samv7/tone_alarm drivers/led drivers/px4fmu -#WIP drivers/px4io - drivers/boards/px4-same70xplained-v1 + drivers/boards drivers/rgbled drivers/mpu6000 drivers/mpu9250 @@ -172,31 +169,4 @@ set(config_module_list # Hardware test #examples/hwtest -) - -set(config_extra_builtin_cmds - serdis - sercon - ) - - set(config_extra_libs -# uavcan -# uavcan_stm32_driver - ) - -set(config_io_extra_libs - ) - -add_custom_target(sercon) -set_target_properties(sercon PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "sercon" - STACK_MAIN "2048" - COMPILE_FLAGS "-Os") - -add_custom_target(serdis) -set_target_properties(serdis PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "serdis" - STACK_MAIN "2048" - COMPILE_FLAGS "-Os") +) \ No newline at end of file diff --git a/cmake/configs/nuttx_px4-stm32f4discovery_default.cmake b/cmake/configs/nuttx_px4-stm32f4discovery_default.cmake index 74b38b787a..8172dcbd0a 100644 --- a/cmake/configs/nuttx_px4-stm32f4discovery_default.cmake +++ b/cmake/configs/nuttx_px4-stm32f4discovery_default.cmake @@ -2,8 +2,6 @@ include(nuttx/px4_impl_nuttx) px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - set(config_module_list # # Board support modules @@ -11,7 +9,7 @@ set(config_module_list drivers/device drivers/stm32 drivers/led - drivers/boards/px4-stm32f4discovery + drivers/boards # # System commands @@ -76,21 +74,4 @@ set(config_module_list # Hardware test #examples/hwtest -) - -set(config_extra_builtin_cmds - serdis - sercon - ) - -add_custom_target(sercon) -set_target_properties(sercon PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "sercon" - STACK_MAIN "2048") - -add_custom_target(serdis) -set_target_properties(serdis PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "serdis" - STACK_MAIN "2048") +) \ No newline at end of file diff --git a/cmake/configs/nuttx_px4cannode-v1_bootloader.cmake b/cmake/configs/nuttx_px4cannode-v1_bootloader.cmake index 687985c3de..ec1c447072 100644 --- a/cmake/configs/nuttx_px4cannode-v1_bootloader.cmake +++ b/cmake/configs/nuttx_px4cannode-v1_bootloader.cmake @@ -1,30 +1,2 @@ -include(nuttx/px4_impl_nuttx) - -px4_nuttx_configure(HWCLASS m3 CONFIG bootloader) - -set(px4_src_base ${CMAKE_SOURCE_DIR}/src/) -set(px4_bootloader_base ${px4_src_base}drivers/bootloaders/) -set(px4_module_base ${px4_src_base}modules/) - -# -# UAVCAN boot loadable Module ID - -# -# Bring in common uavcan hardware identity definitions -# - -include(configs/uavcan_board_ident/px4cannode-v1) - -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - -set(config_module_list - - drivers/boards/px4cannode-v1/bootloader - -) - -# -# Bootloaders use a compact vector table not -# from the lib, but exported in startup -# -set(nuttx_startup_files stm32_vectors.o) +include(nuttx/px4_uavcan_bootloader) +px4_nuttx_configure(HWCLASS m3 CONFIG bootloader) \ No newline at end of file diff --git a/cmake/configs/nuttx_px4cannode-v1_default.cmake b/cmake/configs/nuttx_px4cannode-v1_default.cmake index bf0a78c15d..1e0a57447c 100644 --- a/cmake/configs/nuttx_px4cannode-v1_default.cmake +++ b/cmake/configs/nuttx_px4cannode-v1_default.cmake @@ -7,44 +7,49 @@ add_definitions( px4_nuttx_configure(HWCLASS m3 CONFIG nsh) -# # UAVCAN boot loadable Module ID - set(uavcanblid_sw_version_major 0) set(uavcanblid_sw_version_minor 1) +add_definitions( + -DAPP_VERSION_MAJOR=${uavcanblid_sw_version_major} + -DAPP_VERSION_MINOR=${uavcanblid_sw_version_minor} + ) -# # Bring in common uavcan hardware identity definitions -# - include(configs/uavcan_board_ident/px4cannode-v1) +add_definitions( + -DHW_UAVCAN_NAME=${uavcanblid_name} + -DHW_VERSION_MAJOR=${uavcanblid_hw_version_major} + -DHW_VERSION_MINOR=${uavcanblid_hw_version_minor} +) px4_nuttx_make_uavcan_bootloadable(BOARD ${BOARD} - BIN ${CMAKE_CURRENT_BINARY_DIR}/src/firmware/nuttx/firmware_nuttx.bin - HWNAME ${uavcanblid_name} - HW_MAJOR ${uavcanblid_hw_version_major} - HW_MINOR ${uavcanblid_hw_version_minor} - SW_MAJOR ${uavcanblid_sw_version_major} - SW_MINOR ${uavcanblid_sw_version_minor}) + BIN ${CMAKE_CURRENT_BINARY_DIR}/src/firmware/nuttx/px4cannode-v1.bin + HWNAME ${uavcanblid_name} + HW_MAJOR ${uavcanblid_hw_version_major} + HW_MINOR ${uavcanblid_hw_version_minor} + SW_MAJOR ${uavcanblid_sw_version_major} + SW_MINOR ${uavcanblid_sw_version_minor} +) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) +include_directories(${PX4_SOURCE_DIR}/src/drivers/boards/px4cannode-v1/bootloader) set(config_module_list - # # Board support modules # - - drivers/stm32 + drivers/boards + drivers/bootloaders + drivers/device drivers/led - drivers/boards/px4cannode-v1 + drivers/stm32 # # System commands # + systemcmds/config systemcmds/reboot systemcmds/top - systemcmds/config systemcmds/ver # @@ -55,19 +60,12 @@ set(config_module_list # # Library modules # - modules/systemlib/param - modules/systemlib - modules/uORB - lib/version - - # - # Libraries - # - # had to add for cmake, not sure why wasn't in original config - platforms/nuttx - platforms/common - platforms/nuttx/px4_layer lib/micro-CDR - - -) + lib/version + modules/systemlib + modules/systemlib/param + modules/uORB + platforms/common + platforms/nuttx + platforms/nuttx/px4_layer +) \ No newline at end of file diff --git a/cmake/configs/nuttx_px4esc-v1_bootloader.cmake b/cmake/configs/nuttx_px4esc-v1_bootloader.cmake index cf7c566afd..6f44573bdd 100644 --- a/cmake/configs/nuttx_px4esc-v1_bootloader.cmake +++ b/cmake/configs/nuttx_px4esc-v1_bootloader.cmake @@ -1,30 +1,2 @@ -include(nuttx/px4_impl_nuttx) - -px4_nuttx_configure(HWCLASS m4 CONFIG bootloader) - -set(px4_src_base ${CMAKE_SOURCE_DIR}/src/) -set(px4_bootloader_base ${px4_src_base}drivers/bootloaders/) -set(px4_module_base ${px4_src_base}modules/) - -# -# UAVCAN boot loadable Module ID - -# -# Bring in common uavcan hardware identity definitions -# - -include(configs/uavcan_board_ident/px4esc-v1) - -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - -set(config_module_list - - drivers/boards/px4esc-v1/bootloader - -) - -# -# Bootloaders use a compact vector table not -# from the lib, but exported in startup -# -set(nuttx_startup_files stm32_vectors.o) +include(nuttx/px4_uavcan_bootloader) +px4_nuttx_configure(HWCLASS m4 CONFIG bootloader) \ No newline at end of file diff --git a/cmake/configs/nuttx_px4esc-v1_default.cmake b/cmake/configs/nuttx_px4esc-v1_default.cmake index 4627ef8084..36582bcf20 100644 --- a/cmake/configs/nuttx_px4esc-v1_default.cmake +++ b/cmake/configs/nuttx_px4esc-v1_default.cmake @@ -1,96 +1,80 @@ include(nuttx/px4_impl_nuttx) add_definitions( - -DFLASH_BASED_PARAMS - -DPARAM_NO_ORB - -DPARAM_NO_AUTOSAVE - -DPARAMETER_BUFFER_SIZE=1024 + -DFLASH_BASED_PARAMS + -DPARAM_NO_ORB + -DPARAM_NO_AUTOSAVE + -DPARAMETER_BUFFER_SIZE=1024 ) px4_nuttx_configure(HWCLASS m4 CONFIG nsh) -# # UAVCAN boot loadable Module ID - set(uavcanblid_sw_version_major 0) set(uavcanblid_sw_version_minor 1) +add_definitions( + -DAPP_VERSION_MAJOR=${uavcanblid_sw_version_major} + -DAPP_VERSION_MINOR=${uavcanblid_sw_version_minor} + ) -# # Bring in common uavcan hardware identity definitions -# - include(configs/uavcan_board_ident/px4esc-v1) +add_definitions( + -DHW_UAVCAN_NAME=${uavcanblid_name} + -DHW_VERSION_MAJOR=${uavcanblid_hw_version_major} + -DHW_VERSION_MINOR=${uavcanblid_hw_version_minor} +) px4_nuttx_make_uavcan_bootloadable(BOARD ${BOARD} - BIN ${CMAKE_CURRENT_BINARY_DIR}/src/firmware/nuttx/firmware_nuttx.bin - HWNAME ${uavcanblid_name} - HW_MAJOR ${uavcanblid_hw_version_major} - HW_MINOR ${uavcanblid_hw_version_minor} - SW_MAJOR ${uavcanblid_sw_version_major} - SW_MINOR ${uavcanblid_sw_version_minor}) + BIN ${CMAKE_CURRENT_BINARY_DIR}/src/firmware/nuttx/px4esc-v1.bin + HWNAME ${uavcanblid_name} + HW_MAJOR ${uavcanblid_hw_version_major} + HW_MINOR ${uavcanblid_hw_version_minor} + SW_MAJOR ${uavcanblid_sw_version_major} + SW_MINOR ${uavcanblid_sw_version_minor} +) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) +include_directories(${PX4_SOURCE_DIR}/src/drivers/boards/px4esc-v1/bootloader) set(config_module_list - # # Board support modules # - - drivers/stm32 + drivers/boards + drivers/bootloaders + drivers/device drivers/led - drivers/boards/px4esc-v1 + drivers/stm32 # # System commands # + systemcmds/config systemcmds/reboot systemcmds/top - systemcmds/config + systemcmds/param systemcmds/ver - systemcmds/param # # General system control # - modules/uavcanesc - modules/uavcanesc/nshterm - modules/uavcanesc/commands/cfg - modules/uavcanesc/commands/selftest - modules/uavcanesc/commands/dc - modules/uavcanesc/commands/rpm - modules/uavcanesc/commands/stat + modules/uavcanesc + modules/uavcanesc/nshterm + modules/uavcanesc/commands/cfg + modules/uavcanesc/commands/selftest + modules/uavcanesc/commands/dc + modules/uavcanesc/commands/rpm + modules/uavcanesc/commands/stat # # Library modules # - modules/systemlib/param - modules/systemlib - lib/version - - # - # Libraries - # - # had to add for cmake, not sure why wasn't in original config - platforms/nuttx - platforms/common - platforms/nuttx/px4_layer - modules/uORB lib/micro-CDR - -) - -set(config_extra_builtin_cmds - serdis - sercon - ) - -add_custom_target(sercon) -set_target_properties(sercon PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "sercon" STACK_MAIN "2048") - -add_custom_target(serdis) -set_target_properties(serdis PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "serdis" STACK_MAIN "2048") + lib/version + modules/systemlib + modules/systemlib/param + modules/uORB + platforms/common + platforms/nuttx + platforms/nuttx/px4_layer +) \ No newline at end of file diff --git a/cmake/configs/nuttx_px4flow-v2_bootloader.cmake b/cmake/configs/nuttx_px4flow-v2_bootloader.cmake index 6bcc9af25b..6f44573bdd 100644 --- a/cmake/configs/nuttx_px4flow-v2_bootloader.cmake +++ b/cmake/configs/nuttx_px4flow-v2_bootloader.cmake @@ -1,30 +1,2 @@ -include(nuttx/px4_impl_nuttx) - -px4_nuttx_configure(HWCLASS m4 CONFIG bootloader) - -set(px4_src_base ${CMAKE_SOURCE_DIR}/src/) -set(px4_bootloader_base ${px4_src_base}drivers/bootloaders/) -set(px4_module_base ${px4_src_base}modules/) - -# -# UAVCAN boot loadable Module ID - -# -# Bring in common uavcan hardware identity definitions -# - -include(configs/uavcan_board_ident/px4flow-v2) - -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - -set(config_module_list - - drivers/boards/px4flow-v2/bootloader - -) - -# -# Bootloaders use a compact vector table not -# from the lib, but exported in startup -# -set(nuttx_startup_files stm32_vectors.o) +include(nuttx/px4_uavcan_bootloader) +px4_nuttx_configure(HWCLASS m4 CONFIG bootloader) \ No newline at end of file diff --git a/cmake/configs/nuttx_px4fmu-v2_default.cmake b/cmake/configs/nuttx_px4fmu-v2_default.cmake index 97c0219d7e..9402c0c0be 100644 --- a/cmake/configs/nuttx_px4fmu-v2_default.cmake +++ b/cmake/configs/nuttx_px4fmu-v2_default.cmake @@ -1,10 +1,5 @@ include(nuttx/px4_impl_nuttx) - -px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common) - -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - -set(config_uavcan_num_ifaces 2) +px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common IO px4io-v2) set(config_module_list # @@ -17,7 +12,7 @@ set(config_module_list drivers/led drivers/px4fmu drivers/px4io - drivers/boards/px4fmu-v2 + drivers/boards drivers/rgbled drivers/mpu6000 drivers/mpu9250 @@ -193,26 +188,3 @@ set(config_module_list # Hardware test #examples/hwtest ) - -set(config_extra_builtin_cmds - serdis - sercon - ) - -set(config_io_board - px4io-v2 - ) - -add_custom_target(sercon) -set_target_properties(sercon PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "sercon" - STACK_MAIN "2048" - COMPILE_FLAGS "-Os") - -add_custom_target(serdis) -set_target_properties(serdis PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "serdis" - STACK_MAIN "2048" - COMPILE_FLAGS "-Os") diff --git a/cmake/configs/nuttx_px4fmu-v2_test.cmake b/cmake/configs/nuttx_px4fmu-v2_test.cmake index e0e0fbf408..eacce1f598 100644 --- a/cmake/configs/nuttx_px4fmu-v2_test.cmake +++ b/cmake/configs/nuttx_px4fmu-v2_test.cmake @@ -2,10 +2,6 @@ include(nuttx/px4_impl_nuttx) px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y ROMFSROOT px4fmu_test) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - -set(config_uavcan_num_ifaces 2) - set(config_module_list # # Board support modules @@ -17,7 +13,7 @@ set(config_module_list drivers/led drivers/px4fmu drivers/px4io - drivers/boards/px4fmu-v2 + drivers/boards drivers/rgbled drivers/mpu6000 #TO FIT drivers/mpu9250 @@ -188,24 +184,3 @@ set(config_module_list # Hardware test #examples/hwtest ) - -set(config_extra_builtin_cmds - serdis - sercon - ) - -set(config_io_board - px4io-v2 - ) - -add_custom_target(sercon) -set_target_properties(sercon PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "sercon" STACK_MAIN "2048" - COMPILE_FLAGS "-Os") - -add_custom_target(serdis) -set_target_properties(serdis PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "serdis" STACK_MAIN "2048" - COMPILE_FLAGS "-Os") diff --git a/cmake/configs/nuttx_px4fmu-v3_default.cmake b/cmake/configs/nuttx_px4fmu-v3_default.cmake index 4f02678440..35aba3fa54 100644 --- a/cmake/configs/nuttx_px4fmu-v3_default.cmake +++ b/cmake/configs/nuttx_px4fmu-v3_default.cmake @@ -1,8 +1,5 @@ include(nuttx/px4_impl_nuttx) - -px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common) - -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) +px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common IO px4io-v2) set(config_uavcan_num_ifaces 2) @@ -14,7 +11,7 @@ set(config_module_list drivers/blinkm drivers/bmi160 drivers/bmp280 - drivers/boards/px4fmu-v2 + drivers/boards drivers/bst drivers/camera_trigger drivers/device @@ -220,26 +217,3 @@ set(config_rtps_send_topics set(config_rtps_receive_topics sensor_baro ) - -set(config_extra_builtin_cmds - serdis - sercon - ) - -set(config_io_board - px4io-v2 - ) - -add_custom_target(sercon) -set_target_properties(sercon PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "sercon" - STACK_MAIN "2048" - COMPILE_FLAGS "-Os") - -add_custom_target(serdis) -set_target_properties(serdis PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "serdis" - STACK_MAIN "2048" - COMPILE_FLAGS "-Os") diff --git a/cmake/configs/nuttx_px4fmu-v4_default.cmake b/cmake/configs/nuttx_px4fmu-v4_default.cmake index 33a03d7b9d..9cb297f534 100644 --- a/cmake/configs/nuttx_px4fmu-v4_default.cmake +++ b/cmake/configs/nuttx_px4fmu-v4_default.cmake @@ -2,8 +2,6 @@ include(nuttx/px4_impl_nuttx) px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - set(config_uavcan_num_ifaces 1) set(config_module_list @@ -17,7 +15,7 @@ set(config_module_list drivers/bmi160 drivers/bmm150 drivers/bmp280 - drivers/boards/px4fmu-v4 + drivers/boards drivers/bst drivers/camera_trigger drivers/device @@ -63,56 +61,57 @@ set(config_module_list # System commands # systemcmds/bl_update + systemcmds/config + systemcmds/dumpfile + systemcmds/esc_calib + systemcmds/hardfault_log systemcmds/led_control systemcmds/mixer + systemcmds/motor_ramp + systemcmds/mtd + systemcmds/nshterm systemcmds/param systemcmds/perf systemcmds/pwm - systemcmds/esc_calib - systemcmds/hardfault_log systemcmds/reboot - systemcmds/topic_listener - systemcmds/top - systemcmds/config - systemcmds/nshterm - systemcmds/mtd - systemcmds/dumpfile - systemcmds/ver systemcmds/sd_bench - systemcmds/motor_ramp + systemcmds/top + systemcmds/topic_listener + systemcmds/ver # # Testing # drivers/sf0x/sf0x_tests drivers/test_ppm + #lib/rc/rc_tests modules/commander/commander_tests - modules/mc_pos_control/mc_pos_control_tests lib/controllib/controllib_test modules/mavlink/mavlink_tests + modules/mc_pos_control/mc_pos_control_tests modules/uORB/uORB_tests systemcmds/tests # # General system control # + modules/camera_feedback modules/commander modules/events - modules/load_mon - modules/navigator - modules/mavlink modules/gpio_led - modules/uavcan modules/land_detector - modules/camera_feedback + modules/load_mon + modules/mavlink + modules/navigator + modules/uavcan # - # Estimation modules (EKF/ SO3 / other filters) + # Estimation modules # modules/attitude_estimator_q - modules/position_estimator_inav modules/ekf2 modules/local_position_estimator + modules/position_estimator_inav # # Vehicle Control @@ -128,8 +127,8 @@ set(config_module_list # # Logging # - modules/sdlog2 modules/logger + modules/sdlog2 # # Library modules @@ -162,11 +161,13 @@ set(config_module_list lib/tailsitter_recovery lib/version lib/DriverFramework/framework - platforms/nuttx lib/micro-CDR - # had to add for cmake, not sure why wasn't in original config + # + # Platform + # platforms/common + platforms/nuttx platforms/nuttx/px4_layer # @@ -179,28 +180,33 @@ set(config_module_list # examples/rover_steering_control + # + # Segway + # + examples/segway + # # Demo apps # - #examples/math_demo + # Tutorial code from # https://px4.io/dev/px4_simple_app examples/px4_simple_app # Tutorial code from # https://px4.io/dev/daemon - #examples/px4_daemon_app + examples/px4_daemon_app # Tutorial code from # https://px4.io/dev/debug_values - #examples/px4_mavlink_debug + examples/px4_mavlink_debug # Tutorial code from # https://px4.io/dev/example_fixedwing_control examples/fixedwing_control # Hardware test - #examples/hwtest + examples/hwtest # EKF examples/ekf_att_pos_estimator @@ -213,22 +219,3 @@ set(config_rtps_send_topics set(config_rtps_receive_topics sensor_baro ) - -set(config_extra_builtin_cmds - serdis - sercon - ) - -add_custom_target(sercon) -set_target_properties(sercon PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "sercon" - STACK_MAIN "2048" - COMPILE_FLAGS "-Os") - -add_custom_target(serdis) -set_target_properties(serdis PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "serdis" - STACK_MAIN "2048" - COMPILE_FLAGS "-Os") diff --git a/cmake/configs/nuttx_px4fmu-v4pro_default.cmake b/cmake/configs/nuttx_px4fmu-v4pro_default.cmake index ba07fecb3c..db4f47d448 100644 --- a/cmake/configs/nuttx_px4fmu-v4pro_default.cmake +++ b/cmake/configs/nuttx_px4fmu-v4pro_default.cmake @@ -1,8 +1,6 @@ include(nuttx/px4_impl_nuttx) -px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common) - -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) +px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common IO px4io-v2) set(config_uavcan_num_ifaces 2) @@ -15,7 +13,7 @@ set(config_module_list drivers/bma180 drivers/bmi160 drivers/bmp280 - drivers/boards/px4fmu-v4pro + drivers/boards drivers/bst drivers/camera_trigger drivers/device @@ -220,26 +218,3 @@ set(config_rtps_send_topics set(config_rtps_receive_topics sensor_baro ) - -set(config_extra_builtin_cmds - serdis - sercon - ) - -set(config_io_board - px4io-v2 - ) - -add_custom_target(sercon) -set_target_properties(sercon PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "sercon" - STACK_MAIN "2048" - COMPILE_FLAGS "-Os") - -add_custom_target(serdis) -set_target_properties(serdis PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "serdis" - STACK_MAIN "2048" - COMPILE_FLAGS "-Os") diff --git a/cmake/configs/nuttx_px4fmu-v5_default.cmake b/cmake/configs/nuttx_px4fmu-v5_default.cmake index 36426f8ea3..98483a323a 100644 --- a/cmake/configs/nuttx_px4fmu-v5_default.cmake +++ b/cmake/configs/nuttx_px4fmu-v5_default.cmake @@ -2,8 +2,6 @@ include(nuttx/px4_impl_nuttx) px4_nuttx_configure(HWCLASS m7 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - set(config_uavcan_num_ifaces 2) set(config_module_list @@ -16,7 +14,7 @@ set(config_module_list drivers/bmi055 drivers/bmi160 drivers/bmp280 - drivers/boards/px4fmu-v5 + drivers/boards drivers/bst drivers/camera_trigger drivers/device @@ -221,22 +219,3 @@ set(config_rtps_send_topics set(config_rtps_receive_topics sensor_baro ) - -set(config_extra_builtin_cmds - serdis - sercon - ) - -add_custom_target(sercon) -set_target_properties(sercon PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "sercon" - STACK_MAIN "2048" - COMPILE_FLAGS "-Os") - -add_custom_target(serdis) -set_target_properties(serdis PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "serdis" - STACK_MAIN "2048" - COMPILE_FLAGS "-Os") diff --git a/cmake/configs/nuttx_px4io-v1_default.cmake b/cmake/configs/nuttx_px4io-v1_default.cmake new file mode 100644 index 0000000000..8fef069d9e --- /dev/null +++ b/cmake/configs/nuttx_px4io-v1_default.cmake @@ -0,0 +1,12 @@ +include(nuttx/px4_impl_nuttx) + +px4_nuttx_configure(HWCLASS m3 CONFIG nsh) + +set(config_module_list + drivers/boards + drivers/stm32 + lib/rc + modules/px4iofirmware + modules/systemlib/mixer + platforms/common +) diff --git a/cmake/configs/nuttx_px4io-v2_default.cmake b/cmake/configs/nuttx_px4io-v2_default.cmake new file mode 100644 index 0000000000..abe966fa50 --- /dev/null +++ b/cmake/configs/nuttx_px4io-v2_default.cmake @@ -0,0 +1,14 @@ +include(nuttx/px4_impl_nuttx) + +px4_nuttx_configure(HWCLASS m3 CONFIG nsh) + +set(config_module_list + drivers/boards/px4io-v2 + drivers/stm32 + lib/rc + modules/px4iofirmware + modules/systemlib/mixer + platforms/common + + lib/micro-CDR +) diff --git a/cmake/configs/nuttx_px4nucleoF767ZI-v1_default.cmake b/cmake/configs/nuttx_px4nucleoF767ZI-v1_default.cmake index 158d043f6d..ac8a2ab02c 100644 --- a/cmake/configs/nuttx_px4nucleoF767ZI-v1_default.cmake +++ b/cmake/configs/nuttx_px4nucleoF767ZI-v1_default.cmake @@ -2,8 +2,6 @@ include(nuttx/px4_impl_nuttx) px4_nuttx_configure(HWCLASS m7 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - set(config_uavcan_num_ifaces 2) set(config_module_list @@ -15,7 +13,7 @@ set(config_module_list drivers/bma180 drivers/bmi160 drivers/bmp280 - drivers/boards/px4nucleoF767ZI-v1 + drivers/boards drivers/bst drivers/camera_trigger drivers/device @@ -178,20 +176,3 @@ set(config_module_list # Hardware test #examples/hwtest ) - -set(config_extra_builtin_cmds - serdis - sercon - ) - -add_custom_target(sercon) -set_target_properties(sercon PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "sercon" - STACK_MAIN "2048") - -add_custom_target(serdis) -set_target_properties(serdis PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "serdis" - STACK_MAIN "2048") diff --git a/cmake/configs/nuttx_s2740vc-v1_bootloader.cmake b/cmake/configs/nuttx_s2740vc-v1_bootloader.cmake index 4497e588f8..6f44573bdd 100644 --- a/cmake/configs/nuttx_s2740vc-v1_bootloader.cmake +++ b/cmake/configs/nuttx_s2740vc-v1_bootloader.cmake @@ -1,30 +1,2 @@ -include(nuttx/px4_impl_nuttx) - -px4_nuttx_configure(HWCLASS m4 CONFIG bootloader) - -set(px4_src_base ${CMAKE_SOURCE_DIR}/src/) -set(px4_bootloader_base ${px4_src_base}drivers/bootloaders/) -set(px4_module_base ${px4_src_base}modules/) - -# -# UAVCAN boot loadable Module ID - -# -# Bring in common uavcan hardware identity definitions -# - -include(configs/uavcan_board_ident/s2740vc-v1) - -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - -set(config_module_list - - drivers/boards/s2740vc-v1/bootloader - -) - -# -# Bootloaders use a compact vector table not -# from the lib, but exported in startup -# -set(nuttx_startup_files stm32_vectors.o) +include(nuttx/px4_uavcan_bootloader) +px4_nuttx_configure(HWCLASS m4 CONFIG bootloader) \ No newline at end of file diff --git a/cmake/configs/nuttx_s2740vc-v1_default.cmake b/cmake/configs/nuttx_s2740vc-v1_default.cmake index bd2a577e3f..2c9e138b9a 100644 --- a/cmake/configs/nuttx_s2740vc-v1_default.cmake +++ b/cmake/configs/nuttx_s2740vc-v1_default.cmake @@ -12,6 +12,10 @@ px4_nuttx_configure(HWCLASS m4 CONFIG nsh) set(uavcanblid_sw_version_major 0) set(uavcanblid_sw_version_minor 1) +add_definitions( + -DAPP_VERSION_MAJOR=${uavcanblid_sw_version_major} + -DAPP_VERSION_MINOR=${uavcanblid_sw_version_minor} + ) # # Bring in common uavcan hardware identity definitions @@ -21,15 +25,13 @@ include(configs/uavcan_board_ident/s2740vc-v1) # N.B. this would be uncommented when there is an APP #px4_nuttx_make_uavcan_bootloadable(BOARD ${BOARD} -# BIN ${CMAKE_CURRENT_BINARY_DIR}/src/firmware/nuttx/firmware_nuttx.bin +# BIN ${CMAKE_CURRENT_BINARY_DIR}/src/firmware/nuttx/s2740vc-v1.bin # HWNAME ${uavcanblid_name} # HW_MAJOR ${uavcanblid_hw_version_major} # HW_MINOR ${uavcanblid_hw_version_minor} # SW_MAJOR ${uavcanblid_sw_version_major} # SW_MINOR ${uavcanblid_sw_version_minor}) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - set(config_module_list # @@ -38,7 +40,7 @@ set(config_module_list drivers/stm32 drivers/led - drivers/boards/s2740vc-v1 + drivers/boards # # System commands @@ -67,6 +69,4 @@ set(config_module_list platforms/nuttx platforms/common platforms/nuttx/px4_layer - - ) diff --git a/cmake/configs/nuttx_tap-v1_default.cmake b/cmake/configs/nuttx_tap-v1_default.cmake index e54e81d433..b0489d483f 100644 --- a/cmake/configs/nuttx_tap-v1_default.cmake +++ b/cmake/configs/nuttx_tap-v1_default.cmake @@ -2,8 +2,6 @@ include(nuttx/px4_impl_nuttx) px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y ROMFSROOT tap_common) -set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - set(target_definitions MEMORY_CONSTRAINED_SYSTEM) set(config_module_list @@ -16,7 +14,7 @@ set(config_module_list drivers/stm32/tone_alarm drivers/led drivers/px4fmu - drivers/boards/tap-v1 + drivers/boards drivers/rgbled_pwm drivers/tap_esc drivers/mpu6000 @@ -111,24 +109,4 @@ set(config_module_list # had to add for cmake, not sure why wasn't in original config platforms/common platforms/nuttx/px4_layer -) - -set(config_extra_builtin_cmds - serdis - sercon - ) - -set(config_io_board - ) - -add_custom_target(sercon) -set_target_properties(sercon PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "sercon" - STACK_MAIN "2048") - -add_custom_target(serdis) -set_target_properties(serdis PROPERTIES - PRIORITY "SCHED_PRIORITY_DEFAULT" - MAIN "serdis" - STACK_MAIN "2048") +) \ No newline at end of file diff --git a/cmake/configs/nuttx_zubaxgnss-v1_bootloader.cmake b/cmake/configs/nuttx_zubaxgnss-v1_bootloader.cmake index 76a670bdb1..ec1c447072 100644 --- a/cmake/configs/nuttx_zubaxgnss-v1_bootloader.cmake +++ b/cmake/configs/nuttx_zubaxgnss-v1_bootloader.cmake @@ -1,30 +1,2 @@ -include(nuttx/px4_impl_nuttx) - -px4_nuttx_configure(HWCLASS m3 CONFIG bootloader) - -set(px4_src_base ${CMAKE_SOURCE_DIR}/src/) -set(px4_bootloader_base ${px4_src_base}drivers/bootloaders/) -set(px4_module_base ${px4_src_base}modules/) - -# -# UAVCAN boot loadable Module ID - -# -# Bring in common uavcan hardware identity definitions -# - -include(configs/uavcan_board_ident/zubaxgnss-v1) - -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) - -set(config_module_list - - drivers/boards/zubaxgnss-v1/bootloader - -) - -# -# Bootloaders use a compact vector table not -# from the lib, but exported in startup -# -set(nuttx_startup_files stm32_vectors.o) +include(nuttx/px4_uavcan_bootloader) +px4_nuttx_configure(HWCLASS m3 CONFIG bootloader) \ No newline at end of file diff --git a/cmake/configs/posix_bebop_default.cmake b/cmake/configs/posix_bebop_default.cmake index 1ef5202c00..61665fff13 100644 --- a/cmake/configs/posix_bebop_default.cmake +++ b/cmake/configs/posix_bebop_default.cmake @@ -10,8 +10,6 @@ add_definitions( set(config_module_list - # examples/px4_simple_app - # # Board support modules # diff --git a/cmake/configs/posix_eagle_hil.cmake b/cmake/configs/posix_eagle_hil.cmake index 53dbeec172..65cb84d9e8 100644 --- a/cmake/configs/posix_eagle_hil.cmake +++ b/cmake/configs/posix_eagle_hil.cmake @@ -20,7 +20,7 @@ endif() set(config_module_list drivers/device - drivers/boards/sitl + drivers/boards drivers/led drivers/linux_sbus diff --git a/cmake/configs/posix_sdflight_default.cmake b/cmake/configs/posix_sdflight_default.cmake index 71b6e47ec4..5f870208e7 100644 --- a/cmake/configs/posix_sdflight_default.cmake +++ b/cmake/configs/posix_sdflight_default.cmake @@ -34,7 +34,7 @@ set(config_module_list drivers/pwm_out_sim drivers/rgbled drivers/led - drivers/boards/sitl + drivers/boards drivers/qshell/posix systemcmds/param diff --git a/cmake/configs/posix_sdflight_legacy.cmake b/cmake/configs/posix_sdflight_legacy.cmake index b655f8ed0b..9d7a13bffd 100644 --- a/cmake/configs/posix_sdflight_legacy.cmake +++ b/cmake/configs/posix_sdflight_legacy.cmake @@ -26,7 +26,7 @@ set(config_module_list drivers/pwm_out_sim drivers/rgbled drivers/led - drivers/boards/sitl + drivers/boards drivers/qshell/posix systemcmds/param diff --git a/cmake/configs/posix_sitl_default.cmake b/cmake/configs/posix_sitl_default.cmake index 477e55f6a0..4bba97fa05 100644 --- a/cmake/configs/posix_sitl_default.cmake +++ b/cmake/configs/posix_sitl_default.cmake @@ -3,7 +3,7 @@ include(posix/px4_impl_posix) set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-native.cmake) set(config_module_list - drivers/boards/sitl + drivers/boards drivers/camera_trigger drivers/device drivers/gps @@ -194,11 +194,6 @@ set(config_module_list lib/micro-CDR ) -set(config_extra_builtin_cmds - serdis - sercon - ) - set(config_rtps_send_topics sensor_baro ) diff --git a/cmake/configs/qurt_eagle_hil.cmake b/cmake/configs/qurt_eagle_hil.cmake index e085aadeb3..6ab7e9590a 100644 --- a/cmake/configs/qurt_eagle_hil.cmake +++ b/cmake/configs/qurt_eagle_hil.cmake @@ -22,7 +22,7 @@ include_directories(${HEXAGON_SDK_INCLUDES}) set(config_module_list drivers/device - drivers/boards/sitl + drivers/boards drivers/pwm_out_sim drivers/led drivers/rgbled diff --git a/cmake/configs/qurt_eagle_travis.cmake b/cmake/configs/qurt_eagle_travis.cmake index b6f4b58993..385e901f2a 100644 --- a/cmake/configs/qurt_eagle_travis.cmake +++ b/cmake/configs/qurt_eagle_travis.cmake @@ -27,7 +27,7 @@ include_directories(${HEXAGON_SDK_INCLUDES}) set(config_module_list drivers/device - drivers/boards/sitl + drivers/boards drivers/pwm_out_sim drivers/led drivers/rgbled diff --git a/cmake/nuttx/bin_to_obj.py b/cmake/nuttx/bin_to_obj.py deleted file mode 100755 index 80ce80d741..0000000000 --- a/cmake/nuttx/bin_to_obj.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env python -""" -This converts a binary imagge to an object file -""" -from __future__ import print_function -import subprocess -import argparse -import re -from subprocess import PIPE - -#pylint: disable=invalid-name -parser = argparse.ArgumentParser(description='Convert bin to obj.') -parser.add_argument('--c_flags', required=True) -parser.add_argument('--c_compiler', required=True) -parser.add_argument('--include_path', required=True) -parser.add_argument('--nm', required=True) -parser.add_argument('--ld', required=True) -parser.add_argument('--objcopy', required=True) -parser.add_argument('--bin', required=True) -parser.add_argument('--obj', required=True) -parser.add_argument('--var', required=True) -args = parser.parse_args() - -in_bin = args.bin -c_flags = args.c_flags -c_compiler = args.c_compiler -include_path = args.include_path -nm = args.nm -ld = args.ld -obj = args.obj -var = args.var -objcopy = args.objcopy - -sym = "_binary_" + in_bin.replace('/', '_').replace('.', '_').replace('-', '_') -#print("sym: ", sym) - -# write empty file -with open('{obj:s}.c'.format(**locals()), 'w') as f: - f.write("") - -def run_cmd(cmd, d): - cmd = cmd.format(**d) - #print(cmd) - proc = subprocess.Popen(cmd.split(), stdout=PIPE, stderr=PIPE) - stdout, stderr = proc.communicate() - if stderr.decode() != "": - raise RuntimeError(stderr) - return stdout - -# do compile -run_cmd("{c_compiler:s} -I{include_path:s} {c_flags:s} -c {obj:s}.c -o {obj:s}.c.o", - locals()) - -# link -run_cmd("{ld:s} -r -o {obj:s}.bin.o {obj:s}.c.o -b binary {in_bin:s}", - locals()) - -# get size of image -stdout = run_cmd("{nm:s} -p --radix=x {obj:s}.bin.o", locals()) -re_string = r"^([0-9A-Fa-f]+) .*{sym:s}_size".format(**locals()) -re_size = re.compile(re_string, re.MULTILINE) -size_match = re.search(re_size, stdout.decode()) - -try: - size = size_match.group(1) -except AttributeError as e: - raise RuntimeError("{:s}\nre:{:s}\n{:s}".format( - e, re_string, stdout)) -except IndexError as e: - group0 = size_match.group(0) - raise RuntimeError("{:s}\ngroup 0:{:s}\n{:s}".format( - e, group0, stdout)) - -#print("romfs size: ", size) - -# write size to file -with open('{obj:s}.c'.format(**locals()), 'w') as f: - f.write("const unsigned int {var:s}_len = 0x{size:s};".format( - **locals())) - -# do compile -run_cmd("{c_compiler:s} -I{include_path:s} {c_flags:s} -c {obj:s}.c -o {obj:s}.c.o", - locals()) - -# link -run_cmd("{ld:s} -r -o {obj:s} {obj:s}.c.o {obj:s}.bin.o", - locals()) - -# obj copy -run_cmd(""" -{objcopy:s} {obj:s} - --redefine-sym {sym:s}_start={var:s} - --strip-symbol {sym:s}_size - --strip-symbol {sym:s}_end - --rename-section .data=.rodata -""", locals()) - -# vim: set et ft=python fenc= ff=unix sts=4 sw=4 ts=4 : diff --git a/cmake/nuttx/builtin_commands.c.in b/cmake/nuttx/builtin_commands.c.in deleted file mode 100644 index 77cf43ec90..0000000000 --- a/cmake/nuttx/builtin_commands.c.in +++ /dev/null @@ -1,12 +0,0 @@ -/* builtin command list - automatically generated, do not edit */ -#include -#include -#include -#if ${command_count} -${builtin_apps_decl_string} -const struct builtin_s g_builtins[] = { -${builtin_apps_string} - {NULL, 0, 0, NULL} -}; -const int g_builtin_count = ${command_count}; -#endif \ No newline at end of file diff --git a/cmake/nuttx/px4_impl_nuttx.cmake b/cmake/nuttx/px4_impl_nuttx.cmake index c6abda403e..08dbb9c038 100644 --- a/cmake/nuttx/px4_impl_nuttx.cmake +++ b/cmake/nuttx/px4_impl_nuttx.cmake @@ -37,11 +37,7 @@ # # OS Specific Functions # -# * px4_nuttx_add_firmware # * px4_nuttx_make_uavcan_bootloadable -# * px4_nuttx_generate_builtin_commands -# * px4_nuttx_add_export -# * px4_nuttx_add_romfs # # Required OS Inteface Functions # @@ -51,63 +47,6 @@ include(common/px4_base) -#============================================================================= -# -# px4_nuttx_add_firmware -# -# This function adds a nuttx firmware target. -# -# Usage: -# px4_nuttx_add_firmware(OUT EXE -# PARAM_XML AIRFRAMES_XML ) -# -# Input: -# EXE : the executable to generate the firmware from -# BOARD : the board -# PARAM_XML : param xml file (optional) -# AIRFRAMES_XML : airframes xml file (optional) -# -# Output: -# OUT : the generated firmware target -# -# Example: -# px4_nuttx_add_firmware(TARGET fw_test EXE test) -# -function(px4_nuttx_add_firmware) - px4_parse_function_args( - NAME px4_nuttx_add_firmware - ONE_VALUE BOARD OUT EXE PARAM_XML AIRFRAMES_XML - REQUIRED OUT EXE BOARD - ARGN ${ARGN}) - - set(extra_args) - set(dependencies) - if (PARAM_XML) - list(APPEND extra_args - --parameter_xml ${PARAM_XML} - ) - list(APPEND dependencies parameters_xml) - endif() - - if (AIRFRAMES_XML) - list(APPEND extra_args - --airframe_xml ${AIRFRAMES_XML} - ) - list(APPEND dependencies airframes_xml) - endif() - - add_custom_command(OUTPUT ${OUT} ${EXE}.bin - COMMAND ${OBJCOPY} -O binary ${EXE} ${EXE}.bin - COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_mkfw.py - --prototype ${PX4_SOURCE_DIR}/Images/${BOARD}.prototype - --git_identity ${PX4_SOURCE_DIR} - ${extra_args} - --image ${EXE}.bin > ${OUT} - DEPENDS ${EXE} ${dependencies} - ) - add_custom_target(build_firmware_${BOARD} ALL DEPENDS ${OUT}) -endfunction() - #============================================================================= # # px4_nuttx_make_uavcan_bootloadable @@ -153,16 +92,19 @@ function(px4_nuttx_make_uavcan_bootloadable) ONE_VALUE BOARD BIN HWNAME HW_MAJOR HW_MINOR SW_MAJOR SW_MINOR REQUIRED BOARD BIN HWNAME HW_MAJOR HW_MINOR SW_MAJOR SW_MINOR ARGN ${ARGN}) + string(REPLACE "\"" "" HWNAME ${HWNAME}) + execute_process( COMMAND git rev-list HEAD --max-count=1 --abbrev=8 --abbrev-commit OUTPUT_VARIABLE uavcanbl_git_desc OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY ${PX4_SOURCE_DIR} ) - if ("${uavcanbl_git_desc}" STREQUAL "") + + if ("${uavcanbl_git_desc}" STREQUAL "") set(uavcanbl_git_desc ffffffff) - endif() + endif() set(uavcan_bl_imange_name ${HWNAME}-${HW_MAJOR}.${HW_MINOR}-${SW_MAJOR}.${SW_MINOR}.${uavcanbl_git_desc}.uavcan.bin) message(STATUS "Generating UAVCAN Bootable as ${uavcan_bl_imange_name}") add_custom_command(OUTPUT ${uavcan_bl_imange_name} @@ -172,323 +114,6 @@ function(px4_nuttx_make_uavcan_bootloadable) add_custom_target(build_uavcan_bl_${BOARD} ALL DEPENDS ${uavcan_bl_imange_name}) endfunction() -#============================================================================= -# -# px4_nuttx_generate_builtin_commands -# -# This function generates the builtin_commands.c src for nuttx -# -# Usage: -# px4_nuttx_generate_builtin_commands( -# MODULE_LIST -# OUT ) -# -# Input: -# MODULE_LIST : list of modules -# -# Output: -# OUT : generated builtin_commands.c src -# -# Example: -# px4_nuttx_generate_builtin_commands( -# OUT MODULE_LIST px4_simple_app) -# -function(px4_nuttx_generate_builtin_commands) - px4_parse_function_args( - NAME px4_nuttx_generate_builtin_commands - ONE_VALUE OUT - MULTI_VALUE MODULE_LIST - REQUIRED MODULE_LIST OUT - ARGN ${ARGN}) - set(builtin_apps_string) - set(builtin_apps_decl_string) - set(command_count 0) - foreach(module ${MODULE_LIST}) - foreach(property MAIN STACK_MAIN PRIORITY) - get_target_property(${property} ${module} ${property}) - endforeach() - if (MAIN) - set(builtin_apps_string - "${builtin_apps_string}\t{\"${MAIN}\", ${PRIORITY}, ${STACK_MAIN}, ${MAIN}_main},\n") - set(builtin_apps_decl_string - "${builtin_apps_decl_string}extern int ${MAIN}_main(int argc, char *argv[]);\n") - math(EXPR command_count "${command_count}+1") - endif() - endforeach() - configure_file(${PX4_SOURCE_DIR}/cmake/nuttx/builtin_commands.c.in - ${OUT}) -endfunction() - -#============================================================================= -# -# px4_nuttx_add_export -# -# This function generates a nuttx export. -# -# Usage: -# px4_nuttx_add_export( -# OUT -# CONFIG -# DEPENDS ) -# -# Input: -# CONFIG : the board to generate the export for -# DEPENDS : dependencies -# -# Output: -# OUT : the export target -# -# Example: -# px4_nuttx_add_export(OUT nuttx_export CONFIG px4fmu-v2) -# -function(px4_nuttx_add_export) - - px4_parse_function_args( - NAME px4_nuttx_add_export - ONE_VALUE OUT CONFIG THREADS - MULTI_VALUE DEPENDS - REQUIRED OUT CONFIG THREADS - ARGN ${ARGN}) - - set(nuttx_build_options "--quiet") - set(nuttx_build_output ">nuttx_build.log") - if ($ENV{PX4_NUTTX_BUILD_VERBOSE} MATCHES "1") - set(nuttx_build_options) - set(nuttx_build_output) - set(nuttx_build_uses_terminal "USES_TERMINAL") - endif() - - if ($ENV{PX4_NUTTX_PATCHES_VERBOSE} MATCHES "1") - set(nuttx_patches_uses_terminal "USES_TERMINAL") - endif() - - # nuttx-patches - add_subdirectory(${PX4_SOURCE_DIR}/nuttx-patches ${PX4_BINARY_DIR}/${CONFIG}) - - set(nuttx_build_src ${PX4_BINARY_DIR}/${CONFIG}/NuttX) - set(nuttx_export_dir ${nuttx_build_src}/nuttx/nuttx-export) - - # nuttx cmake dependency files - set(nuttx_copy_stamp ${PX4_BINARY_DIR}/${CONFIG}/nuttx_copy.stamp) - set(nuttx_configure_stamp ${PX4_BINARY_DIR}/${CONFIG}/nuttx_configure.stamp) - set(nuttx_export_stamp ${PX4_BINARY_DIR}/${CONFIG}/nuttx_export.stamp) - - # copy - file(GLOB_RECURSE nuttx_all_files ${PX4_SOURCE_DIR}/NuttX/*) - file(RELATIVE_PATH nuttx_cp_src ${PX4_BINARY_DIR} ${PX4_SOURCE_DIR}/NuttX) - add_custom_command(OUTPUT ${nuttx_copy_stamp} - COMMAND ${MKDIR} -p ${nuttx_build_src} - COMMAND rsync -rp --inplace --delete --exclude=.git --exclude=nuttx-export ${nuttx_cp_src}/ ${CONFIG}/NuttX/ - COMMAND cmake -E touch ${nuttx_copy_stamp} - DEPENDS ${px4_nuttx_patches} ${nuttx_all_files} - COMMENT "Copying NuttX for ${CONFIG} with ${config_nuttx_config}" - WORKING_DIRECTORY ${PX4_BINARY_DIR}) - add_custom_target(nuttx_copy_${CONFIG} DEPENDS ${DEPENDS} ${nuttx_copy_stamp}) - - unset(last_patch) - add_custom_target(nuttx_patch_${CONFIG}) - foreach(patch ${px4_nuttx_patches}) - get_filename_component(patch_file_name ${patch} NAME) - string(REPLACE "/" "_" patch_name "${CONFIG}-nuttx_patch_${patch_file_name}") - set(patch_stamp ${nuttx_build_src}/${patch_name}.stamp) - - add_custom_command(OUTPUT ${patch_stamp} - COMMAND ${PATCH} --verbose -d ${nuttx_build_src} -s -p1 -N < ${patch} - COMMAND cmake -E touch ${patch_stamp} - DEPENDS nuttx_copy_${CONFIG} ${patch} ${last_patch} - COMMENT "${CONFIG}: nuttx-patches/${patch_file_name} applied" - ${nuttx_patches_uses_terminal}) - - add_custom_target(${patch_name} DEPENDS ${patch_stamp}) - add_dependencies(nuttx_patch_${CONFIG} ${patch_name} nuttx_copy_${CONFIG}) - set(last_patch ${patch_name}) - endforeach() - - # Read defconfig to see if CONFIG_ARMV7M_STACKCHECK is yes - # note: CONFIG will be BOARD in the future evaluation of ${hw_stack_check_${CONFIG} - file(STRINGS "${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG}/${config_nuttx_config}/defconfig" - hw_stack_check_${CONFIG} - REGEX "CONFIG_ARMV7M_STACKCHECK=y" - ) - if ("${hw_stack_check_${CONFIG}}" STREQUAL "CONFIG_ARMV7M_STACKCHECK=y") - set(config_nuttx_hw_stack_check_${CONFIG} y CACHE INTERNAL "" FORCE) - endif() - - # nuttx configure - file(GLOB_RECURSE nuttx-configs ${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG}/*) - add_custom_command(OUTPUT ${nuttx_configure_stamp} ${nuttx_build_src}/nuttx/.config - COMMAND ${CP} -rp ${PX4_SOURCE_DIR}/nuttx-configs/*.mk ${nuttx_build_src}/nuttx/ - COMMAND ${CP} -rp ${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG} ${nuttx_build_src}/nuttx/configs - COMMAND ${CP} ${nuttx_build_src}/nuttx/configs/${CONFIG}/${config_nuttx_config}/defconfig ${nuttx_build_src}/nuttx/.config - COMMAND ${CP} ${nuttx_build_src}/nuttx/configs/${CONFIG}/${config_nuttx_config}/Make.defs ${nuttx_build_src}/nuttx/ - COMMAND cmake -E touch ${nuttx_configure_stamp} - DEPENDS nuttx_patch_${CONFIG} ${nuttx-configs} - WORKING_DIRECTORY ${PX4_BINARY_DIR} - COMMENT "Configuring NuttX for ${CONFIG} with ${config_nuttx_config}") - add_custom_target(nuttx_configure_${CONFIG} DEPENDS ${nuttx_configure_stamp} nuttx_patch_${CONFIG}) - - # manual nuttx oldconfig helper - add_custom_target(oldconfig_${CONFIG} - COMMAND ${MAKE} --no-print-directory -C ${nuttx_build_src}/nuttx CONFIG_ARCH_BOARD=${CONFIG} oldconfig - COMMAND ${CP} ${nuttx_build_src}/nuttx/.config ${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG}/${config_nuttx_config}/defconfig - COMMAND ${PX4_SOURCE_DIR}/Tools/nuttx_defconf_tool.sh ${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG}/${config_nuttx_config}/defconfig - DEPENDS nuttx_configure_${CONFIG} - WORKING_DIRECTORY ${nuttx_build_src}/nuttx - COMMENT "Running NuttX make oldconfig for ${CONFIG} with ${config_nuttx_config}" - USES_TERMINAL) - - # manual nuttx menuconfig helper - add_custom_target(menuconfig_${CONFIG} - COMMAND ${MAKE} --no-print-directory -C ${nuttx_build_src}/nuttx CONFIG_ARCH_BOARD=${CONFIG} menuconfig - COMMAND ${CP} ${nuttx_build_src}/nuttx/.config ${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG}/${config_nuttx_config}/defconfig - COMMAND ${PX4_SOURCE_DIR}/Tools/nuttx_defconf_tool.sh ${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG}/${config_nuttx_config}/defconfig - DEPENDS nuttx_configure_${CONFIG} - WORKING_DIRECTORY ${nuttx_build_src}/nuttx - COMMENT "Running NuttX make menuconfig for ${CONFIG} with ${config_nuttx_config}" - USES_TERMINAL) - - # nuttx build and export - add_custom_command( - OUTPUT ${nuttx_export_stamp} - ${nuttx_export_dir}/include/nuttx/config.h - COMMAND ${RM} -rf ${nuttx_export_dir} - COMMAND ${MAKE} ${nuttx_build_options} --no-print-directory -C ${nuttx_build_src}/nuttx -r CONFIG_ARCH_BOARD=${CONFIG} export ${nuttx_build_output} - COMMAND cmake -E touch ${nuttx_export_stamp} - DEPENDS nuttx_configure_${CONFIG} - WORKING_DIRECTORY ${PX4_BINARY_DIR}/${CONFIG} - COMMENT "Building NuttX for ${CONFIG} with ${config_nuttx_config}" - ${nuttx_build_uses_terminal}) - - file(GLOB_RECURSE nuttx_export_src ${nuttx_export_dir}) - foreach(nuttx_export_file ${nuttx_export_dir}) - set_source_files_properties(${nuttx_export_src} PROPERTIES GENERATED TRUE) - endforeach() - - add_custom_target(${OUT} DEPENDS nuttx_copy_${CONFIG} nuttx_patch_${CONFIG} nuttx_configure_${CONFIG} ${nuttx_export_stamp}) - -endfunction() - -#============================================================================= -# -# px4_nuttx_create_bin -# -# The functions generates a bin image for nuttx. -# -# Usage: -# px4_nuttx_create_bin(BIN EXE ) -# -# Input: -# EXE : the exe file -# -# Output: -# OUT : the binary output file -# -# Example: -# px4_nuttx_create_bin(OUT my_exe.bin EXE my_exe) -# -function(px4_nuttx_create_bin) - - px4_parse_function_args( - NAME px4_nuttx_create_bin - ONE_VALUE EXE OUT - REQUIRED EXE OUT - ARGN ${ARGN}) - - add_custom_command(OUTPUT ${OUT} - COMMAND ${OBJCOPY} -O binary ${EXE} ${EXE}.bin - DEPENDS ${EXE}) - - set(${OUT} ${${OUT}} PARENT_SCOPE) - -endfunction() - - -#============================================================================= -# -# px4_nuttx_add_romfs -# -# The functions creates a ROMFS filesystem for nuttx. -# -# Usage: -# px4_nuttx_add_romfs( -# OUT -# ROOT -# EXTRAS ) -# -# Input: -# ROOT : the root of the ROMFS -# EXTRAS : list of extra files -# -# Output: -# OUT : the ROMFS library target -# -# Example: -# px4_nuttx_add_romfs(OUT my_romfs ROOT "ROMFS/my_board") -# -function(px4_nuttx_add_romfs) - - px4_parse_function_args( - NAME px4_nuttx_add_romfs - ONE_VALUE OUT ROOT - MULTI_VALUE EXTRAS - REQUIRED OUT ROOT - ARGN ${ARGN}) - - set(romfs_used y PARENT_SCOPE) - set(romfs_temp_dir ${PX4_BINARY_DIR}/tmp/${ROOT}) - set(romfs_src_dir ${PX4_SOURCE_DIR}/${ROOT}) - set(romfs_autostart ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py) - set(romfs_pruner ${PX4_SOURCE_DIR}/Tools/px_romfs_pruner.py) - set(bin_to_obj ${PX4_SOURCE_DIR}/cmake/nuttx/bin_to_obj.py) - set(extras_dir ${CMAKE_CURRENT_BINARY_DIR}/extras) - - file(GLOB_RECURSE romfs_src_files ${romfs_src_dir} ${romfs_src_dir}/*) - - set(cmake_test ${PX4_SOURCE_DIR}/cmake/test/cmake_tester.py) - - set(extras) - foreach(extra ${EXTRAS}) - get_filename_component(file_name ${extra} NAME) - set(file_dest ${extras_dir}/${file_name}) - add_custom_command(OUTPUT ${file_dest} - COMMAND cmake -E copy ${extra} ${file_dest} - DEPENDS ${extra} - ) - list(APPEND extras ${file_dest}) - endforeach() - add_custom_target(collect_extras DEPENDS ${extras}) - - add_custom_command(OUTPUT romfs.o - COMMAND cmake -E remove_directory ${romfs_temp_dir} - COMMAND cmake -E copy_directory ${romfs_src_dir} ${romfs_temp_dir} - COMMAND cmake -E copy_directory ${extras_dir} ${romfs_temp_dir}/extras - COMMAND ${PYTHON_EXECUTABLE} ${romfs_autostart} - -a ${romfs_temp_dir}/init.d - -s ${romfs_temp_dir}/init.d/rc.autostart - --board ${BOARD} - COMMAND ${PYTHON_EXECUTABLE} ${romfs_pruner} - --folder ${romfs_temp_dir} - --board ${BOARD} - COMMAND ${GENROMFS} -f ${CMAKE_CURRENT_BINARY_DIR}/romfs.bin - -d ${romfs_temp_dir} -V "NSHInitVol" - #COMMAND cmake -E remove_directory ${romfs_temp_dir} - COMMAND ${PYTHON_EXECUTABLE} ${bin_to_obj} - --ld ${LD} --c_flags ${CMAKE_C_FLAGS} - --include_path "${PX4_SOURCE_DIR}/src/include" - --c_compiler ${CMAKE_C_COMPILER} - --nm ${NM} --objcopy ${OBJCOPY} - --obj romfs.o - --var romfs_img - --bin romfs.bin - DEPENDS ${romfs_src_files} ${extras} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - ) - add_library(${OUT} STATIC romfs.o) - set_target_properties(${OUT} PROPERTIES LINKER_LANGUAGE C) - set(${OUT} ${${OUT}} PARENT_SCOPE) - -endfunction() - #============================================================================= # # px4_os_add_flags @@ -550,44 +175,24 @@ function(px4_os_add_flags) LINK_DIRS ${LINK_DIRS} DEFINITIONS ${DEFINITIONS}) - set(nuttx_export_root ${PX4_BINARY_DIR}/${BOARD}/NuttX) - set(nuttx_export_dir ${nuttx_export_root}/nuttx/nuttx-export) set(added_include_dirs - ${nuttx_export_dir}/include - ${nuttx_export_dir}/include/cxx - ${nuttx_export_dir}/arch/chip - ${nuttx_export_dir}/arch/common - ${nuttx_export_dir}/arch/armv7-m - ${nuttx_export_root}/apps/include - ) - set(added_link_dirs - ${nuttx_export_dir}/libs - ) - set(added_definitions - -D__PX4_NUTTX + ${PX4_BINARY_DIR}/NuttX/nuttx/arch/arm/src/armv7-m + ${PX4_BINARY_DIR}/NuttX/nuttx/arch/arm/src/chip + ${PX4_BINARY_DIR}/NuttX/nuttx/arch/arm/src/common + ${PX4_BINARY_DIR}/NuttX/nuttx/include + ${PX4_BINARY_DIR}/NuttX/nuttx/include/cxx + ${PX4_SOURCE_DIR}/platforms/nuttx/NuttX/apps/include ) - if(NOT "${config_nuttx_config}" STREQUAL "bootloader") + #set(added_exe_linker_flags) + #set(added_link_dirs ${nuttx_export_dir}/libs) + set(added_definitions -D__PX4_NUTTX) + + if(NOT ${nuttx_config_type} STREQUAL "bootloader") list(APPEND added_definitions -D__DF_NUTTX) endif() - set(added_c_flags - -nodefaultlibs - -nostdlib - -fstack-usage - ) - set(added_cxx_flags - -nodefaultlibs - -nostdlib - -fstack-usage - ) - - set(added_optimization_flags) - - set(added_exe_linker_flags) # none currently - - set(instrument_flags) - if ("${config_nuttx_hw_stack_check_${BOARD}}" STREQUAL "y") + if("${config_nuttx_hw_stack_check_${BOARD}}" STREQUAL "y") set(instrument_flags -finstrument-functions -ffixed-r10 @@ -596,39 +201,12 @@ function(px4_os_add_flags) list(APPEND cxx_flags ${instrument_flags}) endif() - set(cpu_flags) - if (${config_nuttx_hw} STREQUAL "m7") - set(cpu_flags - -mcpu=cortex-m7 - -mthumb - -mfpu=fpv5-sp-d16 - -mfloat-abi=hard - ) - elseif (${config_nuttx_hw} STREQUAL "m4") - set(cpu_flags - -mcpu=cortex-m4 - -mthumb - -march=armv7e-m - -mfpu=fpv4-sp-d16 - -mfloat-abi=hard - ) - elseif (${config_nuttx_hw} STREQUAL "m3") - set(cpu_flags - -mcpu=cortex-m3 - -mthumb - -march=armv7-m - ) - endif() - list(APPEND c_flags ${cpu_flags}) - list(APPEND cxx_flags ${cpu_flags}) - # output foreach(var ${inout_vars}) string(TOLOWER ${var} lower_var) set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE) #message(STATUS "nuttx: set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE)") endforeach() - endfunction() #============================================================================= @@ -659,11 +237,29 @@ function(px4_os_prebuild_targets) ONE_VALUE OUT BOARD THREADS REQUIRED OUT BOARD ARGN ${ARGN}) - px4_nuttx_add_export(OUT nuttx_export_${BOARD} - CONFIG ${BOARD} - THREADS ${THREADS} - DEPENDS git_nuttx) - add_custom_target(${OUT} DEPENDS nuttx_export_${BOARD}) + + add_custom_target(${OUT} DEPENDS nuttx_context) + + # parse nuttx config options for cmake + file(STRINGS ${PX4_SOURCE_DIR}/nuttx-configs/${BOARD}/${nuttx_config_type}/defconfig ConfigContents) + foreach(NameAndValue ${ConfigContents}) + # Strip leading spaces + string(REGEX REPLACE "^[ ]+" "" NameAndValue ${NameAndValue}) + + # Find variable name + string(REGEX MATCH "^CONFIG[^=]+" Name ${NameAndValue}) + + if (Name) + # Find the value + string(REPLACE "${Name}=" "" Value ${NameAndValue}) + + # remove extra quotes + string(REPLACE "\"" "" Value ${Value}) + + # Set the variable + set(${Name} ${Value} PARENT_SCOPE) + endif() + endforeach() endfunction() #============================================================================= @@ -682,7 +278,7 @@ endfunction() # # Input: # HWCLASS : the class of hardware -# CONFIG : the nuttx condufiguration to use +# CONFIG : the nuttx configuration to use # ROMFS : whether or not to use incllude theROMFS # ROMFSROOT : If ROMFS used set the root the default is px4fmu_common # @@ -695,22 +291,42 @@ endfunction() function(px4_nuttx_configure) px4_parse_function_args( NAME px4_nuttx_configure - ONE_VALUE HWCLASS CONFIG ROMFS ROMFSROOT - REQUIRED HWCLASS CONFIG + ONE_VALUE HWCLASS CONFIG ROMFS ROMFSROOT IO + REQUIRED HWCLASS ARGN ${ARGN}) - set(config_nuttx_config ${CONFIG} PARENT_SCOPE) - set(config_nuttx_hw ${HWCLASS} PARENT_SCOPE) - if ("${ROMFS}" STREQUAL "y") - set(romfs_used ${ROMFS} PARENT_SCOPE) + + # HWCLASS -> CMAKE_SYSTEM_PROCESSOR + if(HWCLASS STREQUAL "m7") + set(CMAKE_SYSTEM_PROCESSOR "cortex-m7" PARENT_SCOPE) + elseif(HWCLASS STREQUAL "m4") + set(CMAKE_SYSTEM_PROCESSOR "cortex-m4" PARENT_SCOPE) + elseif(HWCLASS STREQUAL "m3") + set(CMAKE_SYSTEM_PROCESSOR "cortex-m3" PARENT_SCOPE) + endif() + set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE INTERNAL "system processor" FORCE) + set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake CACHE INTERNAL "toolchain file" FORCE) + + # CONFIG (nsh/bootloader) + if(CONFIG) + set(nuttx_config_type ${CONFIG} PARENT_SCOPE) + else() + set(nuttx_config_type "nsh" PARENT_SCOPE) + endif() + + # ROMFS + if("${ROMFS}" STREQUAL "y") if (NOT DEFINED ROMFSROOT) set(config_romfs_root px4fmu_common) else() set(config_romfs_root ${ROMFSROOT}) endif() - set(HASROMFS "with ROMFS on ${config_romfs_root}") set(config_romfs_root ${config_romfs_root} PARENT_SCOPE) endif() - message(STATUS "Nuttx build for ${BOARD} on ${HWCLASS} hardware, using ${CONFIG} ${HASROMFS}") + + # IO board placed in ROMFS + if(config_romfs_root) + set(config_io_board ${IO} PARENT_SCOPE) + endif() endfunction() # vim: set noet fenc=utf-8 ff=unix nowrap: diff --git a/cmake/nuttx/px4_uavcan_bootloader.cmake b/cmake/nuttx/px4_uavcan_bootloader.cmake new file mode 100644 index 0000000000..86e3955f69 --- /dev/null +++ b/cmake/nuttx/px4_uavcan_bootloader.cmake @@ -0,0 +1,56 @@ +############################################################################ +# +# Copyright (c) 2017 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. +# +############################################################################ + +include(nuttx/px4_impl_nuttx) + +message(STATUS "PX4 bootloader: ${BOARD}") + +# Bring in common uavcan hardware identity definitions +include(configs/uavcan_board_ident/${BOARD}) +add_definitions( + -DHW_UAVCAN_NAME=${uavcanblid_name} + -DHW_VERSION_MAJOR=${uavcanblid_hw_version_major} + -DHW_VERSION_MINOR=${uavcanblid_hw_version_minor} +) + +include_directories(src/drivers/boards/${BOARD}/bootloader) + +set(config_module_list + drivers/boards/common + drivers/boards/${BOARD}/bootloader + drivers/bootloaders +) + +add_library(nuttx_startup ${PX4_SOURCE_DIR}/platforms/nuttx/NuttX/nuttx/arch/arm/src/stm32/gnu/stm32_vectors.S) +target_compile_definitions(nuttx_startup PRIVATE -D__ASSEMBLY__) +add_dependencies(nuttx_startup nuttx_arch_build) diff --git a/cmake/posix/px4_impl_posix.cmake b/cmake/posix/px4_impl_posix.cmake index 6338c4186d..778bca284f 100644 --- a/cmake/posix/px4_impl_posix.cmake +++ b/cmake/posix/px4_impl_posix.cmake @@ -37,10 +37,7 @@ # # OS Specific Functions # -# * px4_posix_add_firmware # * px4_posix_generate_builtin_commands -# * px4_posix_add_export -# * px4_posix_generate_romfs # # Required OS Interface Functions # @@ -167,8 +164,10 @@ function(px4_os_add_flags) LINK_DIRS ${LINK_DIRS} DEFINITIONS ${DEFINITIONS}) - set(added_include_dirs + set(added_include_dirs + src/modules/systemlib src/platforms/posix/include + mavlink/include/mavlink ) # This block sets added_definitions and added_cxx_flags. diff --git a/cmake/toolchains/Toolchain-arm-none-eabi.cmake b/cmake/toolchains/Toolchain-arm-none-eabi.cmake index bc1a83f1e1..72b3abee8d 100644 --- a/cmake/toolchains/Toolchain-arm-none-eabi.cmake +++ b/cmake/toolchains/Toolchain-arm-none-eabi.cmake @@ -72,11 +72,27 @@ foreach(tool ddd) endif() endforeach() -set(LINKER_FLAGS "-Wl,-gc-sections") -set(CMAKE_EXE_LINKER_FLAGS ${LINKER_FLAGS}) +set(cpu_flags) +if (CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m7") + set(cpu_flags "-mcpu=cortex-m7 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard") +elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m4") + set(cpu_flags "-mcpu=cortex-m4 -mthumb -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard") +elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m3") + set(cpu_flags "-mcpu=cortex-m3 -mthumb -march=armv7-m") +else () + message(FATAL_ERROR "Processor not recognised in toolchain file") +endif() + +set(c_flags "-fno-common -ffunction-sections -fdata-sections") +set(cxx_flags "-fno-common -ffunction-sections -fdata-sections") + +set(CMAKE_C_FLAGS "${c_flags} ${cpu_flags}" CACHE INTERNAL "" FORCE) +set(CMAKE_CXX_FLAGS "${cxx_flags} ${cpu_flags}" CACHE INTERNAL "" FORCE) +set(CMAKE_ASM_FLAGS "${cpu_flags} -D__ASSEMBLY__ " CACHE INTERNAL "" FORCE) +set(CMAKE_EXE_LINKER_FLAGS "${cpu_flags} -nodefaultlibs -nostdlib -Wl,--warn-common,--gc-sections" CACHE INTERNAL "" FORCE) # where is the target environment -set(CMAKE_FIND_ROOT_PATH get_file_component(${C_COMPILER} PATH)) +set(CMAKE_FIND_ROOT_PATH get_file_component(${C_COMPILER} PATH)) # search for programs in the build host directories set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) diff --git a/eclipse.cproject b/eclipse.cproject index 45a5108c3f..0c5182db61 100644 --- a/eclipse.cproject +++ b/eclipse.cproject @@ -20,7 +20,7 @@ - + diff --git a/eclipse.project b/eclipse.project index d6a0ce17ff..1cfbea66fc 100644 --- a/eclipse.project +++ b/eclipse.project @@ -52,18 +52,18 @@ 10 org.eclipse.ui.ide.multiFilter - 1.0-name-matches-true-false-build_* + 1.0-name-matches-true-false-build* uORB_LOC - $%7BPROJECT_LOC%7D/build_posix_sitl_default/src/modules/uORB + $%7BPROJECT_LOC%7D/build/posix_sitl_default/src/modules/uORB uORB_SRC - $%7BPROJECT_LOC%7D/build_posix_sitl_default/topics_sources + $%7BPROJECT_LOC%7D/build/posix_sitl_default/topics_sources diff --git a/nuttx-configs/aerocore2/nsh/defconfig b/nuttx-configs/aerocore2/nsh/defconfig index 4337c91e28..987a9e7a60 100644 --- a/nuttx-configs/aerocore2/nsh/defconfig +++ b/nuttx-configs/aerocore2/nsh/defconfig @@ -667,7 +667,7 @@ CONFIG_RAM_SIZE=262144 # Board Selection # CONFIG_ARCH_BOARD_AEROCORE2=y -CONFIG_ARCH_BOARD="AeroCore2" +CONFIG_ARCH_BOARD="aerocore2" # # Custom Board Configuration diff --git a/nuttx-configs/aerofc-v1/nsh/defconfig b/nuttx-configs/aerofc-v1/nsh/defconfig index 27a04b55be..e9ef460174 100644 --- a/nuttx-configs/aerofc-v1/nsh/defconfig +++ b/nuttx-configs/aerofc-v1/nsh/defconfig @@ -677,7 +677,7 @@ CONFIG_ARCH_BOARD="aerofc-v1" # # Board-Specific Options # -CONFIG_BOARD_CRASHDUMP=y +CONFIG_BOARD_CRASHDUMP=n CONFIG_BOARD_RESET_ON_CRASH=y CONFIG_LIB_BOARDCTL=y CONFIG_BOARDCTL_RESET=y diff --git a/nuttx-configs/auav-x21/nsh/defconfig b/nuttx-configs/auav-x21/nsh/defconfig index 5d84012717..db2bd5d314 100644 --- a/nuttx-configs/auav-x21/nsh/defconfig +++ b/nuttx-configs/auav-x21/nsh/defconfig @@ -681,7 +681,7 @@ CONFIG_RAM_SIZE=262144 # Board Selection # CONFIG_ARCH_BOARD_AUAV_X21=y -CONFIG_ARCH_BOARD="auav_x21" +CONFIG_ARCH_BOARD="auav-x21" # # Custom Board Configuration diff --git a/nuttx-configs/px4esc-v1/bootloader/Make.defs b/nuttx-configs/px4esc-v1/bootloader/Make.defs index 80046d2ebd..d0f4390e81 100644 --- a/nuttx-configs/px4esc-v1/bootloader/Make.defs +++ b/nuttx-configs/px4esc-v1/bootloader/Make.defs @@ -59,11 +59,11 @@ OBJCOPY = $(CROSSDEV)objcopy OBJDUMP = $(CROSSDEV)objdump MAXOPTIMIZATION = -Os -ARCHCPUFLAGS = -mcpu=cortex-m4 \ - -mthumb \ - -march=armv7e-m \ - -mfpu=fpv4-sp-d16 \ - -mfloat-abi=hard +ARCHCPUFLAGS = -mcpu=cortex-m4 \ + -mthumb \ + -march=armv7e-m \ + -mfpu=fpv4-sp-d16 \ + -mfloat-abi=hard # Enable precise stack overflow tracking diff --git a/nuttx-configs/px4esc-v1/nsh/defconfig b/nuttx-configs/px4esc-v1/nsh/defconfig index 9fad0367e0..9100999888 100644 --- a/nuttx-configs/px4esc-v1/nsh/defconfig +++ b/nuttx-configs/px4esc-v1/nsh/defconfig @@ -612,8 +612,7 @@ CONFIG_ARCH_BOARD="px4esc-v1" # # Custom Board Configuration # -CONFIG_BOARD_CRASHDUMP=y -CONFIG_BOARD_RESET_ON_CRASH=y +# CONFIG_BOARD_CRASHDUMP is not set # CONFIG_BOARD_CUSTOM_LEDS is not set # CONFIG_BOARD_CUSTOM_BUTTONS is not set @@ -626,8 +625,7 @@ CONFIG_ARCH_LEDS=y # # Board-Specific Options # -CONFIG_BOARD_CRASHDUMP=y -CONFIG_BOARD_RESET_ON_CRASH=y +# CONFIG_BOARD_CRASHDUMP is not set CONFIG_LIB_BOARDCTL=y CONFIG_BOARDCTL_RESET=y # CONFIG_BOARDCTL_UNIQUEID is not set diff --git a/nuttx-configs/px4fmu-v2/nsh/Make.defs b/nuttx-configs/px4fmu-v2/nsh/Make.defs index 20e1afacd0..41194f00e9 100644 --- a/nuttx-configs/px4fmu-v2/nsh/Make.defs +++ b/nuttx-configs/px4fmu-v2/nsh/Make.defs @@ -162,4 +162,3 @@ HOSTCC = gcc HOSTINCLUDES = -I. HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe HOSTLDFLAGS = - diff --git a/nuttx-configs/px4fmu-v3/include/board.h b/nuttx-configs/px4fmu-v3/include/board.h index b20edfa947..827d4f1221 100755 --- a/nuttx-configs/px4fmu-v3/include/board.h +++ b/nuttx-configs/px4fmu-v3/include/board.h @@ -1,5 +1,5 @@ /************************************************************************************ - * configs/px4fmu-v3/include/board.h + * nuttx-configs/px4fmu-v3/include/board.h * include/arch/board/board.h * * Copyright (C) 2009 Gregory Nutt. All rights reserved. diff --git a/nuttx-configs/px4fmu-v3/nsh/Make.defs b/nuttx-configs/px4fmu-v3/nsh/Make.defs index 3332660b98..2cca39c75a 100644 --- a/nuttx-configs/px4fmu-v3/nsh/Make.defs +++ b/nuttx-configs/px4fmu-v3/nsh/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# configs/px4fmu-v3/nsh/Make.defs +# nuttx-configs/px4fmu-v3/nsh/Make.defs # # Copyright (C) 2011 Gregory Nutt. All rights reserved. # Author: Gregory Nutt diff --git a/nuttx-configs/px4fmu-v3/nsh/defconfig b/nuttx-configs/px4fmu-v3/nsh/defconfig index 8818c5ae95..1162058815 100644 --- a/nuttx-configs/px4fmu-v3/nsh/defconfig +++ b/nuttx-configs/px4fmu-v3/nsh/defconfig @@ -680,8 +680,8 @@ CONFIG_RAM_SIZE=262144 # # Board Selection # -CONFIG_ARCH_BOARD_PX4FMU_V2=y -CONFIG_ARCH_BOARD="px4fmu-v2" +CONFIG_ARCH_BOARD_PX4FMU_V3=y +CONFIG_ARCH_BOARD="px4fmu-v3" # # Custom Board Configuration diff --git a/nuttx-patches/00001-REJECTED-add-math.h.patch b/nuttx-patches/00001-REJECTED-add-math.h.patch deleted file mode 100644 index 18650027ec..0000000000 --- a/nuttx-patches/00001-REJECTED-add-math.h.patch +++ /dev/null @@ -1,583 +0,0 @@ -diff -ruN NuttX/nuttx/arch/arm/include/math.h NuttX/nuttx/arch/arm/include/math.h ---- NuttX/nuttx/arch/arm/include/math.h 1969-12-31 14:00:00.000000000 -1000 -+++ NuttX/nuttx/arch/arm/include/math.h 2014-12-25 17:33:53.404950574 -1000 -@@ -0,0 +1,579 @@ -+#ifndef _MATH_H_ -+ -+#define _MATH_H_ -+ -+#include -+#include "_ansi.h" -+ -+_BEGIN_STD_C -+ -+/* Natural log of 2 */ -+#define _M_LN2 0.693147180559945309417 -+ -+#if defined(__GNUC__) && \ -+ ( (__GNUC__ >= 4) || \ -+ ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) ) -+ -+ /* gcc >= 3.3 implicitly defines builtins for HUGE_VALx values. */ -+ -+# ifndef HUGE_VAL -+# define HUGE_VAL (__builtin_huge_val()) -+# endif -+ -+# ifndef HUGE_VALF -+# define HUGE_VALF (__builtin_huge_valf()) -+# endif -+ -+# ifndef HUGE_VALL -+# define HUGE_VALL (__builtin_huge_vall()) -+# endif -+ -+# ifndef INFINITY -+# define INFINITY (__builtin_inff()) -+# endif -+ -+# ifndef NAN -+# define NAN (__builtin_nanf("")) -+# endif -+ -+#else /* !gcc >= 3.3 */ -+ -+ /* No builtins. Use fixed defines instead. (All 3 HUGE plus the INFINITY -+ * * and NAN macros are required to be constant expressions. Using a variable-- -+ * * even a static const--does not meet this requirement, as it cannot be -+ * * evaluated at translation time.) -+ * * The infinities are done using numbers that are far in excess of -+ * * something that would be expected to be encountered in a floating-point -+ * * implementation. (A more certain way uses values from float.h, but that is -+ * * avoided because system includes are not supposed to include each other.) -+ * * This method might produce warnings from some compilers. (It does in -+ * * newer GCCs, but not for ones that would hit this #else.) If this happens, -+ * * please report details to the Newlib mailing list. */ -+ -+ #ifndef HUGE_VAL -+ #define HUGE_VAL (1.0e999999999) -+ #endif -+ -+ #ifndef HUGE_VALF -+ #define HUGE_VALF (1.0e999999999F) -+ #endif -+ -+ #if !defined(HUGE_VALL) && defined(_HAVE_LONG_DOUBLE) -+ #define HUGE_VALL (1.0e999999999L) -+ #endif -+ -+ #if !defined(INFINITY) -+ #define INFINITY (HUGE_VALF) -+ #endif -+ -+ #if !defined(NAN) -+ #if defined(__GNUC__) && defined(__cplusplus) -+ /* Exception: older g++ versions warn about the divide by 0 used in the -+ * * normal case (even though older gccs do not). This trick suppresses the -+ * * warning, but causes errors for plain gcc, so is only used in the one -+ * * special case. */ -+ static const union { __ULong __i[1]; float __d; } __Nanf = {0x7FC00000}; -+ #define NAN (__Nanf.__d) -+ #else -+ #define NAN (0.0F/0.0F) -+ #endif -+ #endif -+ -+#endif /* !gcc >= 3.3 */ -+ -+/* Reentrant ANSI C functions. */ -+ -+#ifndef __math_68881 -+extern double atan _PARAMS((double)); -+extern double cos _PARAMS((double)); -+extern double sin _PARAMS((double)); -+extern double tan _PARAMS((double)); -+extern double tanh _PARAMS((double)); -+extern double frexp _PARAMS((double, int *)); -+extern double modf _PARAMS((double, double *)); -+extern double ceil _PARAMS((double)); -+extern double fabs _PARAMS((double)); -+extern double floor _PARAMS((double)); -+#endif /* ! defined (__math_68881) */ -+ -+/* Non reentrant ANSI C functions. */ -+ -+#ifndef _REENT_ONLY -+#ifndef __math_68881 -+extern double acos _PARAMS((double)); -+extern double asin _PARAMS((double)); -+extern double atan2 _PARAMS((double, double)); -+extern double cosh _PARAMS((double)); -+extern double sinh _PARAMS((double)); -+extern double exp _PARAMS((double)); -+extern double ldexp _PARAMS((double, int)); -+extern double log _PARAMS((double)); -+extern double log10 _PARAMS((double)); -+extern double pow _PARAMS((double, double)); -+extern double sqrt _PARAMS((double)); -+extern double fmod _PARAMS((double, double)); -+#endif /* ! defined (__math_68881) */ -+#endif /* ! defined (_REENT_ONLY) */ -+ -+#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L -+ -+/* ISO C99 types and macros. */ -+ -+#ifndef FLT_EVAL_METHOD -+#define FLT_EVAL_METHOD 0 -+typedef float float_t; -+typedef double double_t; -+#endif /* FLT_EVAL_METHOD */ -+ -+#define FP_NAN 0 -+#define FP_INFINITE 1 -+#define FP_ZERO 2 -+#define FP_SUBNORMAL 3 -+#define FP_NORMAL 4 -+ -+#ifndef FP_ILOGB0 -+# define FP_ILOGB0 (-INT_MAX) -+#endif -+#ifndef FP_ILOGBNAN -+# define FP_ILOGBNAN INT_MAX -+#endif -+ -+#ifndef MATH_ERRNO -+# define MATH_ERRNO 1 -+#endif -+#ifndef MATH_ERREXCEPT -+# define MATH_ERREXCEPT 2 -+#endif -+#ifndef math_errhandling -+# define math_errhandling MATH_ERRNO -+#endif -+ -+extern int __isinff (float x); -+extern int __isinfd (double x); -+extern int __isnanf (float x); -+extern int __isnand (double x); -+extern int __fpclassifyf (float x); -+extern int __fpclassifyd (double x); -+extern int __signbitf (float x); -+extern int __signbitd (double x); -+ -+#define fpclassify(__x) \ -+ ((sizeof(__x) == sizeof(float)) ? __fpclassifyf(__x) : \ -+ __fpclassifyd(__x)) -+ -+#ifndef isfinite -+ #define isfinite(__y) \ -+ (__extension__ ({int __cy = fpclassify(__y); \ -+ __cy != FP_INFINITE && __cy != FP_NAN;})) -+#endif -+ -+/* Note: isinf and isnan were once functions in newlib that took double -+ * * arguments. C99 specifies that these names are reserved for macros -+ * * supporting multiple floating point types. Thus, they are -+ * * now defined as macros. Implementations of the old functions -+ * * taking double arguments still exist for compatibility purposes -+ * * (prototypes for them are in ). */ -+#ifndef isinf -+ #define isinf(y) (fpclassify(y) == FP_INFINITE) -+#endif -+ -+#ifndef isnan -+ #define isnan(y) (fpclassify(y) == FP_NAN) -+#endif -+ -+#define isnormal(y) (fpclassify(y) == FP_NORMAL) -+#define signbit(__x) \ -+ ((sizeof(__x) == sizeof(float)) ? __signbitf(__x) : \ -+ __signbitd(__x)) -+ -+#define isgreater(x,y) \ -+ (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ -+ !isunordered(__x,__y) && (__x > __y);})) -+#define isgreaterequal(x,y) \ -+ (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ -+ !isunordered(__x,__y) && (__x >= __y);})) -+#define isless(x,y) \ -+ (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ -+ !isunordered(__x,__y) && (__x < __y);})) -+#define islessequal(x,y) \ -+ (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ -+ !isunordered(__x,__y) && (__x <= __y);})) -+#define islessgreater(x,y) \ -+ (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ -+ !isunordered(__x,__y) && (__x < __y || __x > __y);})) -+ -+#define isunordered(a,b) \ -+ (__extension__ ({__typeof__(a) __a = (a); __typeof__(b) __b = (b); \ -+ fpclassify(__a) == FP_NAN || fpclassify(__b) == FP_NAN;})) -+ -+/* Non ANSI double precision functions. */ -+ -+extern double infinity _PARAMS((void)); -+extern double nan _PARAMS((const char *)); -+extern int finite _PARAMS((double)); -+extern double copysign _PARAMS((double, double)); -+extern double logb _PARAMS((double)); -+extern int ilogb _PARAMS((double)); -+ -+extern double asinh _PARAMS((double)); -+extern double cbrt _PARAMS((double)); -+extern double nextafter _PARAMS((double, double)); -+extern double rint _PARAMS((double)); -+extern double scalbn _PARAMS((double, int)); -+ -+extern double exp2 _PARAMS((double)); -+extern double scalbln _PARAMS((double, long int)); -+extern double tgamma _PARAMS((double)); -+extern double nearbyint _PARAMS((double)); -+extern long int lrint _PARAMS((double)); -+extern long long int llrint _PARAMS((double)); -+extern double round _PARAMS((double)); -+extern long int lround _PARAMS((double)); -+extern long long int llround _PARAMS((double)); -+extern double trunc _PARAMS((double)); -+extern double remquo _PARAMS((double, double, int *)); -+extern double fdim _PARAMS((double, double)); -+extern double fmax _PARAMS((double, double)); -+extern double fmin _PARAMS((double, double)); -+extern double fma _PARAMS((double, double, double)); -+ -+#ifndef __math_68881 -+extern double log1p _PARAMS((double)); -+extern double expm1 _PARAMS((double)); -+#endif /* ! defined (__math_68881) */ -+ -+#ifndef _REENT_ONLY -+extern double acosh _PARAMS((double)); -+extern double atanh _PARAMS((double)); -+extern double remainder _PARAMS((double, double)); -+extern double gamma _PARAMS((double)); -+extern double lgamma _PARAMS((double)); -+extern double erf _PARAMS((double)); -+extern double erfc _PARAMS((double)); -+extern double log2 _PARAMS((double)); -+ -+#ifndef __math_68881 -+extern double hypot _PARAMS((double, double)); -+#endif -+ -+#endif /* ! defined (_REENT_ONLY) */ -+ -+/* Single precision versions of ANSI functions. */ -+ -+extern float atanf _PARAMS((float)); -+extern float cosf _PARAMS((float)); -+extern float sinf _PARAMS((float)); -+extern float tanf _PARAMS((float)); -+extern float tanhf _PARAMS((float)); -+extern float frexpf _PARAMS((float, int *)); -+extern float modff _PARAMS((float, float *)); -+extern float ceilf _PARAMS((float)); -+extern float fabsf _PARAMS((float)); -+extern float floorf _PARAMS((float)); -+ -+#ifndef _REENT_ONLY -+extern float acosf _PARAMS((float)); -+extern float asinf _PARAMS((float)); -+extern float atan2f _PARAMS((float, float)); -+extern float coshf _PARAMS((float)); -+extern float sinhf _PARAMS((float)); -+extern float expf _PARAMS((float)); -+extern float ldexpf _PARAMS((float, int)); -+extern float logf _PARAMS((float)); -+extern float log10f _PARAMS((float)); -+extern float powf _PARAMS((float, float)); -+extern float sqrtf _PARAMS((float)); -+extern float fmodf _PARAMS((float, float)); -+#endif /* ! defined (_REENT_ONLY) */ -+ -+/* Other single precision functions. */ -+ -+extern float exp2f _PARAMS((float)); -+extern float scalblnf _PARAMS((float, long int)); -+extern float tgammaf _PARAMS((float)); -+extern float nearbyintf _PARAMS((float)); -+extern long int lrintf _PARAMS((float)); -+extern long long llrintf _PARAMS((float)); -+extern float roundf _PARAMS((float)); -+extern long int lroundf _PARAMS((float)); -+extern long long int llroundf _PARAMS((float)); -+extern float truncf _PARAMS((float)); -+extern float remquof _PARAMS((float, float, int *)); -+extern float fdimf _PARAMS((float, float)); -+extern float fmaxf _PARAMS((float, float)); -+extern float fminf _PARAMS((float, float)); -+extern float fmaf _PARAMS((float, float, float)); -+ -+extern float infinityf _PARAMS((void)); -+extern float nanf _PARAMS((const char *)); -+extern int finitef _PARAMS((float)); -+extern float copysignf _PARAMS((float, float)); -+extern float logbf _PARAMS((float)); -+extern int ilogbf _PARAMS((float)); -+ -+extern float asinhf _PARAMS((float)); -+extern float cbrtf _PARAMS((float)); -+extern float nextafterf _PARAMS((float, float)); -+extern float rintf _PARAMS((float)); -+extern float scalbnf _PARAMS((float, int)); -+extern float log1pf _PARAMS((float)); -+extern float expm1f _PARAMS((float)); -+ -+#ifndef _REENT_ONLY -+extern float acoshf _PARAMS((float)); -+extern float atanhf _PARAMS((float)); -+extern float remainderf _PARAMS((float, float)); -+extern float gammaf _PARAMS((float)); -+extern float lgammaf _PARAMS((float)); -+extern float erff _PARAMS((float)); -+extern float erfcf _PARAMS((float)); -+extern float log2f _PARAMS((float)); -+extern float hypotf _PARAMS((float, float)); -+#endif /* ! defined (_REENT_ONLY) */ -+ -+/* On platforms where long double equals double. */ -+#ifdef _LDBL_EQ_DBL -+/* Reentrant ANSI C functions. */ -+#ifndef __math_68881 -+extern long double atanl _PARAMS((long double)); -+extern long double cosl _PARAMS((long double)); -+extern long double sinl _PARAMS((long double)); -+extern long double tanl _PARAMS((long double)); -+extern long double tanhl _PARAMS((long double)); -+extern long double frexpl _PARAMS((long double value, int *)); -+extern long double modfl _PARAMS((long double, long double *)); -+extern long double ceill _PARAMS((long double)); -+extern long double fabsl _PARAMS((long double)); -+extern long double floorl _PARAMS((long double)); -+extern long double log1pl _PARAMS((long double)); -+extern long double expm1l _PARAMS((long double)); -+#endif /* ! defined (__math_68881) */ -+/* Non reentrant ANSI C functions. */ -+#ifndef _REENT_ONLY -+#ifndef __math_68881 -+extern long double acosl _PARAMS((long double)); -+extern long double asinl _PARAMS((long double)); -+extern long double atan2l _PARAMS((long double, long double)); -+extern long double coshl _PARAMS((long double)); -+extern long double sinhl _PARAMS((long double)); -+extern long double expl _PARAMS((long double)); -+extern long double ldexpl _PARAMS((long double, int)); -+extern long double logl _PARAMS((long double)); -+extern long double log2l _PARAMS((long double)); -+extern long double log10l _PARAMS((long double)); -+extern long double powl _PARAMS((long double, long double)); -+extern long double sqrtl _PARAMS((long double)); -+extern long double fmodl _PARAMS((long double, long double)); -+extern long double hypotl _PARAMS((long double, long double)); -+#endif /* ! defined (__math_68881) */ -+#endif /* ! defined (_REENT_ONLY) */ -+extern long double copysignl _PARAMS((long double, long double)); -+extern long double nanl _PARAMS((const char *)); -+extern int ilogbl _PARAMS((long double)); -+extern long double asinhl _PARAMS((long double)); -+extern long double cbrtl _PARAMS((long double)); -+extern long double nextafterl _PARAMS((long double, long double)); -+extern long double rintl _PARAMS((long double)); -+extern long double scalbnl _PARAMS((long double, int)); -+extern long double exp2l _PARAMS((long double)); -+extern long double scalblnl _PARAMS((long double, long)); -+extern long double tgammal _PARAMS((long double)); -+extern long double nearbyintl _PARAMS((long double)); -+extern long int lrintl _PARAMS((long double)); -+extern long long int llrintl _PARAMS((long double)); -+extern long double roundl _PARAMS((long double)); -+extern long lroundl _PARAMS((long double)); -+extern long long int llroundl _PARAMS((long double)); -+extern long double truncl _PARAMS((long double)); -+extern long double remquol _PARAMS((long double, long double, int *)); -+extern long double fdiml _PARAMS((long double, long double)); -+extern long double fmaxl _PARAMS((long double, long double)); -+extern long double fminl _PARAMS((long double, long double)); -+extern long double fmal _PARAMS((long double, long double, long double)); -+#ifndef _REENT_ONLY -+extern long double acoshl _PARAMS((long double)); -+extern long double atanhl _PARAMS((long double)); -+extern long double remainderl _PARAMS((long double, long double)); -+extern long double lgammal _PARAMS((long double)); -+extern long double erfl _PARAMS((long double)); -+extern long double erfcl _PARAMS((long double)); -+#endif /* ! defined (_REENT_ONLY) */ -+#else /* !_LDBL_EQ_DBL */ -+#ifdef __i386__ -+/* Other long double precision functions. */ -+extern _LONG_DOUBLE rintl _PARAMS((_LONG_DOUBLE)); -+extern long int lrintl _PARAMS((_LONG_DOUBLE)); -+extern long long llrintl _PARAMS((_LONG_DOUBLE)); -+#endif /* __i386__ */ -+#endif /* !_LDBL_EQ_DBL */ -+ -+#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L */ -+ -+#if !defined (__STRICT_ANSI__) || defined(__cplusplus) -+ -+extern double drem _PARAMS((double, double)); -+extern void sincos _PARAMS((double, double *, double *)); -+extern double gamma_r _PARAMS((double, int *)); -+extern double lgamma_r _PARAMS((double, int *)); -+ -+extern double y0 _PARAMS((double)); -+extern double y1 _PARAMS((double)); -+extern double yn _PARAMS((int, double)); -+extern double j0 _PARAMS((double)); -+extern double j1 _PARAMS((double)); -+extern double jn _PARAMS((int, double)); -+ -+extern float dremf _PARAMS((float, float)); -+extern void sincosf _PARAMS((float, float *, float *)); -+extern float gammaf_r _PARAMS((float, int *)); -+extern float lgammaf_r _PARAMS((float, int *)); -+ -+extern float y0f _PARAMS((float)); -+extern float y1f _PARAMS((float)); -+extern float ynf _PARAMS((int, float)); -+extern float j0f _PARAMS((float)); -+extern float j1f _PARAMS((float)); -+extern float jnf _PARAMS((int, float)); -+ -+/* GNU extensions */ -+# ifndef exp10 -+extern double exp10 _PARAMS((double)); -+# endif -+# ifndef pow10 -+extern double pow10 _PARAMS((double)); -+# endif -+# ifndef exp10f -+extern float exp10f _PARAMS((float)); -+# endif -+# ifndef pow10f -+extern float pow10f _PARAMS((float)); -+# endif -+ -+#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) */ -+ -+#ifndef __STRICT_ANSI__ -+ -+/* The gamma functions use a global variable, signgam. */ -+#ifndef _REENT_ONLY -+#define signgam (*__signgam()) -+extern int *__signgam _PARAMS((void)); -+#endif /* ! defined (_REENT_ONLY) */ -+ -+#define __signgam_r(ptr) _REENT_SIGNGAM(ptr) -+ -+/* The exception structure passed to the matherr routine. */ -+/* We have a problem when using C++ since `exception' is a reserved -+ * name in C++. */ -+#ifdef __cplusplus -+struct __exception -+#else -+struct exception -+#endif -+{ -+ int type; -+ char *name; -+ double arg1; -+ double arg2; -+ double retval; -+ int err; -+}; -+ -+#ifdef __cplusplus -+extern int matherr _PARAMS((struct __exception *e)); -+#else -+extern int matherr _PARAMS((struct exception *e)); -+#endif -+ -+/* Values for the type field of struct exception. */ -+ -+#define DOMAIN 1 -+#define SING 2 -+#define OVERFLOW 3 -+#define UNDERFLOW 4 -+#define TLOSS 5 -+#define PLOSS 6 -+ -+/* Useful constants. */ -+ -+#define MAXFLOAT 3.40282347e+38F -+ -+#define M_E 2.7182818284590452354 -+#define M_LOG2E 1.4426950408889634074 -+#define M_LOG10E 0.43429448190325182765 -+#define M_LN2 _M_LN2 -+#define M_LN10 2.30258509299404568402 -+#define M_PI 3.14159265358979323846 -+#define M_TWOPI (M_PI * 2.0) -+#define M_PI_2 1.57079632679489661923 -+#define M_PI_4 0.78539816339744830962 -+#define M_3PI_4 2.3561944901923448370E0 -+#define M_SQRTPI 1.77245385090551602792981 -+#define M_1_PI 0.31830988618379067154 -+#define M_2_PI 0.63661977236758134308 -+#define M_2_SQRTPI 1.12837916709551257390 -+#define M_DEG_TO_RAD 0.01745329251994 -+#define M_RAD_TO_DEG 57.2957795130823 -+#define M_SQRT2 1.41421356237309504880 -+#define M_SQRT1_2 0.70710678118654752440 -+#define M_LN2LO 1.9082149292705877000E-10 -+#define M_LN2HI 6.9314718036912381649E-1 -+#define M_SQRT3 1.73205080756887719000 -+#define M_IVLN10 0.43429448190325182765 /* 1 / log(10) */ -+#define M_LOG2_E _M_LN2 -+#define M_INVLN2 1.4426950408889633870E0 /* 1 / log(2) */ -+ -+ -+#define M_E_F 2.7182818284590452354f -+#define M_LOG2E_F 1.4426950408889634074f -+#define M_LOG10E_F 0.43429448190325182765f -+#define M_LN2_F _M_LN2_F -+#define M_LN10_F 2.30258509299404568402f -+#define M_PI_F 3.14159265358979323846f -+#define M_TWOPI_F (M_PI_F * 2.0f) -+#define M_PI_2_F 1.57079632679489661923f -+#define M_PI_4_F 0.78539816339744830962f -+#define M_3PI_4_F 2.3561944901923448370E0f -+#define M_SQRTPI_F 1.77245385090551602792981f -+#define M_1_PI_F 0.31830988618379067154f -+#define M_2_PI_F 0.63661977236758134308f -+#define M_2_SQRTPI_F 1.12837916709551257390f -+#define M_DEG_TO_RAD_F 0.01745329251994f -+#define M_RAD_TO_DEG_F 57.2957795130823f -+#define M_SQRT2_F 1.41421356237309504880f -+#define M_SQRT1_2_F 0.70710678118654752440f -+#define M_LN2LO_F 1.9082149292705877000E-10f -+#define M_LN2HI_F 6.9314718036912381649E-1f -+#define M_SQRT3_F 1.73205080756887719000f -+#define M_IVLN10_F 0.43429448190325182765f /* 1 / log(10) */ -+#define M_LOG2_E_F _M_LN2_F -+#define M_INVLN2_F 1.4426950408889633870E0f /* 1 / log(2) */ -+ -+/* Global control over fdlibm error handling. */ -+ -+enum __fdlibm_version -+{ -+ __fdlibm_ieee = -1, -+ __fdlibm_svid, -+ __fdlibm_xopen, -+ __fdlibm_posix -+}; -+ -+#define _LIB_VERSION_TYPE enum __fdlibm_version -+#define _LIB_VERSION __fdlib_version -+ -+extern __IMPORT _LIB_VERSION_TYPE _LIB_VERSION; -+ -+#define _IEEE_ __fdlibm_ieee -+#define _SVID_ __fdlibm_svid -+#define _XOPEN_ __fdlibm_xopen -+#define _POSIX_ __fdlibm_posix -+ -+#endif /* ! defined (__STRICT_ANSI__) */ -+ -+_END_STD_C -+ -+#ifdef __FAST_MATH__ -+#include -+#endif -+ -+#endif /* _MATH_H_ */ diff --git a/nuttx-patches/00002-REJECTED-fix-shadow-wanings.patch b/nuttx-patches/00002-REJECTED-fix-shadow-wanings.patch deleted file mode 100644 index 396580e9ec..0000000000 --- a/nuttx-patches/00002-REJECTED-fix-shadow-wanings.patch +++ /dev/null @@ -1,64 +0,0 @@ -diff --git NuttX/nuttx/include/signal.h NuttX/nuttx/include/signal.h -index bd8ee9f..7ee242a 100644 ---- NuttX/nuttx/include/signal.h -+++ NuttX/nuttx/include/signal.h -@@ -282,8 +282,11 @@ extern "C" - - int kill(pid_t pid, int signo); - int raise(int signo); -+#pragma GCC diagnostic push -+#pragma GCC diagnostic ignored "-Wshadow" - int sigaction(int signo, FAR const struct sigaction *act, - FAR struct sigaction *oact); -+#pragma GCC diagnostic pop - int sigaddset(FAR sigset_t *set, int signo); - int sigdelset(FAR sigset_t *set, int signo); - int sigemptyset(FAR sigset_t *set); -diff --git NuttX/nuttx/include/stdlib.h NuttX/nuttx/include/stdlib.h -index aa259c9..f2b0640 100644 ---- NuttX/nuttx/include/stdlib.h -+++ NuttX/nuttx/include/stdlib.h -@@ -202,7 +202,10 @@ FAR void *zalloc(size_t); - FAR void *calloc(size_t, size_t); - - #ifdef CONFIG_CAN_PASS_STRUCTS -+#pragma GCC diagnostic push -+#pragma GCC diagnostic ignored "-Wshadow" - struct mallinfo mallinfo(void); -+#pragma GCC diagnostic pop - #else - int mallinfo(FAR struct mallinfo *info); - #endif -diff --git NuttX/nuttx/include/sys/statfs.h NuttX/nuttx/include/sys/statfs.h -index 1d1786a..12f802b 100644 ---- NuttX/nuttx/include/sys/statfs.h -+++ NuttX/nuttx/include/sys/statfs.h -@@ -139,8 +139,11 @@ extern "C" - * form of the struct statfs. - */ - -+#pragma GCC diagnostic push -+#pragma GCC diagnostic ignored "-Wshadow" - int statfs(FAR const char *path, FAR struct statfs *buf); - int fstatfs(int fd, FAR struct statfs *buf); -+#pragma GCC diagnostic pop - - #undef EXTERN - #if defined(__cplusplus) -diff --git NuttX/nuttx/include/sys/stat.h NuttX/nuttx/include/sys/stat.h -index 4d82f62..4d35fcb 100644 ---- NuttX/nuttx/include/sys/stat.h -+++ NuttX/nuttx/include/sys/stat.h -@@ -154,9 +154,11 @@ extern "C" - - int mkdir(FAR const char *pathname, mode_t mode); - int mkfifo(FAR const char *pathname, mode_t mode); -+#pragma GCC diagnostic push -+#pragma GCC diagnostic ignored "-Wshadow" - int stat(const char *path, FAR struct stat *buf); - int fstat(int fd, FAR struct stat *buf); -- -+#pragma GCC diagnostic pop - #undef EXTERN - #if defined(__cplusplus) - } diff --git a/nuttx-patches/00003-REJECTED-add-var-expansion-in-nsh-parse.patch b/nuttx-patches/00003-REJECTED-add-var-expansion-in-nsh-parse.patch deleted file mode 100644 index 27466cba0d..0000000000 --- a/nuttx-patches/00003-REJECTED-add-var-expansion-in-nsh-parse.patch +++ /dev/null @@ -1,271 +0,0 @@ -diff --git NuttX/apps/nshlib/nsh_parse.c NuttX/apps/nshlib/nsh_parse.c -index 30f7ef5..f6fa2e0 100644 ---- NuttX/apps/nshlib/nsh_parse.c -+++ NuttX/apps/nshlib/nsh_parse.c -@@ -156,9 +156,9 @@ static FAR char *nsh_envexpand(FAR struct nsh_vtbl_s *vtbl, - #endif - - static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, -- FAR char **allocation); -+ FAR char **allocation, int* isenvvar); - static FAR char *nsh_argument(FAR struct nsh_vtbl_s *vtbl, char **saveptr, -- FAR NSH_MEMLIST_TYPE *memlist); -+ FAR NSH_MEMLIST_TYPE *memlist, int* isenvvar); - - #ifndef CONFIG_NSH_DISABLESCRIPT - #ifndef CONFIG_NSH_DISABLE_LOOPS -@@ -1009,7 +1009,7 @@ static FAR char *nsh_envexpand(FAR struct nsh_vtbl_s *vtbl, - - #if defined(CONFIG_NSH_ARGCAT) && defined(HAVE_MEMLIST) - static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, -- FAR char **allocation) -+ FAR char **allocation, int* isenvvar) - { - FAR char *working = cmdline; - FAR char *argument = NULL; -@@ -1128,8 +1128,8 @@ static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, - *allocation = argument; - - /* Find the end of the environment variable reference. If the -- * dollar sign ('$') is followed by a right bracket ('{') then the -- * variable name is terminated with the left bracket character -+ * dollar sign ('$') is followed by a left bracket ('{') then the -+ * variable name is terminated with the right bracket character - * ('}'). Otherwise, the variable name goes to the end of the - * argument. - */ -@@ -1167,6 +1167,10 @@ static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, - * nsh_envexpand will return the NULL string. - */ - -+ if (isenvvar) { -+ *isenvvar = 1; -+ } -+ - envstr = nsh_envexpand(vtbl, ptr); - - /* Concatenate the result of the operation with the accumulated -@@ -1187,7 +1191,7 @@ static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, - - #else - static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, -- FAR char **allocation) -+ FAR char **allocation, int* isenvvar) - { - FAR char *argument = (FAR char *)g_nullstring; - -@@ -1223,6 +1227,9 @@ static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, - - if (*cmdline == '$') - { -+ if (isenvvar) { -+ *isenvvar = 1; -+ } - argument = nsh_envexpand(vtbl, cmdline + 1); - } - else -@@ -1245,7 +1252,7 @@ static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, - ****************************************************************************/ - - static FAR char *nsh_argument(FAR struct nsh_vtbl_s *vtbl, FAR char **saveptr, -- FAR NSH_MEMLIST_TYPE *memlist) -+ FAR NSH_MEMLIST_TYPE *memlist, int* isenvvar) - { - FAR char *pbegin = *saveptr; - FAR char *pend = NULL; -@@ -1317,6 +1324,13 @@ static FAR char *nsh_argument(FAR struct nsh_vtbl_s *vtbl, FAR char **saveptr, - - pbegin++; - term = "\""; -+ -+ /* If this is an environment variable in double quotes, we don't want it split into -+ * multiple argument should CONFIG_NSH_ENABLEPX4PARSING be defined -+ * So just invalidate the flag pointer which would otherwise communictate such -+ * back up the call tree. -+ */ -+ isenvvar = NULL; - } - else - { -@@ -1376,11 +1390,11 @@ static FAR char *nsh_argument(FAR struct nsh_vtbl_s *vtbl, FAR char **saveptr, - - /* Perform expansions as necessary for the argument */ - -- argument = nsh_argexpand(vtbl, pbegin, &allocation); -+ argument = nsh_argexpand(vtbl, pbegin, &allocation, isenvvar); - } - - /* If any memory was allocated for this argument, make sure that it is -- * added to the list of memory to be freed at the end of commend -+ * added to the list of memory to be freed at the end of command - * processing. - */ - -@@ -1497,7 +1511,7 @@ static int nsh_loop(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, - - /* Get the cmd following the "while" or "until" */ - -- *ppcmd = nsh_argument(vtbl, saveptr, memlist); -+ *ppcmd = nsh_argument(vtbl, saveptr, memlist, 0); - if (!*ppcmd) - { - nsh_output(vtbl, g_fmtarginvalid, "if"); -@@ -1554,7 +1568,7 @@ static int nsh_loop(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, - { - /* Get the cmd following the "do" -- there may or may not be one */ - -- *ppcmd = nsh_argument(vtbl, saveptr, memlist); -+ *ppcmd = nsh_argument(vtbl, saveptr, memlist, 0); - - /* Verify that "do" is valid in this context */ - -@@ -1574,7 +1588,7 @@ static int nsh_loop(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, - { - /* Get the cmd following the "done" -- there should be one */ - -- *ppcmd = nsh_argument(vtbl, saveptr, memlist); -+ *ppcmd = nsh_argument(vtbl, saveptr, memlist, 0); - if (*ppcmd) - { - nsh_output(vtbl, g_fmtarginvalid, "done"); -@@ -1679,7 +1693,7 @@ static int nsh_itef(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, - { - /* Get the cmd following the if */ - -- *ppcmd = nsh_argument(vtbl, saveptr, memlist); -+ *ppcmd = nsh_argument(vtbl, saveptr, memlist, 0); - if (!*ppcmd) - { - nsh_output(vtbl, g_fmtarginvalid, "if"); -@@ -1717,7 +1731,7 @@ static int nsh_itef(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, - { - /* Get the cmd following the "then" -- there may or may not be one */ - -- *ppcmd = nsh_argument(vtbl, saveptr, memlist); -+ *ppcmd = nsh_argument(vtbl, saveptr, memlist, 0); - - /* Verify that "then" is valid in this context */ - -@@ -1736,7 +1750,7 @@ static int nsh_itef(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, - { - /* Get the cmd following the "else" -- there may or may not be one */ - -- *ppcmd = nsh_argument(vtbl, saveptr, memlist); -+ *ppcmd = nsh_argument(vtbl, saveptr, memlist, 0); - - /* Verify that "else" is valid in this context */ - -@@ -1755,7 +1769,7 @@ static int nsh_itef(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, - { - /* Get the cmd following the fi -- there should be one */ - -- *ppcmd = nsh_argument(vtbl, saveptr, memlist); -+ *ppcmd = nsh_argument(vtbl, saveptr, memlist, 0); - if (*ppcmd) - { - nsh_output(vtbl, g_fmtarginvalid, "fi"); -@@ -1827,10 +1841,10 @@ static int nsh_nice(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, - - /* Get the cmd (or -d option of nice command) */ - -- cmd = nsh_argument(vtbl, saveptr, memlist); -+ cmd = nsh_argument(vtbl, saveptr, memlist, 0); - if (cmd && strcmp(cmd, "-d") == 0) - { -- FAR char *val = nsh_argument(vtbl, saveptr, memlist); -+ FAR char *val = nsh_argument(vtbl, saveptr, memlist, 0); - if (val) - { - char *endptr; -@@ -1841,7 +1855,7 @@ static int nsh_nice(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, - nsh_output(vtbl, g_fmtarginvalid, "nice"); - return ERROR; - } -- cmd = nsh_argument(vtbl, saveptr, memlist); -+ cmd = nsh_argument(vtbl, saveptr, memlist, 0); - } - } - -@@ -1909,7 +1923,7 @@ static int nsh_parse_cmdparm(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, - /* Parse out the command at the beginning of the line */ - - saveptr = cmdline; -- cmd = nsh_argument(vtbl, &saveptr, &memlist); -+ cmd = nsh_argument(vtbl, &saveptr, &memlist, 0); - - /* Check if any command was provided -OR- if command processing is - * currently disabled. -@@ -1943,7 +1957,7 @@ static int nsh_parse_cmdparm(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, - argv[0] = cmd; - for (argc = 1; argc < MAX_ARGV_ENTRIES-1; argc++) - { -- argv[argc] = nsh_argument(vtbl, &saveptr, &memlist); -+ argv[argc] = nsh_argument(vtbl, &saveptr, &memlist, 0); - if (!argv[argc]) - { - break; -@@ -2010,7 +2024,7 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline) - /* Parse out the command at the beginning of the line */ - - saveptr = cmdline; -- cmd = nsh_argument(vtbl, &saveptr, &memlist); -+ cmd = nsh_argument(vtbl, &saveptr, &memlist, 0); - - #ifndef CONFIG_NSH_DISABLESCRIPT - #ifndef CONFIG_NSH_DISABLE_LOOPS -@@ -2078,15 +2092,54 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline) - */ - - argv[0] = cmd; -+ -+#define CONFIG_NSH_ENABLEPX4PARSING -+ - for (argc = 1; argc < MAX_ARGV_ENTRIES-1; argc++) - { -- argv[argc] = nsh_argument(vtbl, &saveptr, &memlist); -+ int isenvvar = 0; /* flag for if an enviroment variable gets expanded */ -+ argv[argc] = nsh_argument(vtbl, &saveptr, &memlist, &isenvvar); - if (!argv[argc]) - { - break; - } -+ -+#ifdef CONFIG_NSH_ENABLEPX4PARSING -+ if (isenvvar) -+ { -+ while (argc < MAX_ARGV_ENTRIES-1) /* TODO: check this bounds check is correct */ -+ { -+ FAR char *pbegin = argv[argc]; -+ -+ /* Find the end of the current token */ -+ for (; *pbegin && !strchr(g_token_separator, *pbegin); pbegin++); -+ -+ /* If end of string, we've processed the last token and we're done */ -+ if ('\0' == *pbegin) -+ { -+ break; -+ } -+ -+ /* Terminate the token to complete the argv variable */ -+ *pbegin = '\0'; -+ -+ /* We've inserted an extra parameter, so bump the count */ -+ argc++; -+ -+ /* Move to the next character in the string of tokens */ -+ pbegin++; -+ -+ /* Throw away any extra separator chars between tokens */ -+ for (; *pbegin && strchr(g_token_separator, *pbegin) != NULL; pbegin++); -+ -+ /* Prepare to loop again on the next argument token */ -+ argv[argc] = pbegin; -+ } -+ } -+#endif /* CONFIG_NSH_ENABLEPX4PARSING */ - } - -+ /* Last argument vector must be empty */ - argv[argc] = NULL; - - /* Check if the command should run in background */ diff --git a/nuttx-patches/00004-REJECTED-avoid-export-copy-with-export-insitu.patch b/nuttx-patches/00004-REJECTED-avoid-export-copy-with-export-insitu.patch deleted file mode 100644 index f1c54466b6..0000000000 --- a/nuttx-patches/00004-REJECTED-avoid-export-copy-with-export-insitu.patch +++ /dev/null @@ -1,56 +0,0 @@ -diff --git NuttX/nuttx/tools/mkexport.sh NuttX/nuttx/tools/mkexport.sh -index 348a14c..3cc9182 100755 ---- NuttX/nuttx/tools/mkexport.sh -+++ NuttX/nuttx/tools/mkexport.sh -@@ -34,19 +34,23 @@ - - # Get the input parameter list - --USAGE="USAGE: $0 [-d] [-z] [-u] [-w|wy|wn] -t [-x ] -l \"lib1 [lib2 [lib3 ...]]\"" -+USAGE="USAGE: $0 [-d] [-e] [-z] [-u] [-w|wy|wn] -t [-x ] -l \"lib1 [lib2 [lib3 ...]]\"" - unset TOPDIR - unset LIBLIST - unset TGZ - USRONLY=n - WINTOOL=n - LIBEXT=.a -+INSITU=y - - while [ ! -z "$1" ]; do - case $1 in - -d ) - set -x - ;; -+ -e ) -+ INSITU=n -+ ;; - -l ) - shift - LIBLIST=$1 -@@ -373,13 +377,17 @@ done - cd "${TOPDIR}" || \ - { echo "MK: 'cd ${TOPDIR}' failed"; exit 1; } - --if [ "X${TGZ}" = "Xy" ]; then -- tar cvf "${EXPORTSUBDIR}.tar" "${EXPORTSUBDIR}" 1>/dev/null 2>&1 -- gzip -f "${EXPORTSUBDIR}.tar" --else -- zip -r "${EXPORTSUBDIR}.zip" "${EXPORTSUBDIR}" 1>/dev/null 2>&1 --fi -+# Should we leave the export insitu -+ -+if [ "X${INSITU}" = "Xn" ]; then -+ if [ "X${TGZ}" = "Xy" ]; then -+ tar cvf "${EXPORTSUBDIR}.tar" "${EXPORTSUBDIR}" 1>/dev/null 2>&1 -+ gzip -f "${EXPORTSUBDIR}.tar" -+ else -+ zip -r "${EXPORTSUBDIR}.zip" "${EXPORTSUBDIR}" 1>/dev/null 2>&1 -+ fi - --# Clean up after ourselves -+ # Clean up after ourselves - --rm -rf "${EXPORTSUBDIR}" -+ rm -rf "${EXPORTSUBDIR}" -+fi -\ No newline at end of file diff --git a/nuttx-patches/00006-REJECTED-cstdint-fix.patch b/nuttx-patches/00006-REJECTED-cstdint-fix.patch deleted file mode 100644 index eb9c6c6056..0000000000 --- a/nuttx-patches/00006-REJECTED-cstdint-fix.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git NuttX/nuttx/include/cxx/cstdint NuttX/nuttx/include/cxx/cstdint -index d662c5d..95334e9 100644 ---- NuttX/nuttx/include/cxx/cstdint -+++ NuttX/nuttx/include/cxx/cstdint -@@ -46,6 +46,9 @@ - // Namespace - //*************************************************************************** - -+ #define GCC_VERSION (__GNUC__ * 10000 \ -+ + __GNUC_MINOR__ * 100 \ -+ + __GNUC_PATCHLEVEL__) - namespace std - { - using ::int8_t; -@@ -72,7 +75,9 @@ namespace std - using ::uint_fast64_t; - using ::uint_least8_t; - using ::uint_least16_t; -+#if GCC_VERSION <= 40804 - using ::uint_least32_t; -+#endif - using ::uint_least64_t; - using ::uintmax_t; - using ::uintptr_t; diff --git a/nuttx-patches/00007-REJECTED-silence-jobserver-warnings.patch b/nuttx-patches/00007-REJECTED-silence-jobserver-warnings.patch deleted file mode 100644 index 899e378fa5..0000000000 --- a/nuttx-patches/00007-REJECTED-silence-jobserver-warnings.patch +++ /dev/null @@ -1,40 +0,0 @@ -diff --git NuttX/apps/Makefile NuttX/apps/Makefile -index 4093b0e..3bdc36a 100644 ---- NuttX/apps/Makefile -+++ NuttX/apps/Makefile -@@ -79,13 +79,13 @@ all: $(BIN) - .PHONY: import install dirlinks context context_serialize context_rest .depdirs preconfig depend clean distclean - - define MAKE_template -- $(Q) cd $(1) && $(MAKE) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" BIN_DIR="$(BIN_DIR)" -+ +$(Q) cd $(1) && $(MAKE) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" BIN_DIR="$(BIN_DIR)" - - endef - - define SDIR_template - $(1)_$(2): -- $(Q) cd $(1) && $(MAKE) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" BIN_DIR="$(BIN_DIR)" -+ +$(Q) cd $(1) && $(MAKE) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" BIN_DIR="$(BIN_DIR)" - - endef - -@@ -108,7 +108,7 @@ install: $(BIN_DIR) .install - .import: $(BIN) install - - import: -- $(Q) $(MAKE) .import TOPDIR="$(APPDIR)$(DELIM)import" -+ +$(Q) $(MAKE) .import TOPDIR="$(APPDIR)$(DELIM)import" - - dirlinks: - $(Q) $(MAKE) -C platform dirlinks TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" -@@ -116,8 +116,8 @@ dirlinks: - context_rest: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_context) - - context_serialize: -- $(Q) $(MAKE) -C builtin context TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" -- $(Q) $(MAKE) context_rest -+ +$(Q) $(MAKE) -C builtin context TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" -+ +$(Q) $(MAKE) context_rest - - context: context_serialize - diff --git a/nuttx-patches/00008-REJECTED-static-assert-fix.patch b/nuttx-patches/00008-REJECTED-static-assert-fix.patch deleted file mode 100644 index 5e1ab2d410..0000000000 --- a/nuttx-patches/00008-REJECTED-static-assert-fix.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git NuttX/nuttx/include/assert.h NuttX/nuttx/include/assert.h -index 88254f6..b9fb6c2 100644 ---- NuttX/nuttx/include/assert.h -+++ NuttX/nuttx/include/assert.h -@@ -94,7 +94,7 @@ - */ - - #ifndef __cplusplus --# define static_assert _Static_assert -+//# define static_assert _Static_assert - #endif - - /**************************************************************************** diff --git a/nuttx-patches/00009-REJECTED-ctype-fix-shadow-wanings.patch b/nuttx-patches/00009-REJECTED-ctype-fix-shadow-wanings.patch deleted file mode 100644 index bfccf94cc3..0000000000 --- a/nuttx-patches/00009-REJECTED-ctype-fix-shadow-wanings.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git NuttX/nuttx/include/ctype.h NuttX/nuttx/include/ctype.h -index dcf918b..65706b7 100644 ---- NuttX/nuttx/include/ctype.h -+++ NuttX/nuttx/include/ctype.h -@@ -50,6 +50,8 @@ - /**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ -+#pragma GCC diagnostic push -+#pragma GCC diagnostic ignored "-Wshadow" - - /**************************************************************************** - * Name: isspace -@@ -340,5 +342,6 @@ extern "C" - #ifdef __cplusplus - } - #endif -+#pragma GCC diagnostic pop - - #endif /* __INCLUDE_CTYPE_H */ diff --git a/nuttx-patches/00010-REJECTED-no-irq-args.patch b/nuttx-patches/00010-REJECTED-no-irq-args.patch deleted file mode 100644 index bfbb714c4f..0000000000 --- a/nuttx-patches/00010-REJECTED-no-irq-args.patch +++ /dev/null @@ -1,60 +0,0 @@ -diff --git NuttX/nuttx/sched/irq/irq.h NuttX/nuttx/sched/irq/irq.h -index ffb6e98..f01318b 100644 ---- NuttX/nuttx/sched/irq/irq.h -+++ NuttX/nuttx/sched/irq/irq.h -@@ -72,7 +72,9 @@ - struct irq_info_s - { - xcpt_t handler; /* Address of the interrupt handler */ -+#if !defined(CONFIG_NOIRQARGS) - FAR void *arg; /* The argument provided to the interrupt handler. */ -+#endif - }; - - /**************************************************************************** -diff --git NuttX/nuttx/sched/irq/irq_attach.c NuttX/nuttx/sched/irq/irq_attach.c -index 9d45d9c..3707906 100644 ---- NuttX/nuttx/sched/irq/irq_attach.c -+++ NuttX/nuttx/sched/irq/irq_attach.c -@@ -112,7 +112,11 @@ int irq_attach(int irq, xcpt_t isr, FAR void *arg) - /* Save the new ISR and its argument in the table. */ - - g_irqvector[ndx].handler = isr; -+#if defined(CONFIG_NOIRQARGS) -+ ASSERT(arg == NULL); -+#else - g_irqvector[ndx].arg = arg; -+#endif - - leave_critical_section(flags); - ret = OK; -diff --git NuttX/nuttx/sched/irq/irq_dispatch.c NuttX/nuttx/sched/irq/irq_dispatch.c -index b507c06..66cb1fe 100644 ---- NuttX/nuttx/sched/irq/irq_dispatch.c -+++ NuttX/nuttx/sched/irq/irq_dispatch.c -@@ -88,7 +88,11 @@ void irq_dispatch(int irq, FAR void *context) - } - #else - vector = g_irqvector[irq].handler; -- arg = g_irqvector[irq].arg; -+# if defined(CONFIG_NOIRQARGS) -+ arg = NULL; -+# else -+ arg = g_irqvector[irq].arg; -+# endif - #endif - } - -diff --git NuttX/nuttx/sched/irq/irq_initialize.c NuttX/nuttx/sched/irq/irq_initialize.c -index 18bbafc..2018788 100644 ---- NuttX/nuttx/sched/irq/irq_initialize.c -+++ NuttX/nuttx/sched/irq/irq_initialize.c -@@ -88,6 +88,8 @@ void irq_initialize(void) - for (i = 0; i < TAB_SIZE; i++) - { - g_irqvector[i].handler = irq_unexpected_isr; -+#if !defined(CONFIG_NOIRQARGS) - g_irqvector[i].arg = NULL; -+#endif - } - } diff --git a/nuttx-patches/00011-REJECTED-stm32_serial_no_irq_args.patch b/nuttx-patches/00011-REJECTED-stm32_serial_no_irq_args.patch deleted file mode 100644 index 5120fd1821..0000000000 --- a/nuttx-patches/00011-REJECTED-stm32_serial_no_irq_args.patch +++ /dev/null @@ -1,222 +0,0 @@ -diff --git NuttX/nuttx/arch/arm/src/stm32/stm32_serial.c NuttX/nuttx/arch/arm/src/stm32/stm32_serial.c -index a6a2d07..ea8ba61 100644 ---- NuttX/nuttx/arch/arm/src/stm32/stm32_serial.c -+++ NuttX/nuttx/arch/arm/src/stm32/stm32_serial.c -@@ -315,6 +315,9 @@ struct up_dev_s - const unsigned int rxdma_channel; /* DMA channel assigned */ - #endif - -+#if defined(CONFIG_NOIRQARGS) -+ int (*const vector)(int irq, void *context, void *arg); /* Interrupt handler */ -+#endif - /* RX DMA state */ - - #ifdef SERIAL_HAVE_DMA -@@ -371,6 +374,32 @@ static int up_pm_prepare(struct pm_callback_s *cb, int domain, - enum pm_state_e pmstate); - #endif - -+#if defined(CONFIG_NOIRQARGS) -+# ifdef CONFIG_STM32_USART1_SERIALDRIVER -+static int up_interrupt_usart1(int irq, void *context, void *arg); -+# endif -+# ifdef CONFIG_STM32_USART2_SERIALDRIVER -+static int up_interrupt_usart2(int irq, void *context, void *arg); -+# endif -+# ifdef CONFIG_STM32_USART3_SERIALDRIVER -+static int up_interrupt_usart3(int irq, void *context, void *arg); -+# endif -+# ifdef CONFIG_STM32_UART4_SERIALDRIVER -+static int up_interrupt_uart4(int irq, void *context, void *arg); -+# endif -+# ifdef CONFIG_STM32_UART5_SERIALDRIVER -+static int up_interrupt_uart5(int irq, void *context, void *arg); -+# endif -+# ifdef CONFIG_STM32_USART6_SERIALDRIVER -+static int up_interrupt_usart6(int irq, void *context, void *arg); -+# endif -+# ifdef CONFIG_STM32_UART7_SERIALDRIVER -+static int up_interrupt_uart7(int irq, void *context, void *arg); -+# endif -+# ifdef CONFIG_STM32_UART8_SERIALDRIVER -+static int up_interrupt_uart8(int irq, void *context, void *arg); -+# endif -+#endif - /**************************************************************************** - * Private Data - ****************************************************************************/ -@@ -536,7 +565,9 @@ static struct up_dev_s g_usart1priv = - .rxdma_channel = DMAMAP_USART1_RX, - .rxfifo = g_usart1rxfifo, - #endif -- -+#if defined(CONFIG_NOIRQARGS) -+ .vector = up_interrupt_usart1, -+#endif - #ifdef CONFIG_USART1_RS485 - .rs485_dir_gpio = GPIO_USART1_RS485_DIR, - # if (CONFIG_USART1_RS485_DIR_POLARITY == 0) -@@ -597,6 +628,9 @@ static struct up_dev_s g_usart2priv = - .rxdma_channel = DMAMAP_USART2_RX, - .rxfifo = g_usart2rxfifo, - #endif -+#if defined(CONFIG_NOIRQARGS) -+ .vector = up_interrupt_usart2, -+#endif - - #ifdef CONFIG_USART2_RS485 - .rs485_dir_gpio = GPIO_USART2_RS485_DIR, -@@ -658,6 +692,9 @@ static struct up_dev_s g_usart3priv = - .rxdma_channel = DMAMAP_USART3_RX, - .rxfifo = g_usart3rxfifo, - #endif -+#if defined(CONFIG_NOIRQARGS) -+ .vector = up_interrupt_usart3, -+#endif - - #ifdef CONFIG_USART3_RS485 - .rs485_dir_gpio = GPIO_USART3_RS485_DIR, -@@ -723,6 +760,9 @@ static struct up_dev_s g_uart4priv = - .rxdma_channel = DMAMAP_UART4_RX, - .rxfifo = g_uart4rxfifo, - #endif -+#if defined(CONFIG_NOIRQARGS) -+ .vector = up_interrupt_uart4, -+#endif - - #ifdef CONFIG_UART4_RS485 - .rs485_dir_gpio = GPIO_UART4_RS485_DIR, -@@ -788,6 +828,9 @@ static struct up_dev_s g_uart5priv = - .rxdma_channel = DMAMAP_UART5_RX, - .rxfifo = g_uart5rxfifo, - #endif -+#if defined(CONFIG_NOIRQARGS) -+ .vector = up_interrupt_uart5, -+#endif - - #ifdef CONFIG_UART5_RS485 - .rs485_dir_gpio = GPIO_UART5_RS485_DIR, -@@ -849,6 +892,9 @@ static struct up_dev_s g_usart6priv = - .rxdma_channel = DMAMAP_USART6_RX, - .rxfifo = g_usart6rxfifo, - #endif -+#if defined(CONFIG_NOIRQARGS) -+ .vector = up_interrupt_uart6, -+#endif - - #ifdef CONFIG_USART6_RS485 - .rs485_dir_gpio = GPIO_USART6_RS485_DIR, -@@ -910,6 +956,9 @@ static struct up_dev_s g_uart7priv = - .rxdma_channel = DMAMAP_UART7_RX, - .rxfifo = g_uart7rxfifo, - #endif -+#if defined(CONFIG_NOIRQARGS) -+ .vector = up_interrupt_uart7, -+#endif - - #ifdef CONFIG_UART7_RS485 - .rs485_dir_gpio = GPIO_UART7_RS485_DIR, -@@ -971,6 +1020,9 @@ static struct up_dev_s g_uart8priv = - .rxdma_channel = DMAMAP_UART8_RX, - .rxfifo = g_uart8rxfifo, - #endif -+#if defined(CONFIG_NOIRQARGS) -+ .vector = up_interrupt_uart8, -+#endif - - #ifdef CONFIG_UART8_RS485 - .rs485_dir_gpio = GPIO_UART8_RS485_DIR, -@@ -1709,7 +1761,11 @@ static int up_attach(struct uart_dev_s *dev) - - /* Attach and enable the IRQ */ - -+#if defined(CONFIG_NOIRQARGS) -+ ret = irq_attach(priv->irq, priv->vector, NULL); -+#else - ret = irq_attach(priv->irq, up_interrupt, priv); -+#endif - if (ret == OK) - { - /* Enable the interrupt (RX and TX interrupts are still disabled -@@ -1740,7 +1796,7 @@ static void up_detach(struct uart_dev_s *dev) - } - - /**************************************************************************** -- * Name: up_interrupt -+ * Name: up_interrupt_common - * - * Description: - * This is the USART interrupt handler. It will be invoked when an -@@ -2480,6 +2536,72 @@ static bool up_txready(struct uart_dev_s *dev) - return ((up_serialin(priv, STM32_USART_SR_OFFSET) & USART_SR_TXE) != 0); - } - -+#if defined(CONFIG_NOIRQARGS) -+/**************************************************************************** -+ * Name: up_interrupt_u[s]art[n] -+ * -+ * Description: -+ * Interrupt handlers for U[S]ART[n] where n=1,..,6. -+ * -+ ****************************************************************************/ -+ -+# ifdef CONFIG_STM32_USART1_SERIALDRIVER -+static int up_interrupt_usart1(int irq, void *context, void *arg) -+{ -+ return up_interrupt(irq, context, &g_usart1priv); -+} -+# endif -+ -+# ifdef CONFIG_STM32_USART2_SERIALDRIVER -+static int up_interrupt_usart2(int irq, void *context, void *arg) -+{ -+ return up_interrupt(irq, context, &g_usart2priv); -+} -+# endif -+ -+# ifdef CONFIG_STM32_USART3_SERIALDRIVER -+static int up_interrupt_usart3(int irq, void *context, void *arg) -+{ -+ return up_interrupt(irq, context, &g_usart3priv); -+} -+# endif -+ -+# ifdef CONFIG_STM32_UART4_SERIALDRIVER -+static int up_interrupt_uart4(int irq, void *context, void *arg) -+{ -+ return up_interrupt(irq, context, &g_uart4priv); -+} -+# endif -+ -+# ifdef CONFIG_STM32_UART5_SERIALDRIVER -+static int up_interrupt_uart5(int irq, void *context, void *arg) -+{ -+ return up_interrupt(irq, context, &g_uart5priv); -+} -+# endif -+ -+# ifdef CONFIG_STM32_USART6_SERIALDRIVER -+static int up_interrupt_usart6(int irq, void *context, void *arg) -+{ -+ return up_interrupt(irq, context, &g_usart6priv); -+} -+# endif -+ -+# ifdef CONFIG_STM32_UART7_SERIALDRIVER -+static int up_interrupt_uart7(int irq, void *context, void *arg) -+{ -+ return up_interrupt(irq, context, &g_uart7priv); -+} -+# endif -+ -+# ifdef CONFIG_STM32_UART8_SERIALDRIVER -+static int up_interrupt_uart8(int irq, void *context, void *arg) -+{ -+ return up_interrupt(irq, context, &g_uart8priv); -+} -+# endif -+#endif -+ - /**************************************************************************** - * Name: up_dma_rxcallback - * diff --git a/nuttx-patches/90000-PENDING-wip-inflight-to-upstream.patch b/nuttx-patches/90000-PENDING-wip-inflight-to-upstream.patch deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/platforms/nuttx/NuttX/CMakeLists.txt b/platforms/nuttx/NuttX/CMakeLists.txt new file mode 100644 index 0000000000..73083543c0 --- /dev/null +++ b/platforms/nuttx/NuttX/CMakeLists.txt @@ -0,0 +1,215 @@ +cmake_minimum_required(VERSION 3.2) + +if(NOT BOARD) + message(FATAL_ERROR "BOARD must be set (eg px4fmu-v2)") +endif() + +if(NOT nuttx_config_type) + # default to nsh if not specified + set(nuttx_config_type "nsh") +endif() + +project(NuttX_${BOARD} LANGUAGES ASM C CXX) +message(STATUS "NuttX: " ${BOARD} " " ${nuttx_config_type} " " ${CMAKE_SYSTEM_PROCESSOR}) + +if (CMAKE_HOST_APPLE OR TRUE) + # copy with rsync and create file dependencies + set(cp_cmd "rsync") + set(cp_opts) + list(APPEND cp_opts + -rp + --inplace + ) +else() + # copy with hard links + # archive, recursive, force, link (hardlinks) + set(cp_cmd "cp") + set(cp_opts "-aRfl") +endif() + +file(GLOB_RECURSE copy_nuttx_files + LIST_DIRECTORIES false + ${CMAKE_CURRENT_SOURCE_DIR}/nuttx/*) + +file(GLOB_RECURSE copy_apps_files + LIST_DIRECTORIES false + ${CMAKE_CURRENT_SOURCE_DIR}/apps/*) + +# copy nuttx to build directory +add_custom_command(OUTPUT nuttx_copy.stamp + COMMAND ${cp_cmd} ${cp_opts} ${CMAKE_CURRENT_SOURCE_DIR}/nuttx ${CMAKE_CURRENT_BINARY_DIR} + COMMAND cmake -E touch nuttx_copy.stamp + DEPENDS ${copy_nuttx_files} + COMMENT "Copying NuttX/nuttx to ${CMAKE_CURRENT_BINARY_DIR}" + ) + +set(NUTTX_DIR ${CMAKE_CURRENT_BINARY_DIR}/nuttx) +set(NUTTX_CONFIG_DIR ${PX4_SOURCE_DIR}/nuttx-configs) + +# copy apps to build directory +add_custom_command(OUTPUT apps_copy.stamp + COMMAND ${cp_cmd} ${cp_opts} ${CMAKE_CURRENT_SOURCE_DIR}/apps ${CMAKE_CURRENT_BINARY_DIR} + COMMAND cmake -E touch apps_copy.stamp + DEPENDS ${copy_apps_files} + COMMENT "Copying NuttX/apps to ${CMAKE_CURRENT_BINARY_DIR}" + ) +set(APPS_DIR ${CMAKE_CURRENT_BINARY_DIR}/apps) + +# copy PX4 board config into nuttx +file(GLOB_RECURSE board_config_files ${NUTTX_CONFIG_DIR}/${BOARD}) +add_custom_command(OUTPUT + ${NUTTX_DIR}/PX4_Config.mk + ${NUTTX_DIR}/PX4_Warnings.mk + ${NUTTX_DIR}/.config + ${NUTTX_DIR}/Make.defs + ${NUTTX_DIR}/configs/${BOARD}/${nuttx_config_type}/defconfig + COMMAND ${CMAKE_COMMAND} -E copy ${NUTTX_CONFIG_DIR}/PX4_Config.mk ${NUTTX_DIR}/PX4_Config.mk + COMMAND ${CMAKE_COMMAND} -E copy ${NUTTX_CONFIG_DIR}/PX4_Warnings.mk ${NUTTX_DIR}/PX4_Warnings.mk + COMMAND ${CMAKE_COMMAND} -E copy ${NUTTX_CONFIG_DIR}/${BOARD}/${nuttx_config_type}/defconfig ${NUTTX_DIR}/.config + COMMAND ${CMAKE_COMMAND} -E remove -f ${NUTTX_DIR}/include/nuttx/config.h + COMMAND ${CMAKE_COMMAND} -E copy ${NUTTX_CONFIG_DIR}/${BOARD}/${nuttx_config_type}/Make.defs ${NUTTX_DIR}/Make.defs + COMMAND ${cp_cmd} ${cp_opts} ${NUTTX_CONFIG_DIR}/${BOARD} ${NUTTX_DIR}/configs/ + DEPENDS + ${NUTTX_CONFIG_DIR}/PX4_Config.mk + ${NUTTX_CONFIG_DIR}/PX4_Warnings.mk + ${NUTTX_CONFIG_DIR}/${BOARD}/${nuttx_config_type}/defconfig + ${NUTTX_CONFIG_DIR}/${BOARD}/${nuttx_config_type}/Make.defs + ${board_config_files} + nuttx_copy.stamp apps_copy.stamp + WORKING_DIRECTORY ${NUTTX_DIR}/tools + COMMENT "Copying NuttX config ${BOARD} and configuring" + ) +add_custom_target(nuttx_configure DEPENDS ${NUTTX_DIR}/.config) + +# context +add_custom_command(OUTPUT ${NUTTX_DIR}/include/nuttx/version.h ${NUTTX_DIR}/include/nuttx/config.h + COMMAND make --no-print-directory --silent context > /dev/null + DEPENDS nuttx_configure ${NUTTX_DIR}/.config + WORKING_DIRECTORY ${NUTTX_DIR} + ) +add_custom_target(nuttx_context DEPENDS ${NUTTX_DIR}/include/nuttx/version.h) + +# library of NuttX libraries +add_library(nuttx_build INTERFACE) + +# builtins +if ("${BOARD}" MATCHES "px4io") + # no apps for px4io + set(nuttx_builtin_list) +else() + # add additional commands to nuttx builtins + set(builtin_registry ${APPS_DIR}/builtin/registry) + set(nuttx_builtin_list) + foreach(module ${module_libraries}) + get_target_property(MAIN ${module} MAIN) + get_target_property(STACK_MAIN ${module} STACK_MAIN) + get_target_property(PRIORITY ${module} PRIORITY) + + if(MAIN) + add_custom_command(OUTPUT ${builtin_registry}/${MAIN}_main.bdat + COMMAND echo "{ \"${MAIN}\", ${PRIORITY}, ${STACK_MAIN}, ${MAIN}_main }," > ${builtin_registry}/${MAIN}_main.bdat + VERBATIM + ) + list(APPEND nuttx_builtin_list ${builtin_registry}/${MAIN}_main.bdat) + + add_custom_command(OUTPUT ${builtin_registry}/${MAIN}_main.pdat + COMMAND echo "int ${MAIN}_main(int argc, char *argv[]);" > ${builtin_registry}/${MAIN}_main.pdat + VERBATIM + ) + list(APPEND nuttx_builtin_list ${builtin_registry}/${MAIN}_main.pdat) + endif() + endforeach() +endif() + +# APPS + +# libapps.a +add_custom_command(OUTPUT ${APPS_DIR}/libapps.a + ${APPS_DIR}/platform/.built + COMMAND find ${APPS_DIR} -name \*.o -o -name \*.built -delete + COMMAND make --silent --no-print-directory -C ../apps TOPDIR="${NUTTX_DIR}" libapps.a > /dev/null + DEPENDS nuttx_context ${nuttx_builtin_list} + WORKING_DIRECTORY ${NUTTX_DIR} + ) +add_custom_target(nuttx_apps_build DEPENDS ${APPS_DIR}/libapps.a) +add_library(nuttx_apps STATIC IMPORTED GLOBAL) +set_property(TARGET nuttx_apps PROPERTY IMPORTED_LOCATION ${APPS_DIR}/libapps.a) +add_dependencies(nuttx_build nuttx_apps_build) +target_link_libraries(nuttx_build INTERFACE nuttx_apps) + +# libboard.a +add_custom_command(OUTPUT ${NUTTX_DIR}/arch/arm/src/board/libboard.a + COMMAND make --silent --no-print-directory -C board TOPDIR="${NUTTX_DIR}" libboard.a EXTRADEFINES=-D__KERNEL__ > /dev/null + DEPENDS nuttx_context + WORKING_DIRECTORY ${NUTTX_DIR}/arch/arm/src + ) +add_custom_target(nuttx_board_build DEPENDS ${NUTTX_DIR}/arch/arm/src/board/libboard.a) +add_library(nuttx_board STATIC IMPORTED GLOBAL) +set_property(TARGET nuttx_board PROPERTY IMPORTED_LOCATION ${NUTTX_DIR}/arch/arm/src/board/libboard.a) +add_dependencies(nuttx_build nuttx_board_build) +target_link_libraries(nuttx_build INTERFACE nuttx_board) + +# helper for all targets +function(add_nuttx_dir nuttx_lib nuttx_lib_dir kernel extra) + file(GLOB_RECURSE nuttx_lib_files + LIST_DIRECTORIES false + ${CMAKE_CURRENT_SOURCE_DIR}/nuttx/${nuttx_lib_dir}/*) + + add_custom_command(OUTPUT ${NUTTX_DIR}/${nuttx_lib_dir}/lib${nuttx_lib}.a + COMMAND find ${nuttx_lib_dir} -type f -name *.o -o -name .built -delete + COMMAND make -C ${nuttx_lib_dir} -j2 --silent --no-print-directory lib${nuttx_lib}.a TOPDIR="${NUTTX_DIR}" KERNEL=${kernel} EXTRADEFINES=${extra} > /dev/null + DEPENDS ${nuttx_lib_files} nuttx_context + WORKING_DIRECTORY ${NUTTX_DIR} + ) + add_custom_target(nuttx_${nuttx_lib}_build DEPENDS ${NUTTX_DIR}/${nuttx_lib_dir}/lib${nuttx_lib}.a) + add_library(nuttx_${nuttx_lib} STATIC IMPORTED GLOBAL) + set_property(TARGET nuttx_${nuttx_lib} PROPERTY IMPORTED_LOCATION ${NUTTX_DIR}/${nuttx_lib_dir}/lib${nuttx_lib}.a) + add_dependencies(nuttx_build nuttx_${nuttx_lib}_build) + target_link_libraries(nuttx_build INTERFACE nuttx_${nuttx_lib}) +endfunction() + +# add_nuttx_dir(NAME DIRECTORY KERNEL EXTRA) + +add_nuttx_dir(arch arch/arm/src y -D__KERNEL__) +add_nuttx_dir(binfmt binfmt y -D__KERNEL__) +add_nuttx_dir(configs configs y -D__KERNEL__) +add_nuttx_dir(drivers drivers y -D__KERNEL__) +add_nuttx_dir(fs fs y -D__KERNEL__) +add_nuttx_dir(sched sched y -D__KERNEL__) + +add_nuttx_dir(c libc n "") +add_nuttx_dir(cxx libxx n "") +add_nuttx_dir(mm mm n "") + + +# oldconfig helper +add_custom_target(oldconfig + COMMAND make --no-print-directory -C ${NUTTX_DIR} CONFIG_ARCH_BOARD=${BOARD} oldconfig + COMMAND cp ${NUTTX_DIR}/.config ${NUTTX_CONFIG_DIR}/${BOARD}/${nuttx_config_type}/defconfig + COMMAND ${PX4_SOURCE_DIR}/Tools/nuttx_defconf_tool.sh ${NUTTX_CONFIG_DIR}/${BOARD}/${nuttx_config_type}/defconfig + DEPENDS nuttx_configure + WORKING_DIRECTORY ${NUTTX_DIR} + COMMENT "Running NuttX make oldconfig for ${BOARD} with ${nuttx_config_type}" + USES_TERMINAL + ) + +# menuconfig helper +add_custom_target(menuconfig + COMMAND make --no-print-directory -C ${NUTTX_DIR} CONFIG_ARCH_BOARD=${BOARD} menuconfig + COMMAND cp ${NUTTX_DIR}/nuttx/.config ${NUTTX_CONFIG_DIR}/${BOARD}/${nuttx_config_type}/defconfig + COMMAND ${PX4_SOURCE_DIR}/Tools/nuttx_defconf_tool.sh ${NUTTX_CONFIG_DIR}/${BOARD}/${nuttx_config_type}/defconfig + DEPENDS nuttx_configure + WORKING_DIRECTORY ${NUTTX_DIR} + COMMENT "Running NuttX make menuconfig for ${BOARD} with ${nuttx_config_type}" + USES_TERMINAL + ) + +# qconfig helper +add_custom_target(qconfig + COMMAND make --no-print-directory -C ${NUTTX_DIR} CONFIG_ARCH_BOARD=${BOARD} qconfig + COMMAND cp .config ${NUTTX_CONFIG_DIR}/${BOARD}/${nuttx_config_type}/defconfig + DEPENDS nuttx_configure + WORKING_DIRECTORY ${NUTTX_DIR} + COMMENT "Running NuttX make qconfig for ${BOARD} with ${nuttx_config_type}" + USES_TERMINAL + ) diff --git a/platforms/nuttx/NuttX/apps b/platforms/nuttx/NuttX/apps new file mode 160000 index 0000000000..42dbbb2038 --- /dev/null +++ b/platforms/nuttx/NuttX/apps @@ -0,0 +1 @@ +Subproject commit 42dbbb2038c83532e367c6813f0ece691ea04524 diff --git a/platforms/nuttx/NuttX/nuttx b/platforms/nuttx/NuttX/nuttx new file mode 160000 index 0000000000..94da3bef49 --- /dev/null +++ b/platforms/nuttx/NuttX/nuttx @@ -0,0 +1 @@ +Subproject commit 94da3bef49efaacee7ec5b1a1aa237c3e2915163 diff --git a/src/drivers/airspeed/CMakeLists.txt b/src/drivers/airspeed/CMakeLists.txt index 6a80c1c2b6..4887b2de66 100644 --- a/src/drivers/airspeed/CMakeLists.txt +++ b/src/drivers/airspeed/CMakeLists.txt @@ -37,5 +37,4 @@ px4_add_module( airspeed.cpp DEPENDS platforms__common - ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : + ) \ No newline at end of file diff --git a/src/drivers/batt_smbus/CMakeLists.txt b/src/drivers/batt_smbus/CMakeLists.txt index fb20856ec2..3bc80cb569 100644 --- a/src/drivers/batt_smbus/CMakeLists.txt +++ b/src/drivers/batt_smbus/CMakeLists.txt @@ -39,4 +39,3 @@ px4_add_module( DEPENDS platforms__common ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/bmi160/bmi160.cpp b/src/drivers/bmi160/bmi160.cpp index 01abb14fe5..ae2066984c 100644 --- a/src/drivers/bmi160/bmi160.cpp +++ b/src/drivers/bmi160/bmi160.cpp @@ -308,10 +308,6 @@ BMI160::accel_set_sample_rate(float frequency) setbits |= BMI_ACCEL_RATE_25_16; _accel_sample_rate = 25 / 16; - } else if (frequency <= 25 / 16) { - setbits |= BMI_ACCEL_RATE_25_16; - _accel_sample_rate = 25 / 16; - } else if (frequency <= 25 / 8) { setbits |= BMI_ACCEL_RATE_25_8; _accel_sample_rate = 25 / 8; diff --git a/src/drivers/samv7/adc/module.mk b/src/drivers/boards/CMakeLists.txt similarity index 87% rename from src/drivers/samv7/adc/module.mk rename to src/drivers/boards/CMakeLists.txt index 38ea490a0e..3ff910cc31 100644 --- a/src/drivers/samv7/adc/module.mk +++ b/src/drivers/boards/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. +# Copyright (c) 2015 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 @@ -31,14 +31,11 @@ # ############################################################################ -# -# STM32 ADC driver -# +if (BOARD) + add_subdirectory(common) + add_subdirectory(${BOARD}) +else() + message(FATAL_ERROR "BOARD not defined") +endif() -MODULE_COMMAND = adc -SRCS = adc.cpp - -INCLUDE_DIRS += $(NUTTX_SRC)/arch/arm/src/stm32 $(NUTTX_SRC)/arch/arm/src/common - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/boards/aerocore/CMakeLists.txt b/src/drivers/boards/aerocore/CMakeLists.txt index 63c2f1a227..c104e7c78e 100644 --- a/src/drivers/boards/aerocore/CMakeLists.txt +++ b/src/drivers/boards/aerocore/CMakeLists.txt @@ -32,17 +32,11 @@ ############################################################################ px4_add_module( MODULE drivers__boards__aerocore - COMPILE_FLAGS SRCS - ../common/board_dma_alloc.c - ../common/stm32/board_reset.c - ../common/stm32/board_identity.c - ../common/stm32/board_mcu_version.c aerocore_init.c aerocore_timer_config.c aerocore_spi.c aerocore_led.c DEPENDS platforms__common - ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : + ) \ No newline at end of file diff --git a/src/drivers/boards/aerocore2/CMakeLists.txt b/src/drivers/boards/aerocore2/CMakeLists.txt index 9cfc74c746..6e48c387b0 100644 --- a/src/drivers/boards/aerocore2/CMakeLists.txt +++ b/src/drivers/boards/aerocore2/CMakeLists.txt @@ -32,12 +32,7 @@ ############################################################################ px4_add_module( MODULE drivers__boards__aerocore2 - COMPILE_FLAGS SRCS - ../common/board_dma_alloc.c - ../common/stm32/board_reset.c - ../common/stm32/board_identity.c - ../common/stm32/board_mcu_version.c aerocore2_can.c aerocore2_init.c aerocore2_timer_config.c @@ -46,5 +41,4 @@ px4_add_module( aerocore2_led.c DEPENDS platforms__common - ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : + ) \ No newline at end of file diff --git a/src/drivers/boards/aerofc-v1/CMakeLists.txt b/src/drivers/boards/aerofc-v1/CMakeLists.txt index 9eb1d7c384..e592f12675 100644 --- a/src/drivers/boards/aerofc-v1/CMakeLists.txt +++ b/src/drivers/boards/aerofc-v1/CMakeLists.txt @@ -33,16 +33,11 @@ ############################################################################ px4_add_module( MODULE drivers__boards__aerofc-v1 - COMPILE_FLAGS SRCS - ../common/stm32/board_reset.c - ../common/stm32/board_identity.c - ../common/stm32/board_mcu_version.c aerofc_init.c aerofc_spi.c aerofc_led.c aerofc_timer_config.c DEPENDS platforms__common - ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : + ) \ No newline at end of file diff --git a/src/drivers/boards/aerofc-v1/aerofc_init.c b/src/drivers/boards/aerofc-v1/aerofc_init.c index 7a65ada56f..0bc8e8b83e 100644 --- a/src/drivers/boards/aerofc-v1/aerofc_init.c +++ b/src/drivers/boards/aerofc-v1/aerofc_init.c @@ -397,10 +397,3 @@ __EXPORT int board_app_initialize(uintptr_t arg) return OK; } - -__EXPORT void board_crashdump(uintptr_t currentsp, FAR void *tcb, FAR const uint8_t *filename, int lineno) -{ -#if defined(CONFIG_BOARD_RESET_ON_CRASH) - board_reset(0); -#endif -} diff --git a/src/drivers/boards/aerofc-v1/board_config.h b/src/drivers/boards/aerofc-v1/board_config.h index 45971f9049..07cfb28a09 100644 --- a/src/drivers/boards/aerofc-v1/board_config.h +++ b/src/drivers/boards/aerofc-v1/board_config.h @@ -150,6 +150,8 @@ #define MEMORY_CONSTRAINED_SYSTEM +#define CRASHDUMP_RESET_ONLY + __BEGIN_DECLS /**************************************************************************************************** diff --git a/src/drivers/boards/auav-x21/CMakeLists.txt b/src/drivers/boards/auav-x21/CMakeLists.txt index 6c12ec0a74..420c0d53bf 100644 --- a/src/drivers/boards/auav-x21/CMakeLists.txt +++ b/src/drivers/boards/auav-x21/CMakeLists.txt @@ -32,13 +32,7 @@ ############################################################################ px4_add_module( MODULE drivers__boards__auav-x21 - COMPILE_FLAGS SRCS - ../common/board_crashdump.c - ../common/board_dma_alloc.c - ../common/stm32/board_reset.c - ../common/stm32/board_identity.c - ../common/stm32/board_mcu_version.c auav_can.c auav_init.c auav_timer_config.c @@ -47,5 +41,4 @@ px4_add_module( auav_led.c DEPENDS platforms__common - ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : + ) \ No newline at end of file diff --git a/nuttx-patches/CMakeLists.txt b/src/drivers/boards/common/CMakeLists.txt similarity index 62% rename from nuttx-patches/CMakeLists.txt rename to src/drivers/boards/common/CMakeLists.txt index 943dfc25ef..3693bc6369 100644 --- a/nuttx-patches/CMakeLists.txt +++ b/src/drivers/boards/common/CMakeLists.txt @@ -31,32 +31,22 @@ # ############################################################################ -set(nuttx_patches - 00001-REJECTED-add-math.h.patch - 00002-REJECTED-fix-shadow-wanings.patch - 00003-REJECTED-add-var-expansion-in-nsh-parse.patch - 00004-REJECTED-avoid-export-copy-with-export-insitu.patch - 00006-REJECTED-cstdint-fix.patch - 00007-REJECTED-silence-jobserver-warnings.patch - 00008-REJECTED-static-assert-fix.patch - 00009-REJECTED-ctype-fix-shadow-wanings.patch - 00010-REJECTED-no-irq-args.patch - 00011-REJECTED-stm32_serial_no_irq_args.patch - 90000-PENDING-wip-inflight-to-upstream.patch - ) +if (${OS} MATCHES "nuttx") -# add absolute path and sort -set(px4_nuttx_patches) -foreach(patch_file ${nuttx_patches}) - list(APPEND px4_nuttx_patches ${CMAKE_CURRENT_SOURCE_DIR}/${patch_file}) -endforeach() -list(SORT px4_nuttx_patches) -set(px4_nuttx_patches ${px4_nuttx_patches} PARENT_SCOPE) - -file(GLOB patches_found *.patch) -foreach(patch_file ${patches_found}) - list (FIND px4_nuttx_patches ${patch_file} _index) - if (${_index} EQUAL -1) - message(FATAL_ERROR "${patch_file} missing from nuttx-patches/CMakeLists.txt") + if (NOT ${LABEL} STREQUAL "bootloader") + px4_add_library(boards_common + board_crashdump.c + board_dma_alloc.c + board_gpio_init.c + ) + add_dependencies(boards_common nuttx_build) endif() -endforeach() + + if (${CONFIG_ARCH_CHIP} MATCHES "kinetis") + add_subdirectory(kinetis) + elseif (${CONFIG_ARCH_CHIP} MATCHES "samv7") + add_subdirectory(samv7) + elseif (${CONFIG_ARCH_CHIP} MATCHES "stm32") + add_subdirectory(stm32) + endif() +endif() \ No newline at end of file diff --git a/src/drivers/boards/common/board_crashdump.c b/src/drivers/boards/common/board_crashdump.c index edc0b692fa..e1143bc06f 100644 --- a/src/drivers/boards/common/board_crashdump.c +++ b/src/drivers/boards/common/board_crashdump.c @@ -1,3 +1,5 @@ +#ifdef CONFIG_BOARD_CRASHDUMP + #include #include @@ -21,8 +23,10 @@ static uint32_t *__attribute__((noinline)) __sdata_addr(void) return &_sdata; } + __EXPORT void board_crashdump(uintptr_t currentsp, FAR void *tcb, FAR const uint8_t *filename, int lineno) { +#ifndef CRASHDUMP_RESET_ONLY /* We need a chunk of ram to save the complete context in. * Since we are going to reboot we will use &_sdata * which is the lowest memory and the amount we will save @@ -162,7 +166,11 @@ __EXPORT void board_crashdump(uintptr_t currentsp, FAR void *tcb, FAR const uint up_lowputc('!'); } +#endif /* CRASHDUMP_RESET_ONLY */ + #if defined(CONFIG_BOARD_RESET_ON_CRASH) board_reset(0); #endif } + +#endif /* CONFIG_BOARD_CRASHDUMP */ diff --git a/src/drivers/boards/common/kinetis/CMakeLists.txt b/src/drivers/boards/common/kinetis/CMakeLists.txt new file mode 100644 index 0000000000..0c477acf1d --- /dev/null +++ b/src/drivers/boards/common/kinetis/CMakeLists.txt @@ -0,0 +1,39 @@ +############################################################################ +# +# Copyright (c) 2017 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_library(board_kinetis + board_identity.c + board_mcu_version.c + board_reset.c + ) +add_dependencies(board_kinetis nuttx_build) \ No newline at end of file diff --git a/src/drivers/boards/common/samv7/CMakeLists.txt b/src/drivers/boards/common/samv7/CMakeLists.txt new file mode 100644 index 0000000000..e98b8ab874 --- /dev/null +++ b/src/drivers/boards/common/samv7/CMakeLists.txt @@ -0,0 +1,39 @@ +############################################################################ +# +# Copyright (c) 2017 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_library(board_samv7 + board_identity.c + board_mcu_version.c + board_reset.c + ) +add_dependencies(board_samv7 nuttx_build) \ No newline at end of file diff --git a/src/drivers/boards/common/stm32/CMakeLists.txt b/src/drivers/boards/common/stm32/CMakeLists.txt new file mode 100644 index 0000000000..7721a56fa7 --- /dev/null +++ b/src/drivers/boards/common/stm32/CMakeLists.txt @@ -0,0 +1,46 @@ +############################################################################ +# +# Copyright (c) 2017 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. +# +############################################################################ + +set(SRCS + board_identity.c +) + +if (NOT ${LABEL} STREQUAL "bootloader") + list(APPEND SRCS + board_mcu_version.c + board_reset.c + ) +endif() + +px4_add_library(board_stm32 ${SRCS}) +add_dependencies(board_stm32 nuttx_build) \ No newline at end of file diff --git a/src/drivers/boards/crazyflie/CMakeLists.txt b/src/drivers/boards/crazyflie/CMakeLists.txt index dfe3f4d950..95ac9c4eac 100644 --- a/src/drivers/boards/crazyflie/CMakeLists.txt +++ b/src/drivers/boards/crazyflie/CMakeLists.txt @@ -33,16 +33,10 @@ px4_add_module( MODULE drivers__boards__crazyflie SRCS - ../common/board_crashdump.c - ../common/board_dma_alloc.c - ../common/stm32/board_reset.c - ../common/stm32/board_identity.c - ../common/stm32/board_mcu_version.c crazyflie_init.c crazyflie_usb.c crazyflie_led.c crazyflie_timer_config.c DEPENDS platforms__common - ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : + ) \ No newline at end of file diff --git a/src/drivers/boards/eagle/CMakeLists.txt b/src/drivers/boards/eagle/CMakeLists.txt new file mode 100644 index 0000000000..b6ea65a1fd --- /dev/null +++ b/src/drivers/boards/eagle/CMakeLists.txt @@ -0,0 +1,41 @@ +############################################################################ +# +# Copyright (c) 2015 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_module( + MODULE drivers__boards__sitl + COMPILE_FLAGS + SRCS + sitl_led.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/boards/eagle/board_config.h b/src/drivers/boards/eagle/board_config.h index 3dc7adc5ab..f9204ad7c6 100644 --- a/src/drivers/boards/eagle/board_config.h +++ b/src/drivers/boards/eagle/board_config.h @@ -34,17 +34,21 @@ /** * @file board_config.h * - * EAGLE internal definitions + * SITL internal definitions */ #pragma once -#define BOARD_OVERRIDE_UUID "EAGLEID " // must be of length 12 (PX4_CPU_UUID_BYTE_LENGTH) +#define BOARD_OVERRIDE_UUID "EAGLE" // must be of length 12 (PX4_CPU_UUID_BYTE_LENGTH) #define BOARD_OVERRIDE_MFGUID BOARD_OVERRIDE_UUID #define BOARD_NAME "EAGLE" #define BOARD_BATTERY1_V_DIV (10.177939394f) #define BOARD_BATTERY1_A_PER_V (15.391030303f) +#define BOARD_HAS_NO_RESET +#define BOARD_HAS_NO_BOOTLOADER + +#define CONFIG_ARCH_BOARD_SITL 1 /* * I2C busses diff --git a/src/drivers/boards/eagle/sitl_led.c b/src/drivers/boards/eagle/sitl_led.c new file mode 100644 index 0000000000..4c43ffc578 --- /dev/null +++ b/src/drivers/boards/eagle/sitl_led.c @@ -0,0 +1,81 @@ +/**************************************************************************** + * + * Copyright (c) 2013 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. + * + ****************************************************************************/ + +/** + * @file sitl_led.c + * + * sitl LED backend. + */ + +#include +#include +#include + +__BEGIN_DECLS +extern void led_init(void); +extern void led_on(int led); +extern void led_off(int led); +extern void led_toggle(int led); +__END_DECLS + +static bool _led_state[2] = { false, false }; + +__EXPORT void led_init() +{ + PX4_DEBUG("LED_INIT"); +} + +__EXPORT void led_on(int led) +{ + if (led == 1 || led == 0) { + PX4_DEBUG("LED%d_ON", led); + _led_state[led] = true; + } +} + +__EXPORT void led_off(int led) +{ + if (led == 1 || led == 0) { + PX4_DEBUG("LED%d_OFF", led); + _led_state[led] = false; + } +} + +__EXPORT void led_toggle(int led) +{ + if (led == 1 || led == 0) { + _led_state[led] = !_led_state[led]; + PX4_DEBUG("LED%d_TOGGLE: %s", led, _led_state[led] ? "ON" : "OFF"); + + } +} diff --git a/src/drivers/boards/esc35-v1/CMakeLists.txt b/src/drivers/boards/esc35-v1/CMakeLists.txt index 285901af92..01f1e0b3c0 100644 --- a/src/drivers/boards/esc35-v1/CMakeLists.txt +++ b/src/drivers/boards/esc35-v1/CMakeLists.txt @@ -42,35 +42,13 @@ message(WARNING-"Configuraton is incomplete") message(WARNING-"Configuraton is incomplete") message(WARNING-"Configuraton is incomplete") -include_directories(../../bootloaders/include) - -set(SRCS) -list(APPEND SRCS - esc35_init.c - esc35_led.c - esc35_usb.c - ../../../drivers/bootloaders/src/common/boot_app_shared.c - ../../../drivers/bootloaders/src/util/crc.c -) - -if(${OS} STREQUAL "nuttx") - if (NOT ${BOARD} STREQUAL "sim") - list(APPEND SRCS - ../../../drivers/device/device_nuttx.cpp - ../../../drivers/device/cdev.cpp - ) - endif() -else() - list(APPEND SRCS - ../../../drivers/device/device_posix.cpp - ../../../drivers/device/vdev.cpp - ) -endif() - px4_add_module( MODULE drivers__boards__esc35-v1 - COMPILE_FLAGS - SRCS ${SRCS} + SRCS + esc35_init.c + esc35_led.c + esc35_usb.c DEPENDS platforms__common ) +include_directories(bootloader) \ No newline at end of file diff --git a/src/drivers/boards/esc35-v1/bootloader/CMakeLists.txt b/src/drivers/boards/esc35-v1/bootloader/CMakeLists.txt index 710bba55b3..696638d005 100644 --- a/src/drivers/boards/esc35-v1/bootloader/CMakeLists.txt +++ b/src/drivers/boards/esc35-v1/bootloader/CMakeLists.txt @@ -31,36 +31,12 @@ # ############################################################################ - -add_definitions( - -DHW_UAVCAN_NAME=${uavcanblid_name} - -DHW_VERSION_MAJOR=${uavcanblid_hw_version_major} - -DHW_VERSION_MINOR=${uavcanblid_hw_version_minor} -) - -include_directories(${px4_bootloader_base}include) -include_directories(${px4_module_base}systemlib) -include_directories(.) - px4_add_module( MODULE drivers__boards__esc35-v1__bootloader - COMPILE_FLAGS SRCS boot.c led.c - ../../common/stm32/board_identity.c - ${px4_bootloader_base}src/uavcan/main.c - ${px4_bootloader_base}src/common/boot_app_shared.c - ${px4_bootloader_base}src/common/nuttx_stubs.c - ${px4_bootloader_base}src/sched/timer.c - ${px4_bootloader_base}src/fs/flash.c - ${px4_bootloader_base}src/util/crc.c - ${px4_bootloader_base}src/util/random.c - ${px4_bootloader_base}src/arch/stm32/drivers/can/driver.c - ${px4_bootloader_base}src/protocol/uavcan.c DEPENDS - nuttx_export_${BOARD} + nuttx_build ) - - -# vim: set noet ft=cmake fenc=utf-8 ff=unix : +target_link_libraries(drivers__boards__esc35-v1__bootloader drivers_bootloaders) \ No newline at end of file diff --git a/src/drivers/boards/mindpx-v2/CMakeLists.txt b/src/drivers/boards/mindpx-v2/CMakeLists.txt index 321d668848..87cc9209f1 100644 --- a/src/drivers/boards/mindpx-v2/CMakeLists.txt +++ b/src/drivers/boards/mindpx-v2/CMakeLists.txt @@ -32,13 +32,7 @@ ############################################################################ px4_add_module( MODULE drivers__boards__mindpx-v2 - COMPILE_FLAGS SRCS - ../common/board_crashdump.c - ../common/board_dma_alloc.c - ../common/stm32/board_reset.c - ../common/stm32/board_identity.c - ../common/stm32/board_mcu_version.c mindpx_can.c mindpx2_init.c mindpx_timer_config.c @@ -47,5 +41,4 @@ px4_add_module( mindpx2_led.c DEPENDS platforms__common - ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : + ) \ No newline at end of file diff --git a/src/drivers/boards/nxphlite-v3/CMakeLists.txt b/src/drivers/boards/nxphlite-v3/CMakeLists.txt index e05e1d782b..4028a03c5f 100644 --- a/src/drivers/boards/nxphlite-v3/CMakeLists.txt +++ b/src/drivers/boards/nxphlite-v3/CMakeLists.txt @@ -32,13 +32,7 @@ ############################################################################ px4_add_module( MODULE drivers__boards__nxphlite-v3 - COMPILE_FLAGS SRCS - ../common/kinetis/board_identity.c - ../common/kinetis/board_mcu_version.c - ../common/kinetis/board_reset.c - ../common/board_crashdump.c - ../common/board_dma_alloc.c nxphlite_autoleds.c nxphlite_automount.c nxphlite_can.c @@ -50,5 +44,4 @@ px4_add_module( nxphlite_usb.c DEPENDS platforms__common - ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : + ) \ No newline at end of file diff --git a/src/drivers/boards/px4-same70xplained-v1/CMakeLists.txt b/src/drivers/boards/px4-same70xplained-v1/CMakeLists.txt index 1f5ae12417..b0b3492857 100644 --- a/src/drivers/boards/px4-same70xplained-v1/CMakeLists.txt +++ b/src/drivers/boards/px4-same70xplained-v1/CMakeLists.txt @@ -32,14 +32,7 @@ ############################################################################ px4_add_module( MODULE drivers__boards__px4-same70xplained-v1 - COMPILE_FLAGS - -Os SRCS - ../common/samv7/board_reset.c - ../common/samv7/board_identity.c - ../common/samv7/board_mcu_version.c - ../common/board_crashdump.c - ../common/board_dma_alloc.c px4same70xplained_can.c px4same70xplained_init.c px4same70xplained_timer_config.c diff --git a/src/drivers/boards/px4-stm32f4discovery/CMakeLists.txt b/src/drivers/boards/px4-stm32f4discovery/CMakeLists.txt index 9f42a6ded7..f885c489e6 100644 --- a/src/drivers/boards/px4-stm32f4discovery/CMakeLists.txt +++ b/src/drivers/boards/px4-stm32f4discovery/CMakeLists.txt @@ -33,13 +33,9 @@ px4_add_module( MODULE drivers__boards__px4-stm32f4discovery SRCS - ../common/stm32/board_reset.c - ../common/stm32/board_identity.c - ../common/stm32/board_mcu_version.c px4discovery_init.c px4discovery_usb.c px4discovery_led.c DEPENDS platforms__common - ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : + ) \ No newline at end of file diff --git a/src/drivers/boards/px4-stm32f4discovery/px4discovery_init.c b/src/drivers/boards/px4-stm32f4discovery/px4discovery_init.c index 019cdcda5e..a8e74ba544 100644 --- a/src/drivers/boards/px4-stm32f4discovery/px4discovery_init.c +++ b/src/drivers/boards/px4-stm32f4discovery/px4discovery_init.c @@ -192,7 +192,3 @@ __EXPORT int board_app_initialize(uintptr_t arg) return OK; } - -__EXPORT void board_crashdump(uintptr_t currentsp, FAR void *tcb, FAR const uint8_t *filename, int lineno) -{ -} diff --git a/src/drivers/boards/px4cannode-v1/CMakeLists.txt b/src/drivers/boards/px4cannode-v1/CMakeLists.txt index a1b52f1949..5848c9b022 100644 --- a/src/drivers/boards/px4cannode-v1/CMakeLists.txt +++ b/src/drivers/boards/px4cannode-v1/CMakeLists.txt @@ -31,40 +31,15 @@ # ############################################################################ -include_directories(../../bootloaders/include) - -set(SRCS) -list(APPEND SRCS - ../common/stm32/board_identity.c - ../common/stm32/board_mcu_version.c - ../common/stm32/board_reset.c - px4cannode_can.c - px4cannode_buttons.c - px4cannode_init.c - px4cannode_led.c - px4cannode_spi.c - ../../../drivers/bootloaders/src/common/boot_app_shared.c - ../../../drivers/bootloaders/src/util/crc.c -) - -if(${OS} STREQUAL "nuttx") - if (NOT ${BOARD} STREQUAL "sim") - list(APPEND SRCS - ../../../drivers/device/device_nuttx.cpp - ../../../drivers/device/cdev.cpp - ) - endif() -else() - list(APPEND SRCS - ../../../drivers/device/device_posix.cpp - ../../../drivers/device/vdev.cpp - ) -endif() - px4_add_module( MODULE drivers__boards__px4cannode-v1 - COMPILE_FLAGS - SRCS ${SRCS} + SRCS + px4cannode_can.c + px4cannode_buttons.c + px4cannode_init.c + px4cannode_led.c + px4cannode_spi.c DEPENDS platforms__common ) +include_directories(bootloader) \ No newline at end of file diff --git a/src/drivers/boards/px4cannode-v1/bootloader/CMakeLists.txt b/src/drivers/boards/px4cannode-v1/bootloader/CMakeLists.txt index 09a101560c..0c0951388c 100644 --- a/src/drivers/boards/px4cannode-v1/bootloader/CMakeLists.txt +++ b/src/drivers/boards/px4cannode-v1/bootloader/CMakeLists.txt @@ -31,36 +31,13 @@ # ############################################################################ - -add_definitions( - -DHW_UAVCAN_NAME=${uavcanblid_name} - -DHW_VERSION_MAJOR=${uavcanblid_hw_version_major} - -DHW_VERSION_MINOR=${uavcanblid_hw_version_minor} -) - -include_directories(${px4_bootloader_base}include) -include_directories(${px4_module_base}systemlib) -include_directories(.) - px4_add_module( MODULE drivers__boards__px4cannode-v1__bootloader COMPILE_FLAGS SRCS boot.c led.c - ../../common/stm32/board_identity.c - ${px4_bootloader_base}src/uavcan/main.c - ${px4_bootloader_base}src/common/boot_app_shared.c - ${px4_bootloader_base}src/common/nuttx_stubs.c - ${px4_bootloader_base}src/sched/timer.c - ${px4_bootloader_base}src/fs/flash.c - ${px4_bootloader_base}src/util/crc.c - ${px4_bootloader_base}src/util/random.c - ${px4_bootloader_base}src/arch/stm32/drivers/can/driver.c - ${px4_bootloader_base}src/protocol/uavcan.c DEPENDS - nuttx_export_${BOARD} + nuttx_build ) - - -# vim: set noet ft=cmake fenc=utf-8 ff=unix : +target_link_libraries(drivers__boards__px4cannode-v1__bootloader drivers_bootloaders) diff --git a/src/drivers/boards/px4esc-v1/CMakeLists.txt b/src/drivers/boards/px4esc-v1/CMakeLists.txt index c776a8d1e9..de58792082 100644 --- a/src/drivers/boards/px4esc-v1/CMakeLists.txt +++ b/src/drivers/boards/px4esc-v1/CMakeLists.txt @@ -31,38 +31,13 @@ # ############################################################################ -include_directories(../../bootloaders/include) - -set(SRCS) -list(APPEND SRCS - ../common/stm32/board_reset.c - ../common/stm32/board_identity.c - ../common/stm32/board_mcu_version.c - px4esc_init.c - px4esc_led.c - px4esc_usb.c - ../../../drivers/bootloaders/src/common/boot_app_shared.c - ../../../drivers/bootloaders/src/util/crc.c -) - -if(${OS} STREQUAL "nuttx") - if (NOT ${BOARD} STREQUAL "sim") - list(APPEND SRCS - ../../../drivers/device/device_nuttx.cpp - ../../../drivers/device/cdev.cpp - ) - endif() -else() - list(APPEND SRCS - ../../../drivers/device/device_posix.cpp - ../../../drivers/device/vdev.cpp - ) -endif() - px4_add_module( MODULE drivers__boards__px4esc-v1 - COMPILE_FLAGS - SRCS ${SRCS} + SRCS + px4esc_init.c + px4esc_led.c + px4esc_usb.c DEPENDS platforms__common ) +include_directories(bootloader) \ No newline at end of file diff --git a/src/drivers/boards/px4esc-v1/bootloader/CMakeLists.txt b/src/drivers/boards/px4esc-v1/bootloader/CMakeLists.txt index 06f6d89e4b..f676d1585e 100644 --- a/src/drivers/boards/px4esc-v1/bootloader/CMakeLists.txt +++ b/src/drivers/boards/px4esc-v1/bootloader/CMakeLists.txt @@ -31,36 +31,12 @@ # ############################################################################ - -add_definitions( - -DHW_UAVCAN_NAME=${uavcanblid_name} - -DHW_VERSION_MAJOR=${uavcanblid_hw_version_major} - -DHW_VERSION_MINOR=${uavcanblid_hw_version_minor} -) - -include_directories(${px4_bootloader_base}include) -include_directories(${px4_module_base}systemlib) -include_directories(.) - px4_add_module( MODULE drivers__boards__px4esc-v1__bootloader - COMPILE_FLAGS SRCS boot.c led.c - ../../common/stm32/board_identity.c - ${px4_bootloader_base}src/uavcan/main.c - ${px4_bootloader_base}src/common/boot_app_shared.c - ${px4_bootloader_base}src/common/nuttx_stubs.c - ${px4_bootloader_base}src/sched/timer.c - ${px4_bootloader_base}src/fs/flash.c - ${px4_bootloader_base}src/util/crc.c - ${px4_bootloader_base}src/util/random.c - ${px4_bootloader_base}src/arch/stm32/drivers/can/driver.c - ${px4_bootloader_base}src/protocol/uavcan.c DEPENDS - nuttx_export_${BOARD} + nuttx_build ) - - -# vim: set noet ft=cmake fenc=utf-8 ff=unix : +target_link_libraries(drivers__boards__px4esc-v1__bootloader drivers_bootloaders) \ No newline at end of file diff --git a/src/drivers/boards/px4esc-v1/px4esc_init.c b/src/drivers/boards/px4esc-v1/px4esc_init.c index d66a80edb2..a7bcbc6e57 100644 --- a/src/drivers/boards/px4esc-v1/px4esc_init.c +++ b/src/drivers/boards/px4esc-v1/px4esc_init.c @@ -205,8 +205,3 @@ __EXPORT int board_app_initialize(uintptr_t arg) #endif return result; } - - -__EXPORT void board_crashdump(uintptr_t currentsp, FAR void *tcb, FAR const uint8_t *filename, int lineno) -{ -} diff --git a/src/drivers/boards/px4flow-v2/CMakeLists.txt b/src/drivers/boards/px4flow-v2/CMakeLists.txt index def01316f6..d370486cf9 100644 --- a/src/drivers/boards/px4flow-v2/CMakeLists.txt +++ b/src/drivers/boards/px4flow-v2/CMakeLists.txt @@ -33,36 +33,13 @@ message(FATAL_ERROR Configuraton is incomplete") -include_directories(../../bootloaders/include) - -set(SRCS) -list(APPEND SRCS - ../common/stm32/board_reset.c - px4flow_init.c - px4flow_led.c - px4flow_can.c - ../../../drivers/bootloaders/src/common/boot_app_shared.c - ../../../drivers/bootloaders/src/util/crc.c -) - -if(${OS} STREQUAL "nuttx") - if (NOT ${BOARD} STREQUAL "sim") - list(APPEND SRCS - ../../../drivers/device/device_nuttx.cpp - ../../../drivers/device/cdev.cpp - ) - endif() -else() - list(APPEND SRCS - ../../../drivers/device/device_posix.cpp - ../../../drivers/device/vdev.cpp - ) -endif() - px4_add_module( MODULE drivers__boards__px4flow-v2 - COMPILE_FLAGS - SRCS ${SRCS} + SRCS + px4flow_init.c + px4flow_led.c + px4flow_can.c DEPENDS platforms__common ) +include_directories(bootloader) \ No newline at end of file diff --git a/src/drivers/boards/px4flow-v2/bootloader/CMakeLists.txt b/src/drivers/boards/px4flow-v2/bootloader/CMakeLists.txt index de789e83fc..67c9c2434e 100644 --- a/src/drivers/boards/px4flow-v2/bootloader/CMakeLists.txt +++ b/src/drivers/boards/px4flow-v2/bootloader/CMakeLists.txt @@ -31,36 +31,12 @@ # ############################################################################ - -add_definitions( - -DHW_UAVCAN_NAME=${uavcanblid_name} - -DHW_VERSION_MAJOR=${uavcanblid_hw_version_major} - -DHW_VERSION_MINOR=${uavcanblid_hw_version_minor} -) - -include_directories(${px4_bootloader_base}include) -include_directories(${px4_module_base}systemlib) -include_directories(.) - px4_add_module( MODULE drivers__boards__px4flow-v2__bootloader - COMPILE_FLAGS SRCS boot.c led.c - ../../common/stm32/board_identity.c - ${px4_bootloader_base}src/uavcan/main.c - ${px4_bootloader_base}src/common/boot_app_shared.c - ${px4_bootloader_base}src/common/nuttx_stubs.c - ${px4_bootloader_base}src/sched/timer.c - ${px4_bootloader_base}src/fs/flash.c - ${px4_bootloader_base}src/util/crc.c - ${px4_bootloader_base}src/util/random.c - ${px4_bootloader_base}src/arch/stm32/drivers/can/driver.c - ${px4_bootloader_base}src/protocol/uavcan.c DEPENDS - nuttx_export_${BOARD} + nuttx_build ) - - -# vim: set noet ft=cmake fenc=utf-8 ff=unix : +target_link_libraries(drivers__boards__px4flow-v2__bootloader drivers_bootloaders) \ No newline at end of file diff --git a/src/drivers/boards/px4fmu-v2/CMakeLists.txt b/src/drivers/boards/px4fmu-v2/CMakeLists.txt index 5fa3fb3c96..5d801d7e0d 100644 --- a/src/drivers/boards/px4fmu-v2/CMakeLists.txt +++ b/src/drivers/boards/px4fmu-v2/CMakeLists.txt @@ -32,13 +32,7 @@ ############################################################################ px4_add_module( MODULE drivers__boards__px4fmu-v2 - COMPILE_FLAGS SRCS - ../common/board_crashdump.c - ../common/board_dma_alloc.c - ../common/stm32/board_reset.c - ../common/stm32/board_identity.c - ../common/stm32/board_mcu_version.c px4fmu_can.c px4fmu2_init.c px4fmu_timer_config.c @@ -48,4 +42,3 @@ px4_add_module( DEPENDS platforms__common ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/boards/px4fmu-v2/px4fmu2_init.c b/src/drivers/boards/px4fmu-v2/px4fmu2_init.c index 9490100774..7d8b460d3a 100644 --- a/src/drivers/boards/px4fmu-v2/px4fmu2_init.c +++ b/src/drivers/boards/px4fmu-v2/px4fmu2_init.c @@ -116,20 +116,6 @@ extern void led_on(int led); extern void led_off(int led); __END_DECLS -/**************************************************************************** - * Private Data - ****************************************************************************/ -#if defined(BOARD_HAS_SIMPLE_HW_VERSIONING) -static int hw_version = -1; -static int hw_revision = -1; -static char hw_type[4] = HW_VER_TYPE_INIT; -#endif -/**************************************************************************** - * Protected Functions - ****************************************************************************/ -/**************************************************************************** - * Public Functions - ****************************************************************************/ /************************************************************************************ * Name: board_peripheral_reset * @@ -194,123 +180,6 @@ __EXPORT void board_on_reset(int status) } } -/************************************************************************************ - * Name: determin_hw_version - * - * Description: - * - * This function looks at HW deltas to determine what the - * build is running on using the following criteria: - * - * MSN PB12 FMUv2 Cube MINI - * CAN2_RX CONECTOR MX30521 NC - * PU.PD 1,0 1,1 1,0 - * - * LSN PB4 FMUv2 Cube MINI - * ACCEL_DRDY LSM303D NC NC - * PU.PD 0,0 1,0 1,0 - - * PB12:PB4 - * ud ud - * 10 00 - 0x8 FMUv2 - * 11 10 - 0xE Cube AKA V2.0 - * 10 10 - 0xA PixhawkMini - * - * This will return OK on success and -1 on not supported - * - * hw_type Initial state is {'V','2',0, 0} - * V 2 - FMUv2 - * V 3 0 - FMUv3 2.0 - * V 3 1 - FMUv3 2.1 - not differentiateable, - * V 2 M - FMUv2 Mini - * - ************************************************************************************/ - -#if defined(BOARD_HAS_SIMPLE_HW_VERSIONING) -static int determin_hw_version(int *version, int *revision) -{ - *revision = -1; /* unknown */ - int rv = 0; - int pos = 0; - stm32_configgpio(GPIO_PULLDOWN | (HW_VER_PB4 & ~GPIO_PUPD_MASK)); - up_udelay(10); - rv |= stm32_gpioread(HW_VER_PB4) << pos++; - stm32_configgpio(HW_VER_PB4); - up_udelay(10); - rv |= stm32_gpioread(HW_VER_PB4) << pos++; - - int votes = 16; - int ones[2] = {0, 0}; - int zeros[2] = {0, 0}; - - while (votes--) { - stm32_configgpio(GPIO_PULLDOWN | (HW_VER_PB12 & ~GPIO_PUPD_MASK)); - up_udelay(10); - stm32_gpioread(HW_VER_PB12) ? ones[0]++ : zeros[0]++; - stm32_configgpio(HW_VER_PB12); - up_udelay(10); - stm32_gpioread(HW_VER_PB12) ? ones[1]++ : zeros[1]++; - } - - if (ones[0] > zeros[0]) { - rv |= 1 << pos; - } - - pos++; - - if (ones[1] > zeros[1]) { - rv |= 1 << pos; - } - - stm32_configgpio(HW_VER_PB4_INIT); - stm32_configgpio(HW_VER_PB12_INIT); - *version = rv; - return OK; -} - -/************************************************************************************ - * Name: board_get_hw_type_name - * - * Description: - * Optional returns a string defining the HW type - * - * - ************************************************************************************/ - -__EXPORT const char *board_get_hw_type_name() -{ - return (const char *) hw_type; -} - -/************************************************************************************ - * Name: board_get_hw_version - * - * Description: - * Optional returns a integer HW version - * - * - ************************************************************************************/ - -__EXPORT int board_get_hw_version() -{ - return HW_VER_SIMPLE(hw_version); -} - -/************************************************************************************ - * Name: board_get_hw_revision - * - * Description: - * Optional returns a integer HW revision - * - * - ************************************************************************************/ - -__EXPORT int board_get_hw_revision() -{ - return hw_revision; -} -#endif // BOARD_HAS_SIMPLE_HW_VERSIONING - /************************************************************************************ * Name: stm32_boardinitialize * @@ -404,29 +273,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) # error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. #endif -#if defined(BOARD_HAS_SIMPLE_HW_VERSIONING) - - if (OK == determin_hw_version(&hw_version, & hw_revision)) { - switch (hw_version) { - default: - case 0x8: - break; - - case 0xE: - hw_type[1]++; - hw_type[2] = '0'; - break; - - case 0xA: - hw_type[2] = 'M'; - break; - } - - PX4_INFO("Ver 0x%1X : Rev %x %s", hw_version, hw_revision, hw_type); - } - -#endif // BOARD_HAS_SIMPLE_HW_VERSIONING - /* Bring up the Sensor power */ stm32_gpiowrite(GPIO_VDD_3V3_SENSORS_EN, 1); diff --git a/src/drivers/boards/px4fmu-v2/px4fmu_spi.c b/src/drivers/boards/px4fmu-v2/px4fmu_spi.c index 8ad297712f..48726c0579 100644 --- a/src/drivers/boards/px4fmu-v2/px4fmu_spi.c +++ b/src/drivers/boards/px4fmu-v2/px4fmu_spi.c @@ -82,30 +82,11 @@ static void stm32_spi1_initialize(void) stm32_configgpio(GPIO_SPI1_EXTI_DRDY_PD15); -# if !defined(BOARD_HAS_VERSIONING) stm32_configgpio(GPIO_SPI1_EXTI_DRDY_PB0); stm32_configgpio(GPIO_SPI1_EXTI_DRDY_PB1); stm32_configgpio(GPIO_SPI1_EXTI_DRDY_PB4); stm32_configgpio(GPIO_SPI1_CS_PC13); stm32_configgpio(GPIO_SPI1_CS_PC15); -# else - - if (HW_VER_FMUV2 == board_get_hw_version()) { - stm32_configgpio(GPIO_SPI1_EXTI_DRDY_PB0); - stm32_configgpio(GPIO_SPI1_EXTI_DRDY_PB1); - stm32_configgpio(GPIO_SPI1_EXTI_DRDY_PB4); - stm32_configgpio(GPIO_SPI1_CS_PC13); - stm32_configgpio(GPIO_SPI1_CS_PC15); - - } else if (HW_VER_FMUV2MINI == board_get_hw_version()) { - stm32_configgpio(GPIO_SPI1_EXTI_20608_DRDY_PC14); - stm32_configgpio(GPIO_SPI1_CS_PC15); - - } else if (HW_VER_FMUV3 == board_get_hw_version()) { - stm32_configgpio(GPIO_SPI1_CS_PC1); - } - -# endif } #endif // CONFIG_STM32_SPI1 @@ -118,23 +99,7 @@ static void stm32_spi1_initialize(void) static void stm32_spi4_initialize(void) { stm32_configgpio(GPIO_SPI4_NSS_PE4); - -# if !defined(BOARD_HAS_VERSIONING) stm32_configgpio(GPIO_SPI4_GPIO_PC14); -# else - - if (HW_VER_FMUV3 == board_get_hw_version()) { - stm32_configgpio(GPIO_SPI4_EXTI_DRDY_PB0); - stm32_configgpio(GPIO_SPI4_CS_PB1); - stm32_configgpio(GPIO_SPI4_CS_PC13); - stm32_configgpio(GPIO_SPI4_CS_PC15); - } - - if (HW_VER_FMUV2MINI != board_get_hw_version()) { - stm32_configgpio(GPIO_SPI4_GPIO_PC14); - } - -# endif } #endif //CONFIG_STM32_SPI4 @@ -158,7 +123,6 @@ __EXPORT void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool s { /* SPI select is active low, so write !selected to select the device */ -# if !defined(BOARD_HAS_VERSIONING) switch (devid) { case PX4_SPIDEV_GYRO: /* Making sure the other peripherals are not selected */ @@ -199,124 +163,6 @@ __EXPORT void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool s default: break; } - -# else // defined(BOARD_HAS_VERSIONING) - - /* SPI select is active low, so write !selected to select the device */ - /* Verification - * PA5 PA6 PA7 PB0 PB1 PB4 PC1 PC2 PC13 PC14 PC15 PD7 PD15 PE2 PE4 PE5 PE6 - * driver X X X X X X - * local - - - V3 a V2 - V2M a - - - */ - - switch (devid) { - case PX4_SPIDEV_GYRO: - - /* Making sure the other peripherals are not selected */ - if (HW_VER_FMUV2 == board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI1_CS_PC13, !selected); - } - - if (HW_VER_FMUV3 != board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI1_CS_PC15, 1); - } - - stm32_gpiowrite(GPIO_SPI1_CS_PD7, 1); - stm32_gpiowrite(GPIO_SPI1_CS_PC2, 1); - - if (HW_VER_FMUV3 == board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI1_CS_PC1, 1); - } - - break; - -# if defined(PX4_SPIDEV_ICM_20608) - - case PX4_SPIDEV_ICM_20608: -# endif - case PX4_SPIDEV_ACCEL_MAG: - - /* Making sure the other peripherals are not selected */ - if (HW_VER_FMUV2 == board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI1_CS_PC13, 1); - } - - if (HW_VER_FMUV3 != board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI1_CS_PC15, !selected); - } - - stm32_gpiowrite(GPIO_SPI1_CS_PD7, 1); - stm32_gpiowrite(GPIO_SPI1_CS_PC2, 1); - - if (HW_VER_FMUV3 == board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI1_CS_PC1, 1); - } - - break; - - case PX4_SPIDEV_BARO: - - /* Making sure the other peripherals are not selected */ - if (HW_VER_FMUV2 == board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI1_CS_PC13, 1); - } - - if (HW_VER_FMUV3 != board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI1_CS_PC15, 1); - } - - stm32_gpiowrite(GPIO_SPI1_CS_PD7, !selected); - stm32_gpiowrite(GPIO_SPI1_CS_PC2, 1); - - if (HW_VER_FMUV3 == board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI1_CS_PC1, 1); - } - - break; - - case PX4_SPIDEV_MPU: - - /* Making sure the other peripherals are not selected */ - if (HW_VER_FMUV2 == board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI1_CS_PC13, 1); - } - - if (HW_VER_FMUV3 != board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI1_CS_PC15, 1); - } - - stm32_gpiowrite(GPIO_SPI1_CS_PD7, 1); - stm32_gpiowrite(GPIO_SPI1_CS_PC2, !selected); - - if (HW_VER_FMUV3 == board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI1_CS_PC1, 1); - } - - break; - - case PX4_SPIDEV_HMC: - if (HW_VER_FMUV2 == board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI1_CS_PC13, 1); - } - - if (HW_VER_FMUV3 != board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI1_CS_PC15, 1); - } - - stm32_gpiowrite(GPIO_SPI1_CS_PD7, 1); - stm32_gpiowrite(GPIO_SPI1_CS_PC2, 1); - - if (HW_VER_FMUV3 == board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI1_CS_PC1, !selected); - } - - break; - - default: - break; - } - -# endif // defined(BOARD_HAS_VERSIONING) } __EXPORT uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) @@ -344,8 +190,6 @@ __EXPORT uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, uint32_t devid) __EXPORT void stm32_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) { /* SPI select is active low, so write !selected to select the device */ - -# if !defined(BOARD_HAS_VERSIONING) switch (devid) { case PX4_SPIDEV_EXT_MPU: /* Making sure the other peripherals are not selected */ @@ -363,88 +207,6 @@ __EXPORT void stm32_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, bool s break; } - -# else // defined(BOARD_HAS_VERSIONING) - /* SPI select is active low, so write !selected to select the device */ - /* Verification - * PA5 PA6 PA7 PB0 PB1 PB4 PC1 PC2 PC13 PC14 PC15 PD7 PD15 PE2 PE4 PE5 PE6 - * driver X X X X X X - * local - - - - - V3 !V2M V3 - - a - */ - - switch (devid) { - case PX4_SPIDEV_EXT_MPU: - /* Making sure the other peripherals are not selected */ - stm32_gpiowrite(GPIO_SPI4_NSS_PE4, !selected); - - if (HW_VER_FMUV2MINI != board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI4_GPIO_PC14, 1); - } - - if (HW_VER_FMUV3 == board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI4_CS_PC15, 1); - stm32_gpiowrite(GPIO_SPI4_CS_PC13, 1); - } - - break; - - case PX4_SPIDEV_EXT_BARO: - /* Making sure the other peripherals are not selected */ - stm32_gpiowrite(GPIO_SPI4_NSS_PE4, 1); - - if (HW_VER_FMUV2MINI != board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI4_GPIO_PC14, !selected); - } - - if (HW_VER_FMUV3 == board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI4_CS_PC15, 1); - stm32_gpiowrite(GPIO_SPI4_CS_PC13, 1); - } - - break; - -# if defined(PX4_SPIDEV_ICM_20608) - - case PX4_SPIDEV_ICM_20608: -# endif - case PX4_SPIDEV_EXT_ACCEL_MAG: - /* Making sure the other peripherals are not selected */ - stm32_gpiowrite(GPIO_SPI4_NSS_PE4, 1); - - if (HW_VER_FMUV2MINI != board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI4_GPIO_PC14, 1); - } - - if (HW_VER_FMUV3 == board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI4_CS_PC15, !selected); - stm32_gpiowrite(GPIO_SPI4_CS_PC13, 1); - } - - break; - - case PX4_SPIDEV_EXT_BMI: - case PX4_SPIDEV_EXT_GYRO: - /* Making sure the other peripherals are not selected */ - stm32_gpiowrite(GPIO_SPI4_NSS_PE4, 1); - - if (HW_VER_FMUV2MINI != board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI4_GPIO_PC14, 1); - } - - if (HW_VER_FMUV3 == board_get_hw_version()) { - stm32_gpiowrite(GPIO_SPI4_CS_PC15, 1); - stm32_gpiowrite(GPIO_SPI4_CS_PC13, !selected); - } - - break; - - default: - break; - - } - -# endif // defined(BOARD_HAS_VERSIONING) - } __EXPORT uint8_t stm32_spi4status(FAR struct spi_dev_s *dev, uint32_t devid) { @@ -489,32 +251,6 @@ __EXPORT void board_spi_reset(int ms) stm32_gpiowrite(_PIN_OFF(GPIO_SPI1_EXTI_DRDY_PB4), 0); stm32_gpiowrite(_PIN_OFF(GPIO_SPI1_EXTI_DRDY_PD15), 0); -#if defined(BOARD_HAS_VERSIONING) - - if (HW_VER_FMUV2 != board_get_hw_version()) { - stm32_configgpio(_PIN_OFF(GPIO_SPI4_CS_PC14)); - stm32_gpiowrite(_PIN_OFF(GPIO_SPI4_CS_PC14), 0); - } - - if (HW_VER_FMUV3 == board_get_hw_version()) { - stm32_configgpio(_PIN_OFF(GPIO_SPI1_CS_PC1)); - stm32_gpiowrite(_PIN_OFF(GPIO_SPI1_CS_PC1), 0); - - stm32_configgpio(_PIN_OFF(GPIO_SPI4_NSS_PE4)); - stm32_gpiowrite(_PIN_OFF(GPIO_SPI4_NSS_PE4), 0); - - stm32_configgpio(_PIN_OFF(GPIO_SPI4_SCK)); - stm32_configgpio(_PIN_OFF(GPIO_SPI4_MISO)); - stm32_configgpio(_PIN_OFF(GPIO_SPI4_MOSI)); - - stm32_gpiowrite(_PIN_OFF(GPIO_SPI4_SCK), 0); - stm32_gpiowrite(_PIN_OFF(GPIO_SPI4_MISO), 0); - stm32_gpiowrite(_PIN_OFF(GPIO_SPI4_MOSI), 0); - - } - -#endif - /* set the sensor rail off */ stm32_configgpio(GPIO_VDD_3V3_SENSORS_EN); stm32_gpiowrite(GPIO_VDD_3V3_SENSORS_EN, 0); @@ -536,16 +272,5 @@ __EXPORT void board_spi_reset(int ms) stm32_configgpio(GPIO_SPI1_MISO); stm32_configgpio(GPIO_SPI1_MOSI); -#if defined(BOARD_HAS_VERSIONING) - - if (HW_VER_FMUV3 == board_get_hw_version()) { - stm32_configgpio(GPIO_SPI4_SCK); - stm32_configgpio(GPIO_SPI4_MISO); - stm32_configgpio(GPIO_SPI4_MOSI); - stm32_spi4_initialize(); - } - -#endif - stm32_spi1_initialize(); } diff --git a/src/drivers/boards/px4fmu-v3/CMakeLists.txt b/src/drivers/boards/px4fmu-v3/CMakeLists.txt new file mode 100644 index 0000000000..a4403c71ae --- /dev/null +++ b/src/drivers/boards/px4fmu-v3/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 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_module( + MODULE drivers__boards__px4fmu-v3 + SRCS + px4fmu3_led.c + px4fmu3_init.c + px4fmu_can.c + px4fmu_spi.c + px4fmu_timer_config.c + px4fmu_usb.c + DEPENDS + platforms__common + ) diff --git a/src/drivers/boards/px4fmu-v3/px4fmu3_init.c b/src/drivers/boards/px4fmu-v3/px4fmu3_init.c new file mode 100644 index 0000000000..9490100774 --- /dev/null +++ b/src/drivers/boards/px4fmu-v3/px4fmu3_init.c @@ -0,0 +1,687 @@ +/**************************************************************************** + * + * Copyright (c) 2012-2015 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. + * + ****************************************************************************/ + +/** + * @file px4fmu2_init.c + * + * PX4FMUv2-specific early startup code. This file implements the + * board_app_initialize() function that is called early by nsh during startup. + * + * Code here is run before the rcS script is invoked; it should start required + * subsystems and perform board-specific initialization. + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include +#include +#include +#include +#include + +#include "platform/cxxinitialize.h" +#include +#include +#include +#include +#include +#include + +#include +#include "board_config.h" +#include + +#include + +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/* Configuration ************************************************************/ + +/* Debug ********************************************************************/ + +#ifdef CONFIG_CPP_HAVE_VARARGS +# ifdef CONFIG_DEBUG +# define message(...) syslog(__VA_ARGS__) +# else +# define message(...) printf(__VA_ARGS__) +# endif +#else +# ifdef CONFIG_DEBUG +# define message syslog +# else +# define message printf +# endif +#endif + +/* + * Ideally we'd be able to get these from up_internal.h, + * but since we want to be able to disable the NuttX use + * of leds for system indication at will and there is no + * separate switch, we need to build independent of the + * CONFIG_ARCH_LEDS configuration switch. + */ +__BEGIN_DECLS +extern void led_init(void); +extern void led_on(int led); +extern void led_off(int led); +__END_DECLS + +/**************************************************************************** + * Private Data + ****************************************************************************/ +#if defined(BOARD_HAS_SIMPLE_HW_VERSIONING) +static int hw_version = -1; +static int hw_revision = -1; +static char hw_type[4] = HW_VER_TYPE_INIT; +#endif +/**************************************************************************** + * Protected Functions + ****************************************************************************/ +/**************************************************************************** + * Public Functions + ****************************************************************************/ +/************************************************************************************ + * Name: board_peripheral_reset + * + * Description: + * + ************************************************************************************/ +__EXPORT void board_peripheral_reset(int ms) +{ + /* set the peripheral rails off */ + stm32_configgpio(GPIO_VDD_5V_PERIPH_EN); + stm32_gpiowrite(GPIO_VDD_5V_PERIPH_EN, 1); + + /* wait for the peripheral rail to reach GND */ + usleep(ms * 1000); + warnx("reset done, %d ms", ms); + + /* re-enable power */ + + /* switch the peripheral rail back on */ + stm32_gpiowrite(GPIO_VDD_5V_PERIPH_EN, 0); +} + +/************************************************************************************ + * Name: board_on_reset + * + * Description: + * Optionally provided function called on entry to board_system_reset + * It should perform any house keeping prior to the rest. + * + * status - 1 if resetting to boot loader + * 0 if just resetting + * + ************************************************************************************/ + +__EXPORT void board_on_reset(int status) +{ + UNUSED(status); + /* configure the GPIO pins to outputs and keep them low */ + + stm32_configgpio(GPIO_GPIO0_OUTPUT); + stm32_configgpio(GPIO_GPIO1_OUTPUT); + stm32_configgpio(GPIO_GPIO2_OUTPUT); + stm32_configgpio(GPIO_GPIO3_OUTPUT); + stm32_configgpio(GPIO_GPIO4_OUTPUT); + stm32_configgpio(GPIO_GPIO5_OUTPUT); + + /* On resets invoked from system (not boot) insure we establish a low + * output state (discharge the pins) on PWM pins before they become inputs. + * + * We also delay the onset of the that 3.1 Ms pulse as boot. This has + * triggered some ESC to spin. By adding this delay here the reset + * is pushed out > 400 ms. So the ESC PWM input can not mistake + * the 3.1 Ms pulse as a valid PWM command. + * + * fixme:Establish in upstream NuttX an CONFIG_IO_INIT_STATE to + * the initialize the IO lines in the clock config. + * + */ + + if (status >= 0) { + up_mdelay(400); + } +} + +/************************************************************************************ + * Name: determin_hw_version + * + * Description: + * + * This function looks at HW deltas to determine what the + * build is running on using the following criteria: + * + * MSN PB12 FMUv2 Cube MINI + * CAN2_RX CONECTOR MX30521 NC + * PU.PD 1,0 1,1 1,0 + * + * LSN PB4 FMUv2 Cube MINI + * ACCEL_DRDY LSM303D NC NC + * PU.PD 0,0 1,0 1,0 + + * PB12:PB4 + * ud ud + * 10 00 - 0x8 FMUv2 + * 11 10 - 0xE Cube AKA V2.0 + * 10 10 - 0xA PixhawkMini + * + * This will return OK on success and -1 on not supported + * + * hw_type Initial state is {'V','2',0, 0} + * V 2 - FMUv2 + * V 3 0 - FMUv3 2.0 + * V 3 1 - FMUv3 2.1 - not differentiateable, + * V 2 M - FMUv2 Mini + * + ************************************************************************************/ + +#if defined(BOARD_HAS_SIMPLE_HW_VERSIONING) +static int determin_hw_version(int *version, int *revision) +{ + *revision = -1; /* unknown */ + int rv = 0; + int pos = 0; + stm32_configgpio(GPIO_PULLDOWN | (HW_VER_PB4 & ~GPIO_PUPD_MASK)); + up_udelay(10); + rv |= stm32_gpioread(HW_VER_PB4) << pos++; + stm32_configgpio(HW_VER_PB4); + up_udelay(10); + rv |= stm32_gpioread(HW_VER_PB4) << pos++; + + int votes = 16; + int ones[2] = {0, 0}; + int zeros[2] = {0, 0}; + + while (votes--) { + stm32_configgpio(GPIO_PULLDOWN | (HW_VER_PB12 & ~GPIO_PUPD_MASK)); + up_udelay(10); + stm32_gpioread(HW_VER_PB12) ? ones[0]++ : zeros[0]++; + stm32_configgpio(HW_VER_PB12); + up_udelay(10); + stm32_gpioread(HW_VER_PB12) ? ones[1]++ : zeros[1]++; + } + + if (ones[0] > zeros[0]) { + rv |= 1 << pos; + } + + pos++; + + if (ones[1] > zeros[1]) { + rv |= 1 << pos; + } + + stm32_configgpio(HW_VER_PB4_INIT); + stm32_configgpio(HW_VER_PB12_INIT); + *version = rv; + return OK; +} + +/************************************************************************************ + * Name: board_get_hw_type_name + * + * Description: + * Optional returns a string defining the HW type + * + * + ************************************************************************************/ + +__EXPORT const char *board_get_hw_type_name() +{ + return (const char *) hw_type; +} + +/************************************************************************************ + * Name: board_get_hw_version + * + * Description: + * Optional returns a integer HW version + * + * + ************************************************************************************/ + +__EXPORT int board_get_hw_version() +{ + return HW_VER_SIMPLE(hw_version); +} + +/************************************************************************************ + * Name: board_get_hw_revision + * + * Description: + * Optional returns a integer HW revision + * + * + ************************************************************************************/ + +__EXPORT int board_get_hw_revision() +{ + return hw_revision; +} +#endif // BOARD_HAS_SIMPLE_HW_VERSIONING + +/************************************************************************************ + * Name: stm32_boardinitialize + * + * Description: + * All STM32 architectures must provide the following entry point. This entry point + * is called early in the intitialization -- after all memory has been configured + * and mapped but before any devices have been initialized. + * + ************************************************************************************/ + +__EXPORT void +stm32_boardinitialize(void) +{ + board_on_reset(-1); + + /* configure LEDs */ + board_autoled_initialize(); + + /* Start with the Sensor voltage off */ + + stm32_configgpio(GPIO_VDD_3V3_SENSORS_EN); + + /* configure ADC pins */ + + stm32_configgpio(GPIO_ADC1_IN2); /* BATT_VOLTAGE_SENS */ + stm32_configgpio(GPIO_ADC1_IN3); /* BATT_CURRENT_SENS */ + stm32_configgpio(GPIO_ADC1_IN4); /* VDD_5V_SENS */ + stm32_configgpio(GPIO_ADC1_IN13); /* FMU_AUX_ADC_1 */ + stm32_configgpio(GPIO_ADC1_IN14); /* FMU_AUX_ADC_2 */ + stm32_configgpio(GPIO_ADC1_IN15); /* PRESSURE_SENS */ + + /* configure power supply control/sense pins */ + stm32_configgpio(GPIO_VDD_5V_PERIPH_EN); + stm32_configgpio(GPIO_VDD_BRICK_VALID); + stm32_configgpio(GPIO_VDD_SERVO_VALID); + stm32_configgpio(GPIO_VDD_USB_VALID); + stm32_configgpio(GPIO_VDD_5V_HIPOWER_OC); + stm32_configgpio(GPIO_VDD_5V_PERIPH_OC); + + + /* configure SPI interfaces is deferred to board_app_initialize + * to delay the sensor power up with out adding a delay + */ + +} + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initalization logic and the the + * matching application logic. The value cold be such things as a + * mode enumeration value, a set of DIP switch switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +static struct spi_dev_s *spi1; +static struct spi_dev_s *spi2; +static struct spi_dev_s *spi4; +static struct sdio_dev_s *sdio; + +__EXPORT int board_app_initialize(uintptr_t arg) +{ + +#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) + + /* run C++ ctors before we go any further */ + + up_cxxinitialize(); + +# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) +# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. +# endif + +#else +# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. +#endif + +#if defined(BOARD_HAS_SIMPLE_HW_VERSIONING) + + if (OK == determin_hw_version(&hw_version, & hw_revision)) { + switch (hw_version) { + default: + case 0x8: + break; + + case 0xE: + hw_type[1]++; + hw_type[2] = '0'; + break; + + case 0xA: + hw_type[2] = 'M'; + break; + } + + PX4_INFO("Ver 0x%1X : Rev %x %s", hw_version, hw_revision, hw_type); + } + +#endif // BOARD_HAS_SIMPLE_HW_VERSIONING + + /* Bring up the Sensor power */ + + stm32_gpiowrite(GPIO_VDD_3V3_SENSORS_EN, 1); + + /* Ensure the power is on 1 ms before we drive the GPIO pins */ + + usleep(1000); + + /* Now it is ok to drive the pins high so configure SPI GPIO */ + + stm32_spiinitialize(); + + + /* configure the high-resolution time/callout interface */ + + hrt_init(); + + param_init(); + + /* configure the DMA allocator */ + + if (board_dma_alloc_init() < 0) { + message("DMA alloc FAILED"); + } + + /* configure CPU load estimation */ +#ifdef CONFIG_SCHED_INSTRUMENTATION + cpuload_initialize_once(); +#endif + + /* set up the serial DMA polling */ + static struct hrt_call serial_dma_call; + struct timespec ts; + + /* + * Poll at 1ms intervals for received bytes that have not triggered + * a DMA event. + */ + ts.tv_sec = 0; + ts.tv_nsec = 1000000; + + hrt_call_every(&serial_dma_call, + ts_to_abstime(&ts), + ts_to_abstime(&ts), + (hrt_callout)stm32_serial_dma_poll, + NULL); + +#if defined(CONFIG_STM32_BBSRAM) + + if (hardfault_check_status) { + /* NB. the use of the console requires the hrt running + * to poll the DMA + */ + + /* Using Battery Backed Up SRAM */ + + int filesizes[CONFIG_STM32_BBSRAM_FILES + 1] = BSRAM_FILE_SIZES; + + stm32_bbsraminitialize(BBSRAM_PATH, filesizes); + +#if defined(CONFIG_STM32_SAVE_CRASHDUMP) + + /* Panic Logging in Battery Backed Up Files */ + + /* + * In an ideal world, if a fault happens in flight the + * system save it to BBSRAM will then reboot. Upon + * rebooting, the system will log the fault to disk, recover + * the flight state and continue to fly. But if there is + * a fault on the bench or in the air that prohibit the recovery + * or committing the log to disk, the things are too broken to + * fly. So the question is: + * + * Did we have a hard fault and not make it far enough + * through the boot sequence to commit the fault data to + * the SD card? + */ + + /* Do we have an uncommitted hard fault in BBSRAM? + * - this will be reset after a successful commit to SD + */ + int hadCrash = hardfault_check_status("boot"); + + if (hadCrash == OK) { + + message("[boot] There is a hard fault logged. Hold down the SPACE BAR," \ + " while booting to halt the system!\n"); + + /* Yes. So add one to the boot count - this will be reset after a successful + * commit to SD + */ + + int reboots = hardfault_increment_reboot("boot", false); + + /* Also end the misery for a user that holds for a key down on the console */ + + int bytesWaiting; + ioctl(fileno(stdin), FIONREAD, (unsigned long)((uintptr_t) &bytesWaiting)); + + if (reboots > 2 || bytesWaiting != 0) { + + /* Since we can not commit the fault dump to disk. Display it + * to the console. + */ + + hardfault_write("boot", fileno(stdout), HARDFAULT_DISPLAY_FORMAT, false); + + message("[boot] There were %d reboots with Hard fault that were not committed to disk - System halted %s\n", + reboots, + (bytesWaiting == 0 ? "" : " Due to Key Press\n")); + + + /* For those of you with a debugger set a break point on up_assert and + * then set dbgContinue = 1 and go. + */ + + /* Clear any key press that got us here */ + + static volatile bool dbgContinue = false; + int c = '>'; + + while (!dbgContinue) { + + switch (c) { + + case EOF: + + + case '\n': + case '\r': + case ' ': + continue; + + default: + + putchar(c); + putchar('\n'); + + switch (c) { + + case 'D': + case 'd': + hardfault_write("boot", fileno(stdout), HARDFAULT_DISPLAY_FORMAT, false); + break; + + case 'C': + case 'c': + hardfault_rearm("boot"); + hardfault_increment_reboot("boot", true); + break; + + case 'B': + case 'b': + dbgContinue = true; + break; + + default: + break; + } // Inner Switch + + message("\nEnter B - Continue booting\n" \ + "Enter C - Clear the fault log\n" \ + "Enter D - Dump fault log\n\n?>"); + fflush(stdout); + + if (!dbgContinue) { + c = getchar(); + } + + break; + + } // outer switch + } // for + + } // inner if + } // outer if + } // hardfault_check_status + +#endif // CONFIG_STM32_SAVE_CRASHDUMP +#endif // CONFIG_STM32_BBSRAM + + /* initial LED state */ + drv_led_start(); + led_off(LED_AMBER); + + /* Configure SPI-based devices */ + + spi1 = stm32_spibus_initialize(PX4_SPI_BUS_SENSORS); + + if (!spi1) { + message("[boot] FAILED to initialize SPI port %d\n", PX4_SPI_BUS_SENSORS); + board_autoled_on(LED_AMBER); + return -ENODEV; + } + + /* Default SPI1 to 1MHz and de-assert the known chip selects. */ + SPI_SETFREQUENCY(spi1, 10000000); + SPI_SETBITS(spi1, 8); + SPI_SETMODE(spi1, SPIDEV_MODE3); + up_udelay(20); + + /* Get the SPI port for the FRAM */ + + spi2 = stm32_spibus_initialize(PX4_SPI_BUS_RAMTRON); + + if (!spi2) { + message("[boot] FAILED to initialize SPI port %d\n", PX4_SPI_BUS_RAMTRON); + board_autoled_on(LED_AMBER); + return -ENODEV; + } + + /* Default SPI2 to 37.5 MHz (40 MHz rounded to nearest valid divider, F4 max) + * and de-assert the known chip selects. */ + + // XXX start with 10.4 MHz in FRAM usage and go up to 37.5 once validated + SPI_SETFREQUENCY(spi2, 12 * 1000 * 1000); + SPI_SETBITS(spi2, 8); + SPI_SETMODE(spi2, SPIDEV_MODE3); + + spi4 = stm32_spibus_initialize(PX4_SPI_BUS_EXT); + + if (!spi4) { + message("[boot] FAILED to initialize SPI port %d\n", PX4_SPI_BUS_EXT); + board_autoled_on(LED_AMBER); + return -ENODEV; + } + + /* Default SPI4 to 1MHz and de-assert the known chip selects. */ + SPI_SETFREQUENCY(spi4, 10000000); + SPI_SETBITS(spi4, 8); + SPI_SETMODE(spi4, SPIDEV_MODE3); + +#ifdef CONFIG_MMCSD + /* First, get an instance of the SDIO interface */ + + sdio = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO); + + if (!sdio) { + message("[boot] Failed to initialize SDIO slot %d\n", + CONFIG_NSH_MMCSDSLOTNO); + return -ENODEV; + } + + /* Now bind the SDIO interface to the MMC/SD driver */ + int ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, sdio); + + if (ret != OK) { + message("[boot] Failed to bind SDIO to the MMC/SD driver: %d\n", ret); + return ret; + } + + /* Then let's guess and say that there is a card in the slot. There is no card detect GPIO. */ + sdio_mediachange(sdio, true); + +#endif + + return OK; +} diff --git a/src/drivers/boards/px4fmu-v3/px4fmu3_led.c b/src/drivers/boards/px4fmu-v3/px4fmu3_led.c new file mode 100644 index 0000000000..09edb2ba66 --- /dev/null +++ b/src/drivers/boards/px4fmu-v3/px4fmu3_led.c @@ -0,0 +1,96 @@ +/**************************************************************************** + * + * Copyright (c) 2013 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. + * + ****************************************************************************/ + +/** + * @file px4fmu2_led.c + * + * PX4FMU LED backend. + */ + +#include + +#include + +#include "stm32.h" +#include "board_config.h" + +#include + +/* + * Ideally we'd be able to get these from up_internal.h, + * but since we want to be able to disable the NuttX use + * of leds for system indication at will and there is no + * separate switch, we need to build independent of the + * CONFIG_ARCH_LEDS configuration switch. + */ +__BEGIN_DECLS +extern void led_init(void); +extern void led_on(int led); +extern void led_off(int led); +extern void led_toggle(int led); +__END_DECLS + +__EXPORT void led_init() +{ + /* Configure LED1 GPIO for output */ + + stm32_configgpio(GPIO_LED1); +} + +__EXPORT void led_on(int led) +{ + if (led == 1) { + /* Pull down to switch on */ + stm32_gpiowrite(GPIO_LED1, false); + } +} + +__EXPORT void led_off(int led) +{ + if (led == 1) { + /* Pull up to switch off */ + stm32_gpiowrite(GPIO_LED1, true); + } +} + +__EXPORT void led_toggle(int led) +{ + if (led == 1) { + if (stm32_gpioread(GPIO_LED1)) { + stm32_gpiowrite(GPIO_LED1, false); + + } else { + stm32_gpiowrite(GPIO_LED1, true); + } + } +} diff --git a/src/drivers/boards/px4fmu-v3/px4fmu_can.c b/src/drivers/boards/px4fmu-v3/px4fmu_can.c new file mode 100644 index 0000000000..7234c4eb8d --- /dev/null +++ b/src/drivers/boards/px4fmu-v3/px4fmu_can.c @@ -0,0 +1,130 @@ +/**************************************************************************** + * + * Copyright (C) 2012 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. + * + ****************************************************************************/ + +/** + * @file px4fmu_can.c + * + * Board-specific CAN functions. + */ + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +#include +#include + +#include +#include + +#include "chip.h" +#include "up_arch.h" + +#include "stm32.h" +#include "stm32_can.h" +#include "board_config.h" + +#ifdef CONFIG_CAN + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ +/* Configuration ********************************************************************/ + +#if defined(CONFIG_STM32_CAN1) && defined(CONFIG_STM32_CAN2) +# warning "Both CAN1 and CAN2 are enabled. Assuming only CAN1." +# undef CONFIG_STM32_CAN2 +#endif + +#ifdef CONFIG_STM32_CAN1 +# define CAN_PORT 1 +#else +# define CAN_PORT 2 +#endif + +/************************************************************************************ + * Private Functions + ************************************************************************************/ + +/************************************************************************************ + * Public Functions + ************************************************************************************/ +int can_devinit(void); + +/************************************************************************************ + * Name: can_devinit + * + * Description: + * All STM32 architectures must provide the following interface to work with + * examples/can. + * + ************************************************************************************/ + +int can_devinit(void) +{ + static bool initialized = false; + struct can_dev_s *can; + int ret; + + /* Check if we have already initialized */ + + if (!initialized) { + /* Call stm32_caninitialize() to get an instance of the CAN interface */ + + can = stm32_caninitialize(CAN_PORT); + + if (can == NULL) { + canerr("ERROR: Failed to get CAN interface\n"); + return -ENODEV; + } + + /* Register the CAN driver at "/dev/can0" */ + + ret = can_register("/dev/can0", can); + + if (ret < 0) { + canerr("ERROR: can_register failed: %d\n", ret); + return ret; + } + + /* Now we are initialized */ + + initialized = true; + } + + return OK; +} + +#endif diff --git a/src/drivers/boards/px4fmu-v3/px4fmu_spi.c b/src/drivers/boards/px4fmu-v3/px4fmu_spi.c new file mode 100644 index 0000000000..8ad297712f --- /dev/null +++ b/src/drivers/boards/px4fmu-v3/px4fmu_spi.c @@ -0,0 +1,551 @@ +/**************************************************************************** + * + * Copyright (C) 2012 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. + * + ****************************************************************************/ + +/** + * @file px4fmu_spi.c + * + * Board-specific SPI functions. + */ + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include "board_config.h" +#include + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: stm32_spiinitialize + * + * Description: + * Called to configure SPI chip select GPIO pins for the PX4FMU board. + * + ************************************************************************************/ + +#ifdef CONFIG_STM32_SPI1 +/* Verification + * PA5 PA6 PA7 PB0 PB1 PB4 PC1 PC2 PC13 PC14 PC15 PD7 PD15 PE2 PE4 PE5 PE6 + * driver X X X X X X + * local V2 v2 V2 V3 a V2 V2M V2x a a 4 + */ +static void stm32_spi1_initialize(void) +{ + stm32_configgpio(GPIO_SPI1_CS_PC2); + stm32_configgpio(GPIO_SPI1_CS_PD7); + + stm32_configgpio(GPIO_SPI1_EXTI_DRDY_PD15); + +# if !defined(BOARD_HAS_VERSIONING) + stm32_configgpio(GPIO_SPI1_EXTI_DRDY_PB0); + stm32_configgpio(GPIO_SPI1_EXTI_DRDY_PB1); + stm32_configgpio(GPIO_SPI1_EXTI_DRDY_PB4); + stm32_configgpio(GPIO_SPI1_CS_PC13); + stm32_configgpio(GPIO_SPI1_CS_PC15); +# else + + if (HW_VER_FMUV2 == board_get_hw_version()) { + stm32_configgpio(GPIO_SPI1_EXTI_DRDY_PB0); + stm32_configgpio(GPIO_SPI1_EXTI_DRDY_PB1); + stm32_configgpio(GPIO_SPI1_EXTI_DRDY_PB4); + stm32_configgpio(GPIO_SPI1_CS_PC13); + stm32_configgpio(GPIO_SPI1_CS_PC15); + + } else if (HW_VER_FMUV2MINI == board_get_hw_version()) { + stm32_configgpio(GPIO_SPI1_EXTI_20608_DRDY_PC14); + stm32_configgpio(GPIO_SPI1_CS_PC15); + + } else if (HW_VER_FMUV3 == board_get_hw_version()) { + stm32_configgpio(GPIO_SPI1_CS_PC1); + } + +# endif +} +#endif // CONFIG_STM32_SPI1 + +#ifdef CONFIG_STM32_SPI4 +/* Verification + * PA5 PA6 PA7 PB0 PB1 PB4 PC1 PC2 PC13 PC14 PC15 PD7 PD15 PE2 PE4 PE5 PE6 + * driver X X X X X X + * local V3 V3 - V3 a V3 V23 V3 - - + */ +static void stm32_spi4_initialize(void) +{ + stm32_configgpio(GPIO_SPI4_NSS_PE4); + +# if !defined(BOARD_HAS_VERSIONING) + stm32_configgpio(GPIO_SPI4_GPIO_PC14); +# else + + if (HW_VER_FMUV3 == board_get_hw_version()) { + stm32_configgpio(GPIO_SPI4_EXTI_DRDY_PB0); + stm32_configgpio(GPIO_SPI4_CS_PB1); + stm32_configgpio(GPIO_SPI4_CS_PC13); + stm32_configgpio(GPIO_SPI4_CS_PC15); + } + + if (HW_VER_FMUV2MINI != board_get_hw_version()) { + stm32_configgpio(GPIO_SPI4_GPIO_PC14); + } + +# endif +} +#endif //CONFIG_STM32_SPI4 + +__EXPORT void stm32_spiinitialize(void) +{ +#ifdef CONFIG_STM32_SPI1 + stm32_spi1_initialize(); +#endif + +#ifdef CONFIG_STM32_SPI2 + stm32_configgpio(GPIO_SPI2_CS_PD10); +#endif + +#ifdef CONFIG_STM32_SPI4 + stm32_spi4_initialize(); +#endif +} + +#ifdef CONFIG_STM32_SPI1 +__EXPORT void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) +{ + /* SPI select is active low, so write !selected to select the device */ + +# if !defined(BOARD_HAS_VERSIONING) + switch (devid) { + case PX4_SPIDEV_GYRO: + /* Making sure the other peripherals are not selected */ + stm32_gpiowrite(GPIO_SPI1_CS_PC13, !selected); + stm32_gpiowrite(GPIO_SPI1_CS_PC15, 1); + stm32_gpiowrite(GPIO_SPI1_CS_PD7, 1); + stm32_gpiowrite(GPIO_SPI1_CS_PC2, 1); + break; + +# if defined(PX4_SPIDEV_ICM_20608) + + case PX4_SPIDEV_ICM_20608: +# endif + case PX4_SPIDEV_ACCEL_MAG: + /* Making sure the other peripherals are not selected */ + stm32_gpiowrite(GPIO_SPI1_CS_PC13, 1); + stm32_gpiowrite(GPIO_SPI1_CS_PC15, !selected); + stm32_gpiowrite(GPIO_SPI1_CS_PD7, 1); + stm32_gpiowrite(GPIO_SPI1_CS_PC2, 1); + break; + + case PX4_SPIDEV_BARO: + /* Making sure the other peripherals are not selected */ + stm32_gpiowrite(GPIO_SPI1_CS_PC13, 1); + stm32_gpiowrite(GPIO_SPI1_CS_PC15, 1); + stm32_gpiowrite(GPIO_SPI1_CS_PD7, !selected); + stm32_gpiowrite(GPIO_SPI1_CS_PC2, 1); + break; + + case PX4_SPIDEV_MPU: + /* Making sure the other peripherals are not selected */ + stm32_gpiowrite(GPIO_SPI1_CS_PC13, 1); + stm32_gpiowrite(GPIO_SPI1_CS_PC15, 1); + stm32_gpiowrite(GPIO_SPI1_CS_PD7, 1); + stm32_gpiowrite(GPIO_SPI1_CS_PC2, !selected); + break; + + default: + break; + } + +# else // defined(BOARD_HAS_VERSIONING) + + /* SPI select is active low, so write !selected to select the device */ + /* Verification + * PA5 PA6 PA7 PB0 PB1 PB4 PC1 PC2 PC13 PC14 PC15 PD7 PD15 PE2 PE4 PE5 PE6 + * driver X X X X X X + * local - - - V3 a V2 - V2M a - - + */ + + switch (devid) { + case PX4_SPIDEV_GYRO: + + /* Making sure the other peripherals are not selected */ + if (HW_VER_FMUV2 == board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI1_CS_PC13, !selected); + } + + if (HW_VER_FMUV3 != board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI1_CS_PC15, 1); + } + + stm32_gpiowrite(GPIO_SPI1_CS_PD7, 1); + stm32_gpiowrite(GPIO_SPI1_CS_PC2, 1); + + if (HW_VER_FMUV3 == board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI1_CS_PC1, 1); + } + + break; + +# if defined(PX4_SPIDEV_ICM_20608) + + case PX4_SPIDEV_ICM_20608: +# endif + case PX4_SPIDEV_ACCEL_MAG: + + /* Making sure the other peripherals are not selected */ + if (HW_VER_FMUV2 == board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI1_CS_PC13, 1); + } + + if (HW_VER_FMUV3 != board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI1_CS_PC15, !selected); + } + + stm32_gpiowrite(GPIO_SPI1_CS_PD7, 1); + stm32_gpiowrite(GPIO_SPI1_CS_PC2, 1); + + if (HW_VER_FMUV3 == board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI1_CS_PC1, 1); + } + + break; + + case PX4_SPIDEV_BARO: + + /* Making sure the other peripherals are not selected */ + if (HW_VER_FMUV2 == board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI1_CS_PC13, 1); + } + + if (HW_VER_FMUV3 != board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI1_CS_PC15, 1); + } + + stm32_gpiowrite(GPIO_SPI1_CS_PD7, !selected); + stm32_gpiowrite(GPIO_SPI1_CS_PC2, 1); + + if (HW_VER_FMUV3 == board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI1_CS_PC1, 1); + } + + break; + + case PX4_SPIDEV_MPU: + + /* Making sure the other peripherals are not selected */ + if (HW_VER_FMUV2 == board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI1_CS_PC13, 1); + } + + if (HW_VER_FMUV3 != board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI1_CS_PC15, 1); + } + + stm32_gpiowrite(GPIO_SPI1_CS_PD7, 1); + stm32_gpiowrite(GPIO_SPI1_CS_PC2, !selected); + + if (HW_VER_FMUV3 == board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI1_CS_PC1, 1); + } + + break; + + case PX4_SPIDEV_HMC: + if (HW_VER_FMUV2 == board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI1_CS_PC13, 1); + } + + if (HW_VER_FMUV3 != board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI1_CS_PC15, 1); + } + + stm32_gpiowrite(GPIO_SPI1_CS_PD7, 1); + stm32_gpiowrite(GPIO_SPI1_CS_PC2, 1); + + if (HW_VER_FMUV3 == board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI1_CS_PC1, !selected); + } + + break; + + default: + break; + } + +# endif // defined(BOARD_HAS_VERSIONING) +} + +__EXPORT uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) +{ + return SPI_STATUS_PRESENT; +} +#endif // CONFIG_STM32_SPI1 + +#ifdef CONFIG_STM32_SPI2 +__EXPORT void stm32_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) +{ + /* there can only be one device on this bus, so always select it */ + stm32_gpiowrite(GPIO_SPI2_CS_PD10, !selected); +} + +__EXPORT uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, uint32_t devid) +{ + /* FRAM is always present */ + return SPI_STATUS_PRESENT; +} +#endif + + +#ifdef CONFIG_STM32_SPI4 +__EXPORT void stm32_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) +{ + /* SPI select is active low, so write !selected to select the device */ + +# if !defined(BOARD_HAS_VERSIONING) + switch (devid) { + case PX4_SPIDEV_EXT_MPU: + /* Making sure the other peripherals are not selected */ + stm32_gpiowrite(GPIO_SPI4_NSS_PE4, !selected); + stm32_gpiowrite(GPIO_SPI4_GPIO_PC14, 1); + break; + + case PX4_SPIDEV_EXT_BARO: + /* Making sure the other peripherals are not selected */ + stm32_gpiowrite(GPIO_SPI4_NSS_PE4, 1); + stm32_gpiowrite(GPIO_SPI4_GPIO_PC14, !selected); + break; + + default: + break; + + } + +# else // defined(BOARD_HAS_VERSIONING) + /* SPI select is active low, so write !selected to select the device */ + /* Verification + * PA5 PA6 PA7 PB0 PB1 PB4 PC1 PC2 PC13 PC14 PC15 PD7 PD15 PE2 PE4 PE5 PE6 + * driver X X X X X X + * local - - - - - V3 !V2M V3 - - a + */ + + switch (devid) { + case PX4_SPIDEV_EXT_MPU: + /* Making sure the other peripherals are not selected */ + stm32_gpiowrite(GPIO_SPI4_NSS_PE4, !selected); + + if (HW_VER_FMUV2MINI != board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI4_GPIO_PC14, 1); + } + + if (HW_VER_FMUV3 == board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI4_CS_PC15, 1); + stm32_gpiowrite(GPIO_SPI4_CS_PC13, 1); + } + + break; + + case PX4_SPIDEV_EXT_BARO: + /* Making sure the other peripherals are not selected */ + stm32_gpiowrite(GPIO_SPI4_NSS_PE4, 1); + + if (HW_VER_FMUV2MINI != board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI4_GPIO_PC14, !selected); + } + + if (HW_VER_FMUV3 == board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI4_CS_PC15, 1); + stm32_gpiowrite(GPIO_SPI4_CS_PC13, 1); + } + + break; + +# if defined(PX4_SPIDEV_ICM_20608) + + case PX4_SPIDEV_ICM_20608: +# endif + case PX4_SPIDEV_EXT_ACCEL_MAG: + /* Making sure the other peripherals are not selected */ + stm32_gpiowrite(GPIO_SPI4_NSS_PE4, 1); + + if (HW_VER_FMUV2MINI != board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI4_GPIO_PC14, 1); + } + + if (HW_VER_FMUV3 == board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI4_CS_PC15, !selected); + stm32_gpiowrite(GPIO_SPI4_CS_PC13, 1); + } + + break; + + case PX4_SPIDEV_EXT_BMI: + case PX4_SPIDEV_EXT_GYRO: + /* Making sure the other peripherals are not selected */ + stm32_gpiowrite(GPIO_SPI4_NSS_PE4, 1); + + if (HW_VER_FMUV2MINI != board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI4_GPIO_PC14, 1); + } + + if (HW_VER_FMUV3 == board_get_hw_version()) { + stm32_gpiowrite(GPIO_SPI4_CS_PC15, 1); + stm32_gpiowrite(GPIO_SPI4_CS_PC13, !selected); + } + + break; + + default: + break; + + } + +# endif // defined(BOARD_HAS_VERSIONING) + +} +__EXPORT uint8_t stm32_spi4status(FAR struct spi_dev_s *dev, uint32_t devid) +{ + return SPI_STATUS_PRESENT; +} +#endif // CONFIG_STM32_SPI4 + +/* V2, V2M SPI1 All signals SPI4, V3 ALL signals */ +/* Verification + * PA5 PA6 PA7 PB0 PB1 PB4 PC1 PC2 PC13 PC14 PC15 PD7 PD15 PE2 PE4 PE5 PE6 + * local A A A A A A V3 A A !V2 A A A V3 V3 V3 V3 + */ + +__EXPORT void board_spi_reset(int ms) +{ + /* disable SPI bus */ + stm32_configgpio(_PIN_OFF(GPIO_SPI1_CS_PC2)); + stm32_configgpio(_PIN_OFF(GPIO_SPI1_CS_PC13)); + stm32_configgpio(_PIN_OFF(GPIO_SPI1_CS_PC15)); + stm32_configgpio(_PIN_OFF(GPIO_SPI1_CS_PD7)); + + stm32_gpiowrite(_PIN_OFF(GPIO_SPI1_CS_PC2), 0); + stm32_gpiowrite(_PIN_OFF(GPIO_SPI1_CS_PC13), 0); + stm32_gpiowrite(_PIN_OFF(GPIO_SPI1_CS_PC15), 0); + stm32_gpiowrite(_PIN_OFF(GPIO_SPI1_CS_PD7), 0); + + stm32_configgpio(_PIN_OFF(GPIO_SPI1_SCK)); + stm32_configgpio(_PIN_OFF(GPIO_SPI1_MISO)); + stm32_configgpio(_PIN_OFF(GPIO_SPI1_MOSI)); + + stm32_gpiowrite(_PIN_OFF(GPIO_SPI1_SCK), 0); + stm32_gpiowrite(_PIN_OFF(GPIO_SPI1_MISO), 0); + stm32_gpiowrite(_PIN_OFF(GPIO_SPI1_MOSI), 0); + + stm32_configgpio(_PIN_OFF(GPIO_SPI1_EXTI_DRDY_PB0)); + stm32_configgpio(_PIN_OFF(GPIO_SPI1_EXTI_DRDY_PB1)); + stm32_configgpio(_PIN_OFF(GPIO_SPI1_EXTI_DRDY_PB4)); + stm32_configgpio(_PIN_OFF(GPIO_SPI1_EXTI_DRDY_PD15)); + + stm32_gpiowrite(_PIN_OFF(GPIO_SPI1_EXTI_DRDY_PB0), 0); + stm32_gpiowrite(_PIN_OFF(GPIO_SPI1_EXTI_DRDY_PB1), 0); + stm32_gpiowrite(_PIN_OFF(GPIO_SPI1_EXTI_DRDY_PB4), 0); + stm32_gpiowrite(_PIN_OFF(GPIO_SPI1_EXTI_DRDY_PD15), 0); + +#if defined(BOARD_HAS_VERSIONING) + + if (HW_VER_FMUV2 != board_get_hw_version()) { + stm32_configgpio(_PIN_OFF(GPIO_SPI4_CS_PC14)); + stm32_gpiowrite(_PIN_OFF(GPIO_SPI4_CS_PC14), 0); + } + + if (HW_VER_FMUV3 == board_get_hw_version()) { + stm32_configgpio(_PIN_OFF(GPIO_SPI1_CS_PC1)); + stm32_gpiowrite(_PIN_OFF(GPIO_SPI1_CS_PC1), 0); + + stm32_configgpio(_PIN_OFF(GPIO_SPI4_NSS_PE4)); + stm32_gpiowrite(_PIN_OFF(GPIO_SPI4_NSS_PE4), 0); + + stm32_configgpio(_PIN_OFF(GPIO_SPI4_SCK)); + stm32_configgpio(_PIN_OFF(GPIO_SPI4_MISO)); + stm32_configgpio(_PIN_OFF(GPIO_SPI4_MOSI)); + + stm32_gpiowrite(_PIN_OFF(GPIO_SPI4_SCK), 0); + stm32_gpiowrite(_PIN_OFF(GPIO_SPI4_MISO), 0); + stm32_gpiowrite(_PIN_OFF(GPIO_SPI4_MOSI), 0); + + } + +#endif + + /* set the sensor rail off */ + stm32_configgpio(GPIO_VDD_3V3_SENSORS_EN); + stm32_gpiowrite(GPIO_VDD_3V3_SENSORS_EN, 0); + + /* wait for the sensor rail to reach GND */ + usleep(ms * 1000); + warnx("reset done, %d ms", ms); + + /* re-enable power */ + + /* switch the sensor rail back on */ + stm32_gpiowrite(GPIO_VDD_3V3_SENSORS_EN, 1); + + /* wait a bit before starting SPI, different times didn't influence results */ + usleep(100); + + /* reconfigure the SPI pins */ + stm32_configgpio(GPIO_SPI1_SCK); + stm32_configgpio(GPIO_SPI1_MISO); + stm32_configgpio(GPIO_SPI1_MOSI); + +#if defined(BOARD_HAS_VERSIONING) + + if (HW_VER_FMUV3 == board_get_hw_version()) { + stm32_configgpio(GPIO_SPI4_SCK); + stm32_configgpio(GPIO_SPI4_MISO); + stm32_configgpio(GPIO_SPI4_MOSI); + stm32_spi4_initialize(); + } + +#endif + + stm32_spi1_initialize(); +} diff --git a/src/drivers/boards/px4fmu-v3/px4fmu_timer_config.c b/src/drivers/boards/px4fmu-v3/px4fmu_timer_config.c new file mode 100644 index 0000000000..5adc4260db --- /dev/null +++ b/src/drivers/boards/px4fmu-v3/px4fmu_timer_config.c @@ -0,0 +1,126 @@ +/**************************************************************************** + * + * Copyright (C) 2012 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. + * + ****************************************************************************/ + +/* + * @file px4fmu_timer_config.c + * + * Configuration data for the stm32 pwm_servo, input capture and pwm input driver. + * + * Note that these arrays must always be fully-sized. + */ + +#include + +#include +#include +#include + +#include +#include + +#include "board_config.h" + +__EXPORT const io_timers_t io_timers[MAX_IO_TIMERS] = { + { + .base = STM32_TIM1_BASE, + .clock_register = STM32_RCC_APB2ENR, + .clock_bit = RCC_APB2ENR_TIM1EN, + .clock_freq = STM32_APB2_TIM1_CLKIN, + .first_channel_index = 0, + .last_channel_index = 3, + .handler = io_timer_handler0, + .vectorno = STM32_IRQ_TIM1CC, + + }, + { + .base = STM32_TIM4_BASE, + .clock_register = STM32_RCC_APB1ENR, + .clock_bit = RCC_APB1ENR_TIM4EN, + .clock_freq = STM32_APB1_TIM4_CLKIN, + .first_channel_index = 4, + .last_channel_index = 5, + .handler = io_timer_handler1, + .vectorno = STM32_IRQ_TIM4 + } +}; + +__EXPORT const timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = { + { + .gpio_out = GPIO_TIM1_CH4OUT, + .gpio_in = GPIO_TIM1_CH4IN, + .timer_index = 0, + .timer_channel = 4, + .ccr_offset = STM32_GTIM_CCR4_OFFSET, + .masks = GTIM_SR_CC4IF | GTIM_SR_CC4OF + }, + { + .gpio_out = GPIO_TIM1_CH3OUT, + .gpio_in = GPIO_TIM1_CH3IN, + .timer_index = 0, + .timer_channel = 3, + .ccr_offset = STM32_GTIM_CCR3_OFFSET, + .masks = GTIM_SR_CC3IF | GTIM_SR_CC3OF + }, + { + .gpio_out = GPIO_TIM1_CH2OUT, + .gpio_in = GPIO_TIM1_CH2IN, + .timer_index = 0, + .timer_channel = 2, + .ccr_offset = STM32_GTIM_CCR2_OFFSET, + .masks = GTIM_SR_CC2IF | GTIM_SR_CC2OF + }, + { + .gpio_out = GPIO_TIM1_CH1OUT, + .gpio_in = GPIO_TIM1_CH1IN, + .timer_index = 0, + .timer_channel = 1, + .ccr_offset = STM32_GTIM_CCR1_OFFSET, + .masks = GTIM_SR_CC1IF | GTIM_SR_CC1OF + }, + { + .gpio_out = GPIO_TIM4_CH2OUT, + .gpio_in = GPIO_TIM4_CH2IN, + .timer_index = 1, + .timer_channel = 2, + .ccr_offset = STM32_GTIM_CCR2_OFFSET, + .masks = GTIM_SR_CC2IF | GTIM_SR_CC2OF + }, + { + .gpio_out = GPIO_TIM4_CH3OUT, + .gpio_in = GPIO_TIM4_CH3IN, + .timer_index = 1, + .timer_channel = 3, + .ccr_offset = STM32_GTIM_CCR3_OFFSET, + .masks = GTIM_SR_CC3IF | GTIM_SR_CC3OF + } +}; diff --git a/src/drivers/boards/px4fmu-v3/px4fmu_usb.c b/src/drivers/boards/px4fmu-v3/px4fmu_usb.c new file mode 100644 index 0000000000..4b455309db --- /dev/null +++ b/src/drivers/boards/px4fmu-v3/px4fmu_usb.c @@ -0,0 +1,107 @@ +/**************************************************************************** + * + * Copyright (C) 2012 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. + * + ****************************************************************************/ + +/** + * @file px4fmu_usb.c + * + * Board-specific USB functions. + */ + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include "board_config.h" + +/************************************************************************************ + * Definitions + ************************************************************************************/ + +/************************************************************************************ + * Private Functions + ************************************************************************************/ + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: stm32_usbinitialize + * + * Description: + * Called to setup USB-related GPIO pins for the PX4FMU board. + * + ************************************************************************************/ + +__EXPORT void stm32_usbinitialize(void) +{ + /* The OTG FS has an internal soft pull-up */ + + /* Configure the OTG FS VBUS sensing GPIO, Power On, and Overcurrent GPIOs */ + +#ifdef CONFIG_STM32_OTGFS + stm32_configgpio(GPIO_OTGFS_VBUS); + /* XXX We only support device mode + stm32_configgpio(GPIO_OTGFS_PWRON); + stm32_configgpio(GPIO_OTGFS_OVER); + */ +#endif +} + +/************************************************************************************ + * Name: stm32_usbsuspend + * + * Description: + * Board logic must provide the stm32_usbsuspend logic if the USBDEV driver is + * used. This function is called whenever the USB enters or leaves suspend mode. + * This is an opportunity for the board logic to shutdown clocks, power, etc. + * while the USB is suspended. + * + ************************************************************************************/ + +__EXPORT void stm32_usbsuspend(FAR struct usbdev_s *dev, bool resume) +{ + uinfo("resume: %d\n", resume); +} diff --git a/src/drivers/boards/px4fmu-v4/CMakeLists.txt b/src/drivers/boards/px4fmu-v4/CMakeLists.txt index 3fd1d9bf96..bdfd0f283e 100644 --- a/src/drivers/boards/px4fmu-v4/CMakeLists.txt +++ b/src/drivers/boards/px4fmu-v4/CMakeLists.txt @@ -32,13 +32,7 @@ ############################################################################ px4_add_module( MODULE drivers__boards__px4fmu-v4 - COMPILE_FLAGS SRCS - ../common/stm32/board_reset.c - ../common/stm32/board_identity.c - ../common/stm32/board_mcu_version.c - ../common/board_crashdump.c - ../common/board_dma_alloc.c px4fmu_can.c px4fmu_init.c px4fmu_timer_config.c @@ -47,5 +41,4 @@ px4_add_module( px4fmu_led.c DEPENDS platforms__common - ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : + ) \ No newline at end of file diff --git a/src/drivers/boards/px4fmu-v4pro/CMakeLists.txt b/src/drivers/boards/px4fmu-v4pro/CMakeLists.txt index 4ee0fb0b3c..3eb7364c62 100644 --- a/src/drivers/boards/px4fmu-v4pro/CMakeLists.txt +++ b/src/drivers/boards/px4fmu-v4pro/CMakeLists.txt @@ -32,13 +32,7 @@ ############################################################################ px4_add_module( MODULE drivers__boards__px4fmu-v4pro - COMPILE_FLAGS SRCS - ../common/stm32/board_reset.c - ../common/stm32/board_identity.c - ../common/stm32/board_mcu_version.c - ../common/board_crashdump.c - ../common/board_dma_alloc.c px4fmu_can.c px4fmu_init.c px4fmu_timer_config.c @@ -47,5 +41,4 @@ px4_add_module( px4fmu_led.c DEPENDS platforms__common - ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : + ) \ No newline at end of file diff --git a/src/drivers/boards/px4fmu-v5/CMakeLists.txt b/src/drivers/boards/px4fmu-v5/CMakeLists.txt index e772cf7f67..a3f31de9cb 100644 --- a/src/drivers/boards/px4fmu-v5/CMakeLists.txt +++ b/src/drivers/boards/px4fmu-v5/CMakeLists.txt @@ -32,14 +32,7 @@ ############################################################################ px4_add_module( MODULE drivers__boards__px4fmu-v5 - COMPILE_FLAGS SRCS - ../common/stm32/board_reset.c - ../common/stm32/board_identity.c - ../common/stm32/board_mcu_version.c - ../common/board_crashdump.c - ../common/board_dma_alloc.c - ../common/board_gpio_init.c # WIP px4fmu_can.c px4fmu_init.c px4fmu_sdio.c @@ -49,4 +42,4 @@ px4_add_module( px4fmu_led.c DEPENDS platforms__common - ) + ) \ No newline at end of file diff --git a/src/drivers/boards/px4io-v2/CMakeLists.txt b/src/drivers/boards/px4io-v2/CMakeLists.txt index 01d9f37205..8a4ddb6aa8 100644 --- a/src/drivers/boards/px4io-v2/CMakeLists.txt +++ b/src/drivers/boards/px4io-v2/CMakeLists.txt @@ -32,11 +32,9 @@ ############################################################################ px4_add_module( MODULE drivers__boards__px4io-v2 - COMPILE_FLAGS SRCS - px4iov2_init.c - px4iov2_timer_config.c + px4io_init.c + px4io_timer_config.c DEPENDS platforms__common - ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : + ) \ No newline at end of file diff --git a/src/drivers/boards/px4io-v2/board_config.h b/src/drivers/boards/px4io-v2/board_config.h index 2ccc26764b..c3acc51244 100644 --- a/src/drivers/boards/px4io-v2/board_config.h +++ b/src/drivers/boards/px4io-v2/board_config.h @@ -47,6 +47,8 @@ #include #include +#include "../common/board_common.h" + /****************************************************************************** * Definitions ******************************************************************************/ diff --git a/src/drivers/boards/px4nucleoF767ZI-v1/CMakeLists.txt b/src/drivers/boards/px4nucleoF767ZI-v1/CMakeLists.txt index 3f1618aaa1..bd08cf3942 100644 --- a/src/drivers/boards/px4nucleoF767ZI-v1/CMakeLists.txt +++ b/src/drivers/boards/px4nucleoF767ZI-v1/CMakeLists.txt @@ -32,13 +32,7 @@ ############################################################################ px4_add_module( MODULE drivers__boards__px4nucleoF767ZI-v1 - COMPILE_FLAGS SRCS - ../common/stm32/board_reset.c - ../common/stm32/board_identity.c - ../common/stm32/board_mcu_version.c - ../common/board_crashdump.c - ../common/board_dma_alloc.c # WIP px4nucleo_can.c px4nucleo_init.c px4nucleo_sdio.c @@ -48,4 +42,4 @@ px4_add_module( px4nucleo_led.c DEPENDS platforms__common - ) + ) \ No newline at end of file diff --git a/src/drivers/boards/s2740vc-v1/CMakeLists.txt b/src/drivers/boards/s2740vc-v1/CMakeLists.txt index 0f5502d542..5de0a80020 100644 --- a/src/drivers/boards/s2740vc-v1/CMakeLists.txt +++ b/src/drivers/boards/s2740vc-v1/CMakeLists.txt @@ -42,35 +42,12 @@ message(WARNING-"Configuraton is incomplete") message(WARNING-"Configuraton is incomplete") message(WARNING-"Configuraton is incomplete") -include_directories(../../bootloaders/include) - -set(SRCS) -list(APPEND SRCS - ../common/stm32/board_reset.c - s2740vc_init.c - s2740vc_can.c - ../../../drivers/bootloaders/src/common/boot_app_shared.c - ../../../drivers/bootloaders/src/util/crc.c -) - -if(${OS} STREQUAL "nuttx") - if (NOT ${BOARD} STREQUAL "sim") - list(APPEND SRCS - ../../../drivers/device/device_nuttx.cpp - ../../../drivers/device/cdev.cpp - ) - endif() -else() - list(APPEND SRCS - ../../../drivers/device/device_posix.cpp - ../../../drivers/device/vdev.cpp - ) -endif() - px4_add_module( MODULE drivers__boards__s2740vc-v1 - COMPILE_FLAGS - SRCS ${SRCS} + SRCS + s2740vc_init.c + s2740vc_can.c DEPENDS platforms__common ) +include_directories(bootloader) \ No newline at end of file diff --git a/src/drivers/boards/s2740vc-v1/bootloader/CMakeLists.txt b/src/drivers/boards/s2740vc-v1/bootloader/CMakeLists.txt index a6a15bf9b3..55a2f2fc54 100644 --- a/src/drivers/boards/s2740vc-v1/bootloader/CMakeLists.txt +++ b/src/drivers/boards/s2740vc-v1/bootloader/CMakeLists.txt @@ -31,35 +31,11 @@ # ############################################################################ - -add_definitions( - -DHW_UAVCAN_NAME=${uavcanblid_name} - -DHW_VERSION_MAJOR=${uavcanblid_hw_version_major} - -DHW_VERSION_MINOR=${uavcanblid_hw_version_minor} -) - -include_directories(${px4_bootloader_base}include) -include_directories(${px4_module_base}systemlib) -include_directories(.) - px4_add_module( MODULE drivers__boards__s2740vc-v1__bootloader - COMPILE_FLAGS SRCS boot.c - ../../common/stm32/board_identity.c - ${px4_bootloader_base}src/uavcan/main.c - ${px4_bootloader_base}src/common/boot_app_shared.c - ${px4_bootloader_base}src/common/nuttx_stubs.c - ${px4_bootloader_base}src/sched/timer.c - ${px4_bootloader_base}src/fs/flash.c - ${px4_bootloader_base}src/util/crc.c - ${px4_bootloader_base}src/util/random.c - ${px4_bootloader_base}src/arch/stm32/drivers/can/driver.c - ${px4_bootloader_base}src/protocol/uavcan.c DEPENDS - nuttx_export_${BOARD} + nuttx_build ) - - -# vim: set noet ft=cmake fenc=utf-8 ff=unix : +target_link_libraries(drivers__boards__s2740vc-v1__bootloader drivers_bootloaders) \ No newline at end of file diff --git a/src/drivers/boards/tap-v1/CMakeLists.txt b/src/drivers/boards/tap-v1/CMakeLists.txt index ac1a95751a..3997902b73 100644 --- a/src/drivers/boards/tap-v1/CMakeLists.txt +++ b/src/drivers/boards/tap-v1/CMakeLists.txt @@ -33,13 +33,7 @@ ############################################################################ px4_add_module( MODULE drivers__boards__tap-v1 - COMPILE_FLAGS SRCS - ../common/stm32/board_reset.c - ../common/stm32/board_identity.c - ../common/stm32/board_mcu_version.c - ../common/board_crashdump.c - ../common/board_dma_alloc.c tap_init.c tap_pwr.c tap_sdio.c @@ -49,5 +43,4 @@ px4_add_module( tap_led.c DEPENDS platforms__common - ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : + ) \ No newline at end of file diff --git a/src/drivers/boards/zubaxgnss-v1/CMakeLists.txt b/src/drivers/boards/zubaxgnss-v1/CMakeLists.txt index 3a96116a3a..938f6a7e5c 100644 --- a/src/drivers/boards/zubaxgnss-v1/CMakeLists.txt +++ b/src/drivers/boards/zubaxgnss-v1/CMakeLists.txt @@ -33,35 +33,12 @@ message(FATAL_ERROR Configuraton is incomplete") -include_directories(../../bootloaders/include) - -set(SRCS) -list(APPEND SRCS - ../common/stm32/board_reset.c - zubax_gnss_init.c - zubax_gnss_led.c - ../../../drivers/bootloaders/src/common/boot_app_shared.c - ../../../drivers/bootloaders/src/util/crc.c -) - -if(${OS} STREQUAL "nuttx") - if (NOT ${BOARD} STREQUAL "sim") - list(APPEND SRCS - ../../../drivers/device/device_nuttx.cpp - ../../../drivers/device/cdev.cpp - ) - endif() -else() - list(APPEND SRCS - ../../../drivers/device/device_posix.cpp - ../../../drivers/device/vdev.cpp - ) -endif() - px4_add_module( MODULE drivers__boards__zubaxgnss-v1 - COMPILE_FLAGS - SRCS ${SRCS} + SRCS + zubax_gnss_init.c + zubax_gnss_led.c DEPENDS platforms__common ) +include_directories(bootloader) \ No newline at end of file diff --git a/src/drivers/boards/zubaxgnss-v1/bootloader/CMakeLists.txt b/src/drivers/boards/zubaxgnss-v1/bootloader/CMakeLists.txt index 963e761748..08b3422dd1 100644 --- a/src/drivers/boards/zubaxgnss-v1/bootloader/CMakeLists.txt +++ b/src/drivers/boards/zubaxgnss-v1/bootloader/CMakeLists.txt @@ -31,36 +31,12 @@ # ############################################################################ - -add_definitions( - -DHW_UAVCAN_NAME=${uavcanblid_name} - -DHW_VERSION_MAJOR=${uavcanblid_hw_version_major} - -DHW_VERSION_MINOR=${uavcanblid_hw_version_minor} -) - -include_directories(${px4_bootloader_base}include) -include_directories(${px4_module_base}systemlib) -include_directories(.) - px4_add_module( MODULE drivers__boards__zubaxgnss-v1__bootloader - COMPILE_FLAGS SRCS boot.c led.c - ../../common/stm32/board_identity.c - ${px4_bootloader_base}src/uavcan/main.c - ${px4_bootloader_base}src/common/boot_app_shared.c - ${px4_bootloader_base}src/common/nuttx_stubs.c - ${px4_bootloader_base}src/sched/timer.c - ${px4_bootloader_base}src/fs/flash.c - ${px4_bootloader_base}src/util/crc.c - ${px4_bootloader_base}src/util/random.c - ${px4_bootloader_base}src/arch/stm32/drivers/can/driver.c - ${px4_bootloader_base}src/protocol/uavcan.c DEPENDS - nuttx_export_${BOARD} + nuttx_build ) - - -# vim: set noet ft=cmake fenc=utf-8 ff=unix : +target_link_libraries(drivers__boards__zubaxgnss-v1__bootloader drivers_bootloaders) \ No newline at end of file diff --git a/src/drivers/bootloaders/CMakeLists.txt b/src/drivers/bootloaders/CMakeLists.txt new file mode 100644 index 0000000000..e699cbdccf --- /dev/null +++ b/src/drivers/bootloaders/CMakeLists.txt @@ -0,0 +1,48 @@ +############################################################################ +# +# Copyright (c) 2017 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_library(drivers_bootloaders + src/arch/stm32/drivers/can/driver.c + src/common/boot_app_shared.c + src/common/nuttx_stubs.c + src/fs/flash.c + src/protocol/uavcan.c + src/sched/timer.c + src/uavcan/main.c + src/util/crc.c + src/util/random.c + ) +add_dependencies(drivers_bootloaders nuttx_build) + +include_directories(include) +target_include_directories(drivers_bootloaders INTERFACE include) diff --git a/src/drivers/bootloaders/include/uavcan.h b/src/drivers/bootloaders/include/uavcan.h index 7a00e52d36..050a663859 100644 --- a/src/drivers/bootloaders/include/uavcan.h +++ b/src/drivers/bootloaders/include/uavcan.h @@ -111,7 +111,7 @@ #include "bitminip.h" #include "can.h" -#include "px4_macros.h" +#include "systemlib/px4_macros.h" /**************************************************************************** * Pre-processor Definitions diff --git a/src/drivers/bootloaders/src/arch/stm32/drivers/can/driver.c b/src/drivers/bootloaders/src/arch/stm32/drivers/can/driver.c index 27e8a83952..42bd59da09 100644 --- a/src/drivers/bootloaders/src/arch/stm32/drivers/can/driver.c +++ b/src/drivers/bootloaders/src/arch/stm32/drivers/can/driver.c @@ -53,7 +53,7 @@ #include "nvic.h" #include "board.h" -#include "px4_macros.h" +#include "systemlib/px4_macros.h" #include "can.h" #include "crc.h" #include "timer.h" diff --git a/src/drivers/bootloaders/src/sched/timer.c b/src/drivers/bootloaders/src/sched/timer.c index fbbcea6129..4d09e65979 100644 --- a/src/drivers/bootloaders/src/sched/timer.c +++ b/src/drivers/bootloaders/src/sched/timer.c @@ -54,7 +54,7 @@ #include #include -#include "px4_macros.h" +#include "systemlib/px4_macros.h" #include "timer.h" #include "nvic.h" diff --git a/src/drivers/device/CMakeLists.txt b/src/drivers/device/CMakeLists.txt index 872e4c682d..0d55c0e1ca 100644 --- a/src/drivers/device/CMakeLists.txt +++ b/src/drivers/device/CMakeLists.txt @@ -39,13 +39,15 @@ list(APPEND SRCS ) if(${OS} STREQUAL "nuttx") - if (NOT ${BOARD} STREQUAL "sim") - list(APPEND SRCS - device_nuttx.cpp - cdev.cpp - i2c_nuttx.cpp - spi.cpp - ) + list(APPEND SRCS + device_nuttx.cpp + cdev.cpp + ) + if ("${CONFIG_I2C}" STREQUAL "y") + list(APPEND SRCS i2c_nuttx.cpp) + endif() + if ("${CONFIG_SPI}" STREQUAL "y") + list(APPEND SRCS spi.cpp) endif() else() list(APPEND SRCS @@ -56,6 +58,7 @@ else() i2c_posix.cpp sim.cpp ) + endif() px4_add_module( @@ -63,5 +66,4 @@ px4_add_module( SRCS ${SRCS} DEPENDS platforms__common - ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : + ) \ No newline at end of file diff --git a/src/drivers/px4io/CMakeLists.txt b/src/drivers/px4io/CMakeLists.txt index 3b2c40a788..dbadf15a66 100644 --- a/src/drivers/px4io/CMakeLists.txt +++ b/src/drivers/px4io/CMakeLists.txt @@ -42,4 +42,28 @@ px4_add_module( DEPENDS platforms__common ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : + +# include the px4io binary in ROMFS +message(STATUS "Building and including ${config_io_board}") + +set(fw_io_exe "${PX4_SOURCE_DIR}/build/${config_io_board}_default/nuttx_${config_io_board}_default.elf") +set(fw_io_bin "${PX4_BINARY_DIR}/ROMFS/${config_romfs_root}/extras/${config_io_board}.bin") + +file(GLOB_RECURSE px4io_driver_files ${PX4_SOURCE_DIR}/src/drivers/boards/${config_io_board}/*) +file(GLOB_RECURSE px4io_config_files ${PX4_SOURCE_DIR}/platforms/nuttx/NuttX/configs/${config_io_board}/*) +file(GLOB_RECURSE px4io_firmware_files ${PX4_SOURCE_DIR}/src/modules/px4iofirmware/*) +file(GLOB_RECURSE px4io_rc_files ${PX4_SOURCE_DIR}/src/lib/rc/*) +add_custom_command(OUTPUT ${fw_io_exe} + COMMAND make --no-print-directory ${config_io_board}_default + DEPENDS ${px4io_driver_files} ${px4io_config_files} ${px4io_firmware_files} ${px4io_rc_files} + WORKING_DIRECTORY ${PX4_SOURCE_DIR} + COMMENT "Building ${config_io_board}" + USES_TERMINAL + ) +add_custom_command(OUTPUT ${fw_io_bin} + COMMAND mkdir -p ${PX4_BINARY_DIR}/ROMFS/${config_romfs_root}/extras/ + COMMAND ${OBJCOPY} -O binary ${fw_io_exe} ${fw_io_bin} + DEPENDS ${fw_io_exe} + COMMENT "Copying ${config_io_board} to ROMFS extras" + ) +add_custom_target(copy_px4io_bin DEPENDS ${fw_io_bin}) diff --git a/src/firmware/nuttx/CMakeLists.txt b/src/firmware/nuttx/CMakeLists.txt index ef8cefd511..5c4ec3cb1e 100644 --- a/src/firmware/nuttx/CMakeLists.txt +++ b/src/firmware/nuttx/CMakeLists.txt @@ -1,175 +1,141 @@ - include(common/px4_upload) -px4_nuttx_generate_builtin_commands( - OUT builtin_commands.c - MODULE_LIST - ${module_libraries} - ${config_extra_builtin_cmds} - ) - # add executable -add_executable(firmware_nuttx - builtin_commands.c) +set(fw_name ${CONFIG}.elf) +add_executable(${fw_name} ${PX4_SOURCE_DIR}/nuttx-configs/${BOARD}/src/empty.c) +get_property(module_libraries GLOBAL PROPERTY PX4_LIBRARIES) -set(nuttx_export_dir ${PX4_BINARY_DIR}/${BOARD}/NuttX/nuttx/nuttx-export) +# build NuttX +add_subdirectory(${PX4_SOURCE_DIR}/platforms/nuttx/NuttX ${PX4_BINARY_DIR}/NuttX) -set(link_libs - apps nuttx m gcc +# Bootloaders use a different ld file, a separate startup file +# and need to override the os version of sched_process_timer +if ("${nuttx_config_type}" STREQUAL "bootloader") + target_link_libraries(${fw_name} + -T${PX4_BINARY_DIR}/NuttX/nuttx/configs/${BOARD}/scripts/bootloaderld.script + -Wl,-Map=${PX4_BINARY_DIR}/${CONFIG}.map + -Wl,-wrap,sched_process_timer -Wl,-wrap,sem_post -Wl,-wrap,sem_wait + -Wl,--warn-common + -Wl,--gc-sections + -Wl,--start-group + ${module_libraries} + nuttx_arch + nuttx_board + nuttx_c + nuttx_sched + nuttx_startup + -Wl,--end-group + ) +else() + target_link_libraries(${fw_name} + -T${PX4_BINARY_DIR}/NuttX/nuttx/configs/${BOARD}/scripts/ld.script + -Wl,-Map=${PX4_BINARY_DIR}/${CONFIG}.map + -Wl,--warn-common + -Wl,--gc-sections + -Wl,--start-group + ${module_libraries} + nuttx_apps + nuttx_arch + nuttx_binfmt + nuttx_binfmt + nuttx_board + nuttx_c + nuttx_configs + nuttx_cxx + nuttx_drivers + nuttx_fs + nuttx_mm + nuttx_sched + -Wl,--end-group + m + gcc + ) +endif() + +if (config_romfs_root) + add_subdirectory(${PX4_SOURCE_DIR}/ROMFS ${PX4_BINARY_DIR}/ROMFS) + target_link_libraries(${fw_name} romfs) + if (config_io_board) + add_dependencies(romfs copy_px4io_bin) + endif() +endif() + +# create px4 file (combined firmware and metadata) +# +# Bootloaders do not need .px4 or xml +if("${nuttx_config_type}" STREQUAL "nsh" AND NOT ${CONFIG} MATCHES "px4io") + set(fw_file ${PX4_BINARY_DIR}/${CONFIG}.px4) + + add_custom_command(OUTPUT ${BOARD}.bin + COMMAND ${OBJCOPY} -O binary ${PX4_BINARY_DIR}/${fw_name} ${BOARD}.bin + DEPENDS ${fw_name} + ) + + add_custom_command(OUTPUT ${PX4_BINARY_DIR}/${CONFIG}.px4 + COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_mkfw.py + --prototype ${PX4_SOURCE_DIR}/Images/${BOARD}.prototype + --git_identity ${PX4_SOURCE_DIR} + --parameter_xml ${PX4_BINARY_DIR}/parameters.xml + --airframe_xml ${PX4_BINARY_DIR}/airframes.xml + --image ${BOARD}.bin > ${fw_file} + DEPENDS ${BOARD}.bin parameters_xml airframes_xml + COMMENT "Creating ${CONFIG}.px4" + ) + + add_custom_target(px4 ALL DEPENDS ${PX4_BINARY_DIR}/${CONFIG}.px4) + + # upload helper + if (${BOARD} STREQUAL "aerofc-v1") + px4_add_upload_aero(OUT upload OS ${OS} BOARD ${BOARD} BUNDLE ${fw_file}) + else() + px4_add_upload(OUT upload OS ${OS} BOARD ${BOARD} BUNDLE ${fw_file}) + endif() +endif() + +# print size +add_custom_target(size + COMMAND size ${fw_name} + DEPENDS ${fw_name} + WORKING_DIRECTORY ${PX4_BINARY_DIR} ) -if("${romfs_used}" STREQUAL "y") - list(APPEND link_libs romfs) -endif() - -# -# Bootloaders use a different ld file, a seperate startup file -# and need to override the os version of sched_process_timer -# -set(startup_libs) - -if("${config_nuttx_config}" STREQUAL "bootloader") - set(nuttx_ld_prefix "bootloader") - set(nuttx_bootloader_wrapers "-Wl,-wrap,sched_process_timer -Wl,-wrap,sem_post -Wl,-wrap,sem_wait") -endif() - -if(NOT "${nuttx_startup_files}" STREQUAL "" ) - - set(nuttx_startup_files ${nuttx_export_dir}/startup/${nuttx_startup_files}) - - add_custom_command(OUTPUT - ${nuttx_startup_files} - DEPENDS nuttx_export_${BOARD}) - - set_source_files_properties( - ${nuttx_startup_files} - PROPERTIES - EXTERNAL_OBJECT true - GENERATED true) - - add_library(startup - ${nuttx_startup_files}) - set_target_properties(startup - PROPERTIES - LINKER_LANGUAGE C) - list(APPEND startup_libs startup) - -endif() - -if(NOT ${BOARD} STREQUAL "sim") - set(main_link_flags - "-T${nuttx_export_dir}/build/${nuttx_ld_prefix}ld.script" - "-Wl,-Map=${PX4_BINARY_DIR}/${BOARD}/main.map" - ) - px4_join(OUT main_link_flags LIST ${main_link_flags} GLUE " ") - set_target_properties(firmware_nuttx PROPERTIES LINK_FLAGS ${main_link_flags}) -endif() - -target_link_libraries(firmware_nuttx - -Wl,--warn-common - -Wl,--gc-sections - -Wl,--start-group - ${startup_libs} - ${module_libraries} - ${df_driver_libs} - ${nuttx_bootloader_wrapers} - ${link_libs} - -Wl,--end-group) - +# print weak symbols add_custom_target(check_weak - COMMAND ${NM} firmware_nuttx | ${GREP} " w " | cat - DEPENDS firmware_nuttx + COMMAND ${NM} ${fw_name} | ${GREP} " w " | cat + DEPENDS ${fw_name} VERBATIM ) -if(NOT ${BOARD} STREQUAL "sim") +# debugger helpers +configure_file(gdbinit.in .gdbinit) - if ("${romfs_used}" STREQUAL "y") +add_custom_target(debug + COMMAND ${GDB} $ + DEPENDS ${fw_name} ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit + ) - if (config_io_board) - set(extras "${CMAKE_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board}.bin") - endif() +add_custom_target(debug_tui + COMMAND ${GDBTUI} $ + DEPENDS ${fw_name} ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit + ) - message(STATUS "Adding ROMFS on ${BOARD}") - px4_nuttx_add_romfs(OUT romfs - ROOT ROMFS/${config_romfs_root} - EXTRAS ${extras} - ) - if (config_io_board) - add_dependencies(romfs fw_io) - endif() - endif() +add_custom_target(debug_ddd + COMMAND ${DDD} --debugger ${GDB} $ + DEPENDS ${fw_name} ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit + ) - set(fw_file - ${CMAKE_CURRENT_BINARY_DIR}/${BOARD}_${LABEL}.px4) +add_custom_target(debug_io + COMMAND ${GDB} ${fw_io_path} + DEPENDS ${fw_name} ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit + ) -# -# Bootloaders do not need .px4 or xml -# - if(NOT "${config_nuttx_config}" STREQUAL "bootloader") - px4_nuttx_add_firmware(OUT ${fw_file} - BOARD ${BOARD} - EXE ${CMAKE_CURRENT_BINARY_DIR}/firmware_nuttx - PARAM_XML ${PX4_BINARY_DIR}/parameters.xml - AIRFRAMES_XML ${PX4_BINARY_DIR}/airframes.xml - ) - endif() +add_custom_target(debug_io_tui + COMMAND ${GDBTUI} ${fw_io_path} + DEPENDS ${fw_name} ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit + ) - configure_file(gdbinit.in .gdbinit) - - add_custom_target(debug - COMMAND ${GDB} ${CMAKE_CURRENT_BINARY_DIR}/firmware_nuttx - DEPENDS firmware_nuttx - ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit - ) - - add_custom_target(debug_tui - COMMAND ${GDBTUI} ${CMAKE_CURRENT_BINARY_DIR}/firmware_nuttx - DEPENDS firmware_nuttx - ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit - ) - - add_custom_target(debug_ddd - COMMAND ${DDD} --debugger ${GDB} ${CMAKE_CURRENT_BINARY_DIR}/firmware_nuttx - DEPENDS firmware_nuttx - ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit - ) - - add_custom_target(debug_io - COMMAND ${GDB} - ${PX4_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board} - DEPENDS firmware_nuttx - ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit - ) - - add_custom_target(debug_io_tui - COMMAND ${GDBTUI} - ${PX4_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board} - DEPENDS firmware_nuttx - ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit - ) - - add_custom_target(debug_io_ddd - COMMAND ${DDD} --debugger ${GDB} - ${PX4_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board} - DEPENDS firmware_nuttx - ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit - ) - - if(NOT "${config_nuttx_config}" STREQUAL "bootloader") - if ("${BOARD}" STREQUAL "aerofc-v1") - px4_add_upload_aero(OUT upload OS ${OS} BOARD ${BOARD} - BUNDLE ${fw_file}) - else() - px4_add_upload(OUT upload OS ${OS} BOARD ${BOARD} - BUNDLE ${fw_file}) - endif() - endif() -endif() - -if(NOT "${config_nuttx_config}" STREQUAL "bootloader") - install(FILES ${fw_file} DESTINATION .) -endif() - -# vim: set noet ft=cmake fenc=utf-8 ff=unix : +add_custom_target(debug_io_ddd + COMMAND ${DDD} --debugger ${GDB} ${fw_io_path}} + DEPENDS ${fw_io} ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit + ) diff --git a/src/firmware/posix/CMakeLists.txt b/src/firmware/posix/CMakeLists.txt index 3287548e0d..3e049635d6 100644 --- a/src/firmware/posix/CMakeLists.txt +++ b/src/firmware/posix/CMakeLists.txt @@ -2,6 +2,8 @@ include (common/px4_upload) include_directories(${CMAKE_CURRENT_BINARY_DIR}) +get_property(module_libraries GLOBAL PROPERTY PX4_LIBRARIES) + px4_posix_generate_builtin_commands( OUT apps MODULE_LIST ${module_libraries}) @@ -12,7 +14,6 @@ set(MAIN_SRC ${PX4_SOURCE_DIR}/src/platforms/posix/main.cpp) set(UPLOAD_NAME upload) if ("${BOARD}" STREQUAL "eagle" OR ("${BOARD}" STREQUAL "excelsior")) - include(fastrpc) include(linux_app) @@ -140,12 +141,9 @@ install(TARGETS px4 DESTINATION ${CMAKE_INSTALL_BINDIR}) install(DIRECTORY ${PROJECT_SOURCE_DIR}/ROMFS DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}) install(DIRECTORY ${PROJECT_SOURCE_DIR}/posix-configs DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}) -add_custom_target(strip - DEPENDS "${APP_NAME}.stripped" -) +add_custom_target(strip DEPENDS "${APP_NAME}.stripped") -add_custom_command(OUTPUT "${APP_NAME}.stripped" +add_custom_command(OUTPUT ${APP_NAME}.stripped COMMAND ${STRIP_TOOL} -R .comment -R .gnu.version -o $.stripped $ - DEPENDS px4) - -# vim: set noet ft=cmake fenc=utf-8 ff=unix : + DEPENDS px4 + ) diff --git a/src/firmware/posix/sitl_target.cmake b/src/firmware/posix/sitl_target.cmake index 0c7f02237a..c1a3a94c41 100644 --- a/src/firmware/posix/sitl_target.cmake +++ b/src/firmware/posix/sitl_target.cmake @@ -1,7 +1,6 @@ function(px4_add_sitl_app) -px4_parse_function_args( - NAME px4_add_sitl_app +px4_parse_function_args(NAME px4_add_sitl_app ONE_VALUE APP_NAME MAIN_SRC UPLOAD_NAME REQUIRED APP_NAME MAIN_SRC ARGN ${ARGN} @@ -27,7 +26,6 @@ px4_parse_function_args( pthread m ) endif() - endfunction() #============================================================================= @@ -63,6 +61,9 @@ add_custom_target(run_config DEPENDS px4 logs_symlink ) +# Add support for external project building +include(ExternalProject) + # project to build sitl_gazebo if necessary ExternalProject_Add(sitl_gazebo SOURCE_DIR ${PX4_SOURCE_DIR}/Tools/sitl_gazebo diff --git a/src/firmware/qurt/CMakeLists.txt b/src/firmware/qurt/CMakeLists.txt index 3909ecb53d..b9923e4940 100644 --- a/src/firmware/qurt/CMakeLists.txt +++ b/src/firmware/qurt/CMakeLists.txt @@ -9,6 +9,8 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-prototypes") +get_property(module_libraries GLOBAL PROPERTY PX4_LIBRARIES) + px4_qurt_generate_builtin_commands( OUT ${PX4_BINARY_DIR}/apps MODULE_LIST ${module_libraries}) @@ -29,15 +31,10 @@ if ("${QURT_ENABLE_STUBS}" STREQUAL "1") target_link_libraries(px4 -Wl,--start-group ${module_libraries} - ${target_libraries} - ${df_driver_libs} + ${df_driver_libs} -Wl,--end-group ) else() - #message("module_libraries = ${module_libraries}") - #message("target_libraries = ${target_libraries}") - #message("df_driver_libs = ${df_driver_libs}") - #message("module_external_libraries = ${module_external_libraries}") # Generate the DSP lib and stubs but not the apps side executable # The Apps side executable is generated via the posix_eagle_xxxx target QURT_LIB(LIB_NAME px4 @@ -46,10 +43,8 @@ else() ${PX4_BINARY_DIR}/apps.cpp LINK_LIBS ${module_libraries} - ${target_libraries} ${df_driver_libs} m - ${module_external_libraries} ) px4_add_adb_push(OUT upload diff --git a/src/lib/version/CMakeLists.txt b/src/lib/version/CMakeLists.txt index abbad55f3e..f39d3c7b9c 100644 --- a/src/lib/version/CMakeLists.txt +++ b/src/lib/version/CMakeLists.txt @@ -30,6 +30,38 @@ # POSSIBILITY OF SUCH DAMAGE. # ############################################################################ + +# check if px4 source is a git repo +if (EXISTS ${PX4_SOURCE_DIR}/.git) + if (IS_DIRECTORY ${PX4_SOURCE_DIR}/.git) + # standard git repo + set(git_dir_path ${PX4_SOURCE_DIR}/.git) + else() + # git submodule + file(READ ${PX4_SOURCE_DIR}/.git git_dir_path) + string(STRIP ${git_dir_path} git_dir_path) + string(REPLACE "gitdir: " "" git_dir_path ${git_dir_path}) + get_filename_component(git_dir_path ${git_dir_path} ABSOLUTE) + endif() +else() + message(FATAL_ERROR "is not a git repository") +endif() +if(NOT IS_DIRECTORY "${git_dir_path}") + message(FATAL_ERROR "${git_dir_path} is not a directory") +endif() + +set(px4_git_ver_header ${PX4_BINARY_DIR}/build_git_version.h) +add_custom_command(OUTPUT ${px4_git_ver_header} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/px_update_git_header.py ${px4_git_ver_header} > ${PX4_BINARY_DIR}/git_header.log + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/px_update_git_header.py + ${git_dir_path}/HEAD + WORKING_DIRECTORY ${PX4_SOURCE_DIR} + COMMENT "Generating git hash header" + ) +set_source_files_properties(${px4_git_ver_header} PROPERTIES GENERATED TRUE) +add_custom_target(ver_gen ALL DEPENDS ${px4_git_ver_header}) + px4_add_module( MODULE lib__version COMPILE_FLAGS diff --git a/Tools/px_update_git_header.py b/src/lib/version/px_update_git_header.py similarity index 75% rename from Tools/px_update_git_header.py rename to src/lib/version/px_update_git_header.py index 95f8a8e6cc..f1ee89b7d2 100755 --- a/Tools/px_update_git_header.py +++ b/src/lib/version/px_update_git_header.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from __future__ import print_function +import os import sys import subprocess import re @@ -23,12 +24,19 @@ try: except: git_branch_name = '' git_version_short = git_version[0:16] -nuttx_git_tag = subprocess.check_output('git describe --always --tags --match nuttx-* --dirty'.split(), - cwd='NuttX/nuttx', stderr=subprocess.STDOUT).decode('utf-8').strip().replace("nuttx-","v") -nuttx_git_tag = re.sub('-.*','.0',nuttx_git_tag) -nuttx_git_version = subprocess.check_output('git rev-parse --verify HEAD'.split(), - cwd='NuttX/nuttx', stderr=subprocess.STDOUT).decode('utf-8').strip() -nuttx_git_version_short = nuttx_git_version[0:16] + +if (os.path.exists('platforms/nuttx/NuttX/nuttx')): + nuttx_git_tag = subprocess.check_output('git describe --always --tags --match nuttx-* --dirty'.split(), + cwd='platforms/nuttx/NuttX/nuttx', stderr=subprocess.STDOUT).decode('utf-8').strip().replace("nuttx-","v") + nuttx_git_tag = re.sub('-.*','.0',nuttx_git_tag) + nuttx_git_version = subprocess.check_output('git rev-parse --verify HEAD'.split(), + cwd='platforms/nuttx/NuttX/nuttx', stderr=subprocess.STDOUT).decode('utf-8').strip() + nuttx_git_version_short = nuttx_git_version[0:16] +else: + nuttx_git_version = "0000000" + nuttx_git_version_short = "0000000" + nuttx_git_tag = "v0.0.0" + mavlink_git_version = subprocess.check_output('git rev-parse --verify HEAD'.split(), cwd='mavlink/include/mavlink/v2.0', stderr=subprocess.STDOUT).decode('utf-8').strip() mavlink_git_version_short = mavlink_git_version[0:16] diff --git a/src/lib/version/version.c b/src/lib/version/version.c index f1345a5db1..a56fa50281 100644 --- a/src/lib/version/version.c +++ b/src/lib/version/version.c @@ -33,7 +33,7 @@ #include "version.h" -#include "build_git_version.h" //generated from build_git_version.h.in +#include "build_git_version.h" #include diff --git a/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt b/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt index 65967fa35a..9091f79318 100644 --- a/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt +++ b/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt @@ -33,88 +33,87 @@ if(NOT GENERATE_RTPS_BRIDGE MATCHES "off") - find_program(FASTRTPSGEN fastrtpsgen - PATHS $ENV{FASTRTPSGEN_DIR}) - if(NOT FASTRTPSGEN) - message(WARNING "WARNING: Unable to find fastrtpsgen. Building PX4 without RTPS bridge support") - px4_add_module( - MODULE modules__micrortps_bridge__micrortps_client - MAIN micrortps_client - SRCS - microRTPS_client_dummy.cpp - DEPENDS - platforms__common - ) - return() - endif() + find_program(FASTRTPSGEN fastrtpsgen PATHS $ENV{FASTRTPSGEN_DIR}) + if(NOT FASTRTPSGEN) + message(STATUS "WARNING: Unable to find fastrtpsgen. Building PX4 without RTPS bridge support") + px4_add_module( + MODULE modules__micrortps_bridge__micrortps_client + MAIN micrortps_client + SRCS + microRTPS_client_dummy.cpp + DEPENDS + platforms__common + ) + return() + endif() - include_directories(.) - include_directories(${CMAKE_CURRENT_BINARY_DIR}) + include_directories(.) + include_directories(${CMAKE_CURRENT_BINARY_DIR}) + include_directories(${PX4_SOURCE_DIR}/src/lib/micro-CDR/include) + include_directories(${PX4_BINARY_DIR}/src/lib/micro-CDR/include/microcdr) - # Do not delete everything in the current dir - set(msg_out_path ${CMAKE_CURRENT_BINARY_DIR}) - set(topic_msg_path ${PX4_SOURCE_DIR}/msg) + # Do not delete everything in the current dir + set(msg_out_path ${CMAKE_CURRENT_BINARY_DIR}) + set(topic_msg_path ${PX4_SOURCE_DIR}/msg) - set(send_topic_files) - foreach(topic ${config_rtps_send_topics}) - list(APPEND send_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg) - endforeach() + set(send_topic_files) + foreach(topic ${config_rtps_send_topics}) + list(APPEND send_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg) + endforeach() - set(receive_topic_files) - foreach(topic ${config_rtps_receive_topics}) - list(APPEND receive_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg) - endforeach() + set(receive_topic_files) + foreach(topic ${config_rtps_receive_topics}) + list(APPEND receive_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg) + endforeach() - foreach(topic ${config_rtps_send_topics}) - list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Publisher.cpp) - list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Publisher.h) - endforeach() + foreach(topic ${config_rtps_send_topics}) + list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Publisher.cpp) + list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Publisher.h) + endforeach() - foreach(topic ${config_rtps_receive_topics}) - list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Subscriber.cpp) - list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Subscriber.h) - endforeach() + foreach(topic ${config_rtps_receive_topics}) + list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Subscriber.cpp) + list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Subscriber.h) + endforeach() if (NOT "${config_rtps_send_topics}" STREQUAL "" OR NOT "${config_rtps_receive_topics}" STREQUAL "") - set(topic_bridge_files_out microRTPS_client.cpp microRTPS_transport.cpp microRTPS_transport.h) + set(topic_bridge_files_out microRTPS_client.cpp microRTPS_transport.cpp microRTPS_transport.h) - set(send_topic_files_opt) - if (NOT "${send_topic_files}" STREQUAL "") - set(send_topic_opt "-s") - endif() + set(send_topic_files_opt) + if (NOT "${send_topic_files}" STREQUAL "") + set(send_topic_opt "-s") + endif() - set(receive_topic_files_opt) - if (NOT "${receive_topic_files}" STREQUAL "") - set(receive_topic_opt "-r") - endif() + set(receive_topic_files_opt) + if (NOT "${receive_topic_files}" STREQUAL "") + set(receive_topic_opt "-r") + endif() - add_custom_command(OUTPUT ${topic_bridge_files_out} - COMMAND ${PYTHON_EXECUTABLE} - ${PX4_SOURCE_DIR}/Tools/generate_microRTPS_bridge.py - -f $ENV{FASTRTPSGEN_DIR} - ${send_topic_opt} ${send_topic_files} - ${receive_topic_opt} ${receive_topic_files} - -t ${topic_msg_path} - -u ${msg_out_path} - DEPENDS ${DEPENDS} ${send_topic_files} ${receive_topic_files} - COMMENT "Generating RTPS topic bridge" - VERBATIM - ) + add_custom_command(OUTPUT ${topic_bridge_files_out} + COMMAND ${PYTHON_EXECUTABLE} + ${PX4_SOURCE_DIR}/Tools/generate_microRTPS_bridge.py + -f $ENV{FASTRTPSGEN_DIR} + ${send_topic_opt} ${send_topic_files} + ${receive_topic_opt} ${receive_topic_files} + -t ${topic_msg_path} + -u ${msg_out_path} + DEPENDS ${DEPENDS} ${send_topic_files} ${receive_topic_files} + COMMENT "Generating RTPS topic bridge" + VERBATIM + ) + add_custom_target(topic_bridge_files DEPENDS ${topic_bridge_files_out}) + + px4_add_module( + MODULE modules__micrortps_bridge__micrortps_client + MAIN micrortps_client + STACK_MAIN 4096 + SRCS + ${msg_out_path}/microRTPS_transport.cpp + ${msg_out_path}/microRTPS_client.cpp + microRTPS_client_main.cpp + DEPENDS + platforms__common + topic_bridge_files + ) endif() - -endif() - -px4_add_module( - MODULE modules__micrortps_bridge__micrortps_client - MAIN micrortps_client - STACK_MAIN 4096 - SRCS - microRTPS_transport.cpp - microRTPS_client.cpp - microRTPS_client.h - microRTPS_client_main.cpp - DEPENDS - platforms__common - ) - -# vim: set noet ft=cmake fenc=utf-8 ff=unix : +endif() \ No newline at end of file diff --git a/src/modules/micrortps_bridge/micrortps_client/microRTPS_client_main.cpp b/src/modules/micrortps_bridge/micrortps_client/microRTPS_client_main.cpp index 1c17fb4bb6..e36e385296 100644 --- a/src/modules/micrortps_bridge/micrortps_client/microRTPS_client_main.cpp +++ b/src/modules/micrortps_bridge/micrortps_client/microRTPS_client_main.cpp @@ -35,15 +35,16 @@ #include #include +#include #include #include #include #include +#include #include #include #include -#include extern "C" __EXPORT int micrortps_client_main(int argc, char *argv[]); diff --git a/src/modules/px4iofirmware/CMakeLists.txt b/src/modules/px4iofirmware/CMakeLists.txt index 9c826bd084..61b9bf0e6a 100644 --- a/src/modules/px4iofirmware/CMakeLists.txt +++ b/src/modules/px4iofirmware/CMakeLists.txt @@ -31,112 +31,19 @@ # ############################################################################ -# kill all flags above us, this is a different board (io) -set_directory_properties(PROPERTIES - INCLUDE_DIRECTORIES "" - LINK_DIRECTORIES "" - COMPILE_DEFINITIONS "" - ) -set(c_flags) -set(exe_linker_flags) -set(cxx_flags) -set(optimization_flags) -set(include_dirs) -set(link_dirs) -set(definitions) - -px4_nuttx_configure(HWCLASS m3 CONFIG nsh) - -px4_os_prebuild_targets(OUT io_prebuild_targets - BOARD ${config_io_board} - THREADS ${THREADS}) - -px4_os_add_flags( - BOARD ${config_io_board} - C_FLAGS c_flags - CXX_FLAGS cxx_flags - OPTIMIZATION_FLAGS optimization_flags - EXE_LINKER_FLAGS exe_linker_flags - INCLUDE_DIRS include_dirs - LINK_DIRS link_dirs - DEFINITIONS definitions) - -px4_join(OUT CMAKE_EXE_LINKER_FLAGS LIST "${exe_linker_flags}" GLUE " ") -px4_join(OUT CMAKE_C_FLAGS LIST "${c_flags};${optimization_flags}" GLUE " ") -px4_join(OUT CMAKE_CXX_FLAGS LIST "${cxx_flags};${optimization_flags}" GLUE " ") - -include_directories( - ${include_dirs} - ${PX4_BINARY_DIR}/src/modules/systemlib/mixer - ) -link_directories(${link_dirs}) -add_definitions(${definitions}) - -set(srcs - ${PX4_SOURCE_DIR}/src/drivers/boards/${config_io_board}/px4io_init.c - ${PX4_SOURCE_DIR}/src/drivers/boards/${config_io_board}/px4io_timer_config.c - ${PX4_SOURCE_DIR}/src/drivers/stm32/drv_hrt.c - ${PX4_SOURCE_DIR}/src/drivers/stm32/drv_io_timer.c - ${PX4_SOURCE_DIR}/src/drivers/stm32/drv_pwm_servo.c - ${PX4_SOURCE_DIR}/src/lib/rc/dsm.cpp - ${PX4_SOURCE_DIR}/src/lib/rc/sbus.cpp - ${PX4_SOURCE_DIR}/src/lib/rc/st24.cpp - ${PX4_SOURCE_DIR}/src/lib/rc/sumd.cpp - ${PX4_SOURCE_DIR}/src/lib/rc/common_rc.cpp - ${PX4_SOURCE_DIR}/src/modules/systemlib/mixer/mixer.cpp - ${PX4_SOURCE_DIR}/src/modules/systemlib/mixer/mixer_group.cpp - ${PX4_SOURCE_DIR}/src/modules/systemlib/mixer/mixer_helicopter.cpp - ${PX4_SOURCE_DIR}/src/modules/systemlib/mixer/mixer_multirotor.cpp - ${PX4_SOURCE_DIR}/src/modules/systemlib/mixer/mixer_simple.cpp - ${PX4_SOURCE_DIR}/src/modules/systemlib/perf_counter.c - ${PX4_SOURCE_DIR}/src/modules/systemlib/pwm_limit/pwm_limit.c - adc.c - controls.c - mixer.cpp - px4io.c - registers.c - safety.c - ) - -if(${config_io_board} STREQUAL "px4io-v2") - list(APPEND srcs +px4_add_module( + MODULE modules__px4iofirmware + SRCS + ../systemlib/hx_stream.c + ../systemlib/perf_counter.c + ../systemlib/pwm_limit/pwm_limit.c + adc.c + controls.c + mixer.cpp + px4io.c + registers.c + safety.c serial.c - ${PX4_SOURCE_DIR}/src/modules/systemlib/hx_stream.c - ) -endif() - -set(fw_io_name ${config_io_board}) - -add_executable(${fw_io_name} ${srcs}) - -add_dependencies(${fw_io_name} - io_prebuild_targets - mixer_gen - msg_gen - nuttx_export_${config_io_board} + DEPENDS + platforms__common ) - -set(nuttx_export_dir ${PX4_BINARY_DIR}/${config_io_board}/NuttX/nuttx/nuttx-export) -set(main_link_flags - "-T${nuttx_export_dir}/build/ld.script" - "-Wl,-Map=${PX4_BINARY_DIR}/${config_io_board}/main.map" - ) -px4_join(OUT main_link_flags LIST ${main_link_flags} GLUE " ") -set_target_properties(${fw_io_name} PROPERTIES LINK_FLAGS ${main_link_flags}) - -target_link_libraries(${fw_io_name} - -Wl,--start-group - apps nuttx nosys m gcc - ${config_io_extra_libs} - -Wl,--end-group - ) - -px4_nuttx_create_bin( - OUT ${CMAKE_CURRENT_BINARY_DIR}/${fw_io_name}.bin - EXE ${fw_io_name} - ) - -add_custom_target(fw_io DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${fw_io_name}.bin) - - -# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/systemlib/px4_macros.h b/src/modules/systemlib/px4_macros.h index a6c11108e9..3d570e2d25 100644 --- a/src/modules/systemlib/px4_macros.h +++ b/src/modules/systemlib/px4_macros.h @@ -96,7 +96,7 @@ #if !defined(CCASSERT) #if defined(static_assert) -# define CCASSERT(predicate) static_assert(predicate) +# define CCASSERT(predicate) static_assert(predicate, STRINGIFY(predicate)) # else # define CCASSERT(predicate) _x_CCASSERT_LINE(predicate, __LINE__) # if !defined(_x_CCASSERT_LINE) diff --git a/src/modules/uORB/CMakeLists.txt b/src/modules/uORB/CMakeLists.txt index e3b23e94b1..1274da703d 100644 --- a/src/modules/uORB/CMakeLists.txt +++ b/src/modules/uORB/CMakeLists.txt @@ -32,29 +32,20 @@ ############################################################################ # this includes the generated topics directory -include_directories( - ${CMAKE_CURRENT_BINARY_DIR} - ) - -link_libraries(msg_gen) - -set(SRCS - uORBUtils.cpp - uORB.cpp - uORBMain.cpp - Publication.cpp - Subscription.cpp - uORBManager.cpp - uORBDevices.cpp - ) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) px4_add_module( MODULE modules__uORB MAIN uorb STACK_MAIN 2100 - COMPILE_FLAGS - SRCS ${SRCS} + SRCS + Publication.cpp + Subscription.cpp + uORB.cpp + uORBDevices.cpp + uORBMain.cpp + uORBManager.cpp + uORBUtils.cpp DEPENDS platforms__common ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/uavcan/CMakeLists.txt b/src/modules/uavcan/CMakeLists.txt index d691962e4e..eb0fab8316 100644 --- a/src/modules/uavcan/CMakeLists.txt +++ b/src/modules/uavcan/CMakeLists.txt @@ -34,6 +34,10 @@ set(UAVCAN_USE_CPP03 ON CACHE BOOL "uavcan cpp03") set(UAVCAN_PLATFORM stm32 CACHE STRING "uavcan platform") +if(NOT config_uavcan_num_ifaces) + message(FATAL_ERROR "config_uavcan_num_ifaces not set") +endif() + string(TOUPPER "${OS}" OS_UPPER) add_definitions( -DUAVCAN_CPP_VERSION=UAVCAN_CPP03 diff --git a/src/modules/uavcanesc/CMakeLists.txt b/src/modules/uavcanesc/CMakeLists.txt index 38dbbd78df..295fa06ac5 100644 --- a/src/modules/uavcanesc/CMakeLists.txt +++ b/src/modules/uavcanesc/CMakeLists.txt @@ -46,22 +46,19 @@ add_definitions( -DUAVCAN_STM32_TIMER_NUMBER=2 -DUAVCAN_USE_CPP03=ON -DUAVCAN_USE_EXTERNAL_SNPRINT - -DAPP_VERSION_MAJOR=${uavcanblid_sw_version_major} - -DAPP_VERSION_MINOR=${uavcanblid_sw_version_minor} - -DHW_UAVCAN_NAME=${uavcanblid_name} - -DHW_VERSION_MAJOR=${uavcanblid_hw_version_major} - -DHW_VERSION_MINOR=${uavcanblid_hw_version_minor} ) -add_subdirectory(../uavcan/libuavcan uavcanesc_libuavcan) +set(LIBUAVCAN_DIR ${PX4_SOURCE_DIR}/src/modules/uavcan/libuavcan) + +add_subdirectory(${LIBUAVCAN_DIR} uavcanesc_libuavcan) add_dependencies(uavcan platforms__nuttx) -include_directories(../../drivers/bootloaders/include) -include_directories(../uavcan/libuavcan/libuavcan/include) -include_directories(../uavcan/libuavcan/libuavcan/include/dsdlc_generated) -include_directories(../uavcan/libuavcan/libuavcan_drivers/posix/include) -include_directories(../uavcan/libuavcan/libuavcan_drivers/stm32/driver/include) -include_directories(../systemlib/flashparams) +include_directories(${PX4_SOURCE_DIR}/src/drivers/bootloaders/include) +include_directories(${PX4_SOURCE_DIR}/src/modules/systemlib/flashparams) +include_directories(${LIBUAVCAN_DIR}/libuavcan/include) +include_directories(${LIBUAVCAN_DIR}/libuavcan/include/dsdlc_generated) +include_directories(${LIBUAVCAN_DIR}/libuavcan_drivers/posix/include) +include_directories(${LIBUAVCAN_DIR}/libuavcan_drivers/stm32/driver/include) px4_add_module( MODULE modules__uavcanesc @@ -76,9 +73,8 @@ px4_add_module( indication_controller.cpp led.cpp uavcanesc_params.c - ../systemlib/flashparams/flashparams.c - ../systemlib/flashparams/flashfs.c - + ${PX4_SOURCE_DIR}/src/modules/systemlib/flashparams/flashparams.c + ${PX4_SOURCE_DIR}/src/modules/systemlib/flashparams/flashfs.c DEPENDS platforms__common uavcan diff --git a/src/modules/uavcannode/CMakeLists.txt b/src/modules/uavcannode/CMakeLists.txt index 8d050f14e5..b24699c1c4 100644 --- a/src/modules/uavcannode/CMakeLists.txt +++ b/src/modules/uavcannode/CMakeLists.txt @@ -46,21 +46,18 @@ add_definitions( -DUAVCAN_STM32_TIMER_NUMBER=2 -DUAVCAN_USE_CPP03=ON -DUAVCAN_USE_EXTERNAL_SNPRINT - -DAPP_VERSION_MAJOR=${uavcanblid_sw_version_major} - -DAPP_VERSION_MINOR=${uavcanblid_sw_version_minor} - -DHW_UAVCAN_NAME=${uavcanblid_name} - -DHW_VERSION_MAJOR=${uavcanblid_hw_version_major} - -DHW_VERSION_MINOR=${uavcanblid_hw_version_minor} ) -add_subdirectory(../uavcan/libuavcan uavcannode_libuavcan) +set(LIBUAVCAN_DIR ${PX4_SOURCE_DIR}/src/modules/uavcan/libuavcan) + +add_subdirectory(${LIBUAVCAN_DIR} uavcannode_libuavcan) add_dependencies(uavcan platforms__nuttx) -include_directories(../../drivers/bootloaders/include) -include_directories(../uavcan/libuavcan/libuavcan/include) -include_directories(../uavcan/libuavcan/libuavcan/include/dsdlc_generated) -include_directories(../uavcan/libuavcan/libuavcan_drivers/posix/include) -include_directories(../uavcan/libuavcan/libuavcan_drivers/stm32/driver/include) +include_directories(${PX4_SOURCE_DIR}/src/drivers/bootloaders/include) +include_directories(${LIBUAVCAN_DIR}/libuavcan/include) +include_directories(${LIBUAVCAN_DIR}/libuavcan/include/dsdlc_generated) +include_directories(${LIBUAVCAN_DIR}/libuavcan_drivers/posix/include) +include_directories(${LIBUAVCAN_DIR}/libuavcan_drivers/stm32/driver/include) px4_add_module( MODULE modules__uavcannode @@ -83,4 +80,6 @@ px4_add_module( uavcan ) -target_link_libraries(modules__uavcannode uavcan uavcan_stm32_driver) +target_link_libraries(modules__uavcannode PUBLIC uavcan uavcan_stm32_driver) + +set_property(GLOBAL APPEND PROPERTY PX4_LIBRARIES uavcan_stm32_driver) diff --git a/src/platforms/common/CMakeLists.txt b/src/platforms/common/CMakeLists.txt index 7229cc02d8..7e536726c1 100644 --- a/src/platforms/common/CMakeLists.txt +++ b/src/platforms/common/CMakeLists.txt @@ -33,9 +33,6 @@ set(depends msg_gen prebuild_targets - git_mavlink - git_uavcan - git_matrix ) px4_add_module( diff --git a/src/platforms/posix/drivers/accelsim/CMakeLists.txt b/src/platforms/posix/drivers/accelsim/CMakeLists.txt index b279726704..3b53503804 100644 --- a/src/platforms/posix/drivers/accelsim/CMakeLists.txt +++ b/src/platforms/posix/drivers/accelsim/CMakeLists.txt @@ -41,6 +41,5 @@ px4_add_module( accelsim.cpp DEPENDS platforms__common - git_jmavsim ) # vim: set noet ft=cmake fenc=utf-8 ff=unix :