Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[microTVM] Update Zephyr 2.5 #7786

Merged
merged 22 commits into from
Apr 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
cleanup
  • Loading branch information
mehrdadh committed Apr 1, 2021
commit 92360f6f7a352bf78246dad1f5b3c22a4664917a
7 changes: 4 additions & 3 deletions apps/microtvm/reference-vm/base-box-tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,12 @@ def build_command(args):
os.path.join(THIS_DIR, args.platform, "base-box", "packer.json"),
args.provider or ALL_PROVIDERS,
)
env = copy.copy(os.environ)
env = None
packer_args = ["packer", "build"]
env["PACKER_LOG"] = "1"
env["PACKER_LOG_PATH"] = "packer.log"
if args.debug_packer:
env = copy.copy(os.environ)
env["PACKER_LOG"] = "1"
env["PACKER_LOG_PATH"] = "packer.log"
packer_args += ["-debug"]

packer_args += ["packer.json"]
Expand Down
1 change: 0 additions & 1 deletion apps/microtvm/reference-vm/zephyr/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ echo "on your network connection and the state of PyPI) as dependencies are"
echo "downloaded and cached for future use."
echo "------------------------------[ TVM Message ]------------------------------"
poetry lock -vvv
poetry install -E importer-onnx # onnx needed for tests/micro/zephyr/test_zephyr.py
poetry run pip3 install -r ~/zephyr/zephyr/scripts/requirements.txt

echo "export TVM_LIBRARY_PATH=\"$TVM_HOME\"/build-microtvm" >>~/.profile
Expand Down
3 changes: 1 addition & 2 deletions apps/microtvm/zephyr/demo_runtime/boards/nucleo_f746zg.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ CONFIG_ENTROPY_GENERATOR=y
# For debugging.
CONFIG_LED=y

# for fused_nn_contrib_conv2d_NCHWc_add_nn_relu_1, which stack-allocates a
# large float array.
# For operations that stack-allocates a large float array.
CONFIG_MAIN_STACK_SIZE=1536
2 changes: 0 additions & 2 deletions apps/microtvm/zephyr/demo_runtime/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,3 @@ CONFIG_FPU=y

# For TVMPlatformAbort().
CONFIG_REBOOT=y

CONFIG_DEBUG=y
4 changes: 0 additions & 4 deletions apps/microtvm/zephyr/demo_runtime/qemu-hack/qemu-system-i386
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,4 @@ while [ "$#" -gt 0 ]; do
shift
done

if [ "${TVM_QEMU_DEBUG}" != "" ]; then
ARGS=( "${ARGS[@]}" -s -S )
fi

"${ARGS[@]}"
38 changes: 2 additions & 36 deletions python/tvm/micro/contrib/zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
"""Defines a compiler integration that uses an externally-supplied Zephyr project."""

import collections
import copy
import logging
import multiprocessing
import os
import pathlib
import re
import tempfile
import textwrap
Expand Down Expand Up @@ -430,28 +428,12 @@ def _get_device_args(self, cmake_entries):
f"runner {flash_runner}"
)

def _zephyr_transport(self, micro_binary):
qemu_debugger = None
if self._debug_rpc_session:
qemu_debugger = debugger.RpcDebugger(
self._debug_rpc_session,
debugger.DebuggerFactory(
QemuGdbDebugger,
(
micro_binary.abspath(micro_binary.debug_files[0]),
),
{},
),
)

return ZephyrQemuTransport(micro_binary.base_dir, startup_timeout_sec=30.0, debugger=qemu_debugger)

def flash(self, micro_binary):
cmake_entries = read_cmake_cache(
micro_binary.abspath(micro_binary.labelled_files["cmake_cache"][0])
)
if "qemu" in cmake_entries["BOARD"]:
return self._zephyr_transport(micro_binary)
return ZephyrQemuTransport(micro_binary.base_dir, startup_timeout_sec=30.0)

build_dir = os.path.dirname(
micro_binary.abspath(micro_binary.labelled_files["cmake_cache"][0])
Expand Down Expand Up @@ -550,22 +532,6 @@ def transport(self, micro_binary):
)


class QemuGdbDebugger(debugger.GdbDebugger):

def __init__(self, elf_file):
super(QemuGdbDebugger, self).__init__()
self._elf_file = elf_file

def popen_kwargs(self):
# expect self._elf file to follow the form .../zephyr/zephyr.elf
cmake_cache_path = (
pathlib.Path(self._elf_file).parent.parent / "CMakeCache.txt")
cmake_cache = read_cmake_cache(cmake_cache_path)
return {
"args": [cmake_cache["CMAKE_GDB"], "-ex", "target remote localhost:1234", "-ex", f"file {self._elf_file}"],
}


class QemuStartupFailureError(Exception):
"""Raised when the qemu pipe is not present within startup_timeout_sec."""

Expand Down Expand Up @@ -605,7 +571,7 @@ def write(self, data, timeout_sec):
class ZephyrQemuTransport(Transport):
"""The user-facing Zephyr QEMU transport class."""

def __init__(self, base_dir, startup_timeout_sec=5.0, debugger=None, **kwargs):
def __init__(self, base_dir, startup_timeout_sec=5.0, **kwargs):
self.base_dir = base_dir
self.startup_timeout_sec = startup_timeout_sec
self.kwargs = kwargs
Expand Down
2 changes: 1 addition & 1 deletion tests/micro/zephyr/test_zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _make_session(model, target, zephyr_board, west_cmd, mod):
test_name = f"{os.path.splitext(os.path.abspath(__file__))[0]}-{model}"
prev_build = f"{test_name}-last-build.micro-binary"
workspace_root = (
f'{test_name}-workspace/{datetime.datetime.now().strftime("%Y-%m-%dT%H-%M-%S")}'
f'{test_name}_workspace/{datetime.datetime.now().strftime("%Y-%m-%dT%H-%M-%S")}'
)
workspace_parent = os.path.dirname(workspace_root)
if not os.path.exists(workspace_parent):
Expand Down