2015-09-08 15:18:59 -04:00
|
|
|
px4_nuttx_generate_builtin_commands(
|
|
|
|
|
OUT builtin_commands.c
|
2015-09-10 23:43:59 -04:00
|
|
|
MODULE_LIST
|
|
|
|
|
${module_libraries}
|
2015-09-12 01:53:01 -04:00
|
|
|
${config_extra_builtin_cmds}
|
2015-09-10 17:44:27 -04:00
|
|
|
)
|
2015-09-08 15:18:59 -04:00
|
|
|
|
|
|
|
|
# add executable
|
2015-09-13 18:30:32 -04:00
|
|
|
add_executable(firmware_nuttx
|
2015-09-19 17:57:54 -04:00
|
|
|
builtin_commands.c)
|
|
|
|
|
|
|
|
|
|
|
2016-12-12 13:11:51 -10:00
|
|
|
set(nuttx_export_dir ${PX4_BINARY_DIR}/${BOARD}/NuttX/nuttx/nuttx-export)
|
2015-09-12 05:26:31 -04:00
|
|
|
|
|
|
|
|
set(link_libs
|
2016-12-12 13:11:51 -10:00
|
|
|
apps nuttx m gcc
|
2015-09-08 15:18:59 -04:00
|
|
|
)
|
|
|
|
|
|
2016-12-12 13:11:51 -10:00
|
|
|
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_startup_files ${nuttx_export_dir}/startup/${nuttx_startup_files})
|
|
|
|
|
set(nuttx_bootloader_wrapers "-Wl,-wrap,sched_process_timer")
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
2015-09-12 05:26:31 -04:00
|
|
|
if(NOT ${BOARD} STREQUAL "sim")
|
|
|
|
|
set(main_link_flags
|
2016-12-12 13:11:51 -10:00
|
|
|
"-T${nuttx_export_dir}/build/${nuttx_ld_prefix}ld.script"
|
2016-08-18 15:37:23 -04:00
|
|
|
"-Wl,-Map=${PX4_BINARY_DIR}/${BOARD}/main.map"
|
2015-09-12 05:26:31 -04:00
|
|
|
)
|
|
|
|
|
px4_join(OUT main_link_flags LIST ${main_link_flags} GLUE " ")
|
|
|
|
|
set_target_properties(firmware_nuttx PROPERTIES LINK_FLAGS ${main_link_flags})
|
|
|
|
|
endif()
|
|
|
|
|
|
2015-09-08 15:18:59 -04:00
|
|
|
target_link_libraries(firmware_nuttx
|
2016-12-12 13:11:51 -10:00
|
|
|
-Wl,--warn-common
|
|
|
|
|
-Wl,--gc-sections
|
2015-09-08 15:18:59 -04:00
|
|
|
-Wl,--start-group
|
2016-12-12 13:11:51 -10:00
|
|
|
${startup_libs}
|
2015-09-10 12:40:34 -04:00
|
|
|
${module_libraries}
|
2016-05-03 01:03:28 -07:00
|
|
|
${df_driver_libs}
|
2015-09-12 05:26:31 -04:00
|
|
|
${config_extra_libs}
|
2016-12-12 13:11:51 -10:00
|
|
|
${nuttx_bootloader_wrapers}
|
2015-09-12 05:26:31 -04:00
|
|
|
${link_libs}
|
2015-09-08 15:18:59 -04:00
|
|
|
-Wl,--end-group)
|
|
|
|
|
|
2015-09-13 14:31:58 -04:00
|
|
|
add_custom_target(check_weak
|
2015-09-12 05:26:31 -04:00
|
|
|
COMMAND ${NM} firmware_nuttx | ${GREP} " w " | cat
|
2015-09-13 14:31:58 -04:00
|
|
|
DEPENDS firmware_nuttx
|
2015-09-12 05:26:31 -04:00
|
|
|
VERBATIM
|
2015-09-13 14:31:58 -04:00
|
|
|
)
|
|
|
|
|
|
2015-09-12 05:26:31 -04:00
|
|
|
if(NOT ${BOARD} STREQUAL "sim")
|
2015-10-24 10:57:46 -04:00
|
|
|
|
2016-12-12 13:11:51 -10:00
|
|
|
if ("${romfs_used}" STREQUAL "y")
|
2015-10-24 10:57:46 -04:00
|
|
|
|
2016-12-12 13:11:51 -10:00
|
|
|
if (config_io_board)
|
|
|
|
|
set(extras "${CMAKE_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board}.bin")
|
|
|
|
|
endif()
|
2016-07-12 14:47:55 -10:00
|
|
|
|
2016-12-12 13:11:51 -10:00
|
|
|
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()
|
2015-10-22 09:22:55 +13:00
|
|
|
endif()
|
2016-04-22 15:15:37 -04:00
|
|
|
|
2016-12-12 13:11:51 -10:00
|
|
|
set(fw_file
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${OS}-${BOARD}-${LABEL}.px4)
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# 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()
|
2015-09-13 14:31:58 -04:00
|
|
|
|
2015-09-12 05:26:31 -04:00
|
|
|
configure_file(gdbinit.in .gdbinit)
|
|
|
|
|
|
|
|
|
|
add_custom_target(debug
|
2015-10-06 12:10:23 -04:00
|
|
|
COMMAND ${GDB} ${CMAKE_CURRENT_BINARY_DIR}/firmware_nuttx
|
|
|
|
|
DEPENDS firmware_nuttx
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/.gdbinit
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
add_custom_target(debug_tui
|
2015-09-19 10:39:54 -04:00
|
|
|
COMMAND ${GDBTUI} ${CMAKE_CURRENT_BINARY_DIR}/firmware_nuttx
|
|
|
|
|
DEPENDS firmware_nuttx
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/.gdbinit
|
|
|
|
|
)
|
|
|
|
|
|
2015-10-06 12:10:23 -04:00
|
|
|
add_custom_target(debug_ddd
|
|
|
|
|
COMMAND ${DDD} --debugger ${GDB} ${CMAKE_CURRENT_BINARY_DIR}/firmware_nuttx
|
|
|
|
|
DEPENDS firmware_nuttx
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/.gdbinit
|
|
|
|
|
)
|
|
|
|
|
|
2015-09-19 10:39:54 -04:00
|
|
|
add_custom_target(debug_io
|
2015-10-06 12:10:23 -04:00
|
|
|
COMMAND ${GDB}
|
2016-08-18 15:37:23 -04:00
|
|
|
${PX4_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board}
|
2015-10-06 12:10:23 -04:00
|
|
|
DEPENDS firmware_nuttx
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/.gdbinit
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
add_custom_target(debug_io_tui
|
2015-09-19 10:39:54 -04:00
|
|
|
COMMAND ${GDBTUI}
|
2016-08-18 15:37:23 -04:00
|
|
|
${PX4_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board}
|
2015-09-12 05:26:31 -04:00
|
|
|
DEPENDS firmware_nuttx
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/.gdbinit
|
|
|
|
|
)
|
2015-09-13 14:31:58 -04:00
|
|
|
|
2015-10-06 12:10:23 -04:00
|
|
|
add_custom_target(debug_io_ddd
|
|
|
|
|
COMMAND ${DDD} --debugger ${GDB}
|
2016-08-18 15:37:23 -04:00
|
|
|
${PX4_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board}
|
2015-10-06 12:10:23 -04:00
|
|
|
DEPENDS firmware_nuttx
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/.gdbinit
|
|
|
|
|
)
|
|
|
|
|
|
2016-12-12 13:11:51 -10:00
|
|
|
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()
|
2016-10-05 16:31:40 -03:00
|
|
|
endif()
|
2015-09-12 05:26:31 -04:00
|
|
|
endif()
|
2015-09-11 06:38:39 -04:00
|
|
|
|
2016-12-12 13:11:51 -10:00
|
|
|
if(NOT "${config_nuttx_config}" STREQUAL "bootloader")
|
|
|
|
|
install(FILES ${fw_file} DESTINATION .)
|
|
|
|
|
endif()
|
2015-09-08 15:18:59 -04:00
|
|
|
|
|
|
|
|
# vim: set noet ft=cmake fenc=utf-8 ff=unix :
|