alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 1 | #---------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2021 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 | set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/build_baremetal) |
| 18 | set(PLAT_HAL ${CMAKE_CURRENT_SOURCE_DIR}/source/application/hal/platforms/bare-metal) |
| 19 | |
| 20 | # If target platform not defined raise an error |
| 21 | # TARGET_PLATFORM either should have been defined by the user or set to default value mps3 |
| 22 | if (NOT DEFINED TARGET_PLATFORM) |
| 23 | message(FATAL_ERROR "Invalid target platform, specify TARGET_PLATFORM=mps3") |
| 24 | endif () |
| 25 | message(STATUS "target platform ${TARGET_PLATFORM}") |
| 26 | |
| 27 | set(SOURCE_GEN_DIR ${CMAKE_BINARY_DIR}/generated/bsp) |
| 28 | if (NOT DEFINED MEM_PROFILES_SRC_DIR) |
| 29 | set(MEM_PROFILES_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/subsystem-profiles) |
| 30 | endif() |
| 31 | set(MEM_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/templates/peripheral_memmap.h.template) |
| 32 | set(IRQ_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/templates/peripheral_irqs.h.template) |
| 33 | set(MEM_REGIONS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/templates/mem_regions.h.template) |
| 34 | set(TA_SETTINGS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/templates/timing_adapter_settings.template) |
| 35 | set(TENSORFLOW_LITE_MICRO_PLATFORM_LIB_NAME "libtensorflow-microlite.a") |
| 36 | set(TENSORFLOW_LITE_MICRO_FLAG "-DTF_LITE_STATIC_MEMORY") |
| 37 | set(ETHOS_U55_FLAG "-DARM_NPU=1") |
| 38 | |
| 39 | if (ETHOS_U55_ENABLED) |
| 40 | set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS} ${ETHOS_U55_FLAG}") |
| 41 | endif () |
| 42 | |
| 43 | # Set specific flags depending on target platform and subsystem |
| 44 | if (TARGET_PLATFORM STREQUAL mps3) |
| 45 | set(MPS3_PLATFORM_FLAG "-DMPS3_PLATFORM=1") |
| 46 | |
| 47 | # If target platform is mps3 and subsystem not defined raise an error, |
| 48 | # TARGET_SUBSYSTEM either should have been defined by the user or set to a default value |
| 49 | if (NOT DEFINED TARGET_SUBSYSTEM) |
| 50 | message(FATAL_ERROR "Target subsystem for mps3 undefined, " |
| 51 | "specify -DTARGET_SUBSYSTEM=<sse-200 or sse-300>") |
| 52 | endif () |
| 53 | |
| 54 | if (TARGET_SUBSYSTEM STREQUAL sse-200 OR TARGET_SUBSYSTEM STREQUAL sse-300) |
| 55 | message(STATUS "target subsystem is ${TARGET_SUBSYSTEM}") |
| 56 | set(BSP_PACKAGE_DIR "${PLAT_HAL}/bsp/bsp-packs/mps3") |
| 57 | set(SCAT_FILE "${PLAT_HAL}/bsp/mem_layout/mps3-${TARGET_SUBSYSTEM}.sct") |
| 58 | |
| 59 | # Include the mem profile definitions specific to our target subsystem |
| 60 | include(${MEM_PROFILES_SRC_DIR}/corstone-${TARGET_SUBSYSTEM}.cmake) |
| 61 | set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS} ${MPS3_PLATFORM_FLAG}") |
| 62 | else () |
| 63 | message(FATAL_ERROR "Non compatible target subsystem: ${TARGET_SUBSYSTEM}") |
| 64 | endif () |
| 65 | elseif (TARGET_PLATFORM STREQUAL simple_platform) |
| 66 | set(BSP_PACKAGE_DIR "${PLAT_HAL}/bsp/bsp-packs/${TARGET_PLATFORM}") |
| 67 | set(SCAT_FILE "${PLAT_HAL}/bsp/mem_layout/${TARGET_PLATFORM}.sct") |
| 68 | include(${MEM_PROFILES_SRC_DIR}/${TARGET_PLATFORM}.cmake) |
| 69 | set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS}") |
| 70 | else () |
| 71 | message(FATAL_ERROR "Non compatible target platform ${TARGET_PLATFORM}") |
| 72 | endif () |
| 73 | |
| 74 | if (ETHOS_U55_ENABLED) |
| 75 | USER_OPTION(TA_CONFIG_FILE "Path to the timing adapter configuration file" |
| 76 | "${CMAKE_SCRIPTS_DIR}/ta_config.cmake" |
| 77 | FILEPATH) |
| 78 | |
| 79 | # must be included after target subsystem CMake file |
| 80 | include(${TA_CONFIG_FILE}) |
| 81 | endif() |
| 82 | |
| 83 | # Generate the memory map header file from the mem profile cmake included in one of |
| 84 | # the previous sections |
| 85 | message(STATUS "Configuring file from ${MEM_PROFILE_TEMPLATE}" |
| 86 | ", ${IRQ_PROFILE_TEMPLATE}" |
| 87 | " and ${MEM_REGIONS_TEMPLATE}") |
| 88 | |
| 89 | configure_file("${MEM_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_memmap.h") |
| 90 | configure_file("${IRQ_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_irqs.h") |
| 91 | configure_file("${MEM_REGIONS_TEMPLATE}" "${SOURCE_GEN_DIR}/mem_regions.h") |
| 92 | configure_file("${TA_SETTINGS_TEMPLATE}" "${SOURCE_GEN_DIR}/timing_adapter_settings.h") |
| 93 | |
| 94 | message(STATUS "Scatter file: ${SCAT_FILE}") |
| 95 | message(STATUS "Using BSP package from: ${BSP_PACKAGE_DIR}") |
| 96 | |
| 97 | if (DEFINED VERIFY_TEST_OUTPUT) |
| 98 | message(STATUS "Test output verification flag is: ${VERIFY_TEST_OUTPUT}") |
| 99 | set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS} -DVERIFY_TEST_OUTPUT=${VERIFY_TEST_OUTPUT}") |
| 100 | endif () |
| 101 | |
| 102 | if (DEFINED LOG_LEVEL) |
| 103 | message(STATUS "Setting log level to ${LOG_LEVEL}") |
| 104 | set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS} -DLOG_LEVEL=${LOG_LEVEL}") |
| 105 | endif() |
| 106 | |
| 107 | if (DEFINED ACTIVATION_BUF_SRAM_SZ) |
| 108 | message(STATUS "Maximum SRAM space for activations buffers for this system: ${ACTIVATION_BUF_SRAM_SZ}") |
| 109 | set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS} -DACTIVATION_BUF_SRAM_SZ=${ACTIVATION_BUF_SRAM_SZ}") |
| 110 | endif() |
| 111 | |
| 112 | if (DEFINED ARMCLANG_DEBUG_DWARF_LEVEL) |
| 113 | message(STATUS "setting dwarf conformance level to gdwarf-${ARMCLANG_DEBUG_DWARF_LEVEL}") |
| 114 | set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS} -gdwarf-${ARMCLANG_DEBUG_DWARF_LEVEL}") |
| 115 | endif() |
| 116 | |
| 117 | set(COMPILER_FLAGS "${ALL_COMMON_FLAGS} ${TENSORFLOW_LITE_MICRO_FLAG} ${PROFILING_OPT} ${OPTIONAL_FLAGS}") |
| 118 | # For some reason, cmake doesn't pass the c++ standard flag, adding it manually |
| 119 | set(CMAKE_CXX_FLAGS "${COMPILER_FLAGS} -std=c++11" CACHE INTERNAL "") |
| 120 | set(CMAKE_C_FLAGS "${COMPILER_FLAGS}" CACHE INTERNAL "") |
| 121 | set(CMAKE_ASM_FLAGS "${CPU_LD}") |
| 122 | set(CMAKE_ASM_COMPILE_OBJECT ${CMAKE_CXX_FLAGS}) |
| 123 | |
| 124 | add_link_options(--strict --callgraph --load_addr_map_info --map) |
| 125 | add_link_options(--symbols --xref --scatter=${SCAT_FILE}) |
| 126 | |
| 127 | # Warnings to be ignored: |
| 128 | # L6314W = No section matches pattern |
| 129 | # L6439W = Multiply defined Global Symbol |
| 130 | add_link_options(--diag_suppress=L6439W,L6314W) |
| 131 | add_link_options(--info sizes,totals,unused,veneers --entry Reset_Handler) |
| 132 | |
| 133 | if (CMAKE_BUILD_TYPE STREQUAL Release) |
| 134 | add_link_options(--no_debug) |
| 135 | endif () |
| 136 | |
| 137 | set(CMAKE_EXE_LINKER_FLAGS "${CPU_LD}") |
| 138 | |
| 139 | set(PLAT_BSP_INCLUDES |
| 140 | ${PLAT_HAL}/bsp/cmsis-device/include |
| 141 | ${PLAT_HAL}/bsp/include/ |
| 142 | ${PLAT_HAL}/bsp/bsp-core/include |
| 143 | ${BSP_PACKAGE_DIR}/include |
| 144 | ) |
| 145 | |
| 146 | # Include directories: |
| 147 | set(PLAT_INCLUDE_DIRS |
| 148 | ${PLAT_BSP_INCLUDES} |
| 149 | ${PLAT_HAL}/utils/include |
| 150 | ${PLAT_HAL}/images/include |
| 151 | ${PLAT_HAL}/data_presentation/lcd/include |
| 152 | ${PLAT_HAL}/timer/include |
| 153 | ${SOURCE_GEN_DIR} |
| 154 | ) |
| 155 | |
| 156 | # Source files |
| 157 | file(GLOB_RECURSE SRC_PLAT_HAL |
| 158 | |
| 159 | # Higher level HAL sources - software logic implementations |
| 160 | "${PLAT_HAL}/data_*/*.c" |
| 161 | "${PLAT_HAL}/images/*.c" |
| 162 | "${PLAT_HAL}/timer/*.c" |
| 163 | "${PLAT_HAL}/utils/*.c" |
| 164 | |
| 165 | # Low level HAL sources - these enable interaction with |
| 166 | # the actual hardware |
| 167 | "${PLAT_HAL}/bsp/cmsis-device/*.c" |
| 168 | "${PLAT_HAL}/bsp/bsp-core/*.c" |
| 169 | "${BSP_PACKAGE_DIR}/*.c" |
| 170 | ) |