forked from Archive/PX4-Autopilot
cmake cleanup jlink flashing helpers
This commit is contained in:
parent
7846771c68
commit
fe1eb8cd62
|
@ -206,6 +206,20 @@ add_custom_target(weak_symbols
|
|||
USES_TERMINAL
|
||||
)
|
||||
|
||||
# generate bootloader.elf and copy to top level build directory
|
||||
if(EXISTS "${PX4_BOARD_DIR}/bootloader/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.bin")
|
||||
add_custom_command(
|
||||
OUTPUT ${PX4_BINARY_DIR}/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.elf
|
||||
COMMAND
|
||||
${CMAKE_OBJCOPY} -I binary -O elf32-little --change-section-address .data=0x08000000
|
||||
${PX4_BOARD_DIR}/bootloader/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.bin
|
||||
${PX4_BINARY_DIR}/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.elf
|
||||
DEPENDS ${PX4_BOARD_DIR}/bootloader/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.bin
|
||||
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
||||
)
|
||||
add_custom_target(bootloader_elf DEPENDS ${PX4_BINARY_DIR}/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.elf)
|
||||
endif()
|
||||
|
||||
|
||||
# debugger helpers
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Debug/gdbinit.in ${PX4_BINARY_DIR}/.gdbinit)
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
Device @DEBUG_DEVICE@
|
||||
eoe 1
|
||||
si SWD
|
||||
speed auto
|
||||
r
|
||||
h
|
||||
loadbin @BOARD_BL_FIRMWARE_BIN@,0x08000000
|
||||
go
|
||||
qc
|
|
@ -31,11 +31,11 @@
|
|||
#
|
||||
############################################################################
|
||||
|
||||
# jlink_upload (flash binary)
|
||||
find_program(JLinkGDBServerCLExe_PATH JLinkGDBServerCLExe
|
||||
HINTS /Applications/SEGGER/JLink
|
||||
)
|
||||
if(JLinkGDBServerCLExe_PATH)
|
||||
# jlink_upload (flash binary)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Debug/jlink_gdb_start.sh.in ${PX4_BINARY_DIR}/jlink_gdb_start.sh @ONLY)
|
||||
add_custom_target(jlink_upload
|
||||
COMMAND ${PX4_BINARY_DIR}/jlink_gdb_start.sh
|
||||
|
@ -47,6 +47,24 @@ if(JLinkGDBServerCLExe_PATH)
|
|||
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
||||
|
||||
# jlink_upload_bootloader
|
||||
# board directory supplied bootloader.bin
|
||||
if(TARGET bootloader_elf)
|
||||
# jlink_upload_bootloader
|
||||
add_custom_target(jlink_upload_bootloader
|
||||
COMMAND ${PX4_BINARY_DIR}/jlink_gdb_start.sh
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/Debug/upload_jlink_gdb.sh ${PX4_BINARY_DIR}/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.elf
|
||||
DEPENDS
|
||||
${PX4_BINARY_DIR}/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.elf
|
||||
${PX4_BINARY_DIR}/jlink_gdb_start.sh
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Debug/upload_jlink_gdb.sh
|
||||
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
||||
USES_TERMINAL
|
||||
)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
# jlink_debug_gdb (flash binary and run with gdb attached)
|
||||
|
@ -82,54 +100,47 @@ if(Ozone_PATH)
|
|||
)
|
||||
endif()
|
||||
|
||||
if(bootloader_bin OR (EXISTS "${PX4_BOARD_DIR}/bootloader/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.bin"))
|
||||
|
||||
if(bootloader_bin)
|
||||
set(BOARD_BL_FIRMWARE_BIN ${bootloader_bin})
|
||||
else()
|
||||
set(BOARD_BL_FIRMWARE_BIN ${PX4_BOARD_DIR}/bootloader/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.bin)
|
||||
endif()
|
||||
|
||||
# jlink_upload_bootloader
|
||||
if(JLinkGDBServerCLExe_PATH)
|
||||
add_custom_target(jlink_upload_bootloader
|
||||
COMMAND ${PX4_BINARY_DIR}/jlink_gdb_start.sh
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/Debug/upload_jlink_gdb.sh ${PX4_BINARY_DIR}/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.elf
|
||||
DEPENDS
|
||||
${PX4_BINARY_DIR}/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.elf
|
||||
${PX4_BINARY_DIR}/jlink_gdb_start.sh
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Debug/upload_jlink_gdb.sh
|
||||
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
||||
USES_TERMINAL
|
||||
)
|
||||
endif()
|
||||
# .bin flashing
|
||||
find_program(JLinkExe_PATH JLinkExe)
|
||||
if(JLinkExe_PATH)
|
||||
|
||||
# jlink_flash_bootloader_bin
|
||||
find_program(JLinkExe_PATH JLinkExe)
|
||||
if(JLinkExe_PATH)
|
||||
file(RELATIVE_PATH BOARD_BL_FIRMWARE_BIN ${PX4_BINARY_DIR} ${BOARD_BL_FIRMWARE_BIN})
|
||||
if(bootloader_bin OR (EXISTS ${PX4_BOARD_DIR}/bootloader/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.bin))
|
||||
|
||||
set(BOARD_FIRMWARE_BIN "${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.bin")
|
||||
set(BOARD_FIRMWARE_APP_OFFSET "0x08000000")
|
||||
configure_file(${PX4_SOURCE_DIR}/platforms/nuttx/Debug/flash_bin.jlink.in ${PX4_BINARY_DIR}/flash_bootloader_bin.jlink @ONLY)
|
||||
|
||||
if(bootloader_bin)
|
||||
add_custom_command(OUTPUT ${PX4_BINARY_DIR}/${BOARD_FIRMWARE_BIN}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${bootloader_bin} ${PX4_BINARY_DIR}/${BOARD_FIRMWARE_BIN}
|
||||
DEPENDS ${bootloader_bin}
|
||||
)
|
||||
elseif(EXISTS ${PX4_BOARD_DIR}/bootloader/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.bin)
|
||||
add_custom_command(OUTPUT ${PX4_BINARY_DIR}/${BOARD_FIRMWARE_BIN}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PX4_BOARD_DIR}/bootloader/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.bin ${PX4_BINARY_DIR}/${BOARD_FIRMWARE_BIN}
|
||||
DEPENDS ${PX4_BOARD_DIR}/bootloader/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.bin
|
||||
)
|
||||
endif()
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Debug/flash_bootloader.jlink.in ${PX4_BINARY_DIR}/flash_bootloader.jlink @ONLY)
|
||||
add_custom_target(jlink_flash_bootloader_bin
|
||||
COMMAND ${JLinkExe_PATH} -CommandFile ${PX4_BINARY_DIR}/flash_bootloader.jlink
|
||||
COMMAND ${JLinkExe_PATH} -CommandFile ${PX4_BINARY_DIR}/flash_bootloader_bin.jlink
|
||||
DEPENDS
|
||||
px4
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Debug/flash_bootloader.jlink.in
|
||||
${PX4_BINARY_DIR}/${BOARD_FIRMWARE_BIN}
|
||||
${PX4_SOURCE_DIR}/platforms/nuttx/Debug/flash_bin.jlink.in
|
||||
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
||||
USES_TERMINAL
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(uavcan_bl_image_name)
|
||||
# jlink_flash_bootloader
|
||||
find_program(JLinkExe_PATH JLinkExe)
|
||||
if(JLinkExe_PATH)
|
||||
set(BOARD_FIRMWARE_BIN ${PX4_BINARY_DIR}/${uavcan_bl_image_name})
|
||||
# jlink_flash_bin
|
||||
if(uavcan_bl_image_name)
|
||||
# uavcan signed firmware
|
||||
set(BOARD_FIRMWARE_BIN ${uavcan_bl_image_name})
|
||||
set(BOARD_FIRMWARE_APP_OFFSET "0x08010000")
|
||||
|
||||
configure_file(${PX4_SOURCE_DIR}/platforms/nuttx/Debug/flash_bin.jlink.in ${PX4_BINARY_DIR}/flash_bin.jlink @ONLY)
|
||||
add_custom_target(jlink_flash_uavcan_bin
|
||||
|
||||
add_custom_target(jlink_flash_bin
|
||||
COMMAND ${JLinkExe_PATH} -CommandFile ${PX4_BINARY_DIR}/flash_bin.jlink
|
||||
DEPENDS
|
||||
${PX4_SOURCE_DIR}/platforms/nuttx/Debug/flash_bin.jlink.in
|
||||
|
@ -137,5 +148,21 @@ if(uavcan_bl_image_name)
|
|||
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
||||
USES_TERMINAL
|
||||
)
|
||||
else()
|
||||
# regular firmware ${PX4_BINARY_DIR}/${PX4_BOARD}.bin
|
||||
set(BOARD_FIRMWARE_BIN ${PX4_BOARD}.bin)
|
||||
set(BOARD_FIRMWARE_APP_OFFSET "0x08008000") # TODO: get from board
|
||||
configure_file(${PX4_SOURCE_DIR}/platforms/nuttx/Debug/flash_bin.jlink.in ${PX4_BINARY_DIR}/flash_bin.jlink @ONLY)
|
||||
|
||||
add_custom_target(jlink_flash_bin
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "WARNING jlink_flash_bin currently assumes starting address ${BOARD_FIRMWARE_APP_OFFSET}"
|
||||
COMMAND ${JLinkExe_PATH} -CommandFile ${PX4_BINARY_DIR}/flash_bin.jlink
|
||||
DEPENDS
|
||||
${PX4_SOURCE_DIR}/platforms/nuttx/Debug/flash_bin.jlink.in
|
||||
${PX4_BINARY_DIR}/${PX4_BOARD}.bin
|
||||
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
||||
USES_TERMINAL
|
||||
)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
|
|
@ -58,12 +58,10 @@ ExternalProject_Add(px4io_firmware
|
|||
USES_TERMINAL_BUILD true
|
||||
DEPENDS git_nuttx git_nuttx_apps
|
||||
BUILD_ALWAYS 1
|
||||
BUILD_BYPRODUCTS "${PX4_BINARY_DIR}/external/Build/px4io_firmware/${config_io_board}.elf"
|
||||
BUILD_BYPRODUCTS ${PX4_BINARY_DIR}/external/Build/px4io_firmware/${config_io_board}.elf
|
||||
)
|
||||
|
||||
ExternalProject_Get_Property(px4io_firmware BINARY_DIR)
|
||||
|
||||
set(fw_io_exe "${BINARY_DIR}/${config_io_board}.elf")
|
||||
set(fw_io_exe "${PX4_BINARY_DIR}/external/Build/px4io_firmware/${config_io_board}.elf")
|
||||
set(fw_io_bin "${PX4_BINARY_DIR}/romfs_extras/${config_io_board}.bin" CACHE FILEPATH "px4io binary path")
|
||||
|
||||
file(RELATIVE_PATH fw_io_exe_relative ${CMAKE_CURRENT_BINARY_DIR} ${fw_io_exe})
|
||||
|
|
|
@ -70,7 +70,8 @@ if(config_build_bootloader)
|
|||
file(RELATIVE_PATH bootloader_exe_relative ${CMAKE_CURRENT_BINARY_DIR} ${board_bootloader_firmware})
|
||||
file(RELATIVE_PATH bootloader_bin_relative ${CMAKE_CURRENT_BINARY_DIR} ${bootloader_bin})
|
||||
|
||||
add_custom_command(OUTPUT ${bootloader_bin}
|
||||
add_custom_command(
|
||||
OUTPUT ${bootloader_bin}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${PX4_BINARY_DIR}/romfs_extras
|
||||
COMMAND ${CMAKE_OBJCOPY} -O binary ${bootloader_exe_relative} ${bootloader_bin_relative}
|
||||
DEPENDS bootloader_firmware
|
||||
|
@ -93,7 +94,8 @@ elseif(EXISTS "${PX4_BOARD_DIR}/bootloader/")
|
|||
set(board_bootloader_firmware ${PX4_BOARD_DIR}/bootloader/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.bin CACHE FILEPATH "bootloader original binary path")
|
||||
set(bootloader_bin "${PX4_BINARY_DIR}/romfs_extras/bootloader.bin" CACHE FILEPATH "bootloader binary path")
|
||||
|
||||
add_custom_command(OUTPUT ${bootloader_bin}
|
||||
add_custom_command(
|
||||
OUTPUT ${bootloader_bin}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${PX4_BINARY_DIR}/romfs_extras
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${board_bootloader_firmware} ${PX4_BINARY_DIR}/romfs_extras/bootloader.bin
|
||||
DEPENDS ${board_bootloader_firmware}
|
||||
|
@ -101,15 +103,6 @@ elseif(EXISTS "${PX4_BOARD_DIR}/bootloader/")
|
|||
)
|
||||
add_custom_target(copy_bootloader_bin DEPENDS ${bootloader_bin})
|
||||
|
||||
# generate bootloader.elf and copy to top level build directory
|
||||
add_custom_command(
|
||||
OUTPUT ${PX4_BINARY_DIR}/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.elf
|
||||
COMMAND ${CMAKE_OBJCOPY} -I binary -O elf32-little --change-section-address .data=0x08000000 ${board_bootloader_firmware} ${PX4_BINARY_DIR}/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.elf
|
||||
DEPENDS ${board_bootloader_firmware}
|
||||
WORKING_DIRECTORY ${PX4_BINARY_DIR}
|
||||
)
|
||||
add_custom_target(bootloader_elf DEPENDS ${PX4_BINARY_DIR}/${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_bootloader.elf)
|
||||
|
||||
else()
|
||||
file(GLOB bootloader_bin_files ${PX4_BOARD_DIR}/bootloader/*.bin)
|
||||
foreach(bin_file ${bootloader_bin_files})
|
||||
|
|
Loading…
Reference in New Issue