diff --git a/apps/microtvm/zephyr/template_project/CMakeLists.txt.template b/apps/microtvm/zephyr/template_project/CMakeLists.txt.template index 742433e82d0d..b5182bf8ac1f 100644 --- a/apps/microtvm/zephyr/template_project/CMakeLists.txt.template +++ b/apps/microtvm/zephyr/template_project/CMakeLists.txt.template @@ -29,7 +29,7 @@ find_package(Zephyr HINTS $ENV{ZEPHYR_BASE}) project(microtvm_autogenerated_project) if(${ENABLE_CMSIS}) - set(CMSIS_PATH $ENV{CMSIS_PATH}) + set(CMSIS_PATH ) file(GLOB_RECURSE cmsis_lib_srcs ${CMSIS_PATH}/CMSIS/NN/Source/SoftmaxFunctions/*.c @@ -40,6 +40,7 @@ if(${ENABLE_CMSIS}) ) set(cmsis_includes + ${CMSIS_PATH}/CMSIS/Core/Include ${CMSIS_PATH}/CMSIS/NN/Include ${CMSIS_PATH}/CMSIS/DSP/Include ${CMSIS_PATH}/CMSIS/DSP/Include/dsp diff --git a/apps/microtvm/zephyr/template_project/microtvm_api_server.py b/apps/microtvm/zephyr/template_project/microtvm_api_server.py index c55bd63fa4dd..eb20c3e88448 100644 --- a/apps/microtvm/zephyr/template_project/microtvm_api_server.py +++ b/apps/microtvm/zephyr/template_project/microtvm_api_server.py @@ -463,6 +463,7 @@ def _create_prj_conf(self, project_dir, options): API_SERVER_CRT_LIBS_TOKEN = "" CMAKE_ARGS_TOKEN = "" QEMU_PIPE_TOKEN = "" + CMSIS_PATH_TOKEN = "" CRT_LIBS_BY_PROJECT_TYPE = { "host_driven": "microtvm_rpc_server microtvm_rpc_common aot_executor_module aot_executor common", @@ -521,6 +522,8 @@ def _generate_cmake_args(self, mlf_extracted_path, options) -> str: cmake_args += f"set(BOARD {options['zephyr_board']})\n" enable_cmsis = self._cmsis_required(mlf_extracted_path) + if enable_cmsis: + assert os.environ.get("CMSIS_PATH"), "CMSIS_PATH is not defined." cmake_args += f"set(ENABLE_CMSIS {str(enable_cmsis).upper()})\n" return cmake_args @@ -587,6 +590,9 @@ def generate_project(self, model_library_format_path, standalone_crt_dir, projec self.qemu_pipe_dir = pathlib.Path(tempfile.mkdtemp()) line = line.replace(self.QEMU_PIPE_TOKEN, str(self.qemu_pipe_dir / "fifo")) + if self.CMSIS_PATH_TOKEN in line and self._cmsis_required(extract_path): + line = line.replace(self.CMSIS_PATH_TOKEN, str(os.environ["CMSIS_PATH"])) + cmake_f.write(line) if options.get("compile_definitions"):