From 6afacd7122354f1495c9172cb2c43a10a754ecce Mon Sep 17 00:00:00 2001 From: Gavin Uberti Date: Tue, 24 Aug 2021 15:23:54 -0700 Subject: [PATCH] Address PR comments Address Mehrdad's PR comments More PR comments Documentation tweaks Add dialout group to user --- apps/microtvm/reference-vm/arduino/README.md | 21 ++++++++++++++-- .../microtvm/reference-vm/arduino/Vagrantfile | 25 +------------------ .../arduino/base-box/base_box_provision.sh | 14 +++++++++-- .../arduino/base-box/base_box_test.sh | 1 + apps/microtvm/reference-vm/base-box-tool.py | 17 ++++++------- 5 files changed, 41 insertions(+), 37 deletions(-) diff --git a/apps/microtvm/reference-vm/arduino/README.md b/apps/microtvm/reference-vm/arduino/README.md index bcb750a9dd91..3fa1d8bfb4e3 100644 --- a/apps/microtvm/reference-vm/arduino/README.md +++ b/apps/microtvm/reference-vm/arduino/README.md @@ -17,11 +17,28 @@ # microTVM Arduino Reference Virtual Machine -This directory contains setup files for Arduino virtual machine used for testing microTVM platforms -that are supported by [Arduino](https://www.arduino.cc/). +This directory contains setup files for Arduino virtual machine used for testing +microTVM platforms that are supported by [Arduino](https://www.arduino.cc/). ## VM Information for Developers Arduino VM is published under [tlcpack](https://app.vagrantup.com/tlcpack). Here is a list of different release versions and their tools. (none currently) + +## Supported Arduino Boards +This RVM has been tested and is known to work with these boards: +- Adafruit Metro M4 +- Adafruit Pybadge +- Arduino Due +- Arduino Nano 33 BLE +- Feather S2 +- Sony Spresense +- Wio Terminal + +However, the RVM *should* work with any Arduino with sufficient memory, provided +its core is installed in `base-box/base_box_provision.sh`. + +Note that this RVM does not work with the Teensy boards, even though they are +supported by microTVM. This is because arduino-cli does not support Teensy +boards (https://github.com/arduino/arduino-cli/issues/700)/). diff --git a/apps/microtvm/reference-vm/arduino/Vagrantfile b/apps/microtvm/reference-vm/arduino/Vagrantfile index b42e5c46dc62..2511a6ae296e 100644 --- a/apps/microtvm/reference-vm/arduino/Vagrantfile +++ b/apps/microtvm/reference-vm/arduino/Vagrantfile @@ -49,7 +49,7 @@ Vagrant.configure("2") do |config| config.vm.provision "shell", path: "provision_setup.sh", env: {"TVM_HOME": dirs_to_mount[0]}, privileged: false # Enable USB Controller on VirtualBox - vm_name = "microtvm-#{Time.now.tv_sec}" + vm_name = "microtvm-arduino-#{Time.now.tv_sec}" config.vm.provider "virtualbox" do |vb, overrides| vb.name = vm_name vb.cpus = num_cores @@ -63,27 +63,4 @@ Vagrant.configure("2") do |config| end end - config.vm.provider "parallels" do |prl, overrides| - prl.name = vm_name - prl.cpus = num_cores - prl.memory = ram_bytes - prl.update_guest_tools = true - prl.customize ["set", :id, "--support-usb30", "on"] - dirs_to_mount.each do |d| - overrides.vm.synced_folder d.to_s, d.to_s, mount_options: ["share", "nosuid", "host_inodes"] - end - end - - config.vm.provider "vmware_desktop" do |vm, overrides| - vm.cpus = num_cores - vm.memory = ram_bytes - vm.vmx["usb_xhci.present"] = "TRUE" - vm.vmx["usb.present"] = "TRUE" - vm.vmx["ehci.present"] = "TRUE" - dirs_to_mount.each do |d| - overrides.vm.synced_folder d.to_s, d.to_s - end - vm.gui = true - end - end 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 e20e9e0a091c..b99d93f02695 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 @@ -34,6 +34,9 @@ sudo apt-get install -y ca-certificates export PATH="/home/vagrant/bin:$PATH" wget -O - https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh -s +# Arduino (the CLI and GUI) require the dialout permission for uploading +sudo usermod -a -G dialout $USER + # ubuntu_init_arduino.sh only installs a few officially # supported architectures, so we don't use it here @@ -58,8 +61,15 @@ arduino-cli core install SPRESENSE:spresense --additional-urls $SPRESENSE_BOARDS # 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_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_BUGFIX_PATH +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 SECOND bug in the Spresense Arduino bindings, relating to how the +# flash_writer path is templated on Linux. This change is only needed to upload code +# (not compile) to the Spresense. +# https://github.com/sonydevworld/spresense-arduino-compatible/issues/127 +SPRESENSE_FLASH_WRITER_BUGFIX_PATH=~/.arduino15/packages/SPRESENSE/hardware/spresense/2.2.1/platform.txt +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 # Cleanup rm -f *.sh diff --git a/apps/microtvm/reference-vm/arduino/base-box/base_box_test.sh b/apps/microtvm/reference-vm/arduino/base-box/base_box_test.sh index 584b8fb9246c..3d8597f19b64 100755 --- a/apps/microtvm/reference-vm/arduino/base-box/base_box_test.sh +++ b/apps/microtvm/reference-vm/arduino/base-box/base_box_test.sh @@ -33,6 +33,7 @@ microtvm_platform=$1 pytest tests/micro/arduino/test_arduino_workflow.py --microtvm-platforms=${microtvm_platform} if [ $microtvm_platform == "nano33ble" ]; then + # https://github.com/apache/tvm/issues/8730 echo "NOTE: skipped test_arduino_rpc_server.py on $microtvm_platform -- known failure" else pytest tests/micro/arduino/test_arduino_rpc_server.py --microtvm-platforms=${microtvm_platform} diff --git a/apps/microtvm/reference-vm/base-box-tool.py b/apps/microtvm/reference-vm/base-box-tool.py index abc3bb2fa586..f32885433c2b 100755 --- a/apps/microtvm/reference-vm/base-box-tool.py +++ b/apps/microtvm/reference-vm/base-box-tool.py @@ -75,10 +75,7 @@ # in [platform]/base-box/base_box_provision.sh EXTRA_SCRIPTS = { "arduino": (), - "zephyr": ( - "docker/install/ubuntu_init_zephyr_project.sh", - "docker/install/ubuntu_install_qemu.sh", - ), + "zephyr": ("docker/install/ubuntu_init_zephyr_project.sh",), } PACKER_FILE_NAME = "packer.json" @@ -392,7 +389,6 @@ def test_command(args): microtvm_test_platform["microtvm_platform"] = args.microtvm_platform providers = args.provider - print(providers) provider_passed = {p: False for p in providers} release_test_dir = os.path.join(THIS_DIR, "release-test") @@ -479,7 +475,7 @@ def parse_args(): # "test" has special options for different platforms, and "build", "release" might # in the future, so we'll add the platform argument to each one individually. - platform_help_str = "Electronics platform to use (e.g. Arduino, Zephyr)" + platform_help_str = "Platform to use (e.g. Arduino, Zephyr)" # Options for build subcommand parser_build = subparsers.add_parser("build", help="Build a base box.") @@ -510,9 +506,9 @@ def parse_args(): "iSerial field from `lsusb -v` output." ), ) - platform_subparsers = parser_test.add_subparsers(help=platform_help_str) + parser_test_platform_subparsers = parser_test.add_subparsers(help=platform_help_str) for platform in ALL_PLATFORMS: - platform_specific_parser = platform_subparsers.add_parser(platform) + platform_specific_parser = parser_test_platform_subparsers.add_parser(platform) platform_specific_parser.set_defaults(platform=platform) platform_specific_parser.add_argument( "--microtvm-platform", @@ -538,7 +534,10 @@ def parse_args(): parser_release.add_argument( "--platform-version", required=True, - help="Platform version to release, in the form 'x.y'.", + help=( + "For Zephyr, the platform version to release, in the form 'x.y'. " + "For Arduino, the version of arduino-cli that's being used, in the form 'x.y.z'." + ), ) return parser.parse_args()