diff --git a/HACKING b/HACKING index 49355957a3..46db3b8f6f 100644 --- a/HACKING +++ b/HACKING @@ -181,10 +181,6 @@ topics. It is possible because @c for/master is not a traditional Git branch. -# You will need to install this hook, we will look into a better solution: @code -scp -p -P 29418 USERNAME@review.openocd.org:hooks/commit-msg .git/hooks/ -@endcode - Or with http only: -@code wget https://review.openocd.org/tools/hooks/commit-msg mv commit-msg .git/hooks chmod +x .git/hooks/commit-msg diff --git a/configure.ac b/configure.ac index 341ee52e9f..274be15c30 100644 --- a/configure.ac +++ b/configure.ac @@ -383,7 +383,7 @@ AC_ARG_ENABLE([internal-libjaylink], [use_internal_libjaylink=$enableval], [use_internal_libjaylink=no]) AC_ARG_ENABLE([remote-bitbang], - AS_HELP_STRING([--enable-remote-bitbang], [Enable building support for the Remote Bitbang jtag driver]), + AS_HELP_STRING([--enable-remote-bitbang], [Enable building support for the Remote Bitbang driver]), [build_remote_bitbang=$enableval], [build_remote_bitbang=yes]) AS_CASE(["${host_cpu}"], @@ -599,9 +599,9 @@ AS_IF([test "x$use_internal_jimtcl" = "xyes"], [ AS_IF([test "x$build_remote_bitbang" = "xyes"], [ build_bitbang=yes - AC_DEFINE([BUILD_REMOTE_BITBANG], [1], [1 if you want the Remote Bitbang JTAG driver.]) + AC_DEFINE([BUILD_REMOTE_BITBANG], [1], [1 if you want the Remote Bitbang driver.]) ], [ - AC_DEFINE([BUILD_REMOTE_BITBANG], [0], [0 if you don't want the Remote Bitbang JTAG driver.]) + AC_DEFINE([BUILD_REMOTE_BITBANG], [0], [0 if you don't want the Remote Bitbang driver.]) ]) AS_IF([test "x$build_sysfsgpio" = "xyes"], [ diff --git a/contrib/firmware/angie/c/include/i2c.h b/contrib/firmware/angie/c/include/i2c.h index 06185efb4d..d0404923b3 100644 --- a/contrib/firmware/angie/c/include/i2c.h +++ b/contrib/firmware/angie/c/include/i2c.h @@ -19,6 +19,7 @@ void repeated_start(void); void stop_cd(void); void clock_cd(void); void send_ack(void); +void send_nack(void); bool get_ack(void); uint8_t get_address(uint8_t adr, uint8_t rdwr); diff --git a/contrib/firmware/angie/c/src/i2c.c b/contrib/firmware/angie/c/src/i2c.c index a7004bfac9..53840100b9 100644 --- a/contrib/firmware/angie/c/src/i2c.c +++ b/contrib/firmware/angie/c/src/i2c.c @@ -60,6 +60,16 @@ void send_ack(void) delay_us(1); } +void send_nack(void) +{ + PIN_SDA = 1; + delay_us(1); + PIN_SCL = 1; + delay_us(1); + PIN_SCL = 0; + delay_us(1); +} + bool get_ack(void) { PIN_SDA_DIR = 1; diff --git a/contrib/firmware/angie/c/src/usb.c b/contrib/firmware/angie/c/src/usb.c index 747fef1246..1b7aa47658 100644 --- a/contrib/firmware/angie/c/src/usb.c +++ b/contrib/firmware/angie/c/src/usb.c @@ -757,14 +757,13 @@ void i2c_recieve(void) PIN_SDA_DIR = 0; if (EP6FIFOBUF[0] == 1) { uint8_t rdwr = EP6FIFOBUF[0]; //read - uint8_t reg_adr_check = EP6FIFOBUF[1]; - uint8_t count = EP6FIFOBUF[2]; //request data count + uint8_t data_count = EP6FIFOBUF[1]; //data sent count + uint8_t count = EP6FIFOBUF[2]; //requested data count uint8_t adr = EP6FIFOBUF[3]; //address - uint8_t reg_adr = EP6FIFOBUF[4]; uint8_t address = get_address(adr, rdwr); //address byte (read command) uint8_t address_2 = get_address(adr, 0); //address byte 2 (write command) - printf("%d\n", address); + printf("%d\n", address - 1); /* start: */ start_cd(); @@ -773,17 +772,15 @@ void i2c_recieve(void) /* ack: */ uint8_t ack = get_ack(); - delay_us(10); - /* send data */ - if (reg_adr_check) { //if there is a byte reg - send_byte(reg_adr); - /* ack(): */ - ack = get_ack(); + if (data_count) { //if there is a byte reg + for (uint8_t i = 0; i < data_count; i++) { + send_byte(EP6FIFOBUF[i + 4]); + /* ack(): */ + ack = get_ack(); + } } - delay_us(10); - /* repeated start: */ repeated_start(); /* address: */ @@ -791,23 +788,22 @@ void i2c_recieve(void) /* get ack: */ ack = get_ack(); - delay_us(10); - /* receive data */ - for (uint8_t i = 0; i < count; i++) { + for (uint8_t i = 0; i < count - 1; i++) { EP8FIFOBUF[i] = receive_byte(); - /* send ack: */ + /* send ack: */ send_ack(); } - delay_ms(1); + EP8FIFOBUF[count - 1] = receive_byte(); + + /* send Nack: */ + send_nack(); /* stop */ stop_cd(); - delay_us(10); - EP8BCH = 0; //EP8 syncdelay(3); EP8BCL = count; //EP8 diff --git a/contrib/loaders/trampoline/espressif/xtensa/Makefile b/contrib/loaders/trampoline/espressif/xtensa/Makefile new file mode 100644 index 0000000000..bd1f630449 --- /dev/null +++ b/contrib/loaders/trampoline/espressif/xtensa/Makefile @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +# Espressif Xtensa Makefile to compile flasher stub wrapper +# Copyright (C) 2023 Espressif Systems Ltd. + +# Prefix for Espressif xtensa cross compilers (can include a directory path) +CROSS ?= xtensa-esp32-elf- + +APP_ARCH := xtensa +APP_CHIP_PATH := $(shell pwd) +SRCS := $(APP_CHIP_PATH)/esp_xtensa_stub_tramp_win.S + +BIN2C = ../../../../../src/helper/bin2char.sh +BUILD_DIR = build + +APP = esp_xtensa_stub_tramp_win +APP_OBJ = $(BUILD_DIR)/$(APP).o +APP_BIN = $(BUILD_DIR)/$(APP).bin +APP_CODE = $(APP).inc + +.PHONY: all clean + +all: $(BUILD_DIR) $(APP_OBJ) $(APP_CODE) + +$(BUILD_DIR): + $(Q) mkdir $@ + +$(APP_OBJ): $(SRCS) + @echo " CC $^ -> $@" + $(Q) $(CROSS)gcc -c $(CFLAGS) -o $@ $^ + +$(APP_CODE): $(APP_OBJ) + @echo " CC $^ -> $@" + $(Q) $(CROSS)objcopy -O binary -j.text $^ $(APP_BIN) + $(Q) $(BIN2C) < $(APP_BIN) > $@ + +clean: + $(Q) rm -rf $(BUILD_DIR) diff --git a/contrib/loaders/trampoline/espressif/xtensa/esp_xtensa_stub_tramp_win.S b/contrib/loaders/trampoline/espressif/xtensa/esp_xtensa_stub_tramp_win.S new file mode 100644 index 0000000000..e0c827d9f3 --- /dev/null +++ b/contrib/loaders/trampoline/espressif/xtensa/esp_xtensa_stub_tramp_win.S @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/*************************************************************************** + * Xtensa flasher stub wrapper * + * Copyright (C) 2017 Espressif Systems Ltd. * + ***************************************************************************/ + +/* + * Expects : + * a0 = zero + * a1 = stack_base + stack_size - 16, 16 bytes aligned + * a8 = address of the function to call + * Params : + * a2 = command arg0, result (out) + * a3 = command arg1 + * a4 = command arg2 + * a5 = command arg3 + * a6 = command arg4 + * Maximum 5 user args + */ + .text + + .align 4 +_stub_enter: + /* initialize initial stack frame for callx8 */ + addi a9, sp, 32 /* point 16 past extra save area */ + s32e a9, sp, -12 /* access to extra save area */ + /* prepare args */ + mov a10, a2 + mov a11, a3 + mov a12, a4 + mov a13, a5 + mov a14, a6 + /* call stub */ + callx8 a8 + /* prepare return value */ + mov a2, a10 + break 0,0 + +_idle_loop: + j _idle_loop diff --git a/contrib/loaders/trampoline/espressif/xtensa/esp_xtensa_stub_tramp_win.inc b/contrib/loaders/trampoline/espressif/xtensa/esp_xtensa_stub_tramp_win.inc new file mode 100644 index 0000000000..1657223e1b --- /dev/null +++ b/contrib/loaders/trampoline/espressif/xtensa/esp_xtensa_stub_tramp_win.inc @@ -0,0 +1,3 @@ +/* Autogenerated with ../../../../../src/helper/bin2char.sh */ +0x92,0xc1,0x20,0x90,0xd1,0x49,0xad,0x02,0xbd,0x03,0xcd,0x04,0xdd,0x05,0x60,0xe6, +0x20,0xe0,0x08,0x00,0x2d,0x0a,0x00,0x40,0x00,0x06,0xff,0xff, diff --git a/contrib/remote_bitbang/remote_bitbang_sysfsgpio.c b/contrib/remote_bitbang/remote_bitbang_sysfsgpio.c index 9294837e3c..1588eb9a3c 100644 --- a/contrib/remote_bitbang/remote_bitbang_sysfsgpio.c +++ b/contrib/remote_bitbang/remote_bitbang_sysfsgpio.c @@ -1,30 +1,31 @@ // SPDX-License-Identifier: GPL-2.0-or-later /*************************************************************************** + * Copyright (C) 2021 by Manuel Wick * * Copyright (C) 2013 Paul Fertser * * Copyright (C) 2012 by Creative Product Design, marc @ cpdesign.com.au * ***************************************************************************/ /* - This is a test application to be used as a remote bitbang server for - the OpenOCD remote_bitbang interface driver. - - To compile run: - gcc -Wall -ansi -pedantic -std=c99 -o remote_bitbang_sysfsgpio remote_bitbang_sysfsgpio.c - - - Usage example: - - On Raspberry Pi run: - socat TCP6-LISTEN:7777,fork EXEC:"sudo ./remote_bitbang_sysfsgpio tck 11 tms 25 tdo 9 tdi 10" - - On host run: - openocd -c "interface remote_bitbang; remote_bitbang host raspberrypi; remote_bitbang port 7777" \ - -f target/stm32f1x.cfg - - Or if you want to test UNIX sockets, run both on Raspberry Pi: - socat UNIX-LISTEN:/tmp/remotebitbang-socket,fork EXEC:"sudo ./remote_bitbang_sysfsgpio tck 11 tms 25 tdo 9 tdi 10" - openocd -c "interface remote_bitbang; remote_bitbang host /tmp/remotebitbang-socket" -f target/stm32f1x.cfg + * This is a test application to be used as a remote bitbang server for + * the OpenOCD remote_bitbang interface driver. + * + * To compile run: + * gcc -Wall -ansi -pedantic -std=c99 -o remote_bitbang_sysfsgpio remote_bitbang_sysfsgpio.c + * + * + * Usage example: + * + * On Raspberry Pi run: + * socat TCP6-LISTEN:7777,fork EXEC:"sudo ./remote_bitbang_sysfsgpio tck 11 tms 25 tdo 9 tdi 10" + * + * On host run: + * openocd -c "adapter driver remote_bitbang; remote_bitbang host raspberrypi; remote_bitbang port 7777" \ + * -f target/stm32f1x.cfg + * + * Or if you want to test UNIX sockets, run both on Raspberry Pi: + * socat UNIX-LISTEN:/tmp/remotebitbang-socket,fork EXEC:"sudo ./remote_bitbang_sysfsgpio tck 11 tms 25 tdo 9 tdi 10" + * openocd -c "adapter driver remote_bitbang; remote_bitbang host /tmp/remotebitbang-socket" -f target/stm32f1x.cfg */ #include @@ -97,11 +98,14 @@ static void unexport_sysfs_gpio(int gpio) * If the gpio is an output, it is initialized according to init_high, * otherwise it is ignored. * + * When open_rw is set, the file descriptor will be open as read and write, + * e.g. for SWDIO (TMS) that is used as input and output. + * * If the gpio is already exported we just show a warning and continue; if * openocd happened to crash (or was killed by user) then the gpios will not * have been cleaned up. */ -static int setup_sysfs_gpio(int gpio, int is_output, int init_high) +static int setup_sysfs_gpio(int gpio, int is_output, int init_high, int open_rw) { char buf[40]; char gpiostr[4]; @@ -132,7 +136,9 @@ static int setup_sysfs_gpio(int gpio, int is_output, int init_high) } snprintf(buf, sizeof(buf), "/sys/class/gpio/gpio%d/value", gpio); - if (is_output) + if (open_rw) + ret = open(buf, O_RDWR | O_NONBLOCK | O_SYNC); + else if (is_output) ret = open(buf, O_WRONLY | O_NONBLOCK | O_SYNC); else ret = open(buf, O_RDONLY | O_NONBLOCK | O_SYNC); @@ -143,6 +149,37 @@ static int setup_sysfs_gpio(int gpio, int is_output, int init_high) return ret; } +/* + * Change direction for gpio. + */ +static int change_dir_sysfs_gpio(int gpio, int is_output, int init_high) +{ + char buf[40]; + int ret; + + if (!is_gpio_valid(gpio)) + return ERROR_OK; + + snprintf(buf, sizeof(buf), "/sys/class/gpio/gpio%d/direction", gpio); + ret = open_write_close(buf, is_output ? (init_high ? "high" : "low") : "in"); + if (ret < 0) { + LOG_ERROR("Couldn't set direction for gpio %d", gpio); + perror("sysfsgpio: "); + unexport_sysfs_gpio(gpio); + return ERROR_FAIL; + } + + return ERROR_OK; +} + +/* gpio numbers for each gpio. Negative values are invalid */ +static int tck_gpio = -1; +static int tms_gpio = -1; +static int tdi_gpio = -1; +static int tdo_gpio = -1; +static int trst_gpio = -1; +static int srst_gpio = -1; + /* * file descriptors for /sys/class/gpio/gpioXX/value * Set up during init. @@ -154,6 +191,15 @@ static int tdo_fd = -1; static int trst_fd = -1; static int srst_fd = -1; +/* + * GPIO state of /sys/class/gpio/gpioXX/value + */ +static int last_tck = -1; +static int last_tms = -1; +static int last_tms_drive = -1; +static int last_tdi = -1; +static int last_initialized = -1; + /* * Bitbang interface read of TDO * @@ -179,26 +225,22 @@ static int sysfsgpio_read(void) /* * Bitbang interface write of TCK, TMS, TDI * - * Seeing as this is the only function where the outputs are changed, - * we can cache the old value to avoid needlessly writing it. + * Output states are changed here and in sysfsgpio_write_swd, + * which are not used simultaneously, so we can cache the old + * value to avoid needlessly writing it. */ static void sysfsgpio_write(int tck, int tms, int tdi) { const char one[] = "1"; const char zero[] = "0"; - static int last_tck; - static int last_tms; - static int last_tdi; - - static int first_time; size_t bytes_written; - if (!first_time) { + if (!last_initialized) { last_tck = !tck; last_tms = !tms; last_tdi = !tdi; - first_time = 1; + last_initialized = 1; } if (tdi != last_tdi) { @@ -251,13 +293,81 @@ static void sysfsgpio_reset(int trst, int srst) } } -/* gpio numbers for each gpio. Negative values are invalid */ -static int tck_gpio = -1; -static int tms_gpio = -1; -static int tdi_gpio = -1; -static int tdo_gpio = -1; -static int trst_gpio = -1; -static int srst_gpio = -1; +/* + * Bitbang interface set direction of SWDIO (TMS) + */ +static void sysfsgpio_swdio_drive(int is_output) +{ + int ret; + + if (is_output != 0 && last_tms == -1) + last_tms = 0; + + ret = change_dir_sysfs_gpio(tms_gpio, (is_output != 0) ? 1 : 0, last_tms); + if (ret != ERROR_OK) + LOG_WARNING("Failed to change SWDIO (TMS) direction to output"); + else + last_tms_drive = (is_output != 0) ? 1 : 0; +} + +/* + * Bitbang interface read of SWDIO (TMS) + * + * The sysfs value will read back either '0' or '1'. The trick here is to call + * lseek to bypass buffering in the sysfs kernel driver. + */ +static int sysfsgpio_swdio_read(void) +{ + char buf[1]; + + /* important to seek to signal sysfs of new read */ + lseek(tms_fd, 0, SEEK_SET); + int ret = read(tms_fd, &buf, sizeof(buf)); + + if (ret < 0) { + LOG_WARNING("reading swdio (tms) failed"); + return 0; + } + + return buf[0]; +} + +/* + * Bitbang interface write of SWCLK (TCK) and SWDIO (TMS) + * + * Output states are changed here and in sysfsgpio_write, which + * are not used simultaneously, so we can cache the old value + * to avoid needlessly writing it. + */ +static void sysfsgpio_swd_write(int swclk, int swdio) +{ + static const char one[] = "1"; + static const char zero[] = "0"; + + size_t bytes_written; + + if (!last_initialized) { + last_tck = !swclk; + last_tms = !swdio; + last_initialized = 1; + } + + if (last_tms_drive == 1 && swdio != last_tms) { + bytes_written = write(tms_fd, swdio ? &one : &zero, 1); + if (bytes_written != 1) + LOG_WARNING("writing swdio (tms) failed"); + } + + /* write clk last */ + if (swclk != last_tck) { + bytes_written = write(tck_fd, swclk ? &one : &zero, 1); + if (bytes_written != 1) + LOG_WARNING("writing swclk (tck) failed"); + } + + last_tms = swdio; + last_tck = swclk; +} /* helper func to close and cleanup files only if they were valid/ used */ static void cleanup_fd(int fd, int gpio) @@ -293,13 +403,21 @@ static void process_remote_protocol(void) char d = c - 'r'; sysfsgpio_reset(!!(d & 2), (d & 1)); - } else if (c >= '0' && c <= '0' + 7) {/* Write */ + } else if (c >= '0' && c <= '0' + 7) { /* Write */ char d = c - '0'; sysfsgpio_write(!!(d & 4), !!(d & 2), (d & 1)); } else if (c == 'R') putchar(sysfsgpio_read()); + else if (c == 'c') /* SWDIO read */ + putchar(sysfsgpio_swdio_read()); + else if (c == 'o' || c == 'O') /* SWDIO drive */ + sysfsgpio_swdio_drive(c == 'o' ? 0 : 1); + else if (c >= 'd' && c <= 'g') { /* SWD write */ + char d = c - 'd'; + sysfsgpio_swd_write((d & 2), (d & 1)); + } else LOG_ERROR("Unknown command '%c' received", c); } @@ -307,7 +425,7 @@ static void process_remote_protocol(void) int main(int argc, char *argv[]) { - LOG_WARNING("SysfsGPIO remote_bitbang JTAG driver\n"); + LOG_WARNING("SysfsGPIO remote_bitbang JTAG+SWD driver\n"); for (int i = 1; i < argc; i++) { if (!strcmp(argv[i], "tck")) @@ -349,36 +467,39 @@ int main(int argc, char *argv[]) * Configure TDO as an input, and TDI, TCK, TMS, TRST, SRST * as outputs. Drive TDI and TCK low, and TMS/TRST/SRST high. */ - tck_fd = setup_sysfs_gpio(tck_gpio, 1, 0); + tck_fd = setup_sysfs_gpio(tck_gpio, 1, 0, 0); if (tck_fd < 0) goto out_error; - tms_fd = setup_sysfs_gpio(tms_gpio, 1, 1); + tms_fd = setup_sysfs_gpio(tms_gpio, 1, 1, 1); if (tms_fd < 0) goto out_error; + last_tms_drive = 0; - tdi_fd = setup_sysfs_gpio(tdi_gpio, 1, 0); + tdi_fd = setup_sysfs_gpio(tdi_gpio, 1, 0, 0); if (tdi_fd < 0) goto out_error; - tdo_fd = setup_sysfs_gpio(tdo_gpio, 0, 0); + tdo_fd = setup_sysfs_gpio(tdo_gpio, 0, 0, 0); if (tdo_fd < 0) goto out_error; /* assume active low */ if (trst_gpio > 0) { - trst_fd = setup_sysfs_gpio(trst_gpio, 1, 1); + trst_fd = setup_sysfs_gpio(trst_gpio, 1, 1, 0); if (trst_fd < 0) goto out_error; } /* assume active low */ if (srst_gpio > 0) { - srst_fd = setup_sysfs_gpio(srst_gpio, 1, 1); + srst_fd = setup_sysfs_gpio(srst_gpio, 1, 1, 0); if (srst_fd < 0) goto out_error; } + last_initialized = 0; + LOG_WARNING("SysfsGPIO nums: tck = %d, tms = %d, tdi = %d, tdo = %d", tck_gpio, tms_gpio, tdi_gpio, tdo_gpio); LOG_WARNING("SysfsGPIO num: srst = %d", srst_gpio); diff --git a/doc/manual/jtag/drivers/remote_bitbang.txt b/doc/manual/jtag/drivers/remote_bitbang.txt index f394d736af..7c8eee289e 100644 --- a/doc/manual/jtag/drivers/remote_bitbang.txt +++ b/doc/manual/jtag/drivers/remote_bitbang.txt @@ -1,15 +1,19 @@ /** @remote_bitbangpage OpenOCD Developer's Guide -The remote_bitbang JTAG driver is used to drive JTAG from a remote process. The -remote_bitbang driver communicates via TCP or UNIX sockets with some remote -process using an ASCII encoding of the bitbang interface. The remote process -presumably then drives the JTAG however it pleases. The remote process should -act as a server, listening for connections from the openocd remote_bitbang -driver. +The remote_bitbang JTAG+SWD driver is used to drive JTAG and/or SWD from a +remote process. The remote_bitbang driver communicates via TCP or UNIX +sockets with some remote process using an ASCII encoding of the bitbang +interface. The remote process presumably then drives the JTAG/SWD however +it pleases. The remote process should act as a server, listening for +connections from the openocd remote_bitbang driver. The remote bitbang driver is useful for debugging software running on processors which are being simulated. +There also is an implementation of the server-side protocol for the +Glasgow Debug Tool (https://github.com/glasgowEmbedded/Glasgow) through +the jtag-openocd applet. + The bitbang interface consists of the following functions. blink on @@ -24,11 +28,20 @@ write tck tms tdi reset trst srst Set the value of trst, srst. +swdio_drive + Set the output enable of the bidirectional swdio (tms) pin + +swdio_read + Sample the value of swdio (tms). + +swd_write + Set the value of swclk (tck) and swdio (tms). + An additional function, quit, is added to the remote_bitbang interface to indicate there will be no more requests and the connection with the remote driver should be closed. -These five functions are encoded in ASCII by assigning a single character to +These eight functions are encoded in ASCII by assigning a single character to each possible request. The assignments are: B - Blink on @@ -47,7 +60,14 @@ each possible request. The assignments are: s - Reset 0 1 t - Reset 1 0 u - Reset 1 1 + O - SWDIO drive 1 + o - SWDIO drive 0 + c - SWDIO read request + d - SWD write 0 0 + e - SWD write 0 1 + f - SWD write 1 0 + g - SWD write 1 1 -The read response is encoded in ASCII as either digit 0 or 1. +The read responses are encoded in ASCII as either digit 0 or 1. */ diff --git a/doc/openocd.texi b/doc/openocd.texi index 1312c5f777..1f145b9dc8 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2543,32 +2543,44 @@ and a specific set of GPIOs is used. ARM CMSIS-DAP compliant based adapter v1 (USB HID based) or v2 (USB bulk). -@deffn {Config Command} {cmsis_dap_vid_pid} [vid pid]+ +@deffn {Config Command} {cmsis-dap vid_pid} [vid pid]+ The vendor ID and product ID of the CMSIS-DAP device. If not specified the driver will attempt to auto detect the CMSIS-DAP device. Currently, up to eight [@var{vid}, @var{pid}] pairs may be given, e.g. @example -cmsis_dap_vid_pid 0xc251 0xf001 0x0d28 0x0204 +cmsis-dap vid_pid 0xc251 0xf001 0x0d28 0x0204 @end example @end deffn -@deffn {Config Command} {cmsis_dap_backend} [@option{auto}|@option{usb_bulk}|@option{hid}] +@deffn {Config Command} {cmsis-dap backend} [@option{auto}|@option{usb_bulk}|@option{hid}] Specifies how to communicate with the adapter: @itemize @minus @item @option{hid} Use HID generic reports - CMSIS-DAP v1 @item @option{usb_bulk} Use USB bulk - CMSIS-DAP v2 @item @option{auto} First try USB bulk CMSIS-DAP v2, if not found try HID CMSIS-DAP v1. -This is the default if @command{cmsis_dap_backend} is not specified. +This is the default if @command{cmsis-dap backend} is not specified. @end itemize @end deffn -@deffn {Config Command} {cmsis_dap_usb interface} [number] +@deffn {Config Command} {cmsis-dap usb interface} [number] Specifies the @var{number} of the USB interface to use in v2 mode (USB bulk). In most cases need not to be specified and interfaces are searched by interface string or for user class interface. @end deffn +@deffn {Command} {cmsis-dap quirk} [@option{enable}|@option{disable}] +Enables or disables the following workarounds of known CMSIS-DAP adapter +quirks: +@itemize @minus +@item disconnect and re-connect before sending a switch sequence +@item packets pipelining is suppressed, only one packet at a time is +submitted to the adapter +@end itemize +The quirk workarounds are disabled by default. +The command without a parameter displays current setting. +@end deffn + @deffn {Command} {cmsis-dap info} Display various device information, like hardware version, firmware version, current bus status. @end deffn @@ -2839,9 +2851,9 @@ If not specified, default 0xFFFF is used. @end deffn @deffn {Interface Driver} {remote_bitbang} -Drive JTAG from a remote process. This sets up a UNIX or TCP socket connection -with a remote process and sends ASCII encoded bitbang requests to that process -instead of directly driving JTAG. +Drive JTAG and SWD from a remote process. This sets up a UNIX or TCP socket +connection with a remote process and sends ASCII encoded bitbang requests to +that process instead of directly driving JTAG and SWD. The remote_bitbang driver is useful for debugging software running on processors which are being simulated. @@ -3020,7 +3032,7 @@ This driver is for Cypress Semiconductor's KitProg adapters. The KitProg is an SWD-only adapter that is designed to be used with Cypress's PSoC and PRoC device families, but it is possible to use it with some other devices. If you are using this adapter with a PSoC or a PRoC, you may need to add -@command{kitprog_init_acquire_psoc} or @command{kitprog acquire_psoc} to your +@command{kitprog init_acquire_psoc} or @command{kitprog acquire_psoc} to your configuration script. Note that this driver is for the proprietary KitProg protocol, not the CMSIS-DAP @@ -3041,14 +3053,14 @@ versions only implement "SWD line reset". Second, due to a firmware quirk, an SWD sequence must be sent after every target reset in order to re-establish communications with the target. @item Due in part to the limitation above, KitProg devices with firmware below -version 2.14 will need to use @command{kitprog_init_acquire_psoc} in order to +version 2.14 will need to use @command{kitprog init_acquire_psoc} in order to communicate with PSoC 5LP devices. This is because, assuming debug is not disabled on the PSoC, the PSoC 5LP needs its JTAG interface switched to SWD mode before communication can begin, but prior to firmware 2.14, "JTAG to SWD" could only be sent with an acquisition sequence. @end itemize -@deffn {Config Command} {kitprog_init_acquire_psoc} +@deffn {Config Command} {kitprog init_acquire_psoc} Indicate that a PSoC acquisition sequence needs to be run during adapter init. Please be aware that the acquisition sequence hard-resets the target. @end deffn @@ -9403,7 +9415,7 @@ Remove the breakpoint at @var{address} or all breakpoints. Remove data watchpoint on @var{address} or all watchpoints. @end deffn -@deffn {Command} {wp} [address len [(@option{r}|@option{w}|@option{a}) [value [mask]]]] +@deffn {Command} {wp} [address length [(@option{r}|@option{w}|@option{a}) [value [mask]]]] With no parameters, lists all active watchpoints. Else sets a data watchpoint on data from @var{address} for @var{length} bytes. The watch point is an "access" watchpoint unless @@ -9477,8 +9489,9 @@ Return a list of all channels and their properties as Tcl list. The list can be manipulated easily from within scripts. @end deffn -@deffn {Command} {rtt server start} port channel -Start a TCP server on @var{port} for the channel @var{channel}. +@deffn {Command} {rtt server start} port channel [message] +Start a TCP server on @var{port} for the channel @var{channel}. When +@var{message} is not empty, it will be sent to a client when it connects. @end deffn @deffn {Command} {rtt server stop} port @@ -9508,7 +9521,7 @@ TCP/IP port 9090. @deffn {Command} {profile} seconds filename [start end] Profiling samples the CPU's program counter as quickly as possible, which is useful for non-intrusive stochastic profiling. -Saves up to 10000 samples in @file{filename} using ``gmon.out'' +Saves up to 1000000 samples in @file{filename} using ``gmon.out'' format. Optional @option{start} and @option{end} parameters allow to limit the address range. @end deffn @@ -11590,16 +11603,18 @@ NOTE: @file{xtensa-core-XXX.cfg} must match the target Xtensa hardware connected to OpenOCD. Some example Xtensa configurations are bundled with OpenOCD for reference: -@itemize @bullet +@enumerate @item Cadence Palladium VDebug emulation target. The user can combine their @file{xtensa-core-XXX.cfg} with the provided @file{board/xtensa-palladium-vdebug.cfg} to debug an emulated Xtensa RTL design. -@item NXP MIMXRT685-EVK evaluation kit. The relevant configuration files are -@file{board/xtensa-rt685-jlink.cfg} and @file{board/xtensa-core-nxp_rt600.cfg}. -Additional information is provided by -@uref{https://www.nxp.com/design/development-boards/i-mx-evaluation-and-development-boards/i-mx-rt600-evaluation-kit:MIMXRT685-EVK, -NXP}. +@item NXP MIMXRT685-EVK evaluation kit. The relevant configuration files are: +@itemize @bullet +@item @file{board/xtensa-rt685-ext.cfg} +@item @file{target/xtensa-core-nxp_rt600.cfg} @end itemize +Additional information is available by searching for "i.MX RT600 Evaluation Kit" +on @url{https://www.nxp.com}. +@end enumerate @subsection Xtensa Configuration Commands @@ -11624,6 +11639,11 @@ others may be common to both but have different valid ranges. Configure Xtensa target memory. Memory type determines access rights, where RAMs are read/write while ROMs are read-only. @var{baseaddr} and @var{bytes} are both integers, typically hexadecimal and decimal, respectively. + +NOTE: Some Xtensa memory types, such as system RAM/ROM or MMIO/device regions, +can be added or modified after the Xtensa core has been generated. Additional +@code{xtensa xtmem} definitions should be manually added to xtensa-core-XXX.cfg +to keep OpenOCD's target address map consistent with the Xtensa configuration. @end deffn @deffn {Config Command} {xtensa xtmem} (@option{icache}|@option{dcache}) linebytes cachebytes ways [writeback] @@ -11706,6 +11726,12 @@ Execute arbitrary instruction(s) provided as an ascii string. The string repres number of instruction bytes, thus its length must be even. @end deffn +@deffn {Command} {xtensa dm} (address) [value] +Read or write Xtensa Debug Module (DM) registers. @var{address} is required for both reads +and writes and is a 4-byte-aligned value typically between 0 and 0x3ffc. @var{value} is specified +only for write accesses. +@end deffn + @subsection Xtensa Performance Monitor Configuration @deffn {Command} {xtensa perfmon_enable}