nsim.cmake 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # SPDX-License-Identifier: Apache-2.0
  2. if("${BOARD_DEBUG_RUNNER}" STREQUAL "mdb-nsim" OR "${BOARD_FLASH_RUNNER}" STREQUAL "mdb-nsim")
  3. # mdb is required to run nsim multicore targets
  4. find_program(
  5. MDB
  6. mdb
  7. )
  8. set(MDB_BASIC_OPTIONS -nooptions -nogoifmain -toggle=include_local_symbols=1)
  9. # remove previous .sc.project folder which has temporary settings for MDB.
  10. set(MDB_OPTIONS ${CMAKE_COMMAND} -E rm -rf ${APPLICATION_BINARY_DIR}/.sc.project)
  11. if(CONFIG_MP_NUM_CPUS GREATER 1)
  12. set(MULTIFILES ${MDB} -multifiles=)
  13. foreach(val RANGE ${CONFIG_MP_NUM_CPUS})
  14. if(val LESS CONFIG_MP_NUM_CPUS)
  15. MATH(EXPR PSET_NUM "${CONFIG_MP_NUM_CPUS}-${val}")
  16. MATH(EXPR CORE_NUM "${CONFIG_MP_NUM_CPUS}-${val}-1")
  17. if(PSET_NUM GREATER 0)
  18. list(APPEND MDB_OPTIONS &&)
  19. endif()
  20. list(APPEND MDB_OPTIONS ${MDB} -pset=${PSET_NUM} -psetname=core${CORE_NUM})
  21. if(PSET_NUM GREATER 1)
  22. list(APPEND MDB_OPTIONS -prop=download=2)
  23. set(MULTIFILES ${MULTIFILES}core${CORE_NUM},)
  24. else()
  25. set(MULTIFILES ${MULTIFILES}core${CORE_NUM})
  26. endif()
  27. list(APPEND MDB_OPTIONS ${MDB_BASIC_OPTIONS} -nsim @${BOARD_DIR}/support/${MDB_ARGS} ${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME})
  28. endif()
  29. endforeach()
  30. list(APPEND MDB_OPTIONS && NSIM_MULTICORE=1 ${MULTIFILES} -run -cl)
  31. else()
  32. list(APPEND MDB_OPTIONS && ${MDB} ${MDB_BASIC_OPTIONS} -nsim @${BOARD_DIR}/support/${MDB_ARGS} -run -cl)
  33. endif()
  34. string(REPLACE ";" " " MDB_COMMAND "${MDB_OPTIONS}")
  35. add_custom_target(run
  36. COMMAND
  37. ${MDB_OPTIONS}
  38. ${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME}
  39. DEPENDS ${logical_target_for_zephyr_elf}
  40. WORKING_DIRECTORY ${APPLICATION_BINARY_DIR}
  41. COMMENT "MDB COMMAND: ${MDB_COMMAND} ${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME}"
  42. USES_TERMINAL
  43. )
  44. else()
  45. find_program(
  46. NSIM
  47. nsimdrv
  48. )
  49. add_custom_target(run
  50. COMMAND
  51. ${NSIM}
  52. -propsfile
  53. ${BOARD_DIR}/support/${NSIM_PROPS}
  54. ${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME}
  55. DEPENDS ${logical_target_for_zephyr_elf}
  56. WORKING_DIRECTORY ${APPLICATION_BINARY_DIR}
  57. COMMENT "nSIM COMMAND: ${NSIM} -propsfile ${BOARD_DIR}/support/${NSIM_PROPS} ${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME}"
  58. USES_TERMINAL
  59. )
  60. add_custom_target(debugserver
  61. COMMAND
  62. ${NSIM}
  63. -propsfile
  64. ${BOARD_DIR}/support/${NSIM_PROPS}
  65. -gdb -port=3333
  66. DEPENDS ${logical_target_for_zephyr_elf}
  67. WORKING_DIRECTORY ${APPLICATION_BINARY_DIR}
  68. USES_TERMINAL
  69. )
  70. endif()