Skip to content

Commit 1d32c40

Browse files
authored
[microtvm][Zephyr] Add project overlay to overwrite device tree configs (#12741)
* add nucleo overlay
1 parent 7596964 commit 1d32c40

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
/*
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
*/
20+
21+
&rcc {
22+
clock-frequency = <DT_FREQ_M(120)>;
23+
};

apps/microtvm/zephyr/template_project/microtvm_api_server.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,8 @@ def _generate_cmake_args(self, mlf_extracted_path, options) -> str:
567567
return cmake_args
568568

569569
def generate_project(self, model_library_format_path, standalone_crt_dir, project_dir, options):
570+
zephyr_board = options["zephyr_board"]
571+
570572
# Check Zephyr version
571573
version = self._get_platform_version(get_zephyr_base(options))
572574
if version != ZEPHYR_VERSION:
@@ -586,6 +588,11 @@ def generate_project(self, model_library_format_path, standalone_crt_dir, projec
586588
# Copy boards.json file to generated project.
587589
shutil.copy2(BOARDS, project_dir / BOARDS.name)
588590

591+
# Copy overlay files
592+
board_overlay_path = API_SERVER_DIR / "app-overlay" / f"{zephyr_board}.overlay"
593+
if board_overlay_path.exists():
594+
shutil.copy2(board_overlay_path, project_dir / f"{zephyr_board}.overlay")
595+
589596
# Place Model Library Format tarball in the special location, which this script uses to decide
590597
# whether it's being invoked in a template or generated project.
591598
project_model_library_format_tar_path = project_dir / MODEL_LIBRARY_FORMAT_RELPATH
@@ -597,9 +604,9 @@ def generate_project(self, model_library_format_path, standalone_crt_dir, projec
597604
os.makedirs(extract_path)
598605
tf.extractall(path=extract_path)
599606

600-
if self._is_qemu(options["zephyr_board"], options.get("use_fvp")):
607+
if self._is_qemu(zephyr_board, options.get("use_fvp")):
601608
shutil.copytree(API_SERVER_DIR / "qemu-hack", project_dir / "qemu-hack")
602-
elif self._is_fvp(options["zephyr_board"], options.get("use_fvp")):
609+
elif self._is_fvp(zephyr_board, options.get("use_fvp")):
603610
shutil.copytree(API_SERVER_DIR / "fvp-hack", project_dir / "fvp-hack")
604611

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

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

656663
self._create_prj_conf(project_dir, options)
@@ -665,7 +672,7 @@ def generate_project(self, model_library_format_path, standalone_crt_dir, projec
665672
# Populate src/
666673
src_dir = project_dir / "src"
667674
if options["project_type"] != "host_driven" or self._is_fvp(
668-
options["zephyr_board"], options.get("use_fvp")
675+
zephyr_board, options.get("use_fvp")
669676
):
670677
shutil.copytree(API_SERVER_DIR / "src" / options["project_type"], src_dir)
671678
else:

cmake/modules/Zephyr.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ if(USE_MICRO)
2929
"apps/microtvm/zephyr/template_project/src/host_driven *.h -> zephyr/src/host_driven"
3030
"apps/microtvm/zephyr/template_project/fvp-hack * -> zephyr/fvp-hack"
3131
"apps/microtvm/zephyr/template_project/qemu-hack * -> zephyr/qemu-hack"
32+
"apps/microtvm/zephyr/template_project/app-overlay * -> zephyr/app-overlay"
3233
"apps/microtvm/zephyr/template_project/crt_config *.h -> zephyr/crt_config"
3334
)
3435

tests/lint/check_file_type.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
"apps/microtvm/zephyr/template_project/qemu-hack/qemu-system-riscv32",
149149
"apps/microtvm/zephyr/template_project/qemu-hack/qemu-system-riscv64",
150150
"apps/microtvm/zephyr/template_project/fvp-hack/FVP_Corstone_SSE-300_Ethos-U55",
151+
"apps/microtvm/zephyr/template_project/app-overlay/nucleo_l4r5zi.overlay",
151152
# microTVM Virtual Machines
152153
"apps/microtvm/poetry.lock",
153154
"apps/microtvm/reference-vm/Vagrantfile",

0 commit comments

Comments
 (0)