cmake: support multiple entries in board.cmake

Currently there is no way to support running a board on multiple
emulation platforms nor to choose a desired emulation platform for the
simulation to be run on. This commit introduces a new
SUPPORTED_EMU_PLATFORMS list, which defines available emulation
platforms for a given board.

Fixes #12375.

Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
This commit is contained in:
Filip Kokosinski 2021-08-30 13:09:48 +02:00 committed by Anas Nashif
parent 6aa783ed6a
commit 94428044e2
32 changed files with 71 additions and 66 deletions

View file

@ -1603,8 +1603,17 @@ if(HEX_FILES_TO_MERGE)
message(VERBOSE "Merging hex files: ${HEX_FILES_TO_MERGE}")
endif()
if(EMU_PLATFORM)
include(${ZEPHYR_BASE}/cmake/emu/${EMU_PLATFORM}.cmake)
if(SUPPORTED_EMU_PLATFORMS)
list(GET SUPPORTED_EMU_PLATFORMS 0 default_emu)
add_custom_target(run DEPENDS run_${default_emu})
foreach(EMU_PLATFORM ${SUPPORTED_EMU_PLATFORMS})
include(${ZEPHYR_BASE}/cmake/emu/${EMU_PLATFORM}.cmake)
endforeach()
if(TARGET debugserver_${default_emu})
add_custom_target(debugserver DEPENDS debugserver_${default_emu})
endif()
else()
add_custom_target(run
COMMAND

View file

@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM nsim)
set(SUPPORTED_EMU_PLATFORMS nsim)
if(NOT (CONFIG_SOC_NSIM_HS_SMP OR CONFIG_SOC_NSIM_HS6X_SMP))
board_set_flasher_ifnset(arc-nsim)

View file

@ -1,4 +1,4 @@
set(EMU_PLATFORM qemu)
set(SUPPORTED_EMU_PLATFORMS qemu)
set(QEMU_CPU_TYPE_${ARCH} arc)

View file

@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM qemu)
set(SUPPORTED_EMU_PLATFORMS qemu)
set(QEMU_CPU_TYPE_${ARCH} cortex-m3)
set(QEMU_FLAGS_${ARCH}

View file

@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM qemu)
set(SUPPORTED_EMU_PLATFORMS qemu)
set(QEMU_CPU_TYPE_${ARCH} cortex-m33)
set(QEMU_FLAGS_${ARCH}

View file

@ -9,35 +9,31 @@
#
# $ west build -b mps3_an547 samples/hello°world -DEMU_PLATFORM=qemu -t run
if(NOT DEFINED EMU_PLATFORM)
set(EMU_PLATFORM qemu)
endif()
set(SUPPORTED_EMU_PLATFORMS qemu armfvp)
if (EMU_PLATFORM STREQUAL "qemu")
# QEMU settings
set(QEMU_CPU_TYPE_${ARCH} cortex-m55)
set(QEMU_FLAGS_${ARCH}
-cpu ${QEMU_CPU_TYPE_${ARCH}}
-machine mps3-an547
-nographic
-vga none
)
board_set_debugger_ifnset(qemu)
else()
# FVP settings
set(ARMFVP_BIN_NAME FVP_Corstone_SSE-300_Ethos-U55)
# QEMU settings
set(QEMU_CPU_TYPE_${ARCH} cortex-m55)
set(QEMU_FLAGS_${ARCH}
-cpu ${QEMU_CPU_TYPE_${ARCH}}
-machine mps3-an547
-nographic
-vga none
)
board_set_debugger_ifnset(qemu)
# FVP Parameters
# -C indicate a config option in the form of:
# instance.parameter=value
# Run the FVP with --list-params to list all options
set(ARMFVP_FLAGS
-C mps3_board.uart0.out_file=-
-C mps3_board.uart0.unbuffered_output=1
-C mps3_board.uart1.out_file=-
-C mps3_board.uart1.unbuffered_output=1
-C mps3_board.uart2.out_file=-
-C mps3_board.uart2.unbuffered_output=1
-C mps3_board.visualisation.disable-visualisation=1
)
endif()
# FVP settings
set(ARMFVP_BIN_NAME FVP_Corstone_SSE-300_Ethos-U55)
# FVP Parameters
# -C indicate a config option in the form of:
# instance.parameter=value
# Run the FVP with --list-params to list all options
set(ARMFVP_FLAGS
-C mps3_board.uart0.out_file=-
-C mps3_board.uart0.unbuffered_output=1
-C mps3_board.uart1.out_file=-
-C mps3_board.uart1.unbuffered_output=1
-C mps3_board.uart2.out_file=-
-C mps3_board.uart2.unbuffered_output=1
-C mps3_board.visualisation.disable-visualisation=1
)

View file

@ -3,7 +3,7 @@
#
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM qemu)
set(SUPPORTED_EMU_PLATFORMS qemu)
set(QEMU_CPU_TYPE_${ARCH} cortex-m0)
set(QEMU_FLAGS_${ARCH}

View file

@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM qemu)
set(SUPPORTED_EMU_PLATFORMS qemu)
set(QEMU_CPU_TYPE_${ARCH} cortex-m3)
set(QEMU_FLAGS_${ARCH}

View file

@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM qemu)
set(SUPPORTED_EMU_PLATFORMS qemu)
set(QEMU_ARCH xilinx-aarch64)
set(QEMU_CPU_TYPE_${ARCH} cortex-r5)

View file

@ -1,7 +1,7 @@
# Copyright (c) 2021 Carlo Caione <ccaione@baylibre.com>
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM armfvp)
set(SUPPORTED_EMU_PLATFORMS armfvp)
set(ARMFVP_BIN_NAME FVP_Base_RevC-2xAEMvA)
set(ARMFVP_FLAGS

View file

@ -1,7 +1,7 @@
# Copyright (c) 2021 Arm Limited (or its affiliates). All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM armfvp)
set(SUPPORTED_EMU_PLATFORMS armfvp)
set(ARMFVP_BIN_NAME FVP_BaseR_AEMv8R)
set(ARMFVP_FLAGS

View file

@ -1,7 +1,7 @@
# Copyright (c) 2019 Carlo Caione <ccaione@baylibre.com>
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM qemu)
set(SUPPORTED_EMU_PLATFORMS qemu)
set(QEMU_ARCH aarch64)
set(QEMU_CPU_TYPE_${ARCH} cortex-a53)

View file

@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM qemu)
set(SUPPORTED_EMU_PLATFORMS qemu)
set(QEMU_CPU_TYPE_${ARCH} nios2)

View file

@ -1,3 +1,3 @@
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM native)
set(SUPPORTED_EMU_PLATFORMS native)

View file

@ -1,3 +1,3 @@
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM native)
set(SUPPORTED_EMU_PLATFORMS native)

View file

@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM qemu)
set(SUPPORTED_EMU_PLATFORMS qemu)
set(QEMU_CPU_TYPE_${ARCH} riscv32)

View file

@ -1,2 +1,2 @@
set(EMU_PLATFORM renode)
set(SUPPORTED_EMU_PLATFORMS renode)
set(RENODE_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/support/it8xxx2_evb.resc)

View file

@ -1,4 +1,4 @@
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM renode)
set(SUPPORTED_EMU_PLATFORMS renode)
set(RENODE_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/support/m2gl025_miv.resc)

View file

@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM qemu)
set(SUPPORTED_EMU_PLATFORMS qemu)
set(QEMU_binary_suffix riscv32)
set(QEMU_CPU_TYPE_${ARCH} riscv32)

View file

@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM qemu)
set(SUPPORTED_EMU_PLATFORMS qemu)
set(QEMU_binary_suffix riscv64)
set(QEMU_CPU_TYPE_${ARCH} riscv64)

View file

@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM tsim)
set(SUPPORTED_EMU_PLATFORMS tsim)
find_program(TSIM tsim-leon3)

View file

@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM tsim)
set(SUPPORTED_EMU_PLATFORMS tsim)
find_program(TSIM tsim-leon3)

View file

@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM qemu)
set(SUPPORTED_EMU_PLATFORMS qemu)
set(QEMU_binary_suffix sparc)
set(QEMU_CPU_TYPE_${ARCH} leon3)

View file

@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM qemu)
set(SUPPORTED_EMU_PLATFORMS qemu)
if(NOT CONFIG_REBOOT)
set(REBOOT_FLAG -no-reboot)

View file

@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
set(EMU_PLATFORM qemu)
set(SUPPORTED_EMU_PLATFORMS qemu)
set(QEMU_CPU_TYPE_${ARCH} sample_controller)

View file

@ -36,7 +36,7 @@ else()
)
endif()
add_custom_target(run
add_custom_target(run_armfvp
COMMAND
${ARMFVP}
${ARMFVP_FLAGS}

View file

@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
add_custom_target(run
add_custom_target(run_native
COMMAND
${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_EXE_NAME}
DEPENDS ${logical_target_for_zephyr_elf}

View file

@ -34,7 +34,7 @@ else()
endif()
string(REPLACE ";" " " MDB_COMMAND "${MDB_OPTIONS}")
add_custom_target(run
add_custom_target(run_nsim
COMMAND
${MDB_OPTIONS}
${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME}
@ -49,7 +49,7 @@ find_program(
nsimdrv
)
add_custom_target(run
add_custom_target(run_nsim
COMMAND
${NSIM}
-propsfile
@ -61,7 +61,7 @@ add_custom_target(run
USES_TERMINAL
)
add_custom_target(debugserver
add_custom_target(debugserver_nsim
COMMAND
${NSIM}
-propsfile

View file

@ -37,8 +37,8 @@ if(CONFIG_QEMU_UEFI_BOOT)
endif()
set(qemu_targets
run
debugserver
run_qemu
debugserver_qemu
)
set(QEMU_FLAGS -pidfile)
@ -340,7 +340,7 @@ set(env_qemu $ENV{QEMU_EXTRA_FLAGS})
separate_arguments(env_qemu)
list(APPEND QEMU_EXTRA_FLAGS ${env_qemu})
list(APPEND MORE_FLAGS_FOR_debugserver -s -S)
list(APPEND MORE_FLAGS_FOR_debugserver_qemu -s -S)
# Architectures can define QEMU_KERNEL_FILE to use a specific output
# file to pass to qemu (and a "qemu_kernel_target" target to generate

View file

@ -11,7 +11,7 @@ set(RENODE_FLAGS
--pid-file renode.pid
)
add_custom_target(run
add_custom_target(run_renode
COMMAND
${RENODE}
${RENODE_FLAGS}

View file

@ -2,7 +2,7 @@
set(TSIM_FLAGS -e run -e exit)
add_custom_target(run
add_custom_target(run_tsim
COMMAND
${TSIM}
${TSIM_SYS}

View file

@ -141,7 +141,7 @@ foreach(target flash debug debugserver attach)
set(comment "Debugging ${BOARD}")
elseif(target STREQUAL debugserver)
set(comment "Debugging ${BOARD}")
if(EMU_PLATFORM)
if(SUPPORTED_EMU_PLATFORMS)
# cmake/qemu/CMakeLists.txt will add a debugserver target for
# emulation platforms, so we don't add one here
continue()