blob: 040b27ded34d5c191471848e8b61fdc1732d2230 [file] [log] [blame]
Yulia Garbovichf61ea352021-11-11 14:16:57 +02001#
Kristofer Jonssonac535f02022-03-10 11:08:39 +01002# Copyright (c) 2020-2022 Arm Limited.
Yulia Garbovichf61ea352021-11-11 14:16:57 +02003#
4# SPDX-License-Identifier: Apache-2.0
5#
6# Licensed under the Apache License, Version 2.0 (the License); you may
7# not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# 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, WITHOUT
14# 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
19if (NOT TARGET freertos_kernel)
20 message("Not building ethosu_message_dispatcher, required freertos not built.")
21 return()
22endif()
23
Kristofer Jonssona739d212022-05-05 12:11:52 +020024set(MESSAGE_HANDLER_ARENA_SIZE 2000000 CACHE STRING "Total size of all message handler tensor arenas")
Kristofer Jonsson585ce692022-03-08 13:28:05 +010025set(MESSAGE_HANDLER_MODEL_0 FALSE CACHE STRING "Path to built in model 0")
26set(MESSAGE_HANDLER_MODEL_1 FALSE CACHE STRING "Path to built in model 1")
27set(MESSAGE_HANDLER_MODEL_2 FALSE CACHE STRING "Path to built in model 2")
28set(MESSAGE_HANDLER_MODEL_3 FALSE CACHE STRING "Path to built in model 3")
Yulia Garbovichf61ea352021-11-11 14:16:57 +020029
30ethosu_add_executable(message_handler
31 SOURCES
32 main.cpp
33 message_handler.cpp
34 message_queue.cpp
35 LIBRARIES
36 cmsis_device
37 $<$<TARGET_EXISTS:ethosu_core_driver>:ethosu_core_driver>
38 ethosu_mailbox
39 freertos_kernel
40 inference_process)
41
42target_include_directories(message_handler PRIVATE
43 ${LINUX_DRIVER_STACK_PATH}/kernel)
44
Kristofer Jonssona739d212022-05-05 12:11:52 +020045# Split total tensor arena equally for each NPU
46if (TARGET ethosu_core_driver AND ETHOSU_TARGET_NPU_COUNT GREATER 0)
47 set(NUM_ARENAS ${ETHOSU_TARGET_NPU_COUNT})
48else()
49 set(NUM_ARENAS 1)
50endif()
51
52math(EXPR TENSOR_ARENA_SIZE "${MESSAGE_HANDLER_ARENA_SIZE} / ${NUM_ARENAS}")
53
Yulia Garbovichf61ea352021-11-11 14:16:57 +020054target_compile_definitions(message_handler PRIVATE
Kristofer Jonssona739d212022-05-05 12:11:52 +020055 TENSOR_ARENA_SIZE=${TENSOR_ARENA_SIZE}
Kristofer Jonsson585ce692022-03-08 13:28:05 +010056 $<$<BOOL:${MESSAGE_HANDLER_MODEL_0}>:MODEL_0=${MESSAGE_HANDLER_MODEL_0}>
57 $<$<BOOL:${MESSAGE_HANDLER_MODEL_1}>:MODEL_1=${MESSAGE_HANDLER_MODEL_1}>
58 $<$<BOOL:${MESSAGE_HANDLER_MODEL_2}>:MODEL_2=${MESSAGE_HANDLER_MODEL_2}>
59 $<$<BOOL:${MESSAGE_HANDLER_MODEL_3}>:MODEL_3=${MESSAGE_HANDLER_MODEL_3}>)
Per Åstrand2c76ec72022-04-26 09:57:20 +020060
61install(FILES $<TARGET_FILE:message_handler>
62 DESTINATION "lib/firmware"
63 RENAME "arm-${ETHOSU_TARGET_NPU_CONFIG}.fw"
64)