2018-01-15 16:34:18 -04:00
|
|
|
############################################################################
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
############################################################################
|
|
|
|
|
2018-01-04 03:46:01 -04:00
|
|
|
include(cygwin_cygpath)
|
2017-06-01 09:47:33 -03:00
|
|
|
|
2018-01-15 16:34:18 -04:00
|
|
|
add_subdirectory(src)
|
|
|
|
|
2018-12-04 12:13:56 -04:00
|
|
|
add_executable(px4 ${PX4_SOURCE_DIR}/src/platforms/empty.c)
|
2018-11-22 00:27:21 -04:00
|
|
|
set(FW_NAME ${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_${PX4_BOARD_LABEL}.elf)
|
2018-12-04 12:13:56 -04:00
|
|
|
set_target_properties(px4 PROPERTIES OUTPUT_NAME ${FW_NAME})
|
|
|
|
add_dependencies(px4 git_nuttx nuttx_build)
|
2015-09-19 18:57:54 -03:00
|
|
|
|
2018-04-11 16:10:51 -03:00
|
|
|
get_property(module_libraries GLOBAL PROPERTY PX4_MODULE_LIBRARIES)
|
2015-09-19 18:57:54 -03:00
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
# build NuttX
|
2018-01-04 23:12:03 -04:00
|
|
|
add_subdirectory(NuttX ${PX4_BINARY_DIR}/NuttX)
|
2016-12-12 19:11:51 -04:00
|
|
|
|
2017-11-18 12:18:53 -04:00
|
|
|
set(nuttx_libs)
|
|
|
|
list(APPEND nuttx_libs
|
2017-09-04 14:33:02 -03:00
|
|
|
nuttx_apps
|
|
|
|
nuttx_arch
|
|
|
|
nuttx_binfmt
|
|
|
|
nuttx_c
|
|
|
|
nuttx_configs
|
|
|
|
nuttx_cxx
|
|
|
|
nuttx_drivers
|
|
|
|
nuttx_fs
|
|
|
|
nuttx_mm
|
|
|
|
nuttx_sched
|
2017-11-18 12:18:53 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
if (CONFIG_NET)
|
|
|
|
list(APPEND nuttx_libs nuttx_net)
|
2018-07-13 12:09:29 -03:00
|
|
|
target_link_libraries(nuttx_fs INTERFACE nuttx_net)
|
2017-11-18 12:18:53 -04:00
|
|
|
endif()
|
|
|
|
|
2017-12-16 13:27:50 -04:00
|
|
|
file(RELATIVE_PATH PX4_BINARY_DIR_REL ${CMAKE_CURRENT_BINARY_DIR} ${PX4_BINARY_DIR})
|
|
|
|
|
2018-01-04 03:46:01 -04:00
|
|
|
# only in the cygwin environment: convert absolute linker script path to mixed windows (C:/...)
|
|
|
|
# because even relative linker script paths are different for linux, mac and windows
|
|
|
|
CYGPATH(PX4_BINARY_DIR PX4_BINARY_DIR_CYG)
|
|
|
|
|
2018-04-11 16:10:51 -03:00
|
|
|
target_link_libraries(nuttx_arch
|
|
|
|
INTERFACE
|
|
|
|
drivers_board
|
|
|
|
drivers_arch
|
|
|
|
drivers_boards_common
|
|
|
|
drivers_boards_common_arch
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(nuttx_c INTERFACE nuttx_drivers)
|
|
|
|
target_link_libraries(nuttx_cxx INTERFACE nuttx_c)
|
|
|
|
|
2018-12-04 12:13:56 -04:00
|
|
|
target_link_libraries(px4 PRIVATE
|
2018-04-11 16:10:51 -03:00
|
|
|
|
2019-01-06 12:33:21 -04:00
|
|
|
-nostartfiles
|
2018-04-11 16:10:51 -03:00
|
|
|
-nodefaultlibs
|
|
|
|
-nostdlib
|
|
|
|
|
|
|
|
-fno-exceptions
|
|
|
|
-fno-rtti
|
2017-12-16 13:27:50 -04:00
|
|
|
|
2018-11-16 13:52:37 -04:00
|
|
|
-Wl,--script=${PX4_BINARY_DIR_CYG}/NuttX/nuttx/configs/${PX4_BOARD}/scripts/ld.script
|
2018-11-23 13:39:44 -04:00
|
|
|
-Wl,-Map=${PX4_CONFIG}.map
|
2018-04-11 16:10:51 -03:00
|
|
|
-Wl,--warn-common
|
|
|
|
-Wl,--gc-sections
|
2017-12-16 13:27:50 -04:00
|
|
|
|
2017-11-18 12:18:53 -04:00
|
|
|
-Wl,--start-group
|
2019-01-22 15:13:20 -04:00
|
|
|
drivers_boards_common_arch
|
2018-04-11 16:10:51 -03:00
|
|
|
${nuttx_libs}
|
2017-09-04 14:33:02 -03:00
|
|
|
-Wl,--end-group
|
2018-05-17 16:20:26 -03:00
|
|
|
|
|
|
|
m
|
2019-01-06 12:33:21 -04:00
|
|
|
gcc
|
2017-09-04 14:33:02 -03:00
|
|
|
)
|
2016-10-14 12:52:10 -03:00
|
|
|
|
2018-12-04 12:13:56 -04:00
|
|
|
target_link_libraries(px4 PRIVATE ${module_libraries})
|
|
|
|
target_link_libraries(px4 PRIVATE modules__uORB)
|
2018-04-11 16:10:51 -03:00
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
if (config_romfs_root)
|
|
|
|
add_subdirectory(${PX4_SOURCE_DIR}/ROMFS ${PX4_BINARY_DIR}/ROMFS)
|
2018-12-04 12:13:56 -04:00
|
|
|
target_link_libraries(px4 PRIVATE romfs)
|
2017-08-29 18:22:05 -03:00
|
|
|
endif()
|
2016-12-12 19:11:51 -04:00
|
|
|
|
2018-11-16 13:52:37 -04:00
|
|
|
add_custom_command(OUTPUT ${PX4_BINARY_DIR_REL}/${PX4_BOARD}.bin
|
|
|
|
COMMAND ${CMAKE_OBJCOPY} -O binary ${PX4_BINARY_DIR_REL}/${FW_NAME} ${PX4_BINARY_DIR_REL}/${PX4_BOARD}.bin
|
2018-12-04 12:13:56 -04:00
|
|
|
DEPENDS px4
|
2017-09-04 14:33:02 -03:00
|
|
|
)
|
2016-12-12 19:11:51 -04:00
|
|
|
|
2018-12-04 12:13:56 -04:00
|
|
|
# create .px4 with parameter and airframe metadata
|
2017-09-04 14:33:02 -03:00
|
|
|
if (TARGET parameters_xml AND TARGET airframes_xml)
|
2018-12-04 12:13:56 -04:00
|
|
|
|
|
|
|
string(REPLACE ".elf" ".px4" fw_package ${FW_NAME})
|
|
|
|
|
|
|
|
add_custom_command(OUTPUT ${fw_package}
|
|
|
|
COMMAND
|
|
|
|
${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_mkfw.py
|
|
|
|
--prototype ${PX4_SOURCE_DIR}/boards/${PX4_BOARD_VENDOR}/${PX4_BOARD_MODEL}/firmware.prototype
|
|
|
|
--git_identity ${PX4_SOURCE_DIR}
|
|
|
|
--parameter_xml ${PX4_BINARY_DIR}/parameters.xml
|
|
|
|
--airframe_xml ${PX4_BINARY_DIR}/airframes.xml
|
|
|
|
--image ${PX4_BINARY_DIR}/${PX4_BOARD}.bin > ${fw_package}
|
|
|
|
DEPENDS
|
|
|
|
${PX4_BINARY_DIR}/${PX4_BOARD}.bin
|
|
|
|
airframes_xml
|
|
|
|
parameters_xml
|
|
|
|
COMMENT "Creating ${fw_package}"
|
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
2017-08-29 18:22:05 -03:00
|
|
|
)
|
2016-12-12 19:11:51 -04:00
|
|
|
|
2018-12-04 12:13:56 -04:00
|
|
|
add_custom_target(px4_package ALL DEPENDS ${fw_package})
|
2016-12-12 19:11:51 -04:00
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
# upload helper
|
2018-12-04 12:13:56 -04:00
|
|
|
# create upload target helper if NuttX USB CDCACM is present
|
|
|
|
if (CONFIG_CDCACM)
|
2018-06-28 12:47:13 -03:00
|
|
|
|
2018-12-04 12:13:56 -04:00
|
|
|
# NuttX CDCACM vendor and product strings
|
|
|
|
set(vendorstr_underscore)
|
|
|
|
set(productstr_underscore)
|
|
|
|
string(REPLACE " " "_" vendorstr_underscore ${CONFIG_CDCACM_VENDORSTR})
|
|
|
|
string(REPLACE " " "_" productstr_underscore ${CONFIG_CDCACM_PRODUCTSTR})
|
2018-06-28 12:47:13 -03:00
|
|
|
|
2018-12-04 12:13:56 -04:00
|
|
|
set(serial_ports)
|
|
|
|
if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
|
2018-06-28 12:47:13 -03:00
|
|
|
|
2018-12-04 12:13:56 -04:00
|
|
|
set(px4_usb_path "${vendorstr_underscore}_${productstr_underscore}")
|
2018-06-28 12:47:13 -03:00
|
|
|
|
2018-12-04 12:13:56 -04:00
|
|
|
list(APPEND serial_ports
|
|
|
|
# NuttX vendor + product string
|
|
|
|
/dev/serial/by-id/*-${px4_usb_path}*
|
2018-06-28 12:47:13 -03:00
|
|
|
|
2018-12-04 12:13:56 -04:00
|
|
|
# Bootloader
|
|
|
|
/dev/serial/by-id/*PX4_BL* # typical bootloader USB device string
|
|
|
|
/dev/serial/by-id/*BL_FMU*
|
2018-06-28 12:47:13 -03:00
|
|
|
|
2018-12-04 12:13:56 -04:00
|
|
|
# TODO: handle these per board
|
|
|
|
/dev/serial/by-id/usb-The_Autopilot*
|
|
|
|
/dev/serial/by-id/usb-Bitcraze*
|
|
|
|
/dev/serial/by-id/pci-Bitcraze*
|
|
|
|
/dev/serial/by-id/usb-Gumstix*
|
2018-06-28 12:47:13 -03:00
|
|
|
|
2018-01-31 19:49:09 -04:00
|
|
|
)
|
2018-06-28 13:01:26 -03:00
|
|
|
|
2018-12-04 12:13:56 -04:00
|
|
|
elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
|
|
|
|
list(APPEND serial_ports
|
|
|
|
/dev/tty.usbmodemPX*,/dev/tty.usbmodem*
|
2018-05-08 15:12:29 -03:00
|
|
|
)
|
2018-12-04 12:13:56 -04:00
|
|
|
elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "CYGWIN")
|
|
|
|
list(APPEND serial_ports
|
|
|
|
/dev/ttyS*
|
|
|
|
)
|
|
|
|
elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
|
|
|
|
foreach(port RANGE 32 0)
|
|
|
|
list(APPEND serial_ports
|
|
|
|
"COM${port}")
|
|
|
|
endforeach()
|
2018-01-31 19:49:09 -04:00
|
|
|
endif()
|
2018-06-28 12:47:13 -03:00
|
|
|
|
2018-12-04 12:13:56 -04:00
|
|
|
string(REPLACE ";" "," serial_ports "${serial_ports}")
|
|
|
|
|
|
|
|
add_custom_target(upload
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_uploader.py --port ${serial_ports} ${fw_package}
|
|
|
|
DEPENDS ${fw_package}
|
|
|
|
COMMENT "uploading px4"
|
|
|
|
VERBATIM
|
|
|
|
USES_TERMINAL
|
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(force-upload
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_uploader.py --force --port ${serial_ports} ${fw_package}
|
|
|
|
DEPENDS ${fw_package}
|
|
|
|
COMMENT "uploading px4 with --force"
|
|
|
|
VERBATIM
|
|
|
|
USES_TERMINAL
|
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
|
|
|
)
|
2017-08-29 18:22:05 -03:00
|
|
|
endif()
|
2018-12-04 12:13:56 -04:00
|
|
|
|
2015-09-12 06:26:31 -03:00
|
|
|
endif()
|
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
# print size
|
|
|
|
add_custom_target(size
|
2018-12-04 12:13:56 -04:00
|
|
|
COMMAND size $<TARGET_FILE:px4>
|
|
|
|
DEPENDS px4
|
2017-08-29 18:22:05 -03:00
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
2018-04-12 17:06:53 -03:00
|
|
|
USES_TERMINAL
|
2017-08-29 18:22:05 -03:00
|
|
|
)
|
2015-09-08 16:18:59 -03:00
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
# print weak symbols
|
2018-04-12 17:06:53 -03:00
|
|
|
add_custom_target(weak_symbols
|
2018-12-04 12:13:56 -04:00
|
|
|
COMMAND ${CMAKE_NM} $<TARGET_FILE:px4> | ${GREP} " w " | cat
|
|
|
|
DEPENDS px4
|
2015-09-12 06:26:31 -03:00
|
|
|
VERBATIM
|
2018-04-12 17:06:53 -03:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(stack_check
|
2018-12-04 12:13:56 -04:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory stack_usage && ${CMAKE_OBJDUMP} -d $<TARGET_FILE:px4> | ${PX4_SOURCE_DIR}/Tools/stack_usage/checkstack.pl arm 0 > stack_usage/checkstack_output.txt 2> stack_usage/checkstack_errors.txt
|
2018-04-12 17:06:53 -03:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo ""
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo ""
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Top 50:"
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "--------------------------------------------------------------------------------"
|
|
|
|
COMMAND head -n 50 stack_usage/checkstack_output.txt | c++filt
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo ""
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Symbols with 'run', 'task', 'thread', 'main', 'update':"
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "--------------------------------------------------------------------------------"
|
|
|
|
COMMAND cat stack_usage/checkstack_output.txt | c++filt | grep -E 'run|task|thread|main|update'
|
2018-12-04 12:13:56 -04:00
|
|
|
DEPENDS px4
|
2018-04-12 17:06:53 -03:00
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
|
|
|
VERBATIM
|
2015-09-13 15:31:58 -03:00
|
|
|
)
|
|
|
|
|
2018-05-17 16:20:26 -03:00
|
|
|
find_program(BLOATY_PROGRAM bloaty)
|
|
|
|
if (BLOATY_PROGRAM)
|
|
|
|
# bloaty symbols
|
|
|
|
add_custom_target(bloaty_symbols
|
2018-12-04 12:13:56 -04:00
|
|
|
COMMAND ${BLOATY_PROGRAM} -d symbols -C full -n 50 -s vm $<TARGET_FILE:px4>
|
|
|
|
DEPENDS px4
|
2018-05-17 16:20:26 -03:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
|
|
|
# bloaty compilation units
|
|
|
|
add_custom_target(bloaty_compileunits
|
2018-12-04 12:13:56 -04:00
|
|
|
COMMAND ${BLOATY_PROGRAM} -d compileunits -C full -n 50 -s vm $<TARGET_FILE:px4>
|
|
|
|
DEPENDS px4
|
2018-05-17 16:20:26 -03:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
|
|
|
# bloaty templates
|
|
|
|
add_custom_target(bloaty_templates
|
2018-12-04 12:13:56 -04:00
|
|
|
COMMAND ${BLOATY_PROGRAM} -d shortsymbols,fullsymbols -n 50 $<TARGET_FILE:px4>
|
|
|
|
DEPENDS px4
|
2018-05-17 16:20:26 -03:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
|
|
|
# bloaty inlines
|
|
|
|
add_custom_target(bloaty_inlines
|
2018-12-04 12:13:56 -04:00
|
|
|
COMMAND ${BLOATY_PROGRAM} -d inlines -C full -n 50 $<TARGET_FILE:px4>
|
|
|
|
DEPENDS px4
|
2018-05-17 16:20:26 -03:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
|
|
|
# bloaty compare with last master build
|
|
|
|
add_custom_target(bloaty_compare_master
|
2018-11-22 00:27:21 -04:00
|
|
|
#COMMAND wget --no-verbose https://s3.amazonaws.com/px4-travis/Firmware/master/${FW_NAME} -O master_${FW_NAME}
|
2018-11-28 16:57:31 -04:00
|
|
|
COMMAND wget --no-verbose https://s3.amazonaws.com/px4-travis/Firmware/master/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_${PX4_BOARD_LABEL}.elf -O master_${FW_NAME}
|
2018-12-04 12:13:56 -04:00
|
|
|
COMMAND ${BLOATY_PROGRAM} -d symbols -n 50 -C full -s vm $<TARGET_FILE:px4> -- master_${FW_NAME}
|
|
|
|
DEPENDS px4
|
2018-05-17 16:20:26 -03:00
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
|
|
|
VERBATIM
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
# debugger helpers
|
2018-08-04 17:48:47 -03:00
|
|
|
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Debug/gdbinit.in ${PX4_BINARY_DIR}/.gdbinit)
|
2016-07-12 21:47:55 -03:00
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
add_custom_target(debug
|
2018-12-04 12:13:56 -04:00
|
|
|
COMMAND ${GDB} -iex 'set auto-load safe-path ${PX4_BINARY_DIR}' $<TARGET_FILE:px4>
|
|
|
|
DEPENDS px4 ${PX4_BINARY_DIR}/.gdbinit
|
2018-08-04 17:48:47 -03:00
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
|
|
|
file(GLOB_RECURSE black_magic_probe_path
|
|
|
|
FOLLOW_SYMLINKS
|
|
|
|
/dev/serial/by-id/usb-Black_Sphere_Technologies_Black_Magic_Probe_*-if00
|
|
|
|
)
|
|
|
|
file(GLOB_RECURSE black_magic_probe_console_path
|
|
|
|
FOLLOW_SYMLINKS
|
|
|
|
/dev/serial/by-id/usb-Black_Sphere_Technologies_Black_Magic_Probe_*-if02
|
|
|
|
)
|
|
|
|
|
|
|
|
if(black_magic_probe_path)
|
|
|
|
|
|
|
|
add_custom_target(blackmagic_debug
|
|
|
|
COMMAND ${GDB} --nh
|
|
|
|
-iex 'set auto-load safe-path ${PX4_BINARY_DIR}'
|
|
|
|
-ex 'target extended-remote ${black_magic_probe_path}'
|
|
|
|
-ex 'monitor version'
|
|
|
|
-ex 'monitor connect_srst enable'
|
|
|
|
-ex 'monitor swdp_scan'
|
|
|
|
-ex 'attach 1'
|
|
|
|
-ex 'load'
|
|
|
|
-ex 'run'
|
2018-12-04 12:13:56 -04:00
|
|
|
$<TARGET_FILE:px4>
|
|
|
|
DEPENDS px4 ${PX4_BINARY_DIR}/.gdbinit
|
2018-08-04 17:48:47 -03:00
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(blackmagic_upload
|
|
|
|
COMMAND ${GDB} --nx --batch
|
|
|
|
-ex 'target extended-remote ${black_magic_probe_path}'
|
|
|
|
-ex 'monitor version'
|
|
|
|
-ex 'monitor connect_srst enable'
|
|
|
|
-ex 'monitor swdp_scan'
|
|
|
|
-ex 'attach 1'
|
|
|
|
-ex 'load'
|
|
|
|
-ex 'kill'
|
2018-12-04 12:13:56 -04:00
|
|
|
$<TARGET_FILE:px4>
|
|
|
|
DEPENDS px4
|
2018-08-04 17:48:47 -03:00
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
|
|
|
USES_TERMINAL
|
|
|
|
COMMENT "Uploading with Black Magic Probe"
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(blackmagic_console
|
2018-11-16 13:52:37 -04:00
|
|
|
COMMAND screen -t "${PX4_BOARD} console" ${black_magic_probe_console_path} 57600 8N1
|
2018-08-04 17:48:47 -03:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_custom_target(jlink_upload
|
|
|
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/Debug/jlink.sh
|
|
|
|
COMMAND ${GDB} --nx --batch
|
|
|
|
-iex 'set auto-load safe-path ${PX4_BINARY_DIR}'
|
|
|
|
-ex 'target remote localhost:2331'
|
|
|
|
-ex 'monitor reset'
|
|
|
|
-ex 'load'
|
|
|
|
-ex 'kill'
|
2018-12-04 12:13:56 -04:00
|
|
|
$<TARGET_FILE:px4>
|
|
|
|
DEPENDS px4 ${PX4_BINARY_DIR}/.gdbinit
|
2018-08-04 17:48:47 -03:00
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(jlink_debug
|
|
|
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/Debug/jlink.sh
|
|
|
|
COMMAND ${GDB} --nh
|
|
|
|
-iex 'set auto-load safe-path ${PX4_BINARY_DIR}'
|
|
|
|
-ex 'target remote localhost:2331'
|
|
|
|
-ex 'monitor reset'
|
|
|
|
-ex 'load'
|
|
|
|
-ex 'monitor reset'
|
|
|
|
-ex 'continue'
|
2018-12-04 12:13:56 -04:00
|
|
|
$<TARGET_FILE:px4>
|
|
|
|
DEPENDS px4 ${PX4_BINARY_DIR}/.gdbinit
|
2018-08-04 17:48:47 -03:00
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
2018-04-09 12:00:52 -03:00
|
|
|
USES_TERMINAL
|
2017-08-29 18:22:05 -03:00
|
|
|
)
|
2018-06-19 16:52:57 -03:00
|
|
|
|
|
|
|
# Poor man's profiler
|
|
|
|
include(ExternalProject)
|
|
|
|
ExternalProject_Add(FlameGraph
|
|
|
|
GIT_REPOSITORY "https://github.com/brendangregg/FlameGraph.git"
|
|
|
|
UPDATE_COMMAND ""
|
|
|
|
PATCH_COMMAND ""
|
|
|
|
CONFIGURE_COMMAND ""
|
|
|
|
BUILD_COMMAND ""
|
|
|
|
INSTALL_COMMAND ""
|
|
|
|
EXCLUDE_FROM_ALL 1
|
|
|
|
)
|
|
|
|
|
2018-04-09 12:00:52 -03:00
|
|
|
add_custom_target(profile
|
2018-08-04 17:48:47 -03:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env PATH="${PX4_BINARY_DIR}/external/Source/FlameGraph:$ENV{PATH}"
|
2018-12-04 12:13:56 -04:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Debug/poor-mans-profiler.sh --elf=$<TARGET_FILE:px4> --nsamples=10000
|
|
|
|
DEPENDS px4 ${CMAKE_CURRENT_SOURCE_DIR}/Debug/poor-mans-profiler.sh FlameGraph
|
2018-04-09 12:00:52 -03:00
|
|
|
USES_TERMINAL
|
2018-08-04 17:48:47 -03:00
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
2017-08-29 18:22:05 -03:00
|
|
|
)
|