blob: 8b348e301fe187d0f4ce4c4d6a765ae48d11542c [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001#----------------------------------------------------------------------------
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#----------------------------------------------------------------------------
17set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/build_baremetal)
18set(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
22if (NOT DEFINED TARGET_PLATFORM)
23 message(FATAL_ERROR "Invalid target platform, specify TARGET_PLATFORM=mps3")
24endif ()
25message(STATUS "target platform ${TARGET_PLATFORM}")
26
27set(SOURCE_GEN_DIR ${CMAKE_BINARY_DIR}/generated/bsp)
28if (NOT DEFINED MEM_PROFILES_SRC_DIR)
29 set(MEM_PROFILES_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/subsystem-profiles)
30endif()
31set(MEM_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/templates/peripheral_memmap.h.template)
32set(IRQ_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/templates/peripheral_irqs.h.template)
33set(MEM_REGIONS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/templates/mem_regions.h.template)
34set(TA_SETTINGS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/templates/timing_adapter_settings.template)
35set(TENSORFLOW_LITE_MICRO_PLATFORM_LIB_NAME "libtensorflow-microlite.a")
36set(TENSORFLOW_LITE_MICRO_FLAG "-DTF_LITE_STATIC_MEMORY")
37set(ETHOS_U55_FLAG "-DARM_NPU=1")
38
39if (ETHOS_U55_ENABLED)
40 set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS} ${ETHOS_U55_FLAG}")
41endif ()
42
43# Set specific flags depending on target platform and subsystem
44if (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, "
alexanderd580eee2021-05-04 21:24:22 +010051 "specify -DTARGET_SUBSYSTEM=<sse-300>")
alexander3c798932021-03-26 21:42:19 +000052 endif ()
53
alexanderd580eee2021-05-04 21:24:22 +010054 if (TARGET_SUBSYSTEM STREQUAL sse-300)
alexander3c798932021-03-26 21:42:19 +000055 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 ()
65elseif (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}")
70else ()
71 message(FATAL_ERROR "Non compatible target platform ${TARGET_PLATFORM}")
72endif ()
73
74if (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})
81endif()
82
83# Generate the memory map header file from the mem profile cmake included in one of
84# the previous sections
85message(STATUS "Configuring file from ${MEM_PROFILE_TEMPLATE}"
86 ", ${IRQ_PROFILE_TEMPLATE}"
87 " and ${MEM_REGIONS_TEMPLATE}")
88
89configure_file("${MEM_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_memmap.h")
90configure_file("${IRQ_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_irqs.h")
91configure_file("${MEM_REGIONS_TEMPLATE}" "${SOURCE_GEN_DIR}/mem_regions.h")
92configure_file("${TA_SETTINGS_TEMPLATE}" "${SOURCE_GEN_DIR}/timing_adapter_settings.h")
93
94message(STATUS "Scatter file: ${SCAT_FILE}")
95message(STATUS "Using BSP package from: ${BSP_PACKAGE_DIR}")
96
97if (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}")
100endif ()
101
102if (DEFINED LOG_LEVEL)
103 message(STATUS "Setting log level to ${LOG_LEVEL}")
104 set(OPTIONAL_FLAGS "${OPTIONAL_FLAGS} -DLOG_LEVEL=${LOG_LEVEL}")
105endif()
106
107if (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}")
110endif()
111
112if (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}")
115endif()
116
117set(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
119set(CMAKE_CXX_FLAGS "${COMPILER_FLAGS} -std=c++11" CACHE INTERNAL "")
120set(CMAKE_C_FLAGS "${COMPILER_FLAGS}" CACHE INTERNAL "")
121set(CMAKE_ASM_FLAGS "${CPU_LD}")
122set(CMAKE_ASM_COMPILE_OBJECT ${CMAKE_CXX_FLAGS})
123
124add_link_options(--strict --callgraph --load_addr_map_info --map)
125add_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
130add_link_options(--diag_suppress=L6439W,L6314W)
131add_link_options(--info sizes,totals,unused,veneers --entry Reset_Handler)
132
133if (CMAKE_BUILD_TYPE STREQUAL Release)
134 add_link_options(--no_debug)
135endif ()
136
137set(CMAKE_EXE_LINKER_FLAGS "${CPU_LD}")
138
139set(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:
147set(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
157file(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 )