Skip to content

Commit cd87366

Browse files
wangnuannuancfriedt
authored andcommitted
cmake: emu: nsim: Allow all nsim platform use mdb
Currently the default runner of nsim_hs_smp is mdb, the runner of other nsim platform is nsimdrv, user can't change the default runner unless he uses west command(--runner). With this change cmake will choose runner according to BOARD_DEBUG_RUNNER or BOARD_FLASH_RUNNER. so if add -DBOARD_FLASH_RUNNER=mdb-nsim or -DBOARD_DEBUG_RUNNER=mdb-nsim to cmake command, the apllication will be run with mdb. Signed-off-by: Jingru Wang <[email protected]>
1 parent f1c8fca commit cd87366

File tree

2 files changed

+42
-44
lines changed

2 files changed

+42
-44
lines changed

boards/arc/nsim/board.cmake

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,18 @@
22
set(EMU_PLATFORM nsim)
33

44
if(NOT (CONFIG_SOC_NSIM_HS_SMP OR CONFIG_SOC_NSIM_HS6X_SMP))
5-
board_set_flasher_ifnset(arc-nsim)
6-
board_set_debugger_ifnset(arc-nsim)
5+
board_set_flasher_ifnset(arc-nsim)
6+
board_set_debugger_ifnset(arc-nsim)
7+
8+
board_runner_args(arc-nsim "--props=${BOARD}.props")
9+
set(NSIM_PROPS "${BOARD}.props")
710
endif()
811

9-
if(${CONFIG_SOC_NSIM_EM})
10-
board_runner_args(arc-nsim "--props=nsim_em.props")
11-
board_runner_args(mdb-nsim "--nsim_args=mdb_em.args")
12-
elseif(${CONFIG_SOC_NSIM_EM7D_V22})
13-
board_runner_args(arc-nsim "--props=nsim_em7d_v22.props")
14-
board_runner_args(mdb-nsim "--nsim_args=mdb_em7d_v22.args")
15-
elseif(${CONFIG_SOC_NSIM_SEM})
16-
board_runner_args(arc-nsim "--props=nsim_sem.props")
17-
board_runner_args(mdb-nsim "--nsim_args=mdb_sem.args")
18-
elseif(${CONFIG_SOC_NSIM_HS})
19-
board_runner_args(arc-nsim "--props=nsim_hs.props")
20-
board_runner_args(mdb-nsim "--nsim_args=mdb_hs.args")
21-
elseif(${CONFIG_SOC_NSIM_HS_SMP})
22-
board_runner_args(mdb-nsim "--cores=${CONFIG_MP_NUM_CPUS}" "--nsim_args=mdb_hs_smp.args")
23-
elseif(${CONFIG_SOC_NSIM_HS6X})
24-
board_runner_args(arc-nsim "--props=nsim_hs6x.props")
25-
board_runner_args(mdb-nsim "--nsim_args=mdb_hs6x.args")
26-
elseif(${CONFIG_SOC_NSIM_HS6X_SMP})
27-
board_runner_args(mdb-nsim "--cores=${CONFIG_MP_NUM_CPUS}" "--nsim_args=mdb_hs6x_smp.args")
12+
string(REPLACE "nsim" "mdb" MDB_ARGS "${BOARD}.args")
13+
if((CONFIG_SOC_NSIM_HS_SMP OR CONFIG_SOC_NSIM_HS6X_SMP))
14+
board_runner_args(mdb-nsim "--cores=${CONFIG_MP_NUM_CPUS}" "--nsim_args=${MDB_ARGS}")
15+
else()
16+
board_runner_args(mdb-nsim "--nsim_args=${MDB_ARGS}")
2817
endif()
2918

3019
board_finalize_runner_args(arc-nsim)

cmake/emu/nsim.cmake

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,54 @@
11
# SPDX-License-Identifier: Apache-2.0
2-
if((${CONFIG_SOC_NSIM_HS_SMP}) OR (${CONFIG_SOC_NSIM_HS6X_SMP}))
2+
if("${BOARD_DEBUG_RUNNER}" STREQUAL "mdb-nsim" OR "${BOARD_FLASH_RUNNER}" STREQUAL "mdb-nsim")
33
# mdb is required to run nsim multicore targets
44
find_program(
55
MDB
66
mdb
77
)
8+
set(MDB_BASIC_OPTIONS -nooptions -nogoifmain -toggle=include_local_symbols=1)
89

9-
if(${CONFIG_SOC_NSIM_HS_SMP})
10-
set(MDB_ARGS mdb_hs_smp.args)
11-
elseif(${CONFIG_SOC_NSIM_HS6X_SMP})
12-
set(MDB_ARGS mdb_hs6x_smp.args)
10+
# remove previous .sc.project folder which has temporary settings for MDB.
11+
set(MDB_OPTIONS ${CMAKE_COMMAND} -E rm -rf ${APPLICATION_BINARY_DIR}/.sc.project)
12+
if(CONFIG_MP_NUM_CPUS GREATER 1)
13+
set(MULTIFILES ${MDB} -multifiles=)
14+
foreach(val RANGE ${CONFIG_MP_NUM_CPUS})
15+
if(val LESS CONFIG_MP_NUM_CPUS)
16+
MATH(EXPR PSET_NUM "${CONFIG_MP_NUM_CPUS}-${val}")
17+
MATH(EXPR CORE_NUM "${CONFIG_MP_NUM_CPUS}-${val}-1")
18+
if(PSET_NUM GREATER 0)
19+
list(APPEND MDB_OPTIONS &&)
20+
endif()
21+
list(APPEND MDB_OPTIONS ${MDB} -pset=${PSET_NUM} -psetname=core${CORE_NUM})
22+
if(PSET_NUM GREATER 1)
23+
list(APPEND MDB_OPTIONS -prop=download=2)
24+
set(MULTIFILES ${MULTIFILES}core${CORE_NUM},)
25+
else()
26+
set(MULTIFILES ${MULTIFILES}core${CORE_NUM})
27+
endif()
28+
list(APPEND MDB_OPTIONS ${MDB_BASIC_OPTIONS} -nsim @${BOARD_DIR}/support/${MDB_ARGS} ${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME})
29+
endif()
30+
endforeach()
31+
list(APPEND MDB_OPTIONS && NSIM_MULTICORE=1 ${MULTIFILES} -run -cl)
32+
else()
33+
list(APPEND MDB_OPTIONS && ${MDB} ${MDB_BASIC_OPTIONS} -nsim @${BOARD_DIR}/support/${MDB_ARGS} -run -cl)
1334
endif()
1435

36+
string(REPLACE ";" " " MDB_COMMAND "${MDB_OPTIONS}")
1537
add_custom_target(run
1638
COMMAND
17-
${MDB} -pset=1 -psetname=core0 -prop=ident=0x00000050 -cmpd=soc
18-
@${BOARD_DIR}/support/${MDB_ARGS} ${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME} &&
19-
${MDB} -pset=2 -psetname=core1 -prop=download=2 -prop=ident=0x00000150 -cmpd=soc
20-
@${BOARD_DIR}/support/${MDB_ARGS} ${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME} &&
21-
NSIM_MULTICORE=1 ${MDB} -multifiles=core0,core1 -cmpd=soc -run -cl
39+
${MDB_OPTIONS}
40+
${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME}
2241
DEPENDS ${logical_target_for_zephyr_elf}
2342
WORKING_DIRECTORY ${APPLICATION_BINARY_DIR}
43+
COMMENT "MDB COMMAND: ${MDB_COMMAND} ${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME}"
2444
USES_TERMINAL
25-
)
45+
)
2646
else()
2747
find_program(
2848
NSIM
2949
nsimdrv
3050
)
3151

32-
if(${CONFIG_SOC_NSIM_EM})
33-
set(NSIM_PROPS nsim_em.props)
34-
elseif(${CONFIG_SOC_NSIM_EM7D_V22})
35-
set(NSIM_PROPS nsim_em7d_v22.props)
36-
elseif(${CONFIG_SOC_NSIM_SEM})
37-
set(NSIM_PROPS nsim_sem.props)
38-
elseif(${CONFIG_SOC_NSIM_HS})
39-
set(NSIM_PROPS nsim_hs.props)
40-
elseif(${CONFIG_SOC_NSIM_HS6X})
41-
set(NSIM_PROPS nsim_hs6x.props)
42-
endif()
43-
4452
add_custom_target(run
4553
COMMAND
4654
${NSIM}
@@ -49,6 +57,7 @@ add_custom_target(run
4957
${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME}
5058
DEPENDS ${logical_target_for_zephyr_elf}
5159
WORKING_DIRECTORY ${APPLICATION_BINARY_DIR}
60+
COMMENT "nSIM COMMAND: ${NSIM} -propsfile ${BOARD_DIR}/support/${NSIM_PROPS} ${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME}"
5261
USES_TERMINAL
5362
)
5463

0 commit comments

Comments
 (0)