@@ -9,21 +9,21 @@ set(NRF_BOARD pca10040)
99
1010# check if all the necessary tools paths have been provided.
1111if (NOT NRF5_SDK_PATH)
12- message (FATAL_ERROR "The path to the nRF5 SDK (NRF5_SDK_PATH) must be set." )
12+ message (FATAL_ERROR "The path to the nRF5 SDK (NRF5_SDK_PATH) must be set." )
1313endif ()
1414if (DEFINED ARM_NONE_EABI_TOOLCHAIN_PATH)
15- set (ARM_NONE_EABI_TOOLCHAIN_BIN_PATH ${ARM_NONE_EABI_TOOLCHAIN_PATH} /bin)
15+ set (ARM_NONE_EABI_TOOLCHAIN_BIN_PATH ${ARM_NONE_EABI_TOOLCHAIN_PATH} /bin)
1616endif ()
1717
1818if (NOT NRF_TARGET MATCHES "nrf52" )
19- message (FATAL_ERROR "Only rRF52 boards are supported right now" )
19+ message (FATAL_ERROR "Only rRF52 boards are supported right now" )
2020endif ()
2121
2222# Setup toolchain
2323include (${CMAKE_SOURCE_DIR} /cmake-nRF5x/arm-gcc-toolchain.cmake )
2424
2525if (NOT DEFINED ARM_GCC_TOOLCHAIN)
26- message (FATAL_ERROR "The toolchain must be set up before calling this macro" )
26+ message (FATAL_ERROR "The toolchain must be set up before calling this macro" )
2727endif ()
2828set (CMAKE_OSX_SYSROOT "/" )
2929set (CMAKE_OSX_DEPLOYMENT_TARGET "" )
@@ -936,11 +936,11 @@ add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME}
936936 )
937937
938938if (BUILD_DFU)
939- add_custom_command (TARGET ${EXECUTABLE_MCUBOOT_NAME}
940- POST_BUILD
941- COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_FILE_NAME} ${DFU_MCUBOOT_FILE_NAME}
942- COMMENT "post build (DFU) steps for ${EXECUTABLE_MCUBOOT_FILE_NAME} "
943- )
939+ add_custom_command (TARGET ${EXECUTABLE_MCUBOOT_NAME}
940+ POST_BUILD
941+ COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_FILE_NAME} ${DFU_MCUBOOT_FILE_NAME}
942+ COMMENT "post build (DFU) steps for ${EXECUTABLE_MCUBOOT_FILE_NAME} "
943+ )
944944endif ()
945945
946946# InfiniTime recovery firmware (autonomous)
@@ -1005,11 +1005,11 @@ add_custom_command(TARGET ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}
10051005 )
10061006
10071007if (BUILD_DFU)
1008- add_custom_command (TARGET ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}
1009- POST_BUILD
1010- COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME} ${DFU_RECOVERY_MCUBOOT_FILE_NAME}
1011- COMMENT "post build (DFU) steps for ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME} "
1012- )
1008+ add_custom_command (TARGET ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}
1009+ POST_BUILD
1010+ COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME} ${DFU_RECOVERY_MCUBOOT_FILE_NAME}
1011+ COMMENT "post build (DFU) steps for ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME} "
1012+ )
10131013endif ()
10141014
10151015# Build binary that writes the recovery image into the SPI flash memory
@@ -1080,75 +1080,75 @@ add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}
10801080 )
10811081
10821082if (BUILD_DFU)
1083- add_custom_command (TARGET ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}
1084- POST_BUILD
1085- COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME} ${DFU_MCUBOOT_RECOVERYLOADER_FILE_NAME}
1086- COMMENT "post build (DFU) steps for ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME} "
1087- )
1083+ add_custom_command (TARGET ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}
1084+ POST_BUILD
1085+ COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME} ${DFU_MCUBOOT_RECOVERYLOADER_FILE_NAME}
1086+ COMMENT "post build (DFU) steps for ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME} "
1087+ )
10881088endif ()
10891089
10901090
10911091# FLASH
10921092if (USE_JLINK)
1093+ add_custom_target (FLASH_ERASE
1094+ COMMAND ${NRFJPROG} --eraseall -f ${NRF_TARGET}
1095+ COMMENT "erasing flashing"
1096+ )
1097+ add_custom_target ("FLASH_${EXECUTABLE_NAME} "
1098+ DEPENDS ${EXECUTABLE_NAME}
1099+ COMMAND ${NRFJPROG} --program ${EXECUTABLE_FILE_NAME} .hex -f ${NRF_TARGET} --sectorerase
1100+ COMMAND sleep 0.5s
1101+ COMMAND ${NRFJPROG} --reset -f ${NRF_TARGET}
1102+ COMMENT "flashing ${EXECUTABLE_FILE_NAME} .hex"
1103+ )
1104+
1105+ elseif (USE_GDB_CLIENT)
1106+ add_custom_target (FLASH_ERASE
1107+ 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'
1108+ COMMENT "erasing flashing"
1109+ )
1110+ add_custom_target ("FLASH_${EXECUTABLE_NAME} "
1111+ DEPENDS ${EXECUTABLE_NAME}
1112+ 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_FILE_NAME} .hex
1113+ COMMENT "flashing ${EXECUTABLE_FILE_NAME} .hex"
1114+ )
1115+ elseif (USE_OPENOCD)
1116+ if (USE_CMSIS_DAP)
10931117 add_custom_target (FLASH_ERASE
1094- COMMAND ${NRFJPROG} --eraseall -f ${NRF_TARGET}
1118+ COMMAND ${OPENOCD_BIN_PATH} -c 'source [find interface /cmsis-dap.cfg]' -c 'transport select swd'
1119+ -c 'source [find target /nrf52.cfg]'
1120+ -c 'init'
1121+ -c 'halt'
1122+ -c 'nrf5 mass_erase'
1123+ -c 'halt'
1124+ -c 'reset'
1125+ -c 'exit'
10951126 COMMENT "erasing flashing"
10961127 )
10971128 add_custom_target ("FLASH_${EXECUTABLE_NAME} "
10981129 DEPENDS ${EXECUTABLE_NAME}
1099- COMMAND ${NRFJPROG} --program ${EXECUTABLE_FILE_NAME} .hex -f ${NRF_TARGET} --sectorerase
1100- COMMAND sleep 0.5s
1101- COMMAND ${NRFJPROG} --reset -f ${NRF_TARGET}
1102- COMMENT "flashing ${EXECUTABLE_FILE_NAME} .hex"
1130+ COMMAND ${OPENOCD_BIN_PATH}
1131+ -c 'tcl_port disabled'
1132+ -c 'gdb_port 3333'
1133+ -c 'telnet_port 4444'
1134+ -c 'source [find interface /cmsis-dap.cfg]'
1135+ -c 'transport select swd'
1136+ -c 'source [find target /nrf52.cfg]'
1137+ -c 'halt'
1138+ -c "program \" ${EXECUTABLE_FILE_NAME} .hex\" "
1139+ -c 'reset'
1140+ -c 'shutdown'
1141+ COMMENT "flashing ${EXECUTABLE_BIN_NAME} .hex"
11031142 )
1104-
1105- elseif (USE_GDB_CLIENT)
1143+ else ()
11061144 add_custom_target (FLASH_ERASE
1107- 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'
1145+ COMMAND ${OPENOCD_BIN_PATH } -f interface /stlink.cfg -c 'transport select hla_swd ' -f target /nrf52.cfg -c init -c halt -c 'nrf5 mass_erase ' -c reset -c shutdown
11081146 COMMENT "erasing flashing"
11091147 )
11101148 add_custom_target ("FLASH_${EXECUTABLE_NAME} "
11111149 DEPENDS ${EXECUTABLE_NAME}
1112- 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_FILE_NAME} .hex
1150+ COMMAND ${OPENOCD_BIN_PATH } -c "tcl_port disabled" -c "gdb_port 3333" -c "telnet_port 4444" -f interface /stlink.cfg -c 'transport select hla_swd ' -f target /nrf52.cfg -c "program \" ${EXECUTABLE_FILE_NAME} .hex\" " -c reset -c shutdown
11131151 COMMENT "flashing ${EXECUTABLE_FILE_NAME} .hex"
11141152 )
1115- elseif (USE_OPENOCD)
1116- if (USE_CMSIS_DAP)
1117- add_custom_target (FLASH_ERASE
1118- COMMAND ${OPENOCD_BIN_PATH} -c 'source [find interface /cmsis-dap.cfg]' -c 'transport select swd'
1119- -c 'source [find target /nrf52.cfg]'
1120- -c 'init'
1121- -c 'halt'
1122- -c 'nrf5 mass_erase'
1123- -c 'halt'
1124- -c 'reset'
1125- -c 'exit'
1126- COMMENT "erasing flashing"
1127- )
1128- add_custom_target ("FLASH_${EXECUTABLE_NAME} "
1129- DEPENDS ${EXECUTABLE_NAME}
1130- COMMAND ${OPENOCD_BIN_PATH}
1131- -c 'tcl_port disabled'
1132- -c 'gdb_port 3333'
1133- -c 'telnet_port 4444'
1134- -c 'source [find interface /cmsis-dap.cfg]'
1135- -c 'transport select swd'
1136- -c 'source [find target /nrf52.cfg]'
1137- -c 'halt'
1138- -c "program \" ${EXECUTABLE_FILE_NAME} .hex\" "
1139- -c 'reset'
1140- -c 'shutdown'
1141- COMMENT "flashing ${EXECUTABLE_BIN_NAME} .hex"
1142- )
1143- else ()
1144- add_custom_target (FLASH_ERASE
1145- COMMAND ${OPENOCD_BIN_PATH} -f interface /stlink.cfg -c 'transport select hla_swd' -f target /nrf52.cfg -c init -c halt -c 'nrf5 mass_erase' -c reset -c shutdown
1146- COMMENT "erasing flashing"
1147- )
1148- add_custom_target ("FLASH_${EXECUTABLE_NAME} "
1149- DEPENDS ${EXECUTABLE_NAME}
1150- COMMAND ${OPENOCD_BIN_PATH} -c "tcl_port disabled" -c "gdb_port 3333" -c "telnet_port 4444" -f interface /stlink.cfg -c 'transport select hla_swd' -f target /nrf52.cfg -c "program \" ${EXECUTABLE_FILE_NAME} .hex\" " -c reset -c shutdown
1151- COMMENT "flashing ${EXECUTABLE_FILE_NAME} .hex"
1152- )
1153- endif ()
1153+ endif ()
11541154endif ()
0 commit comments