Kshitij Sisodia | 4cef9ac | 2024-04-08 09:58:46 +0100 | [diff] [blame] | 1 | #---------------------------------------------------------------------------- |
Kshitij Sisodia | 774c7ca | 2024-04-12 11:30:02 +0100 | [diff] [blame] | 2 | # SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its |
| 3 | # affiliates <open-source-office@arm.com> |
Kshitij Sisodia | 4cef9ac | 2024-04-08 09:58:46 +0100 | [diff] [blame] | 4 | # 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 | |
| 19 | function(set_platform_global_defaults) |
| 20 | message(STATUS "Platform: Arm MPS4 FPGA Prototyping Board or FVP") |
| 21 | |
Kshitij Sisodia | 774c7ca | 2024-04-12 11:30:02 +0100 | [diff] [blame] | 22 | # 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 Sisodia | 4cef9ac | 2024-04-08 09:58:46 +0100 | [diff] [blame] | 37 | 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 Sisodia | 72377a4 | 2024-05-16 09:15:12 +0100 | [diff] [blame] | 46 | set(CMAKE_TOOLCHAIN_FILE ${MLEK_CMAKE_TOOLCHAIN_DIR}/bare-metal-gcc.cmake |
Kshitij Sisodia | 4cef9ac | 2024-04-08 09:58:46 +0100 | [diff] [blame] | 47 | 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 Sisodia | 72377a4 | 2024-05-16 09:15:12 +0100 | [diff] [blame] | 59 | set(PLATFORM_DRIVERS_DIR "${MLEK_HAL_PLATFORM_DIR}/mps4" PARENT_SCOPE) |
Kshitij Sisodia | 4cef9ac | 2024-04-08 09:58:46 +0100 | [diff] [blame] | 60 | |
| 61 | endfunction() |
| 62 | |
| 63 | function(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 Sisodia | 774c7ca | 2024-04-12 11:30:02 +0100 | [diff] [blame] | 71 | ${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 Sisodia | 4cef9ac | 2024-04-08 09:58:46 +0100 | [diff] [blame] | 74 | |
| 75 | add_target_map_file( |
Kshitij Sisodia | 774c7ca | 2024-04-12 11:30:02 +0100 | [diff] [blame] | 76 | ${PARSED_TARGET_NAME} |
| 77 | ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PARSED_TARGET_NAME}.map) |
Kshitij Sisodia | 4cef9ac | 2024-04-08 09:58:46 +0100 | [diff] [blame] | 78 | |
| 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 Tawse | 58251ec | 2024-04-18 15:37:17 +0100 | [diff] [blame] | 86 | set(LINKER_SECTION_TAGS "*.at_boot" "*.at_bram" "*.at_ddr") |
| 87 | set(LINKER_OUTPUT_BIN_TAGS "boot.bin" "bram.bin" "ddr.bin") |
Kshitij Sisodia | 4cef9ac | 2024-04-08 09:58:46 +0100 | [diff] [blame] | 88 | 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 Sisodia | 4cef9ac | 2024-04-08 09:58:46 +0100 | [diff] [blame] | 122 | --stat) |
| 123 | endif() |
| 124 | endif () |
| 125 | |
| 126 | endfunction() |