Skip to content

Commit

Permalink
[microTVM] Update nrfjprog on reference virtual machine (#7723)
Browse files Browse the repository at this point in the history
* update nrfjprog and integration test

* merge

* Revert "merge"

This reverts commit 58d5d91.

* fix comments

* fix clang

* revert format

* new line

* format
  • Loading branch information
mehrdadh authored Mar 23, 2021
1 parent 37e6df1 commit f88c2be
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 13 deletions.
28 changes: 23 additions & 5 deletions apps/microtvm/reference-vm/base-box-tool.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
"vmware_desktop",
)

# List of microTVM platforms for testing.
ALL_MICROTVM_PLATFORMS = (
"stm32f746xx",
"nrf5340dk",
)


def parse_virtualbox_devices():
output = subprocess.check_output(["VBoxManage", "list", "usbhost"], encoding="utf-8")
Expand Down Expand Up @@ -109,6 +115,7 @@ def attach_virtualbox(uuid, vid_hex=None, pid_hex=None, serial=None):
if serial is not None:
rule_args.extend(["--serialnumber", serial])
subprocess.check_call(rule_args)
# TODO(mehrdadh): skip usb attach if it's already attached
subprocess.check_call(["VBoxManage", "controlvm", uuid, "usbattach", dev["UUID"]])
return

Expand Down Expand Up @@ -308,13 +315,17 @@ def test_command(args):
test_config_file = os.path.join(base_box_dir, "test-config.json")
with open(test_config_file) as f:
test_config = json.load(f)

# select microTVM test platform
microtvm_test_platform = test_config[args.microtvm_platform]

for key, expected_type in REQUIRED_TEST_CONFIG_KEYS.items():
assert key in test_config and isinstance(
test_config[key], expected_type
assert key in microtvm_test_platform and isinstance(
microtvm_test_platform[key], expected_type
), f"Expected key {key} of type {expected_type} in {test_config_file}: {test_config!r}"

test_config["vid_hex"] = test_config["vid_hex"].lower()
test_config["pid_hex"] = test_config["pid_hex"].lower()
microtvm_test_platform["vid_hex"] = microtvm_test_platform["vid_hex"].lower()
microtvm_test_platform["pid_hex"] = microtvm_test_platform["pid_hex"].lower()

providers = args.provider
provider_passed = {p: False for p in providers}
Expand All @@ -331,7 +342,7 @@ def test_command(args):
release_test_dir, user_box_dir, base_box_dir, provider_name
)
do_run_release_test(
release_test_dir, provider_name, test_config, args.test_device_serial
release_test_dir, provider_name, microtvm_test_platform, args.test_device_serial
)
provider_passed[provider_name] = True

Expand Down Expand Up @@ -444,6 +455,13 @@ def parse_args():
),
)

parser.add_argument(
"--microtvm-platform",
default="stm32f746xx",
choices=ALL_MICROTVM_PLATFORMS,
help="For use with 'test' command. MicroTVM platfrom that are used for testing.",
)

return parser.parse_args()


Expand Down
15 changes: 10 additions & 5 deletions apps/microtvm/reference-vm/zephyr/base-box/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,22 @@ sudo apt install -y llvm
sudo apt install -y protobuf-compiler libprotoc-dev

# nrfjprog
NRF_COMMANDLINE_TOOLS_FILE=nRFCommandLineToolsLinuxamd64.tar.gz
NRF_COMMANDLINE_TOOLS_URL=https://www.nordicsemi.com/-/media/Software-and-other-downloads/Desktop-software/nRF-command-line-tools/sw/Versions-10-x-x/10-12-1/nRFCommandLineTools10121Linuxamd64.tar.gz
NRF_COMMANDLINE_TOOLS_INSTALLER=nRF-Command-Line-Tools_10_12_1_Linux-amd64.deb
JLINK_LINUX_INSTALLER=JLink_Linux_V688a_x86_64.deb

cd ~
mkdir -p nrfjprog
wget --no-verbose -O nRFCommandLineTools1090Linuxamd64.tar.gz https://www.nordicsemi.com/-/media/Software-and-other-downloads/Desktop-software/nRF-command-line-tools/sw/Versions-10-x-x/10-9-0/nRFCommandLineTools1090Linuxamd64tar.gz
wget --no-verbose -O $NRF_COMMANDLINE_TOOLS_FILE $NRF_COMMANDLINE_TOOLS_URL
cd nrfjprog
tar -xzvf ../nRFCommandLineTools1090Linuxamd64.tar.gz
sudo apt install -y ./JLink_Linux_V680a_x86_64.deb
sudo apt install -y ./nRF-Command-Line-Tools_10_9_0_Linux-amd64.deb
tar -xzvf "../${NRF_COMMANDLINE_TOOLS_FILE}"
sudo apt install -y "./${JLINK_LINUX_INSTALLER}"
sudo apt install -y "./${NRF_COMMANDLINE_TOOLS_INSTALLER}"
source ~/.profile
nrfjprog --help
cd ..
rm -rf nrfjprog nRFCommandLineTools1090Linuxamd64.tar.gz
rm -rf nrfjprog "${NRF_COMMANDLINE_TOOLS_FILE}"

# Zephyr
pip3 install --user -U west
Expand Down
14 changes: 11 additions & 3 deletions apps/microtvm/reference-vm/zephyr/base-box/test-config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{"vid_hex": "0483",
"pid_hex": "374b",
"test_cmd": ["pytest", "tests/micro/qemu/test_zephyr.py", "--microtvm-platforms=stm32f746xx"]
{
"stm32f746xx": {
"vid_hex": "0483",
"pid_hex": "374b",
"test_cmd": ["pytest", "tests/micro/qemu/test_zephyr.py", "--microtvm-platforms=stm32f746xx"]
},
"nrf5340dk": {
"vid_hex": "1366",
"pid_hex": "1055",
"test_cmd": ["pytest", "tests/micro/qemu/test_zephyr.py", "--microtvm-platforms=nrf5340dk"]
}
}

0 comments on commit f88c2be

Please sign in to comment.