1# Copyright (c) 2021-2022 Arm Limited (or its affiliates). All rights reserved. 2# SPDX-License-Identifier: Apache-2.0 3 4find_program( 5 ARMFVP 6 PATHS ENV ARMFVP_BIN_PATH 7 NO_DEFAULT_PATH 8 NAMES ${ARMFVP_BIN_NAME} 9 ) 10 11if(ARMFVP AND (DEFINED ARMFVP_MIN_VERSION)) 12 execute_process( 13 COMMAND ${ARMFVP} --version 14 OUTPUT_VARIABLE out 15 OUTPUT_STRIP_TRAILING_WHITESPACE 16 ) 17 string(REPLACE "\n" "" out ${out}) 18 string(REGEX MATCH "[0-9]+\.[0-9]+\.[0-9]+" armfvp_version ${out}) 19 if(${armfvp_version} VERSION_LESS ${ARMFVP_MIN_VERSION}) 20 set(armfvp_warning_message "Found FVP version is \"${armfvp_version}\", " 21 "the minimum required by the current board is \"${ARMFVP_MIN_VERSION}\".") 22 message(WARNING "${armfvp_warning_message}") 23 set(ARMFVP 24 COMMAND ${CMAKE_COMMAND} -E echo ${armfvp_warning_message} 25 COMMAND ${ARMFVP} 26 ) 27 endif() 28endif() 29 30if(CONFIG_BUILD_WITH_TFA) 31 set(ARMFVP_FLAGS ${ARMFVP_FLAGS} 32 -C bp.secureflashloader.fname=${APPLICATION_BINARY_DIR}/tfa${FVP_SECURE_FLASH_FILE} 33 -C bp.flashloader0.fname=${APPLICATION_BINARY_DIR}/tfa${FVP_FLASH_FILE} 34 ) 35elseif(CONFIG_ARMV8_A_NS) 36 foreach(filetype BL1 FIP) 37 if ((NOT DEFINED ARMFVP_${filetype}_FILE) AND (EXISTS "$ENV{ARMFVP_${filetype}_FILE}")) 38 set(ARMFVP_${filetype}_FILE "$ENV{ARMFVP_${filetype}_FILE}" CACHE FILEPATH 39 "ARM FVP ${filetype} File specified in environment" 40 ) 41 endif() 42 43 if(NOT EXISTS "${ARMFVP_${filetype}_FILE}") 44 string(TOLOWER ${filetype} filename) 45 message(FATAL_ERROR "Please specify ARMFVP_${filetype}_FILE in environment " 46 "or with -DARMFVP_${filetype}_FILE=</path/to/${filename}.bin>") 47 endif() 48 endforeach() 49 50 set(ARMFVP_FLAGS ${ARMFVP_FLAGS} 51 -C bp.secureflashloader.fname=${ARMFVP_BL1_FILE} 52 -C bp.flashloader0.fname=${ARMFVP_FIP_FILE} 53 --data cluster0.cpu0="${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_BIN_NAME}"@0x88000000 54 ) 55else() 56 set(ARMFVP_FLAGS ${ARMFVP_FLAGS} 57 -a ${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME} 58 ) 59endif() 60 61if(CONFIG_ETH_SMSC91X) 62 set(ARMFVP_FLAGS ${ARMFVP_FLAGS} 63 -C bp.smsc_91c111.enabled=1 64 -C bp.hostbridge.userNetworking=1 65 ) 66endif() 67 68# Use flags passed in from the environment 69set(env_fvp $ENV{ARMFVP_EXTRA_FLAGS}) 70separate_arguments(env_fvp) 71list(APPEND ARMFVP_EXTRA_FLAGS ${env_fvp}) 72 73add_custom_target(run_armfvp 74 COMMAND 75 ${ARMFVP} 76 ${ARMFVP_FLAGS} 77 ${ARMFVP_EXTRA_FLAGS} 78 DEPENDS ${logical_target_for_zephyr_elf} 79 WORKING_DIRECTORY ${APPLICATION_BINARY_DIR} 80 COMMENT "${ARMFVP_BIN_NAME}: ${armfvp_version}" 81 USES_TERMINAL 82 ) 83