I am trying out the example provided here: 1. microTVM CLI Tool — tvm 0.12.dev0 documentation and trying to run the example on the EFR32MG21A020F1024 board and I get the following error when I try to run the model on target:
Error: Could not open a session with the micro target.
My environment:
Jlink: 11.0.17
tvmc: 0.12.dev0
Homebrew clang version 16.0.0
Target: arm64-apple-darwin22.4.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin
Zephyr: v3.2-branch (last commit hash: 17238d2e0ed589471919e5bec57e38cbe3132a12)
VID:PID from lsusb: Bus 000 Device 003: ID 1366:0105 1366 J-Link Pro OB Serial: 000440120555
To begin with, I added my board to boards.json as follows:
"efr32_radio_brd4180a": {
"board": "efr32_radio_brd4180a",
"model": "EFR32MG21A020F1024",
"is_qemu": false,
"fpu": true,
"vid_hex": "1366",
"pid_hex": "0105"
}
And then, basically followed the commands provided
wget https://github.com/tensorflow/tflite-micro/raw/a56087ffa2703b4d5632f024a8a4c899815c31bb/tensorflow/lite/micro/examples/micro_speech/micro_speech.tflite
tvmc compile micro_speech.tflite --target="c -keys=cpu -model=efr32_radio_brd4180a" --runtime=crt --runtime-crt-system-lib 1 --executor="aot" --output model.tar --output-format mlf --pass-config tir.disable_vectorize=1
tvmc micro create project model.tar zephyr --project-option project_type=host_driven board=efr32_radio_brd4180a
tvmc micro build project zephyr
tvmc micro flash project zephyr
No explicit errors here
tvmc run --device micro project --fill-mode ones --print-top 3
This command resulted in Error: Could not open a session with the micro target.
.
Given that it doesn’t provide enough debug info, I raised it through the pythonic interface
python3 -c 'import logging; import tvm.driver.tvmc.main; logging.getLogger().setLevel(logging.DEBUG); tvm.driver.tvmc.main.main()' run --device micro project --print-top 3
Here is the output:
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "server_info_query", "params": {"tvm_version": "0.12.dev0"}, "id": 1}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 1, "result": {"platform_name": "zephyr", "is_template": false, "model_library_format_path": "/Users/workspace//project/model.tar", "project_options": [{"name": "verbose", "choices": null, "default": false, "type": "bool", "required": null, "optional": ["generate_project"], "help": "Run build with verbose output."}, {"name": "project_type", "choices": [], "default": null, "type": "str", "required": ["generate_project"], "optional": null, "help": "Type of project to generate."}, {"name": "board", "choices": ["b_u585i_iot02a", "mimxrt1050_evk", "mps2_an521", "mps3_an547", "nrf5340dk_nrf5340_cpuapp", "nucleo_f746zg", "nucleo_l4r5zi", "qemu_cortex_r5", "qemu_riscv32", "qemu_riscv64", "qemu_x86", "stm32f746g_disco", "efr32_radio_brd4180a", "efr32_radio_brd4187a"], "default": null, "type": "str", "required": ["generate_project"], "optional": null, "help": "Name of the board to build for."}, {"name": "cmsis_path", "choices": null, "default": null, "type": "str", "required": null, "optional": ["generate_project"], "help": "Path to the CMSIS directory."}, {"name": "warning_as_error", "choices": null, "default": false, "type": "bool", "required": null, "optional": ["generate_project"], "help": "Treat warnings as errors and raise an Exception."}, {"name": "compile_definitions", "choices": null, "default": null, "type": "str", "required": null, "optional": ["generate_project"], "help": "Extra definitions added project compile."}, {"name": "extra_files_tar", "choices": null, "default": null, "type": "str", "required": null, "optional": ["generate_project"], "help": "If given, during generate_project, uncompress the tarball at this path into the project dir."}, {"name": "gdbserver_port", "choices": null, "default": null, "type": "int", "required": null, "optional": ["open_transport"], "help": "If given, port number to use when running the local gdbserver."}, {"name": "serial_number", "choices": null, "default": null, "type": "str", "required": null, "optional": ["open_transport", "flash"], "help": "Board serial number."}, {"name": "west_cmd", "choices": null, "default": "/Users/user/.pyenv/versions/3.9.15/bin/python -m west", "type": "str", "required": null, "optional": ["generate_project", "build", "flash", "open_transport"], "help": "Path to the west tool. If given, supersedes both the zephyr_base option and ZEPHYR_BASE environment variable."}, {"name": "zephyr_base", "choices": null, "default": "/Users/user/toolchains/zephyrproject/zephyr", "type": "str", "required": null, "optional": ["generate_project", "open_transport"], "help": "Path to the zephyr base directory."}, {"name": "config_main_stack_size", "choices": null, "default": null, "type": "int", "required": null, "optional": ["generate_project"], "help": "Sets CONFIG_MAIN_STACK_SIZE for Zephyr board."}, {"name": "arm_fvp_path", "choices": null, "default": null, "type": "str", "required": null, "optional": ["generate_project", "open_transport"], "help": "Path to the FVP binary to invoke."}, {"name": "use_fvp", "choices": null, "default": false, "type": "bool", "required": null, "optional": ["generate_project"], "help": "Run on the FVP emulator instead of hardware."}, {"name": "workspace_size_bytes", "choices": null, "default": null, "type": "int", "required": null, "optional": ["generate_project"], "help": "Sets the value for TVM_WORKSPACE_SIZE_BYTES passed to K_HEAP_DEFINE() to service TVM memory allocation requests."}], "protocol_version": 1}}
DEBUG:tvm.micro.transport:micro-rpc: opening transport
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "open_transport", "params": {"options": {"verbose": false, "project_type": null, "board": null, "cmsis_path": null, "warning_as_error": false, "compile_definitions": null, "extra_files_tar": null, "gdbserver_port": null, "serial_number": null, "west_cmd": "/Users/user/.pyenv/versions/3.9.15/bin/python -m west", "zephyr_base": "/Users/user/toolchains/zephyrproject/zephyr", "config_main_stack_size": null, "arm_fvp_path": null, "use_fvp": false, "workspace_size_bytes": null}}, "id": 2}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 2, "result": {"timeouts": {"session_start_retry_timeout_sec": 2.0, "session_start_timeout_sec": 5.0, "session_established_timeout_sec": 5.0}}}
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "{r", "timeout_sec": 5.0}, "id": 3}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 3, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 1 B]: fe .
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "|NQ", "timeout_sec": 5.0}, "id": 4}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 4, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 2 B]: ff fd ..
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "0{{R3", "timeout_sec": 5.0}, "id": 5}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 5, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 4 B]: 03 00 00 00 ....
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "0006", "timeout_sec": 5.0}, "id": 6}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 6, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 3 B]: 00 00 02 ...
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "W_J", "timeout_sec": 5.0}, "id": 7}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 7, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 2 B]: 66 77 fw
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "|NQ", "timeout_sec": 5.0}, "id": 8}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 8, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 2 B]: ff fd ..
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "1ONa4", "timeout_sec": 5.0}, "id": 9}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 9, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 4 B]: 04 00 00 00 ....
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "1^@s", "timeout_sec": 5.0}, "id": 10}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 10, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 3 B]: 06 00 00 ...
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "0R", "timeout_sec": 5.0}, "id": 11}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 11, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 1 B]: 01 .
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "vi<", "timeout_sec": 5.0}, "id": 12}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 12, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 2 B]: b2 fe ..
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "read_transport", "params": {"n": 1, "timeout_sec": 1.998125}, "id": 13}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 13, "error": {"code": -32000, "message": "IoTimeoutError", "data": {"traceback": "Traceback (most recent call last):\n File \"/Users/workspace//project/server.py\", line 486, in serve_one_request # <--- Outermost server-side stack frame\n self._dispatch_request(request)\n File \"/Users/workspace//project/server.py\", line 598, in _dispatch_request\n return_value = dispatch_method(**params)\n File \"/Users/workspace//project/server.py\", line 647, in _dispatch_read_transport\n reply_data = self._handler.read_transport(n, timeout_sec)\n File \"/Users/workspace//project/microtvm_api_server.py\", line 855, in read_transport\n return self._transport.read(n, timeout_sec)\n File \"/Users/workspace//project/microtvm_api_server.py\", line 984, in read\n raise server.IoTimeoutError()\nserver.IoTimeoutError: JSON-RPC error # -32000: IoTimeoutError\n"}}}
DEBUG:tvm.micro.transport:micro-rpc: read { 2.00s} 1 B -> [IoTimeoutError 2.00s]
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "|NQ", "timeout_sec": 5.0}, "id": 14}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 14, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 2 B]: ff fd ..
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "0{{R3", "timeout_sec": 5.0}, "id": 15}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 15, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 4 B]: 03 00 00 00 ....
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "0006", "timeout_sec": 5.0}, "id": 16}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 16, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 3 B]: 00 00 02 ...
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "W_J", "timeout_sec": 5.0}, "id": 17}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 17, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 2 B]: 66 77 fw
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "|NQ", "timeout_sec": 5.0}, "id": 18}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 18, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 2 B]: ff fd ..
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "1ONa4", "timeout_sec": 5.0}, "id": 19}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 19, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 4 B]: 04 00 00 00 ....
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "ga7~", "timeout_sec": 5.0}, "id": 20}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 20, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 3 B]: 84 00 00 ...
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "0R", "timeout_sec": 5.0}, "id": 21}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 21, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 1 B]: 01 .
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": ";?4", "timeout_sec": 5.0}, "id": 22}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 22, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 2 B]: e2 ce ..
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "read_transport", "params": {"n": 1, "timeout_sec": 1.979362}, "id": 23}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 23, "error": {"code": -32000, "message": "IoTimeoutError", "data": {"traceback": "Traceback (most recent call last):\n File \"/Users/workspace//project/server.py\", line 486, in serve_one_request # <--- Outermost server-side stack frame\n self._dispatch_request(request)\n File \"/Users/workspace//project/server.py\", line 598, in _dispatch_request\n return_value = dispatch_method(**params)\n File \"/Users/workspace//project/server.py\", line 647, in _dispatch_read_transport\n reply_data = self._handler.read_transport(n, timeout_sec)\n File \"/Users/workspace//project/microtvm_api_server.py\", line 855, in read_transport\n return self._transport.read(n, timeout_sec)\n File \"/Users/workspace//project/microtvm_api_server.py\", line 984, in read\n raise server.IoTimeoutError()\nserver.IoTimeoutError: JSON-RPC error # -32000: IoTimeoutError\n"}}}
DEBUG:tvm.micro.transport:micro-rpc: read { 1.98s} 1 B -> [IoTimeoutError 1.98s]
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "|NQ", "timeout_sec": 5.0}, "id": 24}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 24, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 2 B]: ff fd ..
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "0{{R3", "timeout_sec": 5.0}, "id": 25}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 25, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 4 B]: 03 00 00 00 ....
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "0006", "timeout_sec": 5.0}, "id": 26}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 26, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 3 B]: 00 00 02 ...
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "W_J", "timeout_sec": 5.0}, "id": 27}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 27, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 2 B]: 66 77 fw
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "|NQ", "timeout_sec": 5.0}, "id": 28}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 28, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 2 B]: ff fd ..
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "1ONa4", "timeout_sec": 5.0}, "id": 29}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 29, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 4 B]: 04 00 00 00 ....
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "#sB~", "timeout_sec": 5.0}, "id": 30}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 30, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 3 B]: c6 00 00 ...
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "0R", "timeout_sec": 5.0}, "id": 31}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 31, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 1 B]: 01 .
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "write_transport", "params": {"data": "7EJ", "timeout_sec": 5.0}, "id": 32}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 32, "result": null}
DEBUG:tvm.micro.transport:micro-rpc: write { 5.00s} <- [ 2 B]: 16 4d .M
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "read_transport", "params": {"n": 1, "timeout_sec": 1.986024}, "id": 33}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 33, "error": {"code": -32000, "message": "IoTimeoutError", "data": {"traceback": "Traceback (most recent call last):\n File \"/Users/workspace//project/server.py\", line 486, in serve_one_request # <--- Outermost server-side stack frame\n self._dispatch_request(request)\n File \"/Users/workspace//project/server.py\", line 598, in _dispatch_request\n return_value = dispatch_method(**params)\n File \"/Users/workspace//project/server.py\", line 647, in _dispatch_read_transport\n reply_data = self._handler.read_transport(n, timeout_sec)\n File \"/Users/workspace//project/microtvm_api_server.py\", line 855, in read_transport\n return self._transport.read(n, timeout_sec)\n File \"/Users/workspace//project/microtvm_api_server.py\", line 984, in read\n raise server.IoTimeoutError()\nserver.IoTimeoutError: JSON-RPC error # -32000: IoTimeoutError\n"}}}
DEBUG:tvm.micro.transport:micro-rpc: read { 1.99s} 1 B -> [IoTimeoutError 1.99s]
DEBUG:tvm.micro.transport:micro-rpc: closing transport
DEBUG:tvm.micro.project_api.client:send -> {"jsonrpc": "2.0", "method": "close_transport", "params": {}, "id": 34}
DEBUG:tvm.micro.project_api.client:recv <- {"jsonrpc": "2.0", "id": 34, "result": null}
Any help in this would be appreciated