@@ -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 "" )
@@ -801,24 +801,24 @@ add_definitions(-D__HEAP_SIZE=4096)
801801
802802# Debug configuration
803803if (${CMAKE_BUILD_TYPE} STREQUAL "Debug" )
804- add_definitions (-DDEBUG)
805- add_definitions (-DDEBUG_NRF_USER)
806-
807- # NRF SDK Logging
808- add_definitions (-DNRF_LOG_ENABLED=1)
809- # add_definitions(-DNRF_LOG_BACKEND_RTT_ENABLED=1)
810- # add_definitions(-DNRF_LOG_BACKEND_SERIAL_USES_RTT=1)
811-
812- # NRF SDK individual modules logging
813- # add_definitions(-DCLOCK_CONFIG_LOG_ENABLED=1)
814- # add_definitions(-DCLOCK_CONFIG_LOG_LEVEL=4)
815- # add_definitions(-DRTC_CONFIG_LOG_ENABLED=1)
816- # add_definitions(-DRTC_CONFIG_LOG_LEVEL=4)
817-
818- # Nimble Logging
819- add_definitions (-DMYNEWT_VAL_NEWT_FEATURE_LOGCFG=1)
820- # add_definitions(-DMYNEWT_VAL_LOG_LEVEL=0)
821- # add_definitions(-DMYNEWT_VAL_BLE_HS_LOG_LVL=0)
804+ add_definitions (-DDEBUG)
805+ add_definitions (-DDEBUG_NRF_USER)
806+
807+ # NRF SDK Logging
808+ add_definitions (-DNRF_LOG_ENABLED=1)
809+ # add_definitions(-DNRF_LOG_BACKEND_RTT_ENABLED=1)
810+ # add_definitions(-DNRF_LOG_BACKEND_SERIAL_USES_RTT=1)
811+
812+ # NRF SDK individual modules logging
813+ # add_definitions(-DCLOCK_CONFIG_LOG_ENABLED=1)
814+ # add_definitions(-DCLOCK_CONFIG_LOG_LEVEL=4)
815+ # add_definitions(-DRTC_CONFIG_LOG_ENABLED=1)
816+ # add_definitions(-DRTC_CONFIG_LOG_LEVEL=4)
817+
818+ # Nimble Logging
819+ add_definitions (-DMYNEWT_VAL_NEWT_FEATURE_LOGCFG=1)
820+ # add_definitions(-DMYNEWT_VAL_LOG_LEVEL=0)
821+ # add_definitions(-DMYNEWT_VAL_BLE_HS_LOG_LVL=0)
822822endif ()
823823
824824# NRF SDK
@@ -948,11 +948,11 @@ add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME}
948948 )
949949
950950if (BUILD_DFU)
951- add_custom_command (TARGET ${EXECUTABLE_MCUBOOT_NAME}
952- POST_BUILD
953- COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_FILE_NAME} ${DFU_MCUBOOT_FILE_NAME}
954- COMMENT "post build (DFU) steps for ${EXECUTABLE_MCUBOOT_FILE_NAME} "
955- )
951+ add_custom_command (TARGET ${EXECUTABLE_MCUBOOT_NAME}
952+ POST_BUILD
953+ COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_FILE_NAME} ${DFU_MCUBOOT_FILE_NAME}
954+ COMMENT "post build (DFU) steps for ${EXECUTABLE_MCUBOOT_FILE_NAME} "
955+ )
956956endif ()
957957
958958# InfiniTime recovery firmware (autonomous)
@@ -1017,11 +1017,11 @@ add_custom_command(TARGET ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}
10171017 )
10181018
10191019if (BUILD_DFU)
1020- add_custom_command (TARGET ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}
1021- POST_BUILD
1022- COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME} ${DFU_RECOVERY_MCUBOOT_FILE_NAME}
1023- COMMENT "post build (DFU) steps for ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME} "
1024- )
1020+ add_custom_command (TARGET ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}
1021+ POST_BUILD
1022+ COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME} ${DFU_RECOVERY_MCUBOOT_FILE_NAME}
1023+ COMMENT "post build (DFU) steps for ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME} "
1024+ )
10251025endif ()
10261026
10271027# Build binary that writes the recovery image into the SPI flash memory
@@ -1092,75 +1092,75 @@ add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}
10921092 )
10931093
10941094if (BUILD_DFU)
1095- add_custom_command (TARGET ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}
1096- POST_BUILD
1097- COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME} ${DFU_MCUBOOT_RECOVERYLOADER_FILE_NAME}
1098- COMMENT "post build (DFU) steps for ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME} "
1099- )
1095+ add_custom_command (TARGET ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}
1096+ POST_BUILD
1097+ COMMAND adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME} ${DFU_MCUBOOT_RECOVERYLOADER_FILE_NAME}
1098+ COMMENT "post build (DFU) steps for ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME} "
1099+ )
11001100endif ()
11011101
11021102
11031103# FLASH
11041104if (USE_JLINK)
1105+ add_custom_target (FLASH_ERASE
1106+ COMMAND ${NRFJPROG} --eraseall -f ${NRF_TARGET}
1107+ COMMENT "erasing flashing"
1108+ )
1109+ add_custom_target ("FLASH_${EXECUTABLE_NAME} "
1110+ DEPENDS ${EXECUTABLE_NAME}
1111+ COMMAND ${NRFJPROG} --program ${EXECUTABLE_FILE_NAME} .hex -f ${NRF_TARGET} --sectorerase
1112+ COMMAND sleep 0.5s
1113+ COMMAND ${NRFJPROG} --reset -f ${NRF_TARGET}
1114+ COMMENT "flashing ${EXECUTABLE_FILE_NAME} .hex"
1115+ )
1116+
1117+ elseif (USE_GDB_CLIENT)
1118+ add_custom_target (FLASH_ERASE
1119+ 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'
1120+ COMMENT "erasing flashing"
1121+ )
1122+ add_custom_target ("FLASH_${EXECUTABLE_NAME} "
1123+ DEPENDS ${EXECUTABLE_NAME}
1124+ 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
1125+ COMMENT "flashing ${EXECUTABLE_FILE_NAME} .hex"
1126+ )
1127+ elseif (USE_OPENOCD)
1128+ if (USE_CMSIS_DAP)
11051129 add_custom_target (FLASH_ERASE
1106- COMMAND ${NRFJPROG} --eraseall -f ${NRF_TARGET}
1130+ COMMAND ${OPENOCD_BIN_PATH} -c 'source [find interface /cmsis-dap.cfg]' -c 'transport select swd'
1131+ -c 'source [find target /nrf52.cfg]'
1132+ -c 'init'
1133+ -c 'halt'
1134+ -c 'nrf5 mass_erase'
1135+ -c 'halt'
1136+ -c 'reset'
1137+ -c 'exit'
11071138 COMMENT "erasing flashing"
11081139 )
11091140 add_custom_target ("FLASH_${EXECUTABLE_NAME} "
11101141 DEPENDS ${EXECUTABLE_NAME}
1111- COMMAND ${NRFJPROG} --program ${EXECUTABLE_FILE_NAME} .hex -f ${NRF_TARGET} --sectorerase
1112- COMMAND sleep 0.5s
1113- COMMAND ${NRFJPROG} --reset -f ${NRF_TARGET}
1114- COMMENT "flashing ${EXECUTABLE_FILE_NAME} .hex"
1142+ COMMAND ${OPENOCD_BIN_PATH}
1143+ -c 'tcl_port disabled'
1144+ -c 'gdb_port 3333'
1145+ -c 'telnet_port 4444'
1146+ -c 'source [find interface /cmsis-dap.cfg]'
1147+ -c 'transport select swd'
1148+ -c 'source [find target /nrf52.cfg]'
1149+ -c 'halt'
1150+ -c "program \" ${EXECUTABLE_FILE_NAME} .hex\" "
1151+ -c 'reset'
1152+ -c 'shutdown'
1153+ COMMENT "flashing ${EXECUTABLE_BIN_NAME} .hex"
11151154 )
1116-
1117- elseif (USE_GDB_CLIENT)
1155+ else ()
11181156 add_custom_target (FLASH_ERASE
1119- 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'
1157+ 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
11201158 COMMENT "erasing flashing"
11211159 )
11221160 add_custom_target ("FLASH_${EXECUTABLE_NAME} "
11231161 DEPENDS ${EXECUTABLE_NAME}
1124- 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
1162+ 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
11251163 COMMENT "flashing ${EXECUTABLE_FILE_NAME} .hex"
11261164 )
1127- elseif (USE_OPENOCD)
1128- if (USE_CMSIS_DAP)
1129- add_custom_target (FLASH_ERASE
1130- COMMAND ${OPENOCD_BIN_PATH} -c 'source [find interface /cmsis-dap.cfg]' -c 'transport select swd'
1131- -c 'source [find target /nrf52.cfg]'
1132- -c 'init'
1133- -c 'halt'
1134- -c 'nrf5 mass_erase'
1135- -c 'halt'
1136- -c 'reset'
1137- -c 'exit'
1138- COMMENT "erasing flashing"
1139- )
1140- add_custom_target ("FLASH_${EXECUTABLE_NAME} "
1141- DEPENDS ${EXECUTABLE_NAME}
1142- COMMAND ${OPENOCD_BIN_PATH}
1143- -c 'tcl_port disabled'
1144- -c 'gdb_port 3333'
1145- -c 'telnet_port 4444'
1146- -c 'source [find interface /cmsis-dap.cfg]'
1147- -c 'transport select swd'
1148- -c 'source [find target /nrf52.cfg]'
1149- -c 'halt'
1150- -c "program \" ${EXECUTABLE_FILE_NAME} .hex\" "
1151- -c 'reset'
1152- -c 'shutdown'
1153- COMMENT "flashing ${EXECUTABLE_BIN_NAME} .hex"
1154- )
1155- else ()
1156- add_custom_target (FLASH_ERASE
1157- 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
1158- COMMENT "erasing flashing"
1159- )
1160- add_custom_target ("FLASH_${EXECUTABLE_NAME} "
1161- DEPENDS ${EXECUTABLE_NAME}
1162- 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
1163- COMMENT "flashing ${EXECUTABLE_FILE_NAME} .hex"
1164- )
1165- endif ()
1165+ endif ()
11661166endif ()
0 commit comments