blob: 3536c5b0960d759c6ccc42354e7d37f45d9ab6e7 [file] [log] [blame]
alexander31ae9f02022-02-10 16:15:54 +00001#----------------------------------------------------------------------------
Kshitij Sisodia26bc9232023-03-10 16:33:23 +00002# SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
alexander31ae9f02022-02-10 16:15:54 +00003# 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: Simple platform with minimal peripherals")
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()
Kshitij Sisodia26bc9232023-03-10 16:33:23 +000024
alexander31ae9f02022-02-10 16:15:54 +000025 set(LINKER_SCRIPT_NAME "simple_platform" PARENT_SCOPE)
26 set(PLATFORM_DRIVERS_DIR "${HAL_PLATFORM_DIR}/simple" PARENT_SCOPE)
27endfunction()
28
29function(platform_custom_post_build)
30 set(oneValueArgs TARGET_NAME)
31 cmake_parse_arguments(PARSED "" "${oneValueArgs}" "" ${ARGN} )
32
33 set_target_properties(${PARSED_TARGET_NAME} PROPERTIES SUFFIX ".axf")
alexander31ae9f02022-02-10 16:15:54 +000034
Kshitij Sisodia26bc9232023-03-10 16:33:23 +000035 # For GNU toolchain, we have different linker scripts for Debug and Release
36 # as the code footprint difference between the two is quite big.
37 if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
38 string(TOLOWER ${CMAKE_BUILD_TYPE} LINKER_SCRIPT_SUFFIX)
39 set(LINKER_SCRIPT_NAME "${LINKER_SCRIPT_NAME}_${LINKER_SCRIPT_SUFFIX}" PARENT_SCOPE FORCE)
40 endif()
41
42 # Add link options for the linker script to be used:
alexander31ae9f02022-02-10 16:15:54 +000043 add_linker_script(
44 ${PARSED_TARGET_NAME} # Target
45 ${CMAKE_SCRIPTS_DIR}/platforms/simple_platform # Directory path
46 ${LINKER_SCRIPT_NAME}) # Name of the file without suffix
47
48 add_target_map_file(
49 ${PARSED_TARGET_NAME}
50 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PARSED_TARGET_NAME}.map)
51
52 set(SECTORS_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sectors)
53 set(SECTORS_BIN_DIR ${SECTORS_DIR}/${use_case})
54
55 file(REMOVE_RECURSE ${SECTORS_BIN_DIR})
56 file(MAKE_DIRECTORY ${SECTORS_BIN_DIR})
57
58 set(LINKER_SECTION_TAGS "*.at_itcm" "*.at_ddr")
59 set(LINKER_OUTPUT_BIN_TAGS "itcm.bin" "ddr.bin")
60
61 add_bin_generation_command(
62 TARGET_NAME ${PARSED_TARGET_NAME}
63 OUTPUT_DIR ${SECTORS_BIN_DIR}
64 AXF_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PARSED_TARGET_NAME}.axf
65 SECTION_PATTERNS "${LINKER_SECTION_TAGS}"
66 OUTPUT_BIN_NAMES "${LINKER_OUTPUT_BIN_TAGS}")
Kshitij Sisodia26bc9232023-03-10 16:33:23 +000067endfunction()