blob: 76c9e789cc1fed9757c078838fe1ffbc767539e2 [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")
20 if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
21 set(CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_DIR}/bare-metal-gcc.cmake
22 CACHE FILEPATH "Toolchain file")
23 endif()
24
25 set(LINKER_SCRIPT_NAME "mps3-${TARGET_SUBSYSTEM}" PARENT_SCOPE)
26 set(PLATFORM_DRIVERS_DIR "${HAL_PLATFORM_DIR}/mps3" PARENT_SCOPE)
27
28endfunction()
29
30function(platform_custom_post_build)
31 set(oneValueArgs TARGET_NAME)
32 cmake_parse_arguments(PARSED "" "${oneValueArgs}" "" ${ARGN} )
33
34 set_target_properties(${PARSED_TARGET_NAME} PROPERTIES SUFFIX ".axf")
35 # Add link options for the linker script to be used:
36 add_linker_script(
37 ${PARSED_TARGET_NAME} # Target
38 ${CMAKE_SCRIPTS_DIR}/platforms/mps3 # Directory path
39 ${LINKER_SCRIPT_NAME}) # Name of the file without suffix
40
41 add_target_map_file(
42 ${PARSED_TARGET_NAME}
43 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PARSED_TARGET_NAME}.map)
44
45 set(SECTORS_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sectors)
46 set(SECTORS_BIN_DIR ${SECTORS_DIR}/${use_case})
47
48 file(REMOVE_RECURSE ${SECTORS_BIN_DIR})
49 file(MAKE_DIRECTORY ${SECTORS_BIN_DIR})
50
51 set(LINKER_SECTION_TAGS "*.at_itcm" "*.at_ddr")
52 set(LINKER_OUTPUT_BIN_TAGS "itcm.bin" "ddr.bin")
53
54 add_bin_generation_command(
55 TARGET_NAME ${PARSED_TARGET_NAME}
56 OUTPUT_DIR ${SECTORS_BIN_DIR}
57 AXF_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PARSED_TARGET_NAME}.axf
58 SECTION_PATTERNS "${LINKER_SECTION_TAGS}"
59 OUTPUT_BIN_NAMES "${LINKER_OUTPUT_BIN_TAGS}")
60
61 set(MPS3_FPGA_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/scripts/mps3/${TARGET_SUBSYSTEM}/images.txt")
62
63 add_custom_command(TARGET ${PARSED_TARGET_NAME}
64 POST_BUILD
65 COMMAND ${CMAKE_COMMAND} -E copy ${MPS3_FPGA_CONFIG} ${SECTORS_DIR})
66
67endfunction()