Skip to content

Commit

Permalink
check for CMSIS_PATH in project generation (apache#12547)
Browse files Browse the repository at this point in the history
Co-authored-by: Mohamad <[email protected]>
  • Loading branch information
mkatanbaf and mkatanbaf authored Aug 23, 2022
1 parent 8e95bba commit 3bd1681
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <CMSIS_PATH>)

file(GLOB_RECURSE cmsis_lib_srcs
${CMSIS_PATH}/CMSIS/NN/Source/SoftmaxFunctions/*.c
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions apps/microtvm/zephyr/template_project/microtvm_api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ def _create_prj_conf(self, project_dir, options):
API_SERVER_CRT_LIBS_TOKEN = "<API_SERVER_CRT_LIBS>"
CMAKE_ARGS_TOKEN = "<CMAKE_ARGS>"
QEMU_PIPE_TOKEN = "<QEMU_PIPE>"
CMSIS_PATH_TOKEN = "<CMSIS_PATH>"

CRT_LIBS_BY_PROJECT_TYPE = {
"host_driven": "microtvm_rpc_server microtvm_rpc_common aot_executor_module aot_executor common",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"):
Expand Down

0 comments on commit 3bd1681

Please sign in to comment.