forked from auto-pts/auto-pts
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The goal of this board is to allow an external program to manage the building/flashing and getting the resetting command.
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# | ||
# auto-pts - The Bluetooth PTS Automation Framework | ||
# | ||
# Copyright (c) 2024, Nordic Semiconductor ASA. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms and conditions of the GNU General Public License, | ||
# version 2, as published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
|
||
import os | ||
import logging | ||
import subprocess | ||
|
||
supported_projects = ["zephyr"] | ||
|
||
def reset_cmd(iutctl): | ||
"""Return reset command for DUT | ||
""" | ||
|
||
get_reset_cmd = os.getenv("AUTOPTS_RESET_CMD") | ||
if get_reset_cmd is None: | ||
raise Exception("AUTOPTS_RESET_CMD env variable is not set") | ||
|
||
cmd = subprocess.run( | ||
[get_reset_cmd, "--snr", f"{iutctl.debugger_snr}"], | ||
check=True, | ||
stdout=subprocess.PIPE, | ||
) | ||
|
||
return cmd.stdout.decode() | ||
|
||
|
||
def build_and_flash(zephyr_wd, board, debugger_snr, conf_file=None, *args): | ||
"""Build and flash Zephyr binary | ||
:param zephyr_wd: Zephyr source path | ||
:param board: IUT | ||
:param debugger_snr serial number | ||
:param conf_file: configuration file to be used | ||
""" | ||
|
||
build_and_flash_cmd = os.getenv("AUTOPTS_BUILD_FLASH_CMD") | ||
if build_and_flash_cmd is None: | ||
raise Exception("AUTOPTS_BUILD_FLASH_CMD env variable is not set") | ||
|
||
logging.debug("%s: %s %s %s", build_and_flash.__name__, zephyr_wd, board, conf_file) | ||
|
||
tester_dir = os.path.join(zephyr_wd, "tests", "bluetooth", "tester") | ||
|
||
# board is not send to program as it's not set and this file may be used for different boards | ||
# the program is expected to retrieve board information from SNR | ||
subprocess.run( | ||
[ | ||
build_and_flash_cmd, | ||
"--snr", | ||
f"{debugger_snr}", | ||
"--config", | ||
f"{conf_file}", | ||
], | ||
check=True, | ||
cwd=tester_dir, | ||
) |