2017-06-01 09:47:33 -03:00
|
|
|
include(common/px4_upload)
|
|
|
|
|
2017-12-09 20:41:12 -04:00
|
|
|
if (NOT FW_NAME)
|
|
|
|
set(FW_NAME ${CONFIG}.elf)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_executable(${FW_NAME} ${PX4_SOURCE_DIR}/src/platforms/empty.c)
|
|
|
|
add_dependencies(${FW_NAME} git_nuttx nuttx_build)
|
2015-09-19 18:57:54 -03:00
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
get_property(module_libraries GLOBAL PROPERTY PX4_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_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)
|
|
|
|
endif()
|
|
|
|
|
2017-11-23 00:56:13 -04:00
|
|
|
if (NOT LD_SCRIPT)
|
|
|
|
set(LD_SCRIPT ld.script)
|
|
|
|
endif()
|
|
|
|
|
2017-12-09 20:41:12 -04:00
|
|
|
target_link_libraries(${FW_NAME}
|
2017-12-12 15:24:34 -04:00
|
|
|
-TNuttX/nuttx/configs/${BOARD}/scripts/${LD_SCRIPT}
|
|
|
|
-Wl,-Map=${CONFIG}.map
|
2017-11-18 12:18:53 -04:00
|
|
|
-Wl,--warn-common
|
|
|
|
-Wl,--gc-sections
|
|
|
|
-Wl,--start-group
|
|
|
|
${module_libraries}
|
|
|
|
${nuttx_libs}
|
2017-09-04 14:33:02 -03:00
|
|
|
-Wl,--end-group
|
|
|
|
m
|
|
|
|
gcc
|
|
|
|
)
|
2016-10-14 12:52:10 -03:00
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
if (config_romfs_root)
|
|
|
|
add_subdirectory(${PX4_SOURCE_DIR}/ROMFS ${PX4_BINARY_DIR}/ROMFS)
|
2017-12-09 20:41:12 -04:00
|
|
|
target_link_libraries(${FW_NAME} romfs)
|
2017-08-29 18:22:05 -03:00
|
|
|
if (config_io_board)
|
|
|
|
add_dependencies(romfs copy_px4io_bin)
|
|
|
|
endif()
|
|
|
|
endif()
|
2016-12-12 19:11:51 -04:00
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
# create px4 file (combined firmware and metadata)
|
2017-12-09 21:35:44 -04:00
|
|
|
set(fw_file ${PX4_BINARY_DIR}/${FW_NAME})
|
|
|
|
string(REPLACE ".elf" ".px4" fw_file ${fw_file})
|
|
|
|
string(REPLACE "nuttx_" "" fw_file ${fw_file})
|
2016-12-12 19:11:51 -04:00
|
|
|
|
2017-12-12 15:24:34 -04:00
|
|
|
file(RELATIVE_PATH PX4_BINARY_DIR_REL ${CMAKE_CURRENT_BINARY_DIR} ${PX4_BINARY_DIR})
|
|
|
|
|
2017-09-04 14:33:02 -03:00
|
|
|
add_custom_command(OUTPUT ${BOARD}.bin
|
2017-12-12 15:24:34 -04:00
|
|
|
COMMAND ${OBJCOPY} -O binary ${PX4_BINARY_DIR_REL}/${FW_NAME} ${BOARD}.bin
|
2017-12-09 20:41:12 -04:00
|
|
|
DEPENDS ${FW_NAME}
|
2017-09-04 14:33:02 -03:00
|
|
|
)
|
2016-12-12 19:11:51 -04:00
|
|
|
|
2018-01-01 09:58:00 -04:00
|
|
|
if (NOT FW_PROTOTYPE)
|
|
|
|
set(FW_PROTOTYPE ${BOARD})
|
|
|
|
endif()
|
|
|
|
|
2017-09-04 14:33:02 -03:00
|
|
|
if (TARGET parameters_xml AND TARGET airframes_xml)
|
2017-10-02 14:13:02 -03:00
|
|
|
add_custom_command(OUTPUT ${fw_file}
|
2017-08-29 18:22:05 -03:00
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_mkfw.py
|
2018-01-04 23:50:16 -04:00
|
|
|
--prototype ${PX4_SOURCE_DIR}/platforms/nuttx/Images/${FW_PROTOTYPE}.prototype
|
2017-08-29 18:22:05 -03:00
|
|
|
--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
|
2017-10-02 14:13:02 -03:00
|
|
|
COMMENT "Creating ${fw_file}"
|
2017-08-29 18:22:05 -03:00
|
|
|
)
|
2016-12-12 19:11:51 -04:00
|
|
|
|
2017-10-02 14:13:02 -03:00
|
|
|
add_custom_target(px4 ALL DEPENDS ${fw_file})
|
2016-12-12 19:11:51 -04:00
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
# 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()
|
2015-09-12 06:26:31 -03:00
|
|
|
endif()
|
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
# print size
|
|
|
|
add_custom_target(size
|
2017-12-09 20:41:12 -04:00
|
|
|
COMMAND size ${FW_NAME}
|
|
|
|
DEPENDS ${FW_NAME}
|
2017-08-29 18:22:05 -03:00
|
|
|
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
|
|
|
)
|
2015-09-08 16:18:59 -03:00
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
# print weak symbols
|
2015-09-13 15:31:58 -03:00
|
|
|
add_custom_target(check_weak
|
2017-12-09 20:41:12 -04:00
|
|
|
COMMAND ${NM} ${FW_NAME} | ${GREP} " w " | cat
|
|
|
|
DEPENDS ${FW_NAME}
|
2015-09-12 06:26:31 -03:00
|
|
|
VERBATIM
|
2015-09-13 15:31:58 -03:00
|
|
|
)
|
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
# debugger helpers
|
|
|
|
configure_file(gdbinit.in .gdbinit)
|
2016-07-12 21:47:55 -03:00
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
add_custom_target(debug
|
2017-12-09 20:41:12 -04:00
|
|
|
COMMAND ${GDB} $<TARGET_FILE:${FW_NAME}>
|
|
|
|
DEPENDS ${FW_NAME} ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit
|
2017-08-29 18:22:05 -03:00
|
|
|
)
|
2015-10-06 13:10:23 -03:00
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
add_custom_target(debug_tui
|
2017-12-09 20:41:12 -04:00
|
|
|
COMMAND ${GDBTUI} $<TARGET_FILE:${FW_NAME}>
|
|
|
|
DEPENDS ${FW_NAME} ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit
|
2017-08-29 18:22:05 -03:00
|
|
|
)
|
2015-09-13 15:31:58 -03:00
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
add_custom_target(debug_ddd
|
2017-12-09 20:41:12 -04:00
|
|
|
COMMAND ${DDD} --debugger ${GDB} $<TARGET_FILE:${FW_NAME}>
|
|
|
|
DEPENDS ${FW_NAME} ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit
|
2017-08-29 18:22:05 -03:00
|
|
|
)
|
2015-10-06 13:10:23 -03:00
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
add_custom_target(debug_io
|
|
|
|
COMMAND ${GDB} ${fw_io_path}
|
2017-12-09 20:41:12 -04:00
|
|
|
DEPENDS ${FW_NAME} ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit
|
2017-08-29 18:22:05 -03:00
|
|
|
)
|
2015-09-11 07:38:39 -03:00
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
add_custom_target(debug_io_tui
|
|
|
|
COMMAND ${GDBTUI} ${fw_io_path}
|
2017-12-09 20:41:12 -04:00
|
|
|
DEPENDS ${FW_NAME} ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit
|
2017-08-29 18:22:05 -03:00
|
|
|
)
|
2015-09-08 16:18:59 -03:00
|
|
|
|
2017-08-29 18:22:05 -03:00
|
|
|
add_custom_target(debug_io_ddd
|
|
|
|
COMMAND ${DDD} --debugger ${GDB} ${fw_io_path}}
|
|
|
|
DEPENDS ${fw_io} ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit
|
|
|
|
)
|