artiq_devtool: update for new board file convention.

Also fix a typo in documentation.
This commit is contained in:
whitequark 2018-01-19 09:43:03 +00:00
parent 0cdbc5544a
commit 3c0b164e4d
2 changed files with 27 additions and 26 deletions

View File

@ -30,11 +30,11 @@ Minor (bugfix) releases
Sharing development boards Sharing development boards
========================== ==========================
To avoid conflicts for development boards on the server, while using a board you must hold the corresponding lock file present in ``/var/artiq/boards``. Holding the lock file grants you exclusive access to the board. To avoid conflicts for development boards on the server, while using a board you must hold the corresponding lock file present in ``/var/lib/artiq/boards``. Holding the lock file grants you exclusive access to the board.
To lock the KC705 for 30 minutes or until Ctrl-C is pressed: To lock the KC705 for 30 minutes or until Ctrl-C is pressed:
:: ::
flock --verbose /var/artiq/boards/kc705-1 sleep 1800 flock --verbose /var/lib/artiq/boards/kc705-1 sleep 1800
Check that the command acquires the lock, i.e. prints something such as: Check that the command acquires the lock, i.e. prints something such as:
:: ::
@ -43,18 +43,18 @@ Check that the command acquires the lock, i.e. prints something such as:
To lock the KC705 for the duration of the execution of a shell: To lock the KC705 for the duration of the execution of a shell:
:: ::
flock /var/artiq/boards/kc705-1 bash flock /var/lib/artiq/boards/kc705-1 bash
You may also use this script: You may also use this script:
:: ::
#!/bin/bash #!/bin/bash
exec flock /var/artiq/boards/$1 bash --rcfile <(cat ~/.bashrc; echo PS1=\"[$1\ lock]\ \$PS1\") exec flock /var/lib/artiq/boards/$1 bash --rcfile <(cat ~/.bashrc; echo PS1=\"[$1\ lock]\ \$PS1\")
If the board is already locked by another user, the ``flock`` commands above will wait for the lock to be released. If the board is already locked by another user, the ``flock`` commands above will wait for the lock to be released.
To determine which user is locking a board, use: To determine which user is locking a board, use:
:: ::
fuser -v /var/artiq/boards/kc705-1 fuser -v /var/lib/artiq/boards/kc705-1
Selecting a development board with artiq_flash Selecting a development board with artiq_flash
@ -62,7 +62,7 @@ Selecting a development board with artiq_flash
The board lock file also contains the openocd commands for selecting the corresponding developer board: The board lock file also contains the openocd commands for selecting the corresponding developer board:
:: ::
artiq_flash --preinit-command "$(cat /var/artiq/boards/sayma-1)" artiq_flash --preinit-command "$(cat /var/lib/artiq/boards/sayma-1)"
Using developer tools Using developer tools

View File

@ -37,17 +37,18 @@ def get_argparser():
type=str, default="lab.m-labs.hk", type=str, default="lab.m-labs.hk",
help="SSH host where the development board is located") help="SSH host where the development board is located")
parser.add_argument('-b', "--board", parser.add_argument('-b', "--board",
type=str, default="{boardtype}-1", type=str, default="{board_type}-1",
help="Board to connect to on the development SSH host") help="Board to connect to on the development SSH host")
parser.add_argument("-d", "--device", parser.add_argument("-B", "--board-file",
type=str, default="{board}.{host}", type=str, default="/var/lib/artiq/boards/{board}",
help="Address or domain corresponding to the development board") help="The board file containing the openocd initialization commands; "
"it is also used as the lock file")
parser.add_argument("-s", "--serial", parser.add_argument("-s", "--serial",
type=str, default="/dev/ttyUSB_{board}", type=str, default="/dev/ttyUSB_{board}",
help="TTY device corresponding to the development board") help="TTY device corresponding to the development board")
parser.add_argument("-l", "--lockfile", parser.add_argument("-d", "--device",
type=str, default="/run/boards/{board}", type=str, default="{board}.{host}",
help="The lockfile to be acquired for the duration of the actions") help="Address or domain corresponding to the development board")
parser.add_argument("-w", "--wait", action="store_true", parser.add_argument("-w", "--wait", action="store_true",
help="Wait for the board to unlock instead of aborting the actions") help="Wait for the board to unlock instead of aborting the actions")
@ -70,22 +71,22 @@ def main():
build_args = [] build_args = []
if args.target == "kc705_dds": if args.target == "kc705_dds":
boardtype, firmware = "kc705", "runtime" board_type, firmware = "kc705", "runtime"
elif args.target == "sayma_amc_standalone": elif args.target == "sayma_amc_standalone":
boardtype, firmware = "sayma_amc", "runtime" board_type, firmware = "sayma_amc", "runtime"
build_args += ["--rtm-csr-csv", build_dir("sayma_rtm_csr.csv", target="sayma_rtm")] build_args += ["--rtm-csr-csv", build_dir("sayma_rtm_csr.csv", target="sayma_rtm")]
elif args.target == "sayma_amc_drtio_master": elif args.target == "sayma_amc_drtio_master":
boardtype, firmware = "sayma_amc", "runtime" board_type, firmware = "sayma_amc", "runtime"
elif args.target == "sayma_amc_drtio_satellite": elif args.target == "sayma_amc_drtio_satellite":
boardtype, firmware = "sayma_amc", "satman" board_type, firmware = "sayma_amc", "satman"
elif args.target == "sayma_rtm": elif args.target == "sayma_rtm":
boardtype, firmware = "sayma_rtm", None board_type, firmware = "sayma_rtm", None
else: else:
raise NotImplementedError("unknown target {}".format(args.target)) raise NotImplementedError("unknown target {}".format(args.target))
board = args.board.format(boardtype=boardtype) board = args.board.format(board_type=board_type)
board_file = args.board_file.format(board=board)
device = args.device.format(board=board, host=args.host) device = args.device.format(board=board, host=args.host)
lockfile = args.lockfile.format(board=board)
serial = args.serial.format(board=board) serial = args.serial.format(board=board)
client = SSHClient(args.host) client = SSHClient(args.host)
@ -97,7 +98,7 @@ def main():
nonlocal flock_file nonlocal flock_file
if not flock_acquired: if not flock_acquired:
fuser_args = ["fuser", "-u", lockfile] fuser_args = ["fuser", "-u", board_file]
fuser = client.spawn_command(fuser_args) fuser = client.spawn_command(fuser_args)
fuser_file = fuser.makefile('r') fuser_file = fuser.makefile('r')
fuser_match = re.search(r"\((.+?)\)", fuser_file.readline()) fuser_match = re.search(r"\((.+?)\)", fuser_file.readline())
@ -110,7 +111,7 @@ def main():
flock_args = ["flock"] flock_args = ["flock"]
if not args.wait: if not args.wait:
flock_args.append("--nonblock") flock_args.append("--nonblock")
flock_args += ["--verbose", lockfile] flock_args += ["--verbose", board_file]
flock_args += ["sleep", "86400"] flock_args += ["sleep", "86400"]
flock = client.spawn_command(flock_args, get_pty=True) flock = client.spawn_command(flock_args, get_pty=True)
@ -130,9 +131,9 @@ def main():
flash_args = ["artiq_flash"] flash_args = ["artiq_flash"]
for _ in range(args.verbose): for _ in range(args.verbose):
flash_args.append("-v") flash_args.append("-v")
flash_args += ["-H", args.host, "-t", boardtype] flash_args += ["-H", args.host, "-t", board_type]
flash_args += ["--srcbuild", build_dir()] flash_args += ["--srcbuild", build_dir()]
flash_args += ["--preinit-command", "source /var/boards/{}".format(board)] flash_args += ["--preinit-command", "source {}".format(board_file)]
flash_args += steps flash_args += steps
subprocess.check_call(flash_args) subprocess.check_call(flash_args)