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
38 changes: 9 additions & 29 deletions apps/microtvm/reference-vm/arduino/base-box/base_box_provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ 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"
ARDUINO_CLI_VERSION="0.21.1"

export PATH="/home/vagrant/bin:$PATH"
wget -O - https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh -s ${ARDUINO_CLI_VERSION}
Expand All @@ -45,38 +45,18 @@ sudo usermod -a -G dialout $USER
# supported architectures, so we don't use it here

# 3rd party board URLs
ADAFRUIT_BOARDS_URL="https://adafruit.github.io/arduino-board-index/package_adafruit_index.json"
ADAFRUIT_BOARDS_URL="https://raw.githubusercontent.com/adafruit/arduino-board-index/7840c768/package_adafruit_index.json"
ESP32_BOARDS_URL="https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json"
SPARKFUN_BOARDS_URL="https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json"
SEEED_BOARDS_URL="https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json"
SPRESENSE_BOARDS_URL="https://github.com/sonydevworld/spresense-arduino-compatible/releases/download/v2.2.1/package_spresense_index.json"
arduino-cli core update-index --additional-urls $ADAFRUIT_BOARDS_URL,$ESP32_BOARDS_URL,$SPARKFUN_BOARDS_URL,$SEEED_BOARDS_URL,$SPRESENSE_BOARDS_URL
SPRESENSE_BOARDS_URL="https://github.com/sonydevworld/spresense-arduino-compatible/releases/download/v2.5.0/package_spresense_index.json"
arduino-cli core update-index --additional-urls $ADAFRUIT_BOARDS_URL,$ESP32_BOARDS_URL,$SPRESENSE_BOARDS_URL

# Install supported cores from those URLS
arduino-cli version
arduino-cli core install arduino:mbed_nano
arduino-cli core install arduino:sam
arduino-cli core install adafruit:samd --additional-urls $ADAFRUIT_BOARDS_URL
arduino-cli core install esp32:esp32 --additional-urls $ESP32_BOARDS_URL
arduino-cli core install Seeeduino:samd --additional-urls $SEEED_BOARDS_URL
arduino-cli core install SPRESENSE:spresense --additional-urls $SPRESENSE_BOARDS_URL

# The Sony Spresense SDK has a major bug that breaks TVM. It's scheduled to be fixed in
# release 2.3.0, but until that's published we need to use the below hack. This ONLY
# fixes the bug in the main core release SDK - the subcore release SDK and both
# the main and subcore debug SDKs will continue to fail until an official fix is made.
# https://github.com/sonydevworld/spresense/issues/200
SPRESENSE_NUTTX_BUGFIX_PATH=~/.arduino15/packages/SPRESENSE/tools/spresense-sdk/2.2.1/spresense/release/nuttx/include/sys/types.h
sed -i 's/#ifndef CONFIG_WCHAR_BUILTIN/#if !defined(__cplusplus)/g' $SPRESENSE_NUTTX_BUGFIX_PATH

# There's also a bug in arduino-cli where {runtime.os} is not properly templated in
# platform.txt. This bug only seems to appear with the SPRESENSE SDK. A fix has been
# merged and will be part of arduino-cli 0.18.4, but that has yet to be published.
# This change is only needed to upload code (not compile) for the Spresense.
# https://github.com/arduino/arduino-cli/issues/1198
SPRESENSE_FLASH_WRITER_BUGFIX_PATH=~/.arduino15/packages/SPRESENSE/hardware/spresense/2.2.1/platform.txt
sed -i 's/tools.spresense-tools.cmd.path={path}\/flash_writer\/{runtime.os}\/flash_writer/tools.spresense-tools.cmd.path={path}\/flash_writer\/linux\/flash_writer/g' $SPRESENSE_FLASH_WRITER_BUGFIX_PATH
sed -i 's/tools.spresense-tools.cmd.path.linux={path}\/flash_writer\/{runtime.os}\/flash_writer/tools.spresense-tools.cmd.path.linux={path}\/flash_writer\/linux\/flash_writer/g' $SPRESENSE_FLASH_WRITER_BUGFIX_PATH
arduino-cli core install arduino:mbed_nano@3.0.1
arduino-cli core install arduino:sam@1.6.12
arduino-cli core install adafruit:samd@1.7.10 --additional-urls $ADAFRUIT_BOARDS_URL
arduino-cli core install esp32:esp32@2.0.2 --additional-urls $ESP32_BOARDS_URL
arduino-cli core install SPRESENSE:spresense@2.5.0 --additional-urls $SPRESENSE_BOARDS_URL

# Cleanup
rm -f *.sh
2 changes: 1 addition & 1 deletion docker/install/ubuntu_install_arduino.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set -o pipefail
export DEBIAN_FRONTEND=noninteractive
apt-get install -y ca-certificates

ARDUINO_CLI_VERSION="0.18.3"
ARDUINO_CLI_VERSION="0.21.1"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you consolidate arduino CLI installation into one script and reuse for both docker and RVM?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We decided last summer that the scripts should be separate, as they aren't that similar. I'd be open to revisiting that topic, but it's OOS for this PR.

# Install arduino-cli
wget -O - https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh -s ${ARDUINO_CLI_VERSION}

Expand Down
11 changes: 7 additions & 4 deletions tests/micro/arduino/test_arduino_rpc_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ def _make_sess_from_op(
model, arduino_board, arduino_cli_cmd, workspace_dir, op_name, sched, arg_bufs, build_config
):
target = tvm.target.target.micro(model)
runtime = Runtime("crt", {"system-lib": True})
with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
mod = tvm.build(sched, arg_bufs, target=target, name=op_name)
mod = tvm.build(sched, arg_bufs, target=target, runtime=runtime, name=op_name)

return _make_session(model, arduino_board, arduino_cli_cmd, workspace_dir, mod, build_config)

Expand Down Expand Up @@ -152,8 +153,9 @@ def test_relay(board, arduino_cli_cmd, tvm_debug, workspace_dir):
func = relay.Function([x], z)

target = tvm.target.target.micro(model)
runtime = Runtime("crt", {"system-lib": True})
with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
mod = tvm.relay.build(func, target=target)
mod = tvm.relay.build(func, target=target, runtime=runtime)

with _make_session(model, board, arduino_cli_cmd, workspace_dir, mod, build_config) as session:
graph_mod = tvm.micro.create_local_graph_executor(
Expand Down Expand Up @@ -192,9 +194,9 @@ def test_onnx(board, arduino_cli_cmd, tvm_debug, workspace_dir):
relay_mod = relay.transform.DynamicToStatic()(relay_mod)

target = tvm.target.target.micro(model)
runtime = Runtime("crt", {"system-lib": True})
with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
executor = Executor("graph", {"link-params": True})
runtime = Runtime("crt", {"system-lib": True})
lowered = relay.build(relay_mod, target, params=params, executor=executor, runtime=runtime)
graph = lowered.get_graph_json()

Expand Down Expand Up @@ -233,8 +235,9 @@ def check_result(
"""Helper function to verify results"""
TOL = 1e-5
target = tvm.target.target.micro(model)
runtime = Runtime("crt", {"system-lib": True})
with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
mod = tvm.relay.build(relay_mod, target=target)
mod = tvm.relay.build(relay_mod, target=target, runtime=runtime)

with _make_session(
model, arduino_board, arduino_cli_cmd, workspace_dir, mod, build_config
Expand Down