From e8eacd72b8d55c5798a2b14c943d31eabe9a53b6 Mon Sep 17 00:00:00 2001 From: Mehrdad Hessar Date: Wed, 13 Oct 2021 10:40:30 -0700 Subject: [PATCH 01/12] add platform version to project template --- .../template_project/microtvm_api_server.py | 16 +++++++++++++ .../template_project/microtvm_api_server.py | 23 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/apps/microtvm/arduino/template_project/microtvm_api_server.py b/apps/microtvm/arduino/template_project/microtvm_api_server.py index 3d25d0bcad8f..1e6537b67a43 100644 --- a/apps/microtvm/arduino/template_project/microtvm_api_server.py +++ b/apps/microtvm/arduino/template_project/microtvm_api_server.py @@ -43,6 +43,7 @@ IS_TEMPLATE = not (API_SERVER_DIR / MODEL_LIBRARY_FORMAT_RELPATH).exists() +ARDUINO_CLI_VERSION = "0.18.3" class BoardAutodetectFailed(Exception): """Raised when no attached hardware is found matching the requested board""" @@ -335,7 +336,22 @@ def _find_modified_include_path(self, project_dir, file_path, include_path): # It's probably a standard C/C++ header return include_path + def _get_platform_version(self, arduino_cli_path: str) -> str: + version_output = subprocess.check_output([arduino_cli_path, 'version'], encoding="utf-8") + version_output = version_output.replace("\n", "") + version_output = version_output.replace(":", "") + version_output = version_output.lower() + version_output = version_output.split(" ") + version_index = version_output.index("version") + 1 + + return version_output[version_index] + def generate_project(self, model_library_format_path, standalone_crt_dir, project_dir, options): + # Check Arduino version + version = self._get_platform_version(options["arduino_cli_cmd"]) + if version != ARDUINO_CLI_VERSION: + raise ValueError(f"Arduino CLI version does not math: {version} != {ARDUINO_CLI_VERSION}") + # Reference key directories with pathlib project_dir = pathlib.Path(project_dir) project_dir.mkdir() diff --git a/apps/microtvm/zephyr/template_project/microtvm_api_server.py b/apps/microtvm/zephyr/template_project/microtvm_api_server.py index f700b5774c72..8a0d4d4820d1 100644 --- a/apps/microtvm/zephyr/template_project/microtvm_api_server.py +++ b/apps/microtvm/zephyr/template_project/microtvm_api_server.py @@ -61,6 +61,10 @@ BOARDS = API_SERVER_DIR / "boards.json" + +ZEPHYR_VERSION = "2.5" + + # Data structure to hold the information microtvm_api_server.py needs # to communicate with each of these boards. try: @@ -342,7 +346,26 @@ def _create_prj_conf(self, project_dir, options): "aot_demo": "memory microtvm_rpc_common common", } + def _get_platform_version(self) -> str: + with open(pathlib.Path(os.getenv('ZEPHYR_BASE')) / "VERSION", "r") as f: + lines = f.readlines() + for line in lines: + line = line.replace(" ", "") + line = line.replace("\n", "") + line = line.replace("\r", "") + if "VERSION_MAJOR" in line: + version_major = line.split("=")[1] + if "VERSION_MINOR" in line: + version_minor = line.split("=")[1] + + return f"{version_major}.{version_minor}" + def generate_project(self, model_library_format_path, standalone_crt_dir, project_dir, options): + # Check Zephyr version + version = self._get_platform_version() + if version != ZEPHYR_VERSION: + raise ValueError(f"Zephyr version does not math: {version} != {ZEPHYR_VERSION}") + project_dir = pathlib.Path(project_dir) # Make project directory. project_dir.mkdir() From a0f771bca5f94c4fea59f562495a1336829e7172 Mon Sep 17 00:00:00 2001 From: Mehrdad Hessar Date: Wed, 13 Oct 2021 10:43:43 -0700 Subject: [PATCH 02/12] fix arduino cli version on qemu --- docker/install/ubuntu_install_arduino.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/install/ubuntu_install_arduino.sh b/docker/install/ubuntu_install_arduino.sh index c374850aa1df..6639ac59b506 100644 --- a/docker/install/ubuntu_install_arduino.sh +++ b/docker/install/ubuntu_install_arduino.sh @@ -23,8 +23,8 @@ set -o pipefail export DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates -# Install arduino-cli latest version -wget -O - https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh -s +# Install arduino-cli +wget -O - https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh -s 0.18.3 # Install the cores we want to test on arduino-cli core install arduino:mbed_nano From bd980a88f91ec2de508518cfea9c7b9eaf33fad0 Mon Sep 17 00:00:00 2001 From: Mehrdad Hessar Date: Wed, 13 Oct 2021 10:47:52 -0700 Subject: [PATCH 03/12] specify arduino/zephyr version everywhere --- .../reference-vm/arduino/base-box/base_box_provision.sh | 3 ++- .../reference-vm/zephyr/base-box/base_box_provision.sh | 3 ++- docker/install/ubuntu_install_arduino.sh | 3 ++- docker/install/ubuntu_install_zephyr.sh | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/microtvm/reference-vm/arduino/base-box/base_box_provision.sh b/apps/microtvm/reference-vm/arduino/base-box/base_box_provision.sh index 11d89f2cd44e..d57203b9838f 100644 --- a/apps/microtvm/reference-vm/arduino/base-box/base_box_provision.sh +++ b/apps/microtvm/reference-vm/arduino/base-box/base_box_provision.sh @@ -31,8 +31,9 @@ cd ~ sudo apt-get install -y ca-certificates # Install Arduino-CLI (specific version) +ARDUINO_CLI_VERSION="0.18.3" export PATH="/home/vagrant/bin:$PATH" -wget -O - https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh -s 0.18.3 +wget -O - https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh -s ${ARDUINO_CLI_VERSION} # Arduino (the CLI and GUI) require the dialout permission for uploading sudo usermod -a -G dialout $USER diff --git a/apps/microtvm/reference-vm/zephyr/base-box/base_box_provision.sh b/apps/microtvm/reference-vm/zephyr/base-box/base_box_provision.sh index 0631e89f3bb3..0e83d1b8be97 100644 --- a/apps/microtvm/reference-vm/zephyr/base-box/base_box_provision.sh +++ b/apps/microtvm/reference-vm/zephyr/base-box/base_box_provision.sh @@ -28,7 +28,8 @@ source ~/.profile # Init Zephyr cd ~ # Using most recent commit that passes all the tests. -~/ubuntu_init_zephyr_project.sh ~/zephyr v2.5-branch --commit dabf23758417fd041fec2a2a821d8f526afac29d +ZEPHYR_VERSION="v2.5-branch" +~/ubuntu_init_zephyr_project.sh ~/zephyr ${ZEPHYR_VERSION} --commit dabf23758417fd041fec2a2a821d8f526afac29d # Cleanup rm -f *.sh diff --git a/docker/install/ubuntu_install_arduino.sh b/docker/install/ubuntu_install_arduino.sh index 6639ac59b506..a612261b2a2b 100644 --- a/docker/install/ubuntu_install_arduino.sh +++ b/docker/install/ubuntu_install_arduino.sh @@ -23,8 +23,9 @@ set -o pipefail export DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates +ARDUINO_CLI_VERSION="0.18.3" # Install arduino-cli -wget -O - https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh -s 0.18.3 +wget -O - https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh -s ${ARDUINO_CLI_VERSION} # Install the cores we want to test on arduino-cli core install arduino:mbed_nano diff --git a/docker/install/ubuntu_install_zephyr.sh b/docker/install/ubuntu_install_zephyr.sh index 7e5aae96a38f..1d438f3a592f 100644 --- a/docker/install/ubuntu_install_zephyr.sh +++ b/docker/install/ubuntu_install_zephyr.sh @@ -44,9 +44,10 @@ sudo apt-get install -y cmake pip3 install west # Init ZephyrProject +ZEPHYR_VERSION="v2.5-branch" ZEPHYR_PROJECT_PATH=/opt/zephyrproject ZEPHYR_INIT_SCRIPT=$(find -name "ubuntu_init_zephyr_project.sh") -bash ${ZEPHYR_INIT_SCRIPT} ${ZEPHYR_PROJECT_PATH} v2.5-branch +bash ${ZEPHYR_INIT_SCRIPT} ${ZEPHYR_PROJECT_PATH} ${ZEPHYR_VERSION} cd ${ZEPHYR_PROJECT_PATH} # As part of the build process, Zephyr needs to touch some symlinks in zephyr/misc/generated/syscalls_links (this path is relative to the From 007165a0ca668168d7afde1df704c114169ea7a8 Mon Sep 17 00:00:00 2001 From: Mehrdad Hessar Date: Wed, 13 Oct 2021 10:51:58 -0700 Subject: [PATCH 04/12] cleanup --- .../template_project/microtvm_api_server.py | 14 ++++++++------ .../zephyr/template_project/microtvm_api_server.py | 6 ++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/microtvm/arduino/template_project/microtvm_api_server.py b/apps/microtvm/arduino/template_project/microtvm_api_server.py index 1e6537b67a43..4f9341ce2a1d 100644 --- a/apps/microtvm/arduino/template_project/microtvm_api_server.py +++ b/apps/microtvm/arduino/template_project/microtvm_api_server.py @@ -45,6 +45,7 @@ ARDUINO_CLI_VERSION = "0.18.3" + class BoardAutodetectFailed(Exception): """Raised when no attached hardware is found matching the requested board""" @@ -337,11 +338,10 @@ def _find_modified_include_path(self, project_dir, file_path, include_path): return include_path def _get_platform_version(self, arduino_cli_path: str) -> str: - version_output = subprocess.check_output([arduino_cli_path, 'version'], encoding="utf-8") - version_output = version_output.replace("\n", "") - version_output = version_output.replace(":", "") - version_output = version_output.lower() - version_output = version_output.split(" ") + version_output = subprocess.check_output([arduino_cli_path, "version"], encoding="utf-8") + version_output = ( + version_output.replace("\n", "").replace("\r", "").replace(":", "").lower().split(" ") + ) version_index = version_output.index("version") + 1 return version_output[version_index] @@ -350,7 +350,9 @@ def generate_project(self, model_library_format_path, standalone_crt_dir, projec # Check Arduino version version = self._get_platform_version(options["arduino_cli_cmd"]) if version != ARDUINO_CLI_VERSION: - raise ValueError(f"Arduino CLI version does not math: {version} != {ARDUINO_CLI_VERSION}") + raise ValueError( + f"Arduino CLI version does not math: {version} != {ARDUINO_CLI_VERSION}" + ) # Reference key directories with pathlib project_dir = pathlib.Path(project_dir) diff --git a/apps/microtvm/zephyr/template_project/microtvm_api_server.py b/apps/microtvm/zephyr/template_project/microtvm_api_server.py index 8a0d4d4820d1..790293b40323 100644 --- a/apps/microtvm/zephyr/template_project/microtvm_api_server.py +++ b/apps/microtvm/zephyr/template_project/microtvm_api_server.py @@ -347,12 +347,10 @@ def _create_prj_conf(self, project_dir, options): } def _get_platform_version(self) -> str: - with open(pathlib.Path(os.getenv('ZEPHYR_BASE')) / "VERSION", "r") as f: + with open(pathlib.Path(os.getenv("ZEPHYR_BASE")) / "VERSION", "r") as f: lines = f.readlines() for line in lines: - line = line.replace(" ", "") - line = line.replace("\n", "") - line = line.replace("\r", "") + line = line.replace(" ", "").replace("\n", "").replace("\r", "") if "VERSION_MAJOR" in line: version_major = line.split("=")[1] if "VERSION_MINOR" in line: From 1b0077ccccf79ea7cd15de6ae62185dbedd11d00 Mon Sep 17 00:00:00 2001 From: Mehrdad Hessar Date: Fri, 15 Oct 2021 12:05:28 -0700 Subject: [PATCH 05/12] address comments --- .../template_project/microtvm_api_server.py | 23 +++++++++++++------ .../template_project/microtvm_api_server.py | 18 +++++++++++---- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/apps/microtvm/arduino/template_project/microtvm_api_server.py b/apps/microtvm/arduino/template_project/microtvm_api_server.py index 4f9341ce2a1d..d2418f8685bd 100644 --- a/apps/microtvm/arduino/template_project/microtvm_api_server.py +++ b/apps/microtvm/arduino/template_project/microtvm_api_server.py @@ -36,6 +36,8 @@ import serial.tools.list_ports from tvm.micro.project_api import server +_LOG = logging.getLogger("MicroTVM API Server") + MODEL_LIBRARY_FORMAT_RELPATH = pathlib.Path("src") / "model" / "model.tar" API_SERVER_DIR = pathlib.Path(os.path.dirname(__file__) or os.path.getcwd()) BUILD_DIR = API_SERVER_DIR / "build" @@ -43,7 +45,7 @@ IS_TEMPLATE = not (API_SERVER_DIR / MODEL_LIBRARY_FORMAT_RELPATH).exists() -ARDUINO_CLI_VERSION = "0.18.3" +ARDUINO_CLI_VERSION = 0.18 class BoardAutodetectFailed(Exception): @@ -140,6 +142,11 @@ class BoardAutodetectFailed(Exception): server.ProjectOption( "verbose", help="True to pass --verbose flag to arduino-cli compile and upload" ), + server.ProjectOption( + "warning_as_error", + choices=(True, False), + help="Tread warnings as errors.", + ), ] @@ -337,22 +344,24 @@ def _find_modified_include_path(self, project_dir, file_path, include_path): # It's probably a standard C/C++ header return include_path - def _get_platform_version(self, arduino_cli_path: str) -> str: + def _get_platform_version(self, arduino_cli_path: str) -> float: version_output = subprocess.check_output([arduino_cli_path, "version"], encoding="utf-8") version_output = ( version_output.replace("\n", "").replace("\r", "").replace(":", "").lower().split(" ") ) - version_index = version_output.index("version") + 1 + full_version = version_output[version_output.index("version") + 1].split(".") + version = float(f"{full_version[0]}.{full_version[1]}") - return version_output[version_index] + return version def generate_project(self, model_library_format_path, standalone_crt_dir, project_dir, options): # Check Arduino version version = self._get_platform_version(options["arduino_cli_cmd"]) if version != ARDUINO_CLI_VERSION: - raise ValueError( - f"Arduino CLI version does not math: {version} != {ARDUINO_CLI_VERSION}" - ) + message = f"Arduino CLI version does not match: {version} != {ARDUINO_CLI_VERSION}" + if options.get("warning_as_error") is not None and options["warning_as_error"]: + raise ValueError(message) + _LOG.warning(message) # Reference key directories with pathlib project_dir = pathlib.Path(project_dir) diff --git a/apps/microtvm/zephyr/template_project/microtvm_api_server.py b/apps/microtvm/zephyr/template_project/microtvm_api_server.py index 790293b40323..88fde43a21c8 100644 --- a/apps/microtvm/zephyr/template_project/microtvm_api_server.py +++ b/apps/microtvm/zephyr/template_project/microtvm_api_server.py @@ -44,7 +44,7 @@ from tvm.micro.project_api import server -_LOG = logging.getLogger(__name__) +_LOG = logging.getLogger("MicroTVM API Server") API_SERVER_DIR = pathlib.Path(os.path.dirname(__file__) or os.path.getcwd()) @@ -62,7 +62,7 @@ BOARDS = API_SERVER_DIR / "boards.json" -ZEPHYR_VERSION = "2.5" +ZEPHYR_VERSION = 2.5 # Data structure to hold the information microtvm_api_server.py needs @@ -269,6 +269,11 @@ def _get_nrf_device_args(options): "config_main_stack_size", help="Sets CONFIG_MAIN_STACK_SIZE for Zephyr board.", ), + server.ProjectOption( + "warning_as_error", + choices=(True, False), + help="Tread warnings as errors.", + ), ] @@ -346,7 +351,7 @@ def _create_prj_conf(self, project_dir, options): "aot_demo": "memory microtvm_rpc_common common", } - def _get_platform_version(self) -> str: + def _get_platform_version(self) -> float: with open(pathlib.Path(os.getenv("ZEPHYR_BASE")) / "VERSION", "r") as f: lines = f.readlines() for line in lines: @@ -356,13 +361,16 @@ def _get_platform_version(self) -> str: if "VERSION_MINOR" in line: version_minor = line.split("=")[1] - return f"{version_major}.{version_minor}" + return float(f"{version_major}.{version_minor}") def generate_project(self, model_library_format_path, standalone_crt_dir, project_dir, options): # Check Zephyr version version = self._get_platform_version() if version != ZEPHYR_VERSION: - raise ValueError(f"Zephyr version does not math: {version} != {ZEPHYR_VERSION}") + message = f"Zephyr version does not math: {version} != {ZEPHYR_VERSION}" + if options.get("warning_as_error") is not None and options["warning_as_error"]: + raise ValueError(message) + _LOG.warning(message) project_dir = pathlib.Path(project_dir) # Make project directory. From 489c6995357fb9646371273f13c3372d5ead55f7 Mon Sep 17 00:00:00 2001 From: Mehrdad Hessar Date: Fri, 15 Oct 2021 15:39:08 -0700 Subject: [PATCH 06/12] fix warning message --- apps/microtvm/arduino/template_project/microtvm_api_server.py | 2 +- apps/microtvm/zephyr/template_project/microtvm_api_server.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/microtvm/arduino/template_project/microtvm_api_server.py b/apps/microtvm/arduino/template_project/microtvm_api_server.py index d2418f8685bd..18ad4fdf1eca 100644 --- a/apps/microtvm/arduino/template_project/microtvm_api_server.py +++ b/apps/microtvm/arduino/template_project/microtvm_api_server.py @@ -358,7 +358,7 @@ def generate_project(self, model_library_format_path, standalone_crt_dir, projec # Check Arduino version version = self._get_platform_version(options["arduino_cli_cmd"]) if version != ARDUINO_CLI_VERSION: - message = f"Arduino CLI version does not match: {version} != {ARDUINO_CLI_VERSION}" + message = f"Arduino CLI version found is not supported: found {version}, expected {ARDUINO_CLI_VERSION}." if options.get("warning_as_error") is not None and options["warning_as_error"]: raise ValueError(message) _LOG.warning(message) diff --git a/apps/microtvm/zephyr/template_project/microtvm_api_server.py b/apps/microtvm/zephyr/template_project/microtvm_api_server.py index 88fde43a21c8..f5b11ceb1b10 100644 --- a/apps/microtvm/zephyr/template_project/microtvm_api_server.py +++ b/apps/microtvm/zephyr/template_project/microtvm_api_server.py @@ -367,7 +367,7 @@ def generate_project(self, model_library_format_path, standalone_crt_dir, projec # Check Zephyr version version = self._get_platform_version() if version != ZEPHYR_VERSION: - message = f"Zephyr version does not math: {version} != {ZEPHYR_VERSION}" + message = f"Zephyr version found is not supported: found {version}, expected {ZEPHYR_VERSION}." if options.get("warning_as_error") is not None and options["warning_as_error"]: raise ValueError(message) _LOG.warning(message) From 75ab41d9664442fab8f76a42350c1f5fed96fd3b Mon Sep 17 00:00:00 2001 From: Mehrdad Hessar Date: Mon, 18 Oct 2021 08:52:16 -0700 Subject: [PATCH 07/12] fix typo --- apps/microtvm/arduino/template_project/microtvm_api_server.py | 2 +- apps/microtvm/zephyr/template_project/microtvm_api_server.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/microtvm/arduino/template_project/microtvm_api_server.py b/apps/microtvm/arduino/template_project/microtvm_api_server.py index 18ad4fdf1eca..79c209f8be18 100644 --- a/apps/microtvm/arduino/template_project/microtvm_api_server.py +++ b/apps/microtvm/arduino/template_project/microtvm_api_server.py @@ -145,7 +145,7 @@ class BoardAutodetectFailed(Exception): server.ProjectOption( "warning_as_error", choices=(True, False), - help="Tread warnings as errors.", + help="Treat warnings as errors.", ), ] diff --git a/apps/microtvm/zephyr/template_project/microtvm_api_server.py b/apps/microtvm/zephyr/template_project/microtvm_api_server.py index f5b11ceb1b10..6cf099a1b542 100644 --- a/apps/microtvm/zephyr/template_project/microtvm_api_server.py +++ b/apps/microtvm/zephyr/template_project/microtvm_api_server.py @@ -272,7 +272,7 @@ def _get_nrf_device_args(options): server.ProjectOption( "warning_as_error", choices=(True, False), - help="Tread warnings as errors.", + help="Treat warnings as errors.", ), ] From 39e9b76b539ad35f54fa646c401237650f2dbf65 Mon Sep 17 00:00:00 2001 From: Mehrdad Hessar Date: Mon, 18 Oct 2021 14:37:09 -0700 Subject: [PATCH 08/12] trigger From f3c7be6c934599889576664c23260b65d4819e46 Mon Sep 17 00:00:00 2001 From: Mehrdad Hessar Date: Tue, 19 Oct 2021 10:46:21 -0700 Subject: [PATCH 09/12] trigger From bd97931df9e06d1510c1ac2cd8bcf7b5bbd6aa57 Mon Sep 17 00:00:00 2001 From: Mehrdad Hessar Date: Thu, 21 Oct 2021 10:31:03 -0700 Subject: [PATCH 10/12] address comments --- .../arduino/template_project/microtvm_api_server.py | 8 +++++--- .../reference-vm/arduino/base-box/base_box_provision.sh | 3 +++ .../zephyr/template_project/microtvm_api_server.py | 9 +++++---- docker/install/ubuntu_install_zephyr.sh | 3 +++ 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/apps/microtvm/arduino/template_project/microtvm_api_server.py b/apps/microtvm/arduino/template_project/microtvm_api_server.py index 79c209f8be18..7b65268b34d6 100644 --- a/apps/microtvm/arduino/template_project/microtvm_api_server.py +++ b/apps/microtvm/arduino/template_project/microtvm_api_server.py @@ -36,7 +36,7 @@ import serial.tools.list_ports from tvm.micro.project_api import server -_LOG = logging.getLogger("MicroTVM API Server") +_LOG = logging.getLogger(__name__) MODEL_LIBRARY_FORMAT_RELPATH = pathlib.Path("src") / "model" / "model.tar" API_SERVER_DIR = pathlib.Path(os.path.dirname(__file__) or os.path.getcwd()) @@ -45,6 +45,8 @@ IS_TEMPLATE = not (API_SERVER_DIR / MODEL_LIBRARY_FORMAT_RELPATH).exists() +# Used to check Arduino CLI version installed on the host. +# We only check two levels of the version. ARDUINO_CLI_VERSION = 0.18 @@ -145,7 +147,7 @@ class BoardAutodetectFailed(Exception): server.ProjectOption( "warning_as_error", choices=(True, False), - help="Treat warnings as errors.", + help="Treat warnings as errors and raise an Exception.", ), ] @@ -360,7 +362,7 @@ def generate_project(self, model_library_format_path, standalone_crt_dir, projec if version != ARDUINO_CLI_VERSION: message = f"Arduino CLI version found is not supported: found {version}, expected {ARDUINO_CLI_VERSION}." if options.get("warning_as_error") is not None and options["warning_as_error"]: - raise ValueError(message) + raise server.ServerError(message=message) _LOG.warning(message) # Reference key directories with pathlib diff --git a/apps/microtvm/reference-vm/arduino/base-box/base_box_provision.sh b/apps/microtvm/reference-vm/arduino/base-box/base_box_provision.sh index d57203b9838f..2724069ba722 100644 --- a/apps/microtvm/reference-vm/arduino/base-box/base_box_provision.sh +++ b/apps/microtvm/reference-vm/arduino/base-box/base_box_provision.sh @@ -31,7 +31,10 @@ cd ~ sudo apt-get install -y ca-certificates # Install Arduino-CLI (specific version) +# To keep in sync with the version +# defined in apps/microtvm/arduino/template_project/microtvm_api_server.py ARDUINO_CLI_VERSION="0.18.3" + export PATH="/home/vagrant/bin:$PATH" wget -O - https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh -s ${ARDUINO_CLI_VERSION} diff --git a/apps/microtvm/zephyr/template_project/microtvm_api_server.py b/apps/microtvm/zephyr/template_project/microtvm_api_server.py index 6cf099a1b542..36a5ff12193f 100644 --- a/apps/microtvm/zephyr/template_project/microtvm_api_server.py +++ b/apps/microtvm/zephyr/template_project/microtvm_api_server.py @@ -44,7 +44,7 @@ from tvm.micro.project_api import server -_LOG = logging.getLogger("MicroTVM API Server") +_LOG = logging.getLogger(__name__) API_SERVER_DIR = pathlib.Path(os.path.dirname(__file__) or os.path.getcwd()) @@ -61,7 +61,8 @@ BOARDS = API_SERVER_DIR / "boards.json" - +# Used to check Zephyr version installed on the host. +# We only check two levels of the version. ZEPHYR_VERSION = 2.5 @@ -272,7 +273,7 @@ def _get_nrf_device_args(options): server.ProjectOption( "warning_as_error", choices=(True, False), - help="Treat warnings as errors.", + help="Treat warnings as errors and raise an Exception.", ), ] @@ -369,7 +370,7 @@ def generate_project(self, model_library_format_path, standalone_crt_dir, projec if version != ZEPHYR_VERSION: message = f"Zephyr version found is not supported: found {version}, expected {ZEPHYR_VERSION}." if options.get("warning_as_error") is not None and options["warning_as_error"]: - raise ValueError(message) + raise server.ServerError(message=message) _LOG.warning(message) project_dir = pathlib.Path(project_dir) diff --git a/docker/install/ubuntu_install_zephyr.sh b/docker/install/ubuntu_install_zephyr.sh index 1d438f3a592f..ddd1ea1c1734 100644 --- a/docker/install/ubuntu_install_zephyr.sh +++ b/docker/install/ubuntu_install_zephyr.sh @@ -44,6 +44,9 @@ sudo apt-get install -y cmake pip3 install west # Init ZephyrProject +# To keep in sync with the version +# defined in apps/microtvm/zephyr/template_project/microtvm_api_server.py +# We use `-branch` tag since it tracks the same version with extra patches for bugs. ZEPHYR_VERSION="v2.5-branch" ZEPHYR_PROJECT_PATH=/opt/zephyrproject ZEPHYR_INIT_SCRIPT=$(find -name "ubuntu_init_zephyr_project.sh") From 13df1cfc207aec9ea78df49204cfa5cfc8b85ba8 Mon Sep 17 00:00:00 2001 From: Mehrdad Hessar Date: Thu, 21 Oct 2021 16:11:55 -0700 Subject: [PATCH 11/12] trigger From 643fc054e57f02a4d7d98d38898885d4c0c3de3d Mon Sep 17 00:00:00 2001 From: Mehrdad Hessar Date: Fri, 22 Oct 2021 10:16:54 -0700 Subject: [PATCH 12/12] trigger