@@ -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 "" )
@@ -944,11 +944,11 @@ add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME}
944944 )
945945
946946if (BUILD_DFU)
947- add_custom_command (TARGET ${EXECUTABLE_MCUBOOT_NAME}
948- POST_BUILD
949- COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_FILE_NAME} ${DFU_MCUBOOT_FILE_NAME}
950- COMMENT "post build (DFU) steps for ${EXECUTABLE_MCUBOOT_FILE_NAME} "
951- )
947+ add_custom_command (TARGET ${EXECUTABLE_MCUBOOT_NAME}
948+ POST_BUILD
949+ COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_FILE_NAME} ${DFU_MCUBOOT_FILE_NAME}
950+ COMMENT "post build (DFU) steps for ${EXECUTABLE_MCUBOOT_FILE_NAME} "
951+ )
952952endif ()
953953
954954# InfiniTime recovery firmware (autonomous)
@@ -1013,11 +1013,11 @@ add_custom_command(TARGET ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}
10131013 )
10141014
10151015if (BUILD_DFU)
1016- add_custom_command (TARGET ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}
1017- POST_BUILD
1018- COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME} ${DFU_RECOVERY_MCUBOOT_FILE_NAME}
1019- COMMENT "post build (DFU) steps for ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME} "
1020- )
1016+ add_custom_command (TARGET ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}
1017+ POST_BUILD
1018+ COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME} ${DFU_RECOVERY_MCUBOOT_FILE_NAME}
1019+ COMMENT "post build (DFU) steps for ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME} "
1020+ )
10211021endif ()
10221022
10231023# Build binary that writes the recovery image into the SPI flash memory
@@ -1088,75 +1088,75 @@ add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}
10881088 )
10891089
10901090if (BUILD_DFU)
1091- add_custom_command (TARGET ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}
1092- POST_BUILD
1093- COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME} ${DFU_MCUBOOT_RECOVERYLOADER_FILE_NAME}
1094- COMMENT "post build (DFU) steps for ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME} "
1095- )
1091+ add_custom_command (TARGET ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}
1092+ POST_BUILD
1093+ COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME} ${DFU_MCUBOOT_RECOVERYLOADER_FILE_NAME}
1094+ COMMENT "post build (DFU) steps for ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME} "
1095+ )
10961096endif ()
10971097
10981098
10991099# FLASH
11001100if (USE_JLINK)
1101+ add_custom_target (FLASH_ERASE
1102+ COMMAND ${NRFJPROG} --eraseall -f ${NRF_TARGET}
1103+ COMMENT "erasing flashing"
1104+ )
1105+ add_custom_target ("FLASH_${EXECUTABLE_NAME} "
1106+ DEPENDS ${EXECUTABLE_NAME}
1107+ COMMAND ${NRFJPROG} --program ${EXECUTABLE_FILE_NAME} .hex -f ${NRF_TARGET} --sectorerase
1108+ COMMAND sleep 0.5s
1109+ COMMAND ${NRFJPROG} --reset -f ${NRF_TARGET}
1110+ COMMENT "flashing ${EXECUTABLE_FILE_NAME} .hex"
1111+ )
1112+
1113+ elseif (USE_GDB_CLIENT)
1114+ add_custom_target (FLASH_ERASE
1115+ 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'
1116+ COMMENT "erasing flashing"
1117+ )
1118+ add_custom_target ("FLASH_${EXECUTABLE_NAME} "
1119+ DEPENDS ${EXECUTABLE_NAME}
1120+ 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
1121+ COMMENT "flashing ${EXECUTABLE_FILE_NAME} .hex"
1122+ )
1123+ elseif (USE_OPENOCD)
1124+ if (USE_CMSIS_DAP)
11011125 add_custom_target (FLASH_ERASE
1102- COMMAND ${NRFJPROG} --eraseall -f ${NRF_TARGET}
1126+ COMMAND ${OPENOCD_BIN_PATH} -c 'source [find interface /cmsis-dap.cfg]' -c 'transport select swd'
1127+ -c 'source [find target /nrf52.cfg]'
1128+ -c 'init'
1129+ -c 'halt'
1130+ -c 'nrf5 mass_erase'
1131+ -c 'halt'
1132+ -c 'reset'
1133+ -c 'exit'
11031134 COMMENT "erasing flashing"
11041135 )
11051136 add_custom_target ("FLASH_${EXECUTABLE_NAME} "
11061137 DEPENDS ${EXECUTABLE_NAME}
1107- COMMAND ${NRFJPROG} --program ${EXECUTABLE_FILE_NAME} .hex -f ${NRF_TARGET} --sectorerase
1108- COMMAND sleep 0.5s
1109- COMMAND ${NRFJPROG} --reset -f ${NRF_TARGET}
1110- COMMENT "flashing ${EXECUTABLE_FILE_NAME} .hex"
1138+ COMMAND ${OPENOCD_BIN_PATH}
1139+ -c 'tcl_port disabled'
1140+ -c 'gdb_port 3333'
1141+ -c 'telnet_port 4444'
1142+ -c 'source [find interface /cmsis-dap.cfg]'
1143+ -c 'transport select swd'
1144+ -c 'source [find target /nrf52.cfg]'
1145+ -c 'halt'
1146+ -c "program \" ${EXECUTABLE_FILE_NAME} .hex\" "
1147+ -c 'reset'
1148+ -c 'shutdown'
1149+ COMMENT "flashing ${EXECUTABLE_BIN_NAME} .hex"
11111150 )
1112-
1113- elseif (USE_GDB_CLIENT)
1151+ else ()
11141152 add_custom_target (FLASH_ERASE
1115- 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'
1153+ 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
11161154 COMMENT "erasing flashing"
11171155 )
11181156 add_custom_target ("FLASH_${EXECUTABLE_NAME} "
11191157 DEPENDS ${EXECUTABLE_NAME}
1120- 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
1158+ 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
11211159 COMMENT "flashing ${EXECUTABLE_FILE_NAME} .hex"
11221160 )
1123- elseif (USE_OPENOCD)
1124- if (USE_CMSIS_DAP)
1125- add_custom_target (FLASH_ERASE
1126- COMMAND ${OPENOCD_BIN_PATH} -c 'source [find interface /cmsis-dap.cfg]' -c 'transport select swd'
1127- -c 'source [find target /nrf52.cfg]'
1128- -c 'init'
1129- -c 'halt'
1130- -c 'nrf5 mass_erase'
1131- -c 'halt'
1132- -c 'reset'
1133- -c 'exit'
1134- COMMENT "erasing flashing"
1135- )
1136- add_custom_target ("FLASH_${EXECUTABLE_NAME} "
1137- DEPENDS ${EXECUTABLE_NAME}
1138- COMMAND ${OPENOCD_BIN_PATH}
1139- -c 'tcl_port disabled'
1140- -c 'gdb_port 3333'
1141- -c 'telnet_port 4444'
1142- -c 'source [find interface /cmsis-dap.cfg]'
1143- -c 'transport select swd'
1144- -c 'source [find target /nrf52.cfg]'
1145- -c 'halt'
1146- -c "program \" ${EXECUTABLE_FILE_NAME} .hex\" "
1147- -c 'reset'
1148- -c 'shutdown'
1149- COMMENT "flashing ${EXECUTABLE_BIN_NAME} .hex"
1150- )
1151- else ()
1152- add_custom_target (FLASH_ERASE
1153- 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
1154- COMMENT "erasing flashing"
1155- )
1156- add_custom_target ("FLASH_${EXECUTABLE_NAME} "
1157- DEPENDS ${EXECUTABLE_NAME}
1158- 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
1159- COMMENT "flashing ${EXECUTABLE_FILE_NAME} .hex"
1160- )
1161- endif ()
1161+ endif ()
11621162endif ()
0 commit comments