From 814d6914d0cd6e733a8a19629f410068e75c131e Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Fri, 24 Sep 2021 14:23:06 +1000 Subject: [PATCH 1/4] flash-arty: Add cable argument To select the cable config. Defaults to arty Signed-off-by: Benjamin Herrenschmidt --- openocd/arty.cfg | 6 ++++++ openocd/flash-arty | 8 +++++--- openocd/xilinx-xc7.cfg | 6 ------ openocd/xilinx-xc7_openocd_v0.11.cfg | 7 ------- 4 files changed, 11 insertions(+), 16 deletions(-) create mode 100644 openocd/arty.cfg diff --git a/openocd/arty.cfg b/openocd/arty.cfg new file mode 100644 index 0000000..6cd9939 --- /dev/null +++ b/openocd/arty.cfg @@ -0,0 +1,6 @@ +interface ftdi +ftdi_vid_pid 0x0403 0x6010 +ftdi_channel 0 +ftdi_layout_init 0x00e8 0x60eb +reset_config none +adapter_khz 25000 diff --git a/openocd/flash-arty b/openocd/flash-arty index 815dea9..6d4d13d 100755 --- a/openocd/flash-arty +++ b/openocd/flash-arty @@ -7,7 +7,7 @@ import sys BASE = os.path.dirname(os.path.abspath(__file__)) -def flash(config, flash_proxy, address, data, filetype="", set_qe=False): +def flash(cable, config, flash_proxy, address, data, filetype="", set_qe=False): script = "; ".join([ "init", "jtagspi_init 0 {{{}}}".format(flash_proxy), @@ -17,7 +17,7 @@ def flash(config, flash_proxy, address, data, filetype="", set_qe=False): "exit" ]) print(script) - subprocess.call(["openocd", "-f", config, "-c", script]) + subprocess.call(["openocd", "-f", cable, "-f", config, "-c", script]) def get_version(): a = subprocess.run(["openocd", "-v"], capture_output=True) @@ -33,6 +33,7 @@ parser.add_argument("file", help="file to write to flash") parser.add_argument("-a", "--address", help="offset in flash", type=lambda x: int(x,0), default=0) parser.add_argument("-f", "--fpga", help="a35, a100 or a200", default="a35") parser.add_argument("-t", "--filetype", help="file type such as 'bin'", default="") +parser.add_argument("-c", "--cable", help="cable type such as 'arty'", default="arty") args = parser.parse_args() version = get_version() @@ -49,5 +50,6 @@ else: proxy = os.path.join(BASE, proxy) config = os.path.join(BASE, "xilinx-xc7{}.cfg".format(version)) +cable = os.path.join(BASE, "{}.cfg".format(args.cable)) -flash(config, proxy, args.address, args.file, args.filetype.lower()) +flash(cable, config, proxy, args.address, args.file, args.filetype.lower()) diff --git a/openocd/xilinx-xc7.cfg b/openocd/xilinx-xc7.cfg index 5359d4f..5017632 100644 --- a/openocd/xilinx-xc7.cfg +++ b/openocd/xilinx-xc7.cfg @@ -1,9 +1,3 @@ -interface ftdi -ftdi_vid_pid 0x0403 0x6010 -ftdi_channel 0 -ftdi_layout_init 0x00e8 0x60eb -reset_config none -adapter_khz 25000 source [find cpld/xilinx-xc7.cfg] diff --git a/openocd/xilinx-xc7_openocd_v0.11.cfg b/openocd/xilinx-xc7_openocd_v0.11.cfg index 8f7df34..2cece58 100644 --- a/openocd/xilinx-xc7_openocd_v0.11.cfg +++ b/openocd/xilinx-xc7_openocd_v0.11.cfg @@ -1,13 +1,6 @@ # This file is the same sa xilinx-xc7.cfg, except we use # verify_image instead of verify_bank -interface ftdi -ftdi_vid_pid 0x0403 0x6010 -ftdi_channel 0 -ftdi_layout_init 0x00e8 0x60eb -reset_config none -adapter_khz 25000 - source [find cpld/xilinx-xc7.cfg] # From jtagspi.cfg with modification to support From 4bdfef9a207ea9f0f14f7af626af0a6b10d242dd Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Fri, 24 Sep 2021 14:23:06 +1000 Subject: [PATCH 2/4] mw_debug: Probe cable if unspecified Instead of defaulting to DigilentHS1 Signed-off-by: Benjamin Herrenschmidt --- scripts/mw_debug/mw_debug.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/mw_debug/mw_debug.c b/scripts/mw_debug/mw_debug.c index 4179264..d9fe749 100644 --- a/scripts/mw_debug/mw_debug.c +++ b/scripts/mw_debug/mw_debug.c @@ -220,7 +220,7 @@ static int jtag_init(const char *target) int rc, part; if (!target) - target = "DigilentHS1"; + target = "probe"; sep = strchr(target, ':'); cable = strndup(target, sep - target); if (sep && *sep) { @@ -237,6 +237,15 @@ static int jtag_init(const char *target) } jc->main_part = 0; + if (strcmp(cable, "probe") == 0) { + char *cparams[] = { NULL, NULL,}; + rc = urj_tap_cable_usb_probe(cparams); + if (rc != URJ_STATUS_OK) { + fprintf(stderr, "JTAG cable probe failed\n"); + return -1; + } + cable = strdup(cparams[1]); + } rc = urj_tap_chain_connect(jc, cable, params); if (rc != URJ_STATUS_OK) { fprintf(stderr, "JTAG cable detect failed\n"); From b557ec3a057ab094e66aec0a8f8b0a5810125846 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Fri, 24 Sep 2021 14:23:06 +1000 Subject: [PATCH 3/4] mw_debug: Default to jtag backend if unspecified It avoids typing it all the time Signed-off-by: Benjamin Herrenschmidt --- scripts/mw_debug/mw_debug.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/mw_debug/mw_debug.c b/scripts/mw_debug/mw_debug.c index d9fe749..30803e5 100644 --- a/scripts/mw_debug/mw_debug.c +++ b/scripts/mw_debug/mw_debug.c @@ -744,10 +744,8 @@ int main(int argc, char *argv[]) } } - if (b == NULL) { - fprintf(stderr, "No backend selected\n"); - exit(1); - } + if (b == NULL) + b = &jtag_backend; rc = b->init(target); if (rc < 0) From e6cb72fcd97197d5638a4e0ef0dd68f6df3282c6 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Fri, 24 Sep 2021 14:23:06 +1000 Subject: [PATCH 4/4] Add liteeth/build to gitignore Signed-off-by: Benjamin Herrenschmidt --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0e89c7d..867971b 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ tests/*/*.hex tests/*/*.elf TAGS litedram/build/* +liteeth/build/* obj_dir/*