Skip to content

Commit

Permalink
[microtvm][Zephyr] Add project overlay to overwrite device tree confi…
Browse files Browse the repository at this point in the history
…gs (apache#12741)

* add nucleo overlay
  • Loading branch information
mehrdadh authored Sep 9, 2022
1 parent 7596964 commit 1d32c40
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

&rcc {
clock-frequency = <DT_FREQ_M(120)>;
};
15 changes: 11 additions & 4 deletions apps/microtvm/zephyr/template_project/microtvm_api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,8 @@ def _generate_cmake_args(self, mlf_extracted_path, options) -> str:
return cmake_args

def generate_project(self, model_library_format_path, standalone_crt_dir, project_dir, options):
zephyr_board = options["zephyr_board"]

# Check Zephyr version
version = self._get_platform_version(get_zephyr_base(options))
if version != ZEPHYR_VERSION:
Expand All @@ -586,6 +588,11 @@ def generate_project(self, model_library_format_path, standalone_crt_dir, projec
# Copy boards.json file to generated project.
shutil.copy2(BOARDS, project_dir / BOARDS.name)

# Copy overlay files
board_overlay_path = API_SERVER_DIR / "app-overlay" / f"{zephyr_board}.overlay"
if board_overlay_path.exists():
shutil.copy2(board_overlay_path, project_dir / f"{zephyr_board}.overlay")

# Place Model Library Format tarball in the special location, which this script uses to decide
# whether it's being invoked in a template or generated project.
project_model_library_format_tar_path = project_dir / MODEL_LIBRARY_FORMAT_RELPATH
Expand All @@ -597,9 +604,9 @@ def generate_project(self, model_library_format_path, standalone_crt_dir, projec
os.makedirs(extract_path)
tf.extractall(path=extract_path)

if self._is_qemu(options["zephyr_board"], options.get("use_fvp")):
if self._is_qemu(zephyr_board, options.get("use_fvp")):
shutil.copytree(API_SERVER_DIR / "qemu-hack", project_dir / "qemu-hack")
elif self._is_fvp(options["zephyr_board"], options.get("use_fvp")):
elif self._is_fvp(zephyr_board, options.get("use_fvp")):
shutil.copytree(API_SERVER_DIR / "fvp-hack", project_dir / "fvp-hack")

# Populate CRT.
Expand Down Expand Up @@ -650,7 +657,7 @@ def generate_project(self, model_library_format_path, standalone_crt_dir, projec
for item in flags:
cmake_f.write(f"target_compile_definitions(app PUBLIC {item})\n")

if self._is_fvp(options["zephyr_board"], options.get("use_fvp")):
if self._is_fvp(zephyr_board, options.get("use_fvp")):
cmake_f.write(f"target_compile_definitions(app PUBLIC -DFVP=1)\n")

self._create_prj_conf(project_dir, options)
Expand All @@ -665,7 +672,7 @@ def generate_project(self, model_library_format_path, standalone_crt_dir, projec
# Populate src/
src_dir = project_dir / "src"
if options["project_type"] != "host_driven" or self._is_fvp(
options["zephyr_board"], options.get("use_fvp")
zephyr_board, options.get("use_fvp")
):
shutil.copytree(API_SERVER_DIR / "src" / options["project_type"], src_dir)
else:
Expand Down
1 change: 1 addition & 0 deletions cmake/modules/Zephyr.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if(USE_MICRO)
"apps/microtvm/zephyr/template_project/src/host_driven *.h -> zephyr/src/host_driven"
"apps/microtvm/zephyr/template_project/fvp-hack * -> zephyr/fvp-hack"
"apps/microtvm/zephyr/template_project/qemu-hack * -> zephyr/qemu-hack"
"apps/microtvm/zephyr/template_project/app-overlay * -> zephyr/app-overlay"
"apps/microtvm/zephyr/template_project/crt_config *.h -> zephyr/crt_config"
)

Expand Down
1 change: 1 addition & 0 deletions tests/lint/check_file_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
"apps/microtvm/zephyr/template_project/qemu-hack/qemu-system-riscv32",
"apps/microtvm/zephyr/template_project/qemu-hack/qemu-system-riscv64",
"apps/microtvm/zephyr/template_project/fvp-hack/FVP_Corstone_SSE-300_Ethos-U55",
"apps/microtvm/zephyr/template_project/app-overlay/nucleo_l4r5zi.overlay",
# microTVM Virtual Machines
"apps/microtvm/poetry.lock",
"apps/microtvm/reference-vm/Vagrantfile",
Expand Down

0 comments on commit 1d32c40

Please sign in to comment.