From 1a0a0196dd6de16e773ba227ed1e227acec022cf Mon Sep 17 00:00:00 2001 From: Appana Durga Kedareswara rao Date: Tue, 1 Jul 2025 18:41:28 +0530 Subject: [PATCH 1/3] runners: xsdb: Add support for optional bl31, pdi, system.dtb arguments This update enhances the runner script to optionally accept bl31, pdi, and system.dtb as arguments. These inputs are not mandatory and will only be used if explicitly provided. This allows for more flexible boot configurations, especially useful when testing different firmware and system setups without modifying the script. Signed-off-by: Appana Durga Kedareswara rao --- scripts/west_commands/runners/xsdb.py | 17 ++++++- scripts/west_commands/tests/test_xsdb.py | 58 ++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/scripts/west_commands/runners/xsdb.py b/scripts/west_commands/runners/xsdb.py index 7029a3a9354ae..79fff79c2e673 100644 --- a/scripts/west_commands/runners/xsdb.py +++ b/scripts/west_commands/runners/xsdb.py @@ -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: @@ -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): @@ -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: @@ -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) diff --git a/scripts/west_commands/tests/test_xsdb.py b/scripts/west_commands/tests/test_xsdb.py index 0711da5f38e3e..fa94c489b80ab 100644 --- a/scripts/west_commands/tests/test_xsdb.py +++ b/scripts/west_commands/tests/test_xsdb.py @@ -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", + ], + }, ] @@ -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") @@ -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) From b29895725e0c9ed76405474ba1c98bc2c9fe771a Mon Sep 17 00:00:00 2001 From: Appana Durga Kedareswara rao Date: Tue, 1 Jul 2025 18:43:54 +0530 Subject: [PATCH 2/3] versal2_rpu: Update configuration to align with latest target definitions In 2025.1 xsdb release for Versal Gen 2 platform target definitions got changed, Updated config file to align with latest target definitions. Signed-off-by: Appana Durga Kedareswara rao --- boards/amd/versal2_rpu/support/xsdb.cfg | 34 ++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/boards/amd/versal2_rpu/support/xsdb.cfg b/boards/amd/versal2_rpu/support/xsdb.cfg index 88313923170d5..fe09338bc4453 100644 --- a/boards/amd/versal2_rpu/support/xsdb.cfg +++ b/boards/amd/versal2_rpu/support/xsdb.cfg @@ -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 @@ -58,7 +58,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) From 7fcc43d05ab2fe71ab4f36f134c64f61ee5c14b4 Mon Sep 17 00:00:00 2001 From: Appana Durga Kedareswara rao Date: Tue, 1 Jul 2025 18:46:06 +0530 Subject: [PATCH 3/3] boards: amd: Use PDI path from runner arguments instead of environment Modified the XSDB configuration to take the PDI path directly from the runner script's arguments rather than relying on an environment variable. This change improves usability and makes the runner more self-contained. Signed-off-by: Appana Durga Kedareswara rao --- boards/amd/versal2_rpu/support/xsdb.cfg | 8 ++------ boards/amd/versalnet_rpu/support/xsdb.cfg | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/boards/amd/versal2_rpu/support/xsdb.cfg b/boards/amd/versal2_rpu/support/xsdb.cfg index fe09338bc4453..e800adebc671e 100644 --- a/boards/amd/versal2_rpu/support/xsdb.cfg +++ b/boards/amd/versal2_rpu/support/xsdb.cfg @@ -33,6 +33,7 @@ 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) @@ -40,12 +41,7 @@ proc load_image args { 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) ":"] diff --git a/boards/amd/versalnet_rpu/support/xsdb.cfg b/boards/amd/versalnet_rpu/support/xsdb.cfg index 087ed4c85c113..809e974f83e55 100644 --- a/boards/amd/versalnet_rpu/support/xsdb.cfg +++ b/boards/amd/versalnet_rpu/support/xsdb.cfg @@ -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) @@ -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"}