|
| 1 | +# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | +# All rights reserved. |
| 3 | +# |
| 4 | +# This source code is licensed under the BSD-style license found in the |
| 5 | +# LICENSE file in the root directory of this source tree. |
| 6 | + |
| 7 | +# Set the minimum required version of CMake for this project. |
| 8 | +cmake_minimum_required(VERSION 3.10) |
| 9 | + |
| 10 | +if(NOT CMAKE_CXX_STANDARD) |
| 11 | + set(CMAKE_CXX_STANDARD 17) |
| 12 | +endif() |
| 13 | + |
| 14 | +# Set the project name. |
| 15 | +project(cadence_executorch_example) |
| 16 | + |
| 17 | +# Source root directory for executorch. |
| 18 | +if(NOT EXECUTORCH_ROOT) |
| 19 | + set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..) |
| 20 | +endif() |
| 21 | + |
| 22 | +include(${EXECUTORCH_ROOT}/build/Utils.cmake) |
| 23 | + |
| 24 | +if(NOT PYTHON_EXECUTABLE) |
| 25 | + resolve_python_executable() |
| 26 | +endif() |
| 27 | + |
| 28 | +# Let files say "include <executorch/path/to/header.h>". |
| 29 | +set(_common_include_directories ${EXECUTORCH_ROOT}/..) |
| 30 | + |
| 31 | +# Find prebuilt executorch lib |
| 32 | +find_package(executorch CONFIG REQUIRED) |
| 33 | + |
| 34 | +add_compile_options( |
| 35 | + -DSDK_DEBUGCONSOLE=1 |
| 36 | + -DSERIAL_PORT_TYPE_UART=1 |
| 37 | + -DDEBUG_CONSOLE_RX_ENABLE=0 |
| 38 | + -DDEBUG |
| 39 | + -DCPU_MIMXRT685SFVKB_dsp |
| 40 | + -DMCUXPRESSO_SDK |
| 41 | + -g |
| 42 | + -O0 |
| 43 | + -Wall |
| 44 | + -fsigned-char |
| 45 | + -Wno-missing-braces |
| 46 | + -fmessage-length=0 |
| 47 | + -DPRINTF_FLOAT_ENABLE=1 |
| 48 | +) |
| 49 | + |
| 50 | +if(NOT DEFINED NXP_SDK_ROOT_DIR) |
| 51 | + message(FATAL_ERROR "NXP_SDK_ROOT_DIR is not set") |
| 52 | +endif() |
| 53 | + |
| 54 | +# lint_cmake: -linelength |
| 55 | +set(SOURCES |
| 56 | + ${NXP_SDK_ROOT_DIR}/components/lists/fsl_component_generic_list.c |
| 57 | + ${NXP_SDK_ROOT_DIR}/components/uart/fsl_adapter_usart.c |
| 58 | + ${NXP_SDK_ROOT_DIR}/devices/MIMXRT685S/drivers/fsl_clock.c |
| 59 | + ${NXP_SDK_ROOT_DIR}/devices/MIMXRT685S/drivers/fsl_common.c |
| 60 | + ${NXP_SDK_ROOT_DIR}/devices/MIMXRT685S/drivers/fsl_common_dsp.c |
| 61 | + ${NXP_SDK_ROOT_DIR}/devices/MIMXRT685S/drivers/fsl_flexcomm.c |
| 62 | + ${NXP_SDK_ROOT_DIR}/devices/MIMXRT685S/drivers/fsl_gpio.c |
| 63 | + ${NXP_SDK_ROOT_DIR}/devices/MIMXRT685S/drivers/fsl_mu.c |
| 64 | + ${NXP_SDK_ROOT_DIR}/devices/MIMXRT685S/drivers/fsl_reset.c |
| 65 | + ${NXP_SDK_ROOT_DIR}/devices/MIMXRT685S/drivers/fsl_usart.c |
| 66 | + ${NXP_SDK_ROOT_DIR}/devices/MIMXRT685S/system_MIMXRT685S_dsp.c |
| 67 | + ${NXP_SDK_ROOT_DIR}/devices/MIMXRT685S/utilities/debug_console_lite/fsl_assert.c |
| 68 | + ${NXP_SDK_ROOT_DIR}/devices/MIMXRT685S/utilities/debug_console_lite/fsl_debug_console.c |
| 69 | + ${NXP_SDK_ROOT_DIR}/boards/evkmimxrt685/dsp_examples/mu_polling/dsp/board_hifi4.c |
| 70 | + ${NXP_SDK_ROOT_DIR}/boards/evkmimxrt685/dsp_examples/mu_polling/dsp/pin_mux.c |
| 71 | + ${NXP_SDK_ROOT_DIR}/devices/MIMXRT685S/utilities/str/fsl_str.c |
| 72 | +) |
| 73 | + |
| 74 | +add_library(dsp_mu_polling_libs STATIC ${SOURCES}) |
| 75 | + |
| 76 | +target_include_directories( |
| 77 | + dsp_mu_polling_libs |
| 78 | + PUBLIC ${NXP_SDK_ROOT_DIR} |
| 79 | + ${NXP_SDK_ROOT_DIR}/components/uart |
| 80 | + ${NXP_SDK_ROOT_DIR}/devices/MIMXRT685S/drivers |
| 81 | + ${NXP_SDK_ROOT_DIR}/devices/MIMXRT685S/utilities/debug_console_lite |
| 82 | + ${NXP_SDK_ROOT_DIR}/components/lists |
| 83 | + ${NXP_SDK_ROOT_DIR}/devices/MIMXRT685S |
| 84 | + ${NXP_SDK_ROOT_DIR}/CMSIS/Core/Include |
| 85 | + ${NXP_SDK_ROOT_DIR}/devices/MIMXRT685S/utilities/str |
| 86 | + ${NXP_SDK_ROOT_DIR}/boards/evkmimxrt685/dsp_examples/mu_polling/dsp |
| 87 | +) |
| 88 | + |
| 89 | +add_library(extension_runner_util STATIC IMPORTED) |
| 90 | +set_property( |
| 91 | + TARGET extension_runner_util |
| 92 | + PROPERTY |
| 93 | + IMPORTED_LOCATION |
| 94 | + "${CMAKE_CURRENT_LIST_DIR}/../../cmake-out/extension/runner_util/libextension_runner_util.a" |
| 95 | +) |
| 96 | + |
| 97 | +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/hifi/operators) |
| 98 | +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/hifi/kernels) |
| 99 | + |
| 100 | +# Generate the model header file |
| 101 | +add_custom_command( |
| 102 | + OUTPUT ${CMAKE_BINARY_DIR}/model_pte.h |
| 103 | + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/utils/gen_header.py |
| 104 | + --model_path ${MODEL_PATH} --header_output_path ${CMAKE_BINARY_DIR} |
| 105 | + COMMENT "Converting .pte model to header file..." |
| 106 | + DEPENDS ${CMAKE_CURRENT_LIST_DIR}/utils/gen_header.py |
| 107 | +) |
| 108 | + |
| 109 | +add_custom_target(gen_model_header DEPENDS ${CMAKE_BINARY_DIR}/model_pte.h) |
| 110 | + |
| 111 | +add_executable(cadence_executorch_example executor_runner.cpp) |
| 112 | +add_dependencies(cadence_executorch_example gen_model_header) |
| 113 | + |
| 114 | +# lint_cmake: -linelength |
| 115 | +target_include_directories( |
| 116 | + cadence_executorch_example PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR} |
| 117 | + ${_common_include_directories} |
| 118 | +) |
| 119 | + |
| 120 | +target_link_options( |
| 121 | + cadence_executorch_example PRIVATE |
| 122 | + -mlsp=${NXP_SDK_ROOT_DIR}/devices/MIMXRT685S/xtensa/min-rt |
| 123 | +) |
| 124 | +target_link_libraries( |
| 125 | + cadence_executorch_example dsp_mu_polling_libs cadence_ops_lib |
| 126 | + extension_runner_util executorch |
| 127 | +) |
| 128 | + |
| 129 | +add_custom_command( |
| 130 | + TARGET cadence_executorch_example |
| 131 | + POST_BUILD |
| 132 | + COMMAND |
| 133 | + ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/utils/post_compilation.py |
| 134 | + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME} ${CMAKE_BINARY_DIR} |
| 135 | + COMMENT |
| 136 | + "Generating .bin files that can be used to flash the DSP with. Copy over |
| 137 | + the dsp_text_release.bin and dsp_data_release.bin that are generated into |
| 138 | + your NXP MCUXpresso IDE workspace and flash the DSP with these binaries." |
| 139 | + DEPENDS |
| 140 | + ${CMAKE_CURRENT_LIST_DIR}/utils/post_compilation.py |
| 141 | +) |
0 commit comments