guberti commented on a change in pull request #8708:
URL: https://github.com/apache/tvm/pull/8708#discussion_r687097969



##########
File path: apps/microtvm/arduino/template_project/microtvm_api_server.py
##########
@@ -0,0 +1,423 @@
+import collections
+import functools
+import json
+import logging
+import os
+import os.path
+import pathlib
+import re
+import shlex
+import shutil
+import subprocess
+import sys
+import tarfile
+from string import Template
+import tempfile
+import time
+
+import serial
+import serial.tools.list_ports
+
+from tvm.micro.project_api import 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"
+MODEL_LIBRARY_FORMAT_PATH = API_SERVER_DIR / MODEL_LIBRARY_FORMAT_RELPATH
+
+IS_TEMPLATE = not (API_SERVER_DIR / MODEL_LIBRARY_FORMAT_RELPATH).exists()
+
+
+class InvalidPortException(Exception):
+    """Raised when the given port could not be opened"""
+
+
+class SketchUploadException(Exception):
+    """Raised when a sketch cannot be uploaded for an unknown reason."""
+
+
+class BoardAutodetectFailed(Exception):
+    """Raised when no attached hardware is found matching the requested 
board"""
+
+
+BOARD_PROPERTIES = {
+    "due": {"package": "arduino", "architecture": "sam", "board": 
"arduino_due_x"},
+    # Due to the way the Feather S2 bootloader works, compilation
+    # behaves fine but uploads cannot be done automatically
+    "feathers2": {
+        "package": "esp32",
+        "architecture": "esp32",
+        "board": "feathers2",
+    },
+    # Spresense only works as of its v2.3.0 sdk
+    "spresense": {
+        "package": "SPRESENSE",
+        "architecture": "spresense",
+        "board": "spresense",
+    },
+    "nano33ble": {
+        "package": "arduino",
+        "architecture": "mbed_nano",
+        "board": "nano33ble",
+    },
+    "pybadge": {
+        "package": "adafruit",
+        "architecture": "samd",
+        "board": "adafruit_pybadge_m4",
+    },
+    # The Teensy boards are listed here for completeness, but they
+    # won't work until https://github.com/arduino/arduino-cli/issues/700
+    # is finished
+    "teensy40": {
+        "package": "teensy",
+        "architecture": "avr",
+        "board": "teensy40",
+    },
+    "teensy41": {
+        "package": "teensy",
+        "architecture": "avr",
+        "board": "teensy41",
+    },
+}
+
+PROJECT_TYPES = ["example_project", "host_driven"]
+
+PROJECT_OPTIONS = [
+    server.ProjectOption(
+        "arduino_board",
+        choices=list(BOARD_PROPERTIES),
+        help="Name of the Arduino board to build for",
+    ),
+    server.ProjectOption("arduino_cli_cmd", help="Path to the arduino-cli 
tool."),
+    server.ProjectOption("port", help="Port to use for connecting to 
hardware"),
+    server.ProjectOption(
+        "example_project",

Review comment:
       Yep, you're right. Fixed!




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to