2024-09-25 10:53:01 +05:30
|
|
|
# Copyright (c) 2024 Advanced Micro Devices, Inc.
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
"""Runner for flashing with xsdb CLI, the official programming
|
|
|
|
utility from AMD platforms.
|
|
|
|
"""
|
|
|
|
import argparse
|
|
|
|
import os
|
2024-11-20 15:54:37 +01:00
|
|
|
|
|
|
|
from runners.core import RunnerCaps, RunnerConfig, ZephyrBinaryRunner
|
|
|
|
|
2024-09-25 10:53:01 +05:30
|
|
|
|
|
|
|
class XSDBBinaryRunner(ZephyrBinaryRunner):
|
|
|
|
def __init__(self, cfg: RunnerConfig, config=None, bitstream=None,
|
|
|
|
fsbl=None):
|
2024-11-20 15:20:09 +01:00
|
|
|
super().__init__(cfg)
|
2024-09-25 10:53:01 +05:30
|
|
|
self.elf_file = cfg.elf_file
|
|
|
|
if not config:
|
|
|
|
cfgfile_path = os.path.join(cfg.board_dir, 'support')
|
|
|
|
default = os.path.join(cfgfile_path, 'xsdb.cfg')
|
|
|
|
if os.path.exists(default):
|
|
|
|
config = default
|
|
|
|
self.xsdb_cfg_file = config
|
|
|
|
self.bitstream = bitstream
|
|
|
|
self.fsbl = fsbl
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def name(cls):
|
|
|
|
return 'xsdb'
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def capabilities(cls):
|
|
|
|
return RunnerCaps(flash_addr=True)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def do_add_parser(cls, parser):
|
|
|
|
parser.add_argument('--config', help='if given, override default config file')
|
|
|
|
parser.add_argument('--bitstream', help='path to the bitstream file')
|
|
|
|
parser.add_argument('--fsbl', help='path to the fsbl elf file')
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def do_create(
|
|
|
|
cls, cfg: RunnerConfig, args: argparse.Namespace
|
|
|
|
) -> "XSDBBinaryRunner":
|
|
|
|
return XSDBBinaryRunner(cfg, config=args.config,
|
|
|
|
bitstream=args.bitstream, fsbl=args.fsbl)
|
|
|
|
|
|
|
|
def do_run(self, command, **kwargs):
|
|
|
|
if self.bitstream and self.fsbl:
|
|
|
|
cmd = ['xsdb', self.xsdb_cfg_file, self.elf_file, self.bitstream, self.fsbl]
|
|
|
|
elif self.bitstream:
|
|
|
|
cmd = ['xsdb', self.xsdb_cfg_file, self.elf_file, self.bitstream]
|
|
|
|
elif self.fsbl:
|
|
|
|
cmd = ['xsdb', self.xsdb_cfg_file, self.elf_file, self.fsbl]
|
|
|
|
else:
|
2025-01-29 08:19:33 +00:00
|
|
|
cmd = ['xsdb', self.xsdb_cfg_file, self.elf_file]
|
2024-09-25 10:53:01 +05:30
|
|
|
self.check_call(cmd)
|