Skip to content

Runner fixes in xsdb #92464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 19 additions & 23 deletions boards/amd/versal2_rpu/support/xsdb.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
# SPDX-License-Identifier: Apache-2.0

proc rpu0_core0_rst { {mem "default"} } {
targets -set -filter {name =~ "DAP*"}
#CRL write protect
mwr -force 0xeb5e001c 0x0
mwr -force 0xEB580000 1
targets -set -filter {name =~ "Versal Gen 2*"}
# CRL write protect
mwr -force 0xeb5e001c 0
mwr -force 0xeb580000 1
mwr -force 0xbbf20000 0xeafffffe
# write BASE_HI and BASE_LO
if {$mem eq "ddr"} {
set addr 0x100000
} elseif {$mem eq "tcm"} {
set addr 0x0
} elseif {$mem eq "default"} {
set addr 0xbbf20000
}
mwr -force 0xEB588008 $addr
if {$mem eq "ddr"} {
set addr 0x100000
} elseif {$mem eq "tcm"} {
set addr 0
} elseif {$mem eq "default"} {
set addr 0xbbf20000
}
mwr -force 0xeb588008 $addr
# write TCMBOOT as one
mask_write 0xEB588000 0x10 0x10
mask_write 0xeb588000 0x10 0x10
# reset CORE0A_RESET out of reset A_TOPRESET and CORE0A_POR
mask_write 0xEB5E0310 0x10101 0x1
mask_write 0xeb5e0310 0x10101 0x1
# out of reset CORE0A_RESET
mask_write 0xEB5E0310 0x1 0x0
targets -set -filter {name =~ "Cortex-R52*0" && parent =~ "*0x00100000"}
mask_write 0xeb5e0310 0x1 0
targets -set -filter {name =~ "Cortex-R52*0.0"}
after 300
stop
after 1000
Expand All @@ -33,19 +33,15 @@ proc rpu0_core0_rst { {mem "default"} } {

proc load_image args {
set elf_file [lindex $args 0]
set pdi_file [lindex $args 1]

if { [info exists ::env(HW_SERVER_URL)] } {
connect -url $::env(HW_SERVER_URL)
} else {
connect
}

if { [info exists ::env(PDI_FILE_PATH)] } {
device program $::env(PDI_FILE_PATH)
} else {
puts "Error: env variable PDI_FILE_PATH is not set"
exit
}
device program $pdi_file

if { [info exists ::env(HW_SERVER_URL)] } {
set hw_server_url [split $::env(HW_SERVER_URL) ":"]
Expand All @@ -58,7 +54,7 @@ proc load_image args {
ta
}
after 1000
targets -set -nocase -filter {name =~ "DAP*"}
targets -set -filter {name =~ "Versal Gen 2*"}
after 100
# Configure timestamp generator to run global timer gracefully
# Ideally these registers should be set from bootloader (cdo)
Expand Down
8 changes: 2 additions & 6 deletions boards/amd/versalnet_rpu/support/xsdb.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

proc load_image args {
set elf_file [lindex $args 0]
set pdi_file [lindex $args 1]

if { [info exists ::env(HW_SERVER_URL)] } {
connect -url $::env(HW_SERVER_URL)
Expand All @@ -17,12 +18,7 @@ proc load_image args {
rst -system
after 100

if { [info exists ::env(PDI_FILE_PATH)] } {
device program $::env(PDI_FILE_PATH)
} else {
puts "Error: env variable PDI_FILE_PATH is not set"
exit
}
device program $pdi_file

after 100
targets -set -nocase -filter {name =~ "DPC"}
Expand Down
17 changes: 15 additions & 2 deletions scripts/west_commands/runners/xsdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class XSDBBinaryRunner(ZephyrBinaryRunner):
def __init__(self, cfg: RunnerConfig, config=None, bitstream=None,
fsbl=None):
fsbl=None, pdi=None, bl31=None, dtb=None):
super().__init__(cfg)
self.elf_file = cfg.elf_file
if not config:
Expand All @@ -24,6 +24,9 @@ def __init__(self, cfg: RunnerConfig, config=None, bitstream=None,
self.xsdb_cfg_file = config
self.bitstream = bitstream
self.fsbl = fsbl
self.pdi = pdi
self.bl31 = bl31
self.dtb = dtb

@classmethod
def name(cls):
Expand All @@ -38,13 +41,17 @@ 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')
parser.add_argument('--pdi', help='path to the base/boot pdi file')
parser.add_argument('--bl31', help='path to the bl31(ATF) elf file')
parser.add_argument('--system-dtb', help='path to the system.dtb file')

@classmethod
def do_create(
cls, cfg: RunnerConfig, args: argparse.Namespace
) -> "XSDBBinaryRunner":
return XSDBBinaryRunner(cfg, config=args.config,
bitstream=args.bitstream, fsbl=args.fsbl)
bitstream=args.bitstream, fsbl=args.fsbl,
pdi=args.pdi, bl31=args.bl31, dtb=args.system_dtb)

def do_run(self, command, **kwargs):
if self.bitstream and self.fsbl:
Expand All @@ -53,6 +60,12 @@ def do_run(self, command, **kwargs):
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]
elif self.pdi and self.bl31 and self.dtb:
cmd = ['xsdb', self.xsdb_cfg_file, self.elf_file, self.pdi, self.bl31, self.dtb]
elif self.pdi and self.bl31:
cmd = ['xsdb', self.xsdb_cfg_file, self.elf_file, self.pdi, self.bl31]
elif self.pdi:
cmd = ['xsdb', self.xsdb_cfg_file, self.elf_file, self.pdi]
else:
cmd = ['xsdb', self.xsdb_cfg_file, self.elf_file]
self.check_call(cmd)
58 changes: 58 additions & 0 deletions scripts/west_commands/tests/test_xsdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,81 @@
"config": None,
"bitstream": None,
"fsbl": None,
"pdi": None,
"bl31": None,
"dtb": None,
"expected_cmd": ["xsdb", "default_cfg_path", RC_KERNEL_ELF],
},
{
"config": "custom_cfg_path",
"bitstream": None,
"fsbl": None,
"pdi": None,
"bl31": None,
"dtb": None,
"expected_cmd": ["xsdb", "custom_cfg_path", RC_KERNEL_ELF],
},
{
"config": None,
"bitstream": "bitstream_path",
"fsbl": None,
"pdi": None,
"bl31": None,
"dtb": None,
"expected_cmd": ["xsdb", "default_cfg_path", RC_KERNEL_ELF, "bitstream_path"],
},
{
"config": None,
"bitstream": None,
"fsbl": "fsbl_path",
"pdi": None,
"bl31": None,
"dtb": None,
"expected_cmd": ["xsdb", "default_cfg_path", RC_KERNEL_ELF, "fsbl_path"],
},
{
"config": None,
"bitstream": "bitstream_path",
"fsbl": "fsbl_path",
"pdi": None,
"bl31": None,
"dtb": None,
"expected_cmd": ["xsdb", "default_cfg_path", RC_KERNEL_ELF, "bitstream_path", "fsbl_path"],
},
{
"config": None,
"bitstream": None,
"fsbl": None,
"pdi": "pdi_path",
"bl31": None,
"dtb": None,
"expected_cmd": ["xsdb", "default_cfg_path", RC_KERNEL_ELF, "pdi_path"],
},
{
"config": None,
"bitstream": None,
"fsbl": None,
"pdi": "pdi_path",
"bl31": "bl31_path",
"dtb": None,
"expected_cmd": ["xsdb", "default_cfg_path", RC_KERNEL_ELF, "pdi_path", "bl31_path"],
},
{
"config": None,
"bitstream": None,
"fsbl": None,
"pdi": "pdi_path",
"bl31": "bl31_path",
"dtb": "dtb_path",
"expected_cmd": [
"xsdb",
"default_cfg_path",
RC_KERNEL_ELF,
"pdi_path",
"bl31_path",
"dtb_path",
],
},
]


Expand All @@ -54,6 +103,9 @@ def test_xsdbbinaryrunner_init(check_call, path_exists, tc, runner_config):
config=tc["config"],
bitstream=tc["bitstream"],
fsbl=tc["fsbl"],
pdi=tc["pdi"],
bl31=tc["bl31"],
dtb=tc["dtb"],
)

runner.do_run("flash")
Expand All @@ -73,6 +125,12 @@ def test_xsdbbinaryrunner_create(check_call, path_exists, tc, runner_config):
args.extend(["--bitstream", tc["bitstream"]])
if tc["fsbl"]:
args.extend(["--fsbl", tc["fsbl"]])
if tc["pdi"]:
args.extend(["--pdi", tc["pdi"]])
if tc["bl31"]:
args.extend(["--bl31", tc["bl31"]])
if tc["dtb"]:
args.extend(["--system-dtb", tc["dtb"]])

parser = argparse.ArgumentParser(allow_abbrev=False)
XSDBBinaryRunner.add_parser(parser)
Expand Down
Loading