Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)>;
};
Comment on lines +21 to +23
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not correct.
You should update the PLL configuration accordingly:

&pll {
	div-m = <2>;
	mul-n = <30>;
	div-p = <7>;
	div-q = <2>;
	div-r = <2>;
	clocks = <&clk_hsi>;
	status = "okay";
};

Note that the impacts of effects on bus configurations have to be tested.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erwango Thanks a lot. Do you mind to tell how exactly one finds the params (M, N, P, Q, and R) for the PLL? I see them in the clock tree in RM0432 rev. 9 (Arm Reference Manual), Figure 16, but could not find any formula about how to relate them to the 120 MHz freq.

Copy link

@erwango erwango Sep 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erwango Thanks a lot. Do you mind to tell how exactly one finds the params (M, N, P, Q, and R) for the PLL? I see them in the clock tree in RM0432 rev. 9 (Arm Reference Manual), Figure 16, but could not find any formula about how to relate them to the 120 MHz freq.

Core freq = Input freq (HSI: 16MHz) / M(2) * N(30) / R(2)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erwango Thanks for the explanation. I found also the formula in the Reference Manual, below the bit descriptions for the RCC_PLLCFGR, where also there are formulas using the Q and P params. Could you please review #12756 ?

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