openocd-nrf5.board.cmake 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # SPDX-License-Identifier: Apache-2.0
  2. # Infer nrf51 vs nrf52 etc from the BOARD name. This enforces a board
  3. # naming convention: "nrf5x" must appear somewhere in the board name
  4. # for this to work.
  5. #
  6. # Boards which don't meet this convention can set this variable before
  7. # including this script.
  8. if (NOT DEFINED OPENOCD_NRF5_SUBFAMILY)
  9. string(REGEX MATCH nrf5. OPENOCD_NRF5_SUBFAMILY "${BOARD}")
  10. endif()
  11. if("${OPENOCD_NRF5_SUBFAMILY}" STREQUAL "")
  12. message(FATAL_ERROR
  13. "Can't match nrf5 subfamily from BOARD name. "
  14. "To fix, set CMake variable OPENOCD_NRF5_SUBFAMILY.")
  15. endif()
  16. if (NOT DEFINED OPENOCD_NRF5_INTERFACE)
  17. set(OPENOCD_NRF5_INTERFACE "jlink")
  18. endif()
  19. # We can do the right thing for supported subfamilies using a generic
  20. # script, at least for openocd 0.10.0 and the openocd shipped with
  21. # Zephyr SDK 0.10.3.
  22. set(pre_init_cmds
  23. "set WORKAREASIZE 0x4000" # 16 kB RAM used for flashing
  24. "source [find interface/${OPENOCD_NRF5_INTERFACE}.cfg]"
  25. "transport select swd"
  26. "source [find target/${OPENOCD_NRF5_SUBFAMILY}.cfg]"
  27. )
  28. foreach(cmd ${pre_init_cmds})
  29. board_runner_args(openocd --cmd-pre-init "${cmd}")
  30. endforeach()
  31. include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)