alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 1 | #---------------------------------------------------------------------------- |
Kshitij Sisodia | 774c7ca | 2024-04-12 11:30:02 +0100 | [diff] [blame] | 2 | # SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its |
| 3 | # affiliates <open-source-office@arm.com> |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 4 | # 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 | |
| 19 | function(set_platform_global_defaults) |
| 20 | message(STATUS "Platform: Simple platform with minimal peripherals") |
Kshitij Sisodia | 774c7ca | 2024-04-12 11:30:02 +0100 | [diff] [blame] | 21 | |
| 22 | # Include NPU and CMSIS configuration options |
| 23 | include(npu_opts) |
| 24 | include(cmsis_opts) |
| 25 | |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 26 | if (NOT DEFINED CMAKE_TOOLCHAIN_FILE) |
Kshitij Sisodia | 72377a4 | 2024-05-16 09:15:12 +0100 | [diff] [blame] | 27 | set(CMAKE_TOOLCHAIN_FILE ${MLEK_CMAKE_TOOLCHAIN_DIR}/bare-metal-gcc.cmake |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 28 | CACHE FILEPATH "Toolchain file") |
| 29 | endif() |
Kshitij Sisodia | 26bc923 | 2023-03-10 16:33:23 +0000 | [diff] [blame] | 30 | |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 31 | set(LINKER_SCRIPT_NAME "simple_platform" PARENT_SCOPE) |
Kshitij Sisodia | 72377a4 | 2024-05-16 09:15:12 +0100 | [diff] [blame] | 32 | set(PLATFORM_DRIVERS_DIR "${MLEK_HAL_PLATFORM_DIR}/simple" PARENT_SCOPE) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 33 | endfunction() |
| 34 | |
| 35 | function(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") |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 40 | |
Kshitij Sisodia | 26bc923 | 2023-03-10 16:33:23 +0000 | [diff] [blame] | 41 | # 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: |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 49 | add_linker_script( |
Kshitij Sisodia | 774c7ca | 2024-04-12 11:30:02 +0100 | [diff] [blame] | 50 | ${PARSED_TARGET_NAME} # Target |
| 51 | ${CMAKE_CURRENT_FUNCTION_LIST_DIR} # Directory path |
| 52 | ${LINKER_SCRIPT_NAME}) # Name of the file without suffix |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 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 | |
| 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 Sisodia | 26bc923 | 2023-03-10 16:33:23 +0000 | [diff] [blame] | 73 | endfunction() |