alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 1 | #---------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2022 Arm Limited. All rights reserved. |
| 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | #---------------------------------------------------------------------------- |
| 17 | |
| 18 | function(set_platform_global_defaults) |
| 19 | message(STATUS "Platform: MPS3 FPGA Prototyping Board or FVP") |
Kshitij Sisodia | 8c61c0a | 2022-05-17 11:16:22 +0100 | [diff] [blame] | 20 | |
| 21 | if (NOT DEFINED CMAKE_SYSTEM_PROCESSOR) |
| 22 | if (TARGET_SUBSYSTEM STREQUAL sse-300) |
| 23 | set(CMAKE_SYSTEM_PROCESSOR cortex-m55 CACHE STRING "Cortex-M CPU to use") |
| 24 | elseif(TARGET_SUBSYSTEM STREQUAL sse-310) |
Kshitij Sisodia | 9c6f9f8 | 2022-05-20 14:30:02 +0100 | [diff] [blame] | 25 | set(CMAKE_SYSTEM_PROCESSOR cortex-m85 CACHE STRING "Cortex-M CPU to use") |
Kshitij Sisodia | 8c61c0a | 2022-05-17 11:16:22 +0100 | [diff] [blame] | 26 | endif() |
| 27 | endif() |
| 28 | |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 29 | if (NOT DEFINED CMAKE_TOOLCHAIN_FILE) |
| 30 | set(CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_DIR}/bare-metal-gcc.cmake |
| 31 | CACHE FILEPATH "Toolchain file") |
| 32 | endif() |
| 33 | |
Kshitij Sisodia | 01334f9 | 2022-08-12 11:53:45 +0100 | [diff] [blame] | 34 | # Arm Corstone-310's timing adapter behaviour is very different to Arm Corstone-300 and cannot |
| 35 | # be used for bandwidth/latency related performance sweeps for the Arm Ethos-U NPU. Read |
| 36 | # docs/sections/timing_adapters.md for more details. |
Nina Drozd | 27c5e30 | 2022-09-20 10:58:19 +0100 | [diff] [blame^] | 37 | if ((TARGET_SUBSYSTEM STREQUAL "sse-310") AND (DEFINED ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)) |
Kshitij Sisodia | 01334f9 | 2022-08-12 11:53:45 +0100 | [diff] [blame] | 38 | message(STATUS "Timing adapter will NOT be used for target subsystem ${TARGET_SUBSYSTEM}") |
| 39 | set(ETHOS_U_NPU_TIMING_ADAPTER_ENABLED OFF CACHE BOOL "Use of TA" FORCE) |
Kshitij Sisodia | 8c61c0a | 2022-05-17 11:16:22 +0100 | [diff] [blame] | 40 | endif() |
| 41 | |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 42 | set(LINKER_SCRIPT_NAME "mps3-${TARGET_SUBSYSTEM}" PARENT_SCOPE) |
| 43 | set(PLATFORM_DRIVERS_DIR "${HAL_PLATFORM_DIR}/mps3" PARENT_SCOPE) |
| 44 | |
| 45 | endfunction() |
| 46 | |
| 47 | function(platform_custom_post_build) |
| 48 | set(oneValueArgs TARGET_NAME) |
| 49 | cmake_parse_arguments(PARSED "" "${oneValueArgs}" "" ${ARGN} ) |
| 50 | |
| 51 | set_target_properties(${PARSED_TARGET_NAME} PROPERTIES SUFFIX ".axf") |
| 52 | # Add link options for the linker script to be used: |
| 53 | add_linker_script( |
| 54 | ${PARSED_TARGET_NAME} # Target |
Kshitij Sisodia | 8c61c0a | 2022-05-17 11:16:22 +0100 | [diff] [blame] | 55 | ${CMAKE_SCRIPTS_DIR}/platforms/mps3/${TARGET_SUBSYSTEM} # Directory path |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 56 | ${LINKER_SCRIPT_NAME}) # Name of the file without suffix |
| 57 | |
| 58 | add_target_map_file( |
| 59 | ${PARSED_TARGET_NAME} |
| 60 | ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PARSED_TARGET_NAME}.map) |
| 61 | |
| 62 | set(SECTORS_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sectors) |
| 63 | set(SECTORS_BIN_DIR ${SECTORS_DIR}/${use_case}) |
| 64 | |
| 65 | file(REMOVE_RECURSE ${SECTORS_BIN_DIR}) |
| 66 | file(MAKE_DIRECTORY ${SECTORS_BIN_DIR}) |
| 67 | |
Kshitij Sisodia | 8c61c0a | 2022-05-17 11:16:22 +0100 | [diff] [blame] | 68 | if (TARGET_SUBSYSTEM STREQUAL sse-310) |
| 69 | set(LINKER_SECTION_TAGS "*.at_bram" "*.at_ddr") |
| 70 | set(LINKER_OUTPUT_BIN_TAGS "bram.bin" "ddr.bin") |
| 71 | else() |
| 72 | set(LINKER_SECTION_TAGS "*.at_itcm" "*.at_ddr") |
| 73 | set(LINKER_OUTPUT_BIN_TAGS "itcm.bin" "ddr.bin") |
| 74 | endif() |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 75 | |
| 76 | add_bin_generation_command( |
| 77 | TARGET_NAME ${PARSED_TARGET_NAME} |
| 78 | OUTPUT_DIR ${SECTORS_BIN_DIR} |
| 79 | AXF_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PARSED_TARGET_NAME}.axf |
| 80 | SECTION_PATTERNS "${LINKER_SECTION_TAGS}" |
| 81 | OUTPUT_BIN_NAMES "${LINKER_OUTPUT_BIN_TAGS}") |
| 82 | |
| 83 | set(MPS3_FPGA_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/scripts/mps3/${TARGET_SUBSYSTEM}/images.txt") |
| 84 | |
| 85 | add_custom_command(TARGET ${PARSED_TARGET_NAME} |
| 86 | POST_BUILD |
| 87 | COMMAND ${CMAKE_COMMAND} -E copy ${MPS3_FPGA_CONFIG} ${SECTORS_DIR}) |
| 88 | |
Kshitij Sisodia | 8c61c0a | 2022-05-17 11:16:22 +0100 | [diff] [blame] | 89 | endfunction() |