blob: 72e12606ae4d0eb8afdc172d293160cb4e151584 [file] [log] [blame]
alexander31ae9f02022-02-10 16:15:54 +00001#----------------------------------------------------------------------------
Kshitij Sisodia774c7ca2024-04-12 11:30:02 +01002# SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its
3# affiliates <open-source-office@arm.com>
alexander31ae9f02022-02-10 16:15:54 +00004# 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
19function(set_platform_global_defaults)
20 message(STATUS "Platform: Simple platform with minimal peripherals")
Kshitij Sisodia774c7ca2024-04-12 11:30:02 +010021
22 # Include NPU and CMSIS configuration options
23 include(npu_opts)
24 include(cmsis_opts)
25
alexander31ae9f02022-02-10 16:15:54 +000026 if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
Kshitij Sisodia72377a42024-05-16 09:15:12 +010027 set(CMAKE_TOOLCHAIN_FILE ${MLEK_CMAKE_TOOLCHAIN_DIR}/bare-metal-gcc.cmake
alexander31ae9f02022-02-10 16:15:54 +000028 CACHE FILEPATH "Toolchain file")
29 endif()
Kshitij Sisodia26bc9232023-03-10 16:33:23 +000030
alexander31ae9f02022-02-10 16:15:54 +000031 set(LINKER_SCRIPT_NAME "simple_platform" PARENT_SCOPE)
Kshitij Sisodia72377a42024-05-16 09:15:12 +010032 set(PLATFORM_DRIVERS_DIR "${MLEK_HAL_PLATFORM_DIR}/simple" PARENT_SCOPE)
alexander31ae9f02022-02-10 16:15:54 +000033endfunction()
34
35function(platform_custom_post_build)
36 set(oneValueArgs TARGET_NAME)
37 cmake_parse_arguments(PARSED "" "${oneValueArgs}" "" ${ARGN} )
38
39 set_target_properties(${PARSED_TARGET_NAME} PROPERTIES SUFFIX ".axf")
alexander31ae9f02022-02-10 16:15:54 +000040
Kshitij Sisodia26bc9232023-03-10 16:33:23 +000041 # For GNU toolchain, we have different linker scripts for Debug and Release
42 # as the code footprint difference between the two is quite big.
43 if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
44 string(TOLOWER ${CMAKE_BUILD_TYPE} LINKER_SCRIPT_SUFFIX)
45 set(LINKER_SCRIPT_NAME "${LINKER_SCRIPT_NAME}_${LINKER_SCRIPT_SUFFIX}" PARENT_SCOPE FORCE)
46 endif()
47
48 # Add link options for the linker script to be used:
alexander31ae9f02022-02-10 16:15:54 +000049 add_linker_script(
Kshitij Sisodia774c7ca2024-04-12 11:30:02 +010050 ${PARSED_TARGET_NAME} # Target
51 ${CMAKE_CURRENT_FUNCTION_LIST_DIR} # Directory path
52 ${LINKER_SCRIPT_NAME}) # Name of the file without suffix
alexander31ae9f02022-02-10 16:15:54 +000053
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
64 set(LINKER_SECTION_TAGS "*.at_itcm" "*.at_ddr")
65 set(LINKER_OUTPUT_BIN_TAGS "itcm.bin" "ddr.bin")
66
67 add_bin_generation_command(
68 TARGET_NAME ${PARSED_TARGET_NAME}
69 OUTPUT_DIR ${SECTORS_BIN_DIR}
70 AXF_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PARSED_TARGET_NAME}.axf
71 SECTION_PATTERNS "${LINKER_SECTION_TAGS}"
72 OUTPUT_BIN_NAMES "${LINKER_OUTPUT_BIN_TAGS}")
Kshitij Sisodia26bc9232023-03-10 16:33:23 +000073endfunction()