blob: 749b1e1b36bbaf4562adcfd5ecf4919e40245a3f [file] [log] [blame]
alexander31ae9f02022-02-10 16:15:54 +00001#----------------------------------------------------------------------------
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
18function(set_platform_global_defaults)
19 message(STATUS "Platform: MPS3 FPGA Prototyping Board or FVP")
Kshitij Sisodia8c61c0a2022-05-17 11:16:22 +010020
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 Sisodia9c6f9f82022-05-20 14:30:02 +010025 set(CMAKE_SYSTEM_PROCESSOR cortex-m85 CACHE STRING "Cortex-M CPU to use")
Kshitij Sisodia8c61c0a2022-05-17 11:16:22 +010026 endif()
27 endif()
28
alexander31ae9f02022-02-10 16:15:54 +000029 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 Sisodia8c61c0a2022-05-17 11:16:22 +010034 if ((ETHOS_U_NPU_ID STREQUAL U65) AND (TARGET_SUBSYSTEM STREQUAL sse-310))
35 message(FATAL_ERROR "Non compatible Ethos-U NPU processor ${ETHOS_U_NPU_ID} and target subsystem ${TARGET_SUBSYSTEM}")
36 endif()
37
alexander31ae9f02022-02-10 16:15:54 +000038 set(LINKER_SCRIPT_NAME "mps3-${TARGET_SUBSYSTEM}" PARENT_SCOPE)
39 set(PLATFORM_DRIVERS_DIR "${HAL_PLATFORM_DIR}/mps3" PARENT_SCOPE)
40
41endfunction()
42
43function(platform_custom_post_build)
44 set(oneValueArgs TARGET_NAME)
45 cmake_parse_arguments(PARSED "" "${oneValueArgs}" "" ${ARGN} )
46
47 set_target_properties(${PARSED_TARGET_NAME} PROPERTIES SUFFIX ".axf")
48 # Add link options for the linker script to be used:
49 add_linker_script(
50 ${PARSED_TARGET_NAME} # Target
Kshitij Sisodia8c61c0a2022-05-17 11:16:22 +010051 ${CMAKE_SCRIPTS_DIR}/platforms/mps3/${TARGET_SUBSYSTEM} # Directory path
alexander31ae9f02022-02-10 16:15:54 +000052 ${LINKER_SCRIPT_NAME}) # Name of the file without suffix
53
54 add_target_map_file(
55 ${PARSED_TARGET_NAME}
56 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PARSED_TARGET_NAME}.map)
57
58 set(SECTORS_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sectors)
59 set(SECTORS_BIN_DIR ${SECTORS_DIR}/${use_case})
60
61 file(REMOVE_RECURSE ${SECTORS_BIN_DIR})
62 file(MAKE_DIRECTORY ${SECTORS_BIN_DIR})
63
Kshitij Sisodia8c61c0a2022-05-17 11:16:22 +010064 if (TARGET_SUBSYSTEM STREQUAL sse-310)
65 set(LINKER_SECTION_TAGS "*.at_bram" "*.at_ddr")
66 set(LINKER_OUTPUT_BIN_TAGS "bram.bin" "ddr.bin")
67 else()
68 set(LINKER_SECTION_TAGS "*.at_itcm" "*.at_ddr")
69 set(LINKER_OUTPUT_BIN_TAGS "itcm.bin" "ddr.bin")
70 endif()
alexander31ae9f02022-02-10 16:15:54 +000071
72 add_bin_generation_command(
73 TARGET_NAME ${PARSED_TARGET_NAME}
74 OUTPUT_DIR ${SECTORS_BIN_DIR}
75 AXF_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PARSED_TARGET_NAME}.axf
76 SECTION_PATTERNS "${LINKER_SECTION_TAGS}"
77 OUTPUT_BIN_NAMES "${LINKER_OUTPUT_BIN_TAGS}")
78
79 set(MPS3_FPGA_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/scripts/mps3/${TARGET_SUBSYSTEM}/images.txt")
80
81 add_custom_command(TARGET ${PARSED_TARGET_NAME}
82 POST_BUILD
83 COMMAND ${CMAKE_COMMAND} -E copy ${MPS3_FPGA_CONFIG} ${SECTORS_DIR})
84
Kshitij Sisodia8c61c0a2022-05-17 11:16:22 +010085endfunction()