Add support for Black magic probe (using GDB client).
Add documentation about that in README.md
This commit is contained in:
@@ -5,9 +5,9 @@ if (NOT NRF5_SDK_PATH)
|
||||
message(FATAL_ERROR "The path to the nRF5 SDK (NRF5_SDK_PATH) must be set.")
|
||||
endif ()
|
||||
|
||||
if (NOT NRFJPROG)
|
||||
message(FATAL_ERROR "The path to the nrfjprog utility (NRFJPROG) must be set.")
|
||||
endif ()
|
||||
#if (NOT NRFJPROG)
|
||||
# message(FATAL_ERROR "The path to the nrfjprog utility (NRFJPROG) must be set.")
|
||||
#endif ()
|
||||
|
||||
# convert toolchain path to bin path
|
||||
if(DEFINED ARM_NONE_EABI_TOOLCHAIN_PATH)
|
||||
@@ -323,17 +323,28 @@ macro(nRF5x_setup)
|
||||
)
|
||||
|
||||
# adds target for erasing and flashing the board with a softdevice
|
||||
add_custom_target(FLASH_SOFTDEVICE ALL
|
||||
COMMAND ${NRFJPROG} --program ${SOFTDEVICE_PATH} -f ${NRF_TARGET} --sectorerase
|
||||
COMMAND sleep 0.5s
|
||||
COMMAND ${NRFJPROG} --reset -f ${NRF_TARGET}
|
||||
COMMENT "flashing SoftDevice"
|
||||
)
|
||||
if(USE_JLINK)
|
||||
add_custom_target(FLASH_SOFTDEVICE ALL
|
||||
COMMAND ${NRFJPROG} --program ${SOFTDEVICE_PATH} -f ${NRF_TARGET} --sectorerase
|
||||
COMMAND sleep 0.5s
|
||||
COMMAND ${NRFJPROG} --reset -f ${NRF_TARGET}
|
||||
COMMENT "flashing SoftDevice"
|
||||
)
|
||||
|
||||
add_custom_target(FLASH_ERASE ALL
|
||||
COMMAND ${NRFJPROG} --eraseall -f ${NRF_TARGET}
|
||||
COMMENT "erasing flashing"
|
||||
)
|
||||
add_custom_target(FLASH_ERASE ALL
|
||||
COMMAND ${NRFJPROG} --eraseall -f ${NRF_TARGET}
|
||||
COMMENT "erasing flashing"
|
||||
)
|
||||
elseif(USE_GDB_CLIENT)
|
||||
add_custom_target(FLASH_SOFTDEVICE ALL
|
||||
COMMAND ${GDB_CLIENT_BIN_PATH} -nx --batch -ex 'target extended-remote ${GDB_CLIENT_TARGET_REMOTE}' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'load' -ex 'kill' ${SOFTDEVICE_PATH}
|
||||
COMMENT "flashing SoftDevice"
|
||||
)
|
||||
add_custom_target(FLASH_ERASE ALL
|
||||
COMMAND ${GDB_CLIENT_BIN_PATH} -nx --batch -ex 'target extended-remote ${GDB_CLIENT_TARGET_REMOTE}' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'mon erase_mass'
|
||||
COMMENT "erasing flashing"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
|
||||
set(TERMINAL "open")
|
||||
@@ -343,13 +354,15 @@ macro(nRF5x_setup)
|
||||
set(TERMINAL "gnome-terminal")
|
||||
endif()
|
||||
|
||||
add_custom_target(START_JLINK ALL
|
||||
COMMAND ${TERMINAL} "${DIR_OF_nRF5x_CMAKE}/runJLinkGDBServer-${NRF_TARGET}"
|
||||
COMMAND ${TERMINAL} "${DIR_OF_nRF5x_CMAKE}/runJLinkExe-${NRF_TARGET}"
|
||||
COMMAND sleep 2s
|
||||
COMMAND ${TERMINAL} "${DIR_OF_nRF5x_CMAKE}/runJLinkRTTClient"
|
||||
COMMENT "started JLink commands"
|
||||
)
|
||||
if(USE_JLINK)
|
||||
add_custom_target(START_JLINK ALL
|
||||
COMMAND ${TERMINAL} "${DIR_OF_nRF5x_CMAKE}/runJLinkGDBServer-${NRF_TARGET}"
|
||||
COMMAND ${TERMINAL} "${DIR_OF_nRF5x_CMAKE}/runJLinkExe-${NRF_TARGET}"
|
||||
COMMAND sleep 2s
|
||||
COMMAND ${TERMINAL} "${DIR_OF_nRF5x_CMAKE}/runJLinkRTTClient"
|
||||
COMMENT "started JLink commands"
|
||||
)
|
||||
endif()
|
||||
|
||||
endmacro(nRF5x_setup)
|
||||
|
||||
@@ -368,14 +381,46 @@ macro(nRF5x_addExecutable EXECUTABLE_NAME SOURCE_FILES)
|
||||
COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_NAME}.out "${EXECUTABLE_NAME}.hex"
|
||||
COMMENT "post build steps for ${EXECUTABLE_NAME}")
|
||||
|
||||
if(MERGEHEX)
|
||||
add_custom_command(TARGET ${EXECUTABLE_NAME}
|
||||
POST_BUILD
|
||||
COMMAND ${MERGEHEX} --merge ${EXECUTABLE_NAME}.hex ${NRF5_SDK_PATH}/components/softdevice/s132/hex/s132_nrf52_6.1.1_softdevice.hex --output ${EXECUTABLE_NAME}-full.hex
|
||||
COMMENT "merging HEX files")
|
||||
|
||||
if(USE_JLINK)
|
||||
add_custom_target("FLASH_MERGED_${EXECUTABLE_NAME}" ALL
|
||||
DEPENDS ${EXECUTABLE_NAME}
|
||||
COMMAND ${NRFJPROG} --program ${EXECUTABLE_NAME}-full.hex -f ${NRF_TARGET} --sectorerase
|
||||
COMMAND sleep 0.5s
|
||||
COMMAND ${NRFJPROG} --reset -f ${NRF_TARGET}
|
||||
COMMENT "flashing ${EXECUTABLE_NAME}-full.hex"
|
||||
)
|
||||
elseif(USE_GDB_CLIENT)
|
||||
add_custom_target("FLASH_MERGED_${EXECUTABLE_NAME}" ALL
|
||||
DEPENDS ${EXECUTABLE_NAME}
|
||||
COMMAND ${GDB_CLIENT_BIN_PATH} -nx --batch -ex 'target extended-remote ${GDB_CLIENT_TARGET_REMOTE}' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'load' -ex 'kill' ${EXECUTABLE_NAME}-full.hex
|
||||
COMMENT "flashing ${EXECUTABLE_NAME}-full.hex"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# custom target for flashing the board
|
||||
add_custom_target("FLASH_${EXECUTABLE_NAME}" ALL
|
||||
DEPENDS ${EXECUTABLE_NAME}
|
||||
COMMAND ${NRFJPROG} --program ${EXECUTABLE_NAME}.hex -f ${NRF_TARGET} --sectorerase
|
||||
COMMAND sleep 0.5s
|
||||
COMMAND ${NRFJPROG} --reset -f ${NRF_TARGET}
|
||||
COMMENT "flashing ${EXECUTABLE_NAME}.hex"
|
||||
)
|
||||
if(USE_JLINK)
|
||||
add_custom_target("FLASH_${EXECUTABLE_NAME}" ALL
|
||||
DEPENDS ${EXECUTABLE_NAME}
|
||||
COMMAND ${NRFJPROG} --program ${EXECUTABLE_NAME}.hex -f ${NRF_TARGET} --sectorerase
|
||||
COMMAND sleep 0.5s
|
||||
COMMAND ${NRFJPROG} --reset -f ${NRF_TARGET}
|
||||
COMMENT "flashing ${EXECUTABLE_NAME}.hex"
|
||||
)
|
||||
elseif(USE_GDB_CLIENT)
|
||||
add_custom_target("FLASH_${EXECUTABLE_NAME}" ALL
|
||||
DEPENDS ${EXECUTABLE_NAME}
|
||||
COMMAND ${GDB_CLIENT_BIN_PATH} -nx --batch -ex 'target extended-remote ${GDB_CLIENT_TARGET_REMOTE}' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'load' -ex 'kill' ${EXECUTABLE_NAME}.hex
|
||||
COMMENT "flashing ${EXECUTABLE_NAME}.hex"
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
|
||||
|
Reference in New Issue
Block a user