blob: 6ea34efd3350767ecda5e7f13a040e959f0bf956 [file] [log] [blame]
Kshitij Sisodia4cef9ac2024-04-08 09:58:46 +01001#----------------------------------------------------------------------------
Kshitij Sisodia774c7ca2024-04-12 11:30:02 +01002# SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its
3# affiliates <open-source-office@arm.com>
Kshitij Sisodia4cef9ac2024-04-08 09:58:46 +01004# SPDX-License-Identifier: Apache-2.0
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#----------------------------------------------------------------------------
18
19function(set_platform_global_defaults)
20 message(STATUS "Platform: Arm MPS4 FPGA Prototyping Board or FVP")
21
Kshitij Sisodia774c7ca2024-04-12 11:30:02 +010022 # Default sub-system for MPS4
23 USER_OPTION(TARGET_SUBSYSTEM "Specify platform target subsystem: sse-315"
24 sse-315
25 STRING)
26
27 # Default NPU for SSE-315 target:
28 USER_OPTION(ETHOS_U_NPU_ID "Arm Ethos-U NPU IP (U55 or U65)"
29 "U65"
30 STRING)
31
32 # Include NPU, FVP tests and CMSIS configuration options
33 include(npu_opts)
34 include(fvp_test_opts)
35 include(cmsis_opts)
36
Kshitij Sisodia4cef9ac2024-04-08 09:58:46 +010037 if (NOT DEFINED CMAKE_SYSTEM_PROCESSOR)
38 if(TARGET_SUBSYSTEM STREQUAL sse-315)
39 set(CMAKE_SYSTEM_PROCESSOR cortex-m85 CACHE STRING "Cortex-M CPU to use")
40 else()
41 message(FATAL_ERROR "${TARGET_SUBSYSTEM} unsupported by ${TARGET_PLATFORM}")
42 endif()
43 endif()
44
45 if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
Kshitij Sisodia72377a42024-05-16 09:15:12 +010046 set(CMAKE_TOOLCHAIN_FILE ${MLEK_CMAKE_TOOLCHAIN_DIR}/bare-metal-gcc.cmake
Kshitij Sisodia4cef9ac2024-04-08 09:58:46 +010047 CACHE FILEPATH "Toolchain file")
48 endif()
49
50 # Arm Corstone-315's timing adapter behaviour is very different to Arm Corstone-300 and cannot
51 # be used for bandwidth/latency related performance sweeps for the Arm Ethos-U NPU. Read
52 # docs/sections/timing_adapters.md for more details.
53 if ((TARGET_SUBSYSTEM STREQUAL "sse-315") AND (DEFINED ETHOS_U_NPU_TIMING_ADAPTER_ENABLED))
54 message(STATUS "Timing adapter will NOT be used for target subsystem ${TARGET_SUBSYSTEM}")
55 set(ETHOS_U_NPU_TIMING_ADAPTER_ENABLED OFF CACHE BOOL "Use of TA" FORCE)
56 endif()
57
58 set(LINKER_SCRIPT_NAME "mps4-${TARGET_SUBSYSTEM}" PARENT_SCOPE)
Kshitij Sisodia72377a42024-05-16 09:15:12 +010059 set(PLATFORM_DRIVERS_DIR "${MLEK_HAL_PLATFORM_DIR}/mps4" PARENT_SCOPE)
Kshitij Sisodia4cef9ac2024-04-08 09:58:46 +010060
61endfunction()
62
63function(platform_custom_post_build)
64 set(oneValueArgs TARGET_NAME)
65 cmake_parse_arguments(PARSED "" "${oneValueArgs}" "" ${ARGN} )
66
67 set_target_properties(${PARSED_TARGET_NAME} PROPERTIES SUFFIX ".axf")
68
69 # Add link options for the linker script to be used:
70 add_linker_script(
Kshitij Sisodia774c7ca2024-04-12 11:30:02 +010071 ${PARSED_TARGET_NAME} # Target
72 ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${TARGET_SUBSYSTEM} # Directory path
73 ${LINKER_SCRIPT_NAME}) # Name of the file without suffix
Kshitij Sisodia4cef9ac2024-04-08 09:58:46 +010074
75 add_target_map_file(
Kshitij Sisodia774c7ca2024-04-12 11:30:02 +010076 ${PARSED_TARGET_NAME}
77 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PARSED_TARGET_NAME}.map)
Kshitij Sisodia4cef9ac2024-04-08 09:58:46 +010078
79 set(SECTORS_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sectors)
80 set(SECTORS_BIN_DIR ${SECTORS_DIR}/${use_case})
81
82 file(REMOVE_RECURSE ${SECTORS_BIN_DIR})
83 file(MAKE_DIRECTORY ${SECTORS_BIN_DIR})
84
85 if (TARGET_SUBSYSTEM STREQUAL sse-315)
Alex Tawse58251ec2024-04-18 15:37:17 +010086 set(LINKER_SECTION_TAGS "*.at_boot" "*.at_bram" "*.at_ddr")
87 set(LINKER_OUTPUT_BIN_TAGS "boot.bin" "bram.bin" "ddr.bin")
Kshitij Sisodia4cef9ac2024-04-08 09:58:46 +010088 endif()
89
90 add_bin_generation_command(
91 TARGET_NAME ${PARSED_TARGET_NAME}
92 OUTPUT_DIR ${SECTORS_BIN_DIR}
93 AXF_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PARSED_TARGET_NAME}.axf
94 SECTION_PATTERNS "${LINKER_SECTION_TAGS}"
95 OUTPUT_BIN_NAMES "${LINKER_OUTPUT_BIN_TAGS}")
96
97 set(MPS4_FPGA_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/scripts/mps4/${TARGET_SUBSYSTEM}/images.txt")
98
99 add_custom_command(TARGET ${PARSED_TARGET_NAME}
100 POST_BUILD
101 COMMAND ${CMAKE_COMMAND} -E copy ${MPS4_FPGA_CONFIG} ${SECTORS_DIR})
102
103 # Add tests for application on FVP if FVP path specified
104 if (BUILD_FVP_TESTS)
105
106 # Build for all use cases if USE_SINGLE_INPUT as no telnet interaction required
107 # otherwise only build for inference runner
108 if ((USE_SINGLE_INPUT) OR (${use_case} STREQUAL "inference_runner"))
109 set(AXF_PATH "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PARSED_TARGET_NAME}.axf")
110 set(TEST_TARGET_NAME "${use_case}_fvp_test")
111
112 message(STATUS "Adding FVP test for ${use_case}")
113
114 add_test(
115 NAME "${TEST_TARGET_NAME}"
116 COMMAND ${FVP_PATH} -a ${AXF_PATH}
117 -C mps4_board.telnetterminal0.start_telnet=0
118 -C mps4_board.uart0.out_file='-'
119 -C mps4_board.uart0.shutdown_on_eot=1
120 -C mps4_board.visualisation.disable-visualisation=1
121 -C vis_hdlcd.disable_visualisation=1
Kshitij Sisodia4cef9ac2024-04-08 09:58:46 +0100122 --stat)
123 endif()
124 endif ()
125
126endfunction()