openocd.git
2 weeks agojtag: linuxgpiod: drop extra parenthesis 87/8187/2 master
Antonio Borneo [Sun, 24 Mar 2024 21:57:52 +0000 (22:57 +0100)]
jtag: linuxgpiod: drop extra parenthesis

Checkpatch complains for extra parenthesis not required.

Drop them.

Change-Id: I311409f5732acf10a4910de5dcf0fb05f43e21b5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8187
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2 weeks agotarget/mips32: fix clang sbuild check fail 79/8179/2
Walter Ji [Mon, 18 Mar 2024 09:24:51 +0000 (17:24 +0800)]
target/mips32: fix clang sbuild check fail

Initialized `value` variables that could only be set in a branch.

Change-Id: Iec7413ade9d053c93352a58ff954ad49a6545923
Signed-off-by: Walter Ji <walter.ji@oss.cipunited.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8179
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 weeks agoremote_bitbang: Change sleep commands to Zz to avoid conflict with SWD 91/8191/5
J. Neuschäfer [Sat, 30 Mar 2024 12:18:43 +0000 (13:18 +0100)]
remote_bitbang: Change sleep commands to Zz to avoid conflict with SWD

It was noticed that the remote_bitbang protocol has a design issue:
SWD and sleep commands cannot be implemented at the same time, because
they overlap:

 - SWD uses d,e,f,g for setting pin state
 - sleep uses d,D for microsecond and millisecond sleep, respectively

This has previously been reported by Marek Vrbka, but it wasn't fixed.

This commit does the following to resolve the issue:

 - Change the sleep commands to 'Z' for 1 ms, 'z' for 1 µs
 - Document 'D' and 'd' as deprecated aliases
 - Switch the remote_bitbang driver in OpenOCD to 'Z' and 'z'

Unfortunately that's a breaking change, because existing adapter-side
implementations of the protocol will have to implement the new commands
to keep working with future versions of OpenOCD. Fortunately, the
remote sleep commands haven't been part of an OpenOCD release yet,
which should limit the breakage somewhat.

Reported-by: Marek Vrbka <marek.vrbka@codasip.com>
Link: https://sourceforge.net/p/openocd/mailman/openocd-devel/thread/670d28d2-75a1-45ec-afe5-541415701d7a%40codasip.com/
Fixes: e8e09b1b5 ("remote_bitbang: add use_remote_sleep option to send delays to remote")
Change-Id: I04d2790a33bff9d47eb7f69b3275fd9a271625ae
Signed-off-by: J. Neuschäfer <j.neuschaefer@gmx.net>
Reviewed-on: https://review.openocd.org/c/openocd/+/8191
Reviewed-by: David Ryskalczyk <david.rysk@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Jeremy Herbert <jeremy.006@gmail.com>
2 weeks agojtag: linuxgpiod: fix detection for line request bias 86/8186/2
Antonio Borneo [Sun, 24 Mar 2024 15:17:11 +0000 (16:17 +0100)]
jtag: linuxgpiod: fix detection for line request bias

Commit 290eac04b93c ("drivers/linuxgpiod: Migrate to adapter gpio
commands") introduced an incorrect check to determine if the
library libgpiod declares the line request flags:
GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE
GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP
GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN
The names above are declared by the library inside an enum, thus
cannot be used by the C preprocessor in a #ifdef.

Determine in configure if the version of libgpiod provides the
line request flags for "bias" and define a C macro.
Use the new macro in the driver code.

Change-Id: Iaa452230f4753fce4c6e9daa254299cedb7cab7f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 290eac04b93c ("drivers/linuxgpiod: Migrate to adapter gpio commands")
Reviewed-on: https://review.openocd.org/c/openocd/+/8186
Tested-by: jenkins
Reviewed-by: Michael Heimpold <michaheimpold@gmail.com>
2 weeks agoconfigure: prevent build of linuxgpiod with libgpiod v2 85/8185/2
Antonio Borneo [Sun, 24 Mar 2024 14:53:33 +0000 (15:53 +0100)]
configure: prevent build of linuxgpiod with libgpiod v2

The API in libgpiod v2 have changed, and current driver code for
linuxgpiod does not build anymore.

Prevent building the current driver linuxgpiod with the new
library.

Change-Id: Ie673db786dc50ae18a263d2c0a2b46b106866450
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8185
Reviewed-by: Michael Heimpold <michaheimpold@gmail.com>
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 weeks agozynq_7000.cfg: Fix issue 'Error: can't read "zynq_pl": no such variable' 90/8190/2
Dominik Wernberger [Tue, 26 Mar 2024 19:32:22 +0000 (20:32 +0100)]
zynq_7000.cfg: Fix issue 'Error: can't read "zynq_pl": no such variable'

Change-Id: Ic79ce114b60d0707a6e082a81743b378b164b4e2
Signed-off-by: Dominik Wernberger <dominik.wernberger@gmx.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8190
Reviewed-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
3 weeks agoflash/nor/eneispif: support ENE KB1200 ispi flash 36/8136/5
Steven Chang [Sun, 11 Feb 2024 13:34:50 +0000 (21:34 +0800)]
flash/nor/eneispif: support ENE KB1200 ispi flash

Change-Id: I03bccceb1956ee121e6a3728b7d647ef1262fa23
Signed-off-by: Steven Chang <steven@ene.com.tw>
Reviewed-on: https://review.openocd.org/c/openocd/+/8136
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 weeks agotarget/adi_v5_swd: move setting of do_reconnect one level up 55/8155/2
Tomas Vanek [Fri, 16 Feb 2024 16:17:05 +0000 (17:17 +0100)]
target/adi_v5_swd: move setting of do_reconnect one level up

Move setting of do_reconnect flag from swd_run_inner()
to swd_run(). Reconnect is not used at the inner level
and the flag had to be cleared after swd_run_inner()
to prevent recursion.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: Ib1de80bbdf10d1cbfb1dd351c6a5658e50d12af2
Reviewed-on: https://review.openocd.org/c/openocd/+/8155
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
4 weeks agohelper/list: include the correct header file 73/8173/2
Antonio Borneo [Sat, 9 Mar 2024 17:12:36 +0000 (18:12 +0100)]
helper/list: include the correct header file

The file 'list.h', copied from FreeBSD, does not depend from any
OpenOCD specific include file, but only needs 'stddef.h' for the
type 'size_t'.

Let 'list.h' to include the correct header file, then fix the now
broken dependencies in the other files that were incorrectly
relying on 'list.h' to include 'helper/types.h'

Change-Id: Idd31b5bf607e226cac44ef41b2aa335ae4dbf519
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8173
Tested-by: jenkins
4 weeks agohelper/list: Replace Linux code with FreeBSD one 72/8172/2
Antonio Borneo [Sat, 9 Mar 2024 16:53:16 +0000 (17:53 +0100)]
helper/list: Replace Linux code with FreeBSD one

The file list.h was originally taken from the Linux kernel code,
thus under license GPL-2.0-only. This locks OpenOCD to follow the
same license, even if the majority of OpenOCD files are licensed
as GPL-2.0-or-later.

A similar file is also present in FreeBSD code base under the more
permissive license BSD-2-Clause.

Drop the code from Linux kernel and replace it with the code from
FreeBSD 13.3.0.
Adapt the code to OpenOCD coding style by fixing the majority of
issues identified by checkpatch.
Add the OpenOCD specific macros and comments.

Unfortunately this causes the lost of all the doxygen comments.

Checkpatch-ignore: MACRO_ARG_REUSE, MACRO_ARG_PRECEDENCE
Change-Id: I6d86752c50158f3174c4e8c4add81e9998d01e0e
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8172
Tested-by: jenkins
4 weeks agogdb_server: drop useless check in gdb_keep_client_alive() 66/8166/2
Antonio Borneo [Sun, 25 Feb 2024 22:03:27 +0000 (23:03 +0100)]
gdb_server: drop useless check in gdb_keep_client_alive()

OpenOCD can send it's log to gdb, and gdb replies with 'OK'.
Calls to LOG_XXX() are also present in the code that communicates
with gdb. This can cause infinite nested calls.

OpenOCD uses the flag 'gdb_con->busy' to protect the communication
with gdb and prevent nested calls.

There is no reason to check for 'gdb_con->busy' in the code for
keep-alive, as keep_alive() is never called in this gdb server;
the flag would eventually be set if the current keep_alive() will
send something to gdb.

Drop the flag 'gdb_con->busy' in gdb_keep_client_alive().
While there, document the use of 'gdb_con->busy'.

Change-Id: I1ea20bf96abb5d2f1fcdba1e3861df257c396bb6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8166
Tested-by: jenkins
4 weeks agogdb_server: add async-notif keep-alive during memory read/write 65/8165/2
Antonio Borneo [Sun, 25 Feb 2024 21:55:35 +0000 (22:55 +0100)]
gdb_server: add async-notif keep-alive during memory read/write

To avoid gdb to timeout, OpenOCD implements a keep-alive mechanism
that consists in sending periodically to gdb empty strings embedded
in the "O" remote reply packet.

The main purpose of "O" packets is to forward in the gdb console
the output of the remote execution; the gdb-remote puts in the "O"
packet the string that gdb will print. It's use is restricted to
few "running/execution" contexts listed in
http://sourceware.org/gdb/onlinedocs/gdb/Stop-Reply-Packets.html
and this currently limits the keep-alive capabilities of OpenOCD.

Long data transfer (memory R/W) can also cause gdb to timeout if
the interface is too slow. In this case the usual keep-alive based
on "O" packet cannot be used and, if used, would trigger a protocol
error that causes the transfer to be dropped.
The slow transfer rate can be simulated by adding some delay in the
main loop of mem_ap_write() and mem_ap_read(), then using the gdb
commands "dump" and "restore".

In the wait loop during a memory R/W, gdb drops any extra character
received from the gdb-remote that is not recognized as a valid
reply to the memory command. Every dropped character re-initializes
the timeout counter and could be used as keep-alive.

From gdb 7.0 (released 2009-10-06), an asynchronous notification
can also be received from gdb-remote during a memory R/W and has
the effect to reset the timeout counter, thus can be used as
keep-alive.
The notification would be treated as "junk" extra characters by any
gdb older than 7.0, being still valid as keep-alive.
Check putpkt_binary() and getpkt_sane() in gdb commit
74531fed1f2d662debc2c209b8b3faddceb55960

Currently, only one notification packet ("Stop") is recognized by
gdb, and gdb documentation reports that notification packets that
are not recognized should be silently dropped.
Use 'set debug remote 1' in gdb to dump the received notifications
and the junk extra characters.

Add a new level in enum gdb_output_flag for using the asynchronous
notifications.
Activate this new level during memory transfers.
Send a custom "oocd_keepalive" notification packet as keep_alive.
While there, drop a useless return in the switch/case, already
managed in case of break.

After this commit, the proper calls to keep_alive() have to be
added in the loops that code the memory transfers. Of course, the
keep_alive() should be placed during the wait for JTAG flush, not
while locally queuing the JTAG elementary transfers.

Change-Id: I9ca8e78630611597d15984bd0e8634c8fc3c32b9
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8165
Tested-by: jenkins
5 weeks agotarget/mips32: add fpu access support 66/7866/28
Walter Ji [Fri, 17 Nov 2023 08:46:55 +0000 (16:46 +0800)]
target/mips32: add fpu access support

Add access to fpr and cp1 registers.
GDB can now check the FPRs with `info reg f` and change them.
Checkpatch-ignore: MACRO_ARG_REUSE

Change-Id: I63896ab6f6737054d8108db105a13a58e1446fbc
Signed-off-by: Walter Ji <walter.ji@oss.cipunited.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7866
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
5 weeks agoipdbg: configurable queue size used between JTAG-Host and JTAG-Hub 80/7980/11
Daniel Anselmi [Mon, 1 Jan 2024 15:05:07 +0000 (16:05 +0100)]
ipdbg: configurable queue size used between JTAG-Host and JTAG-Hub

Change-Id: I7941de02a968ccab730bfebd3483b8c3b84d7e53
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7980
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
5 weeks agoipdbg: split ipdbg command into multiple commands 79/7979/10
Daniel Anselmi [Mon, 1 Jan 2024 15:05:07 +0000 (16:05 +0100)]
ipdbg: split ipdbg command into multiple commands

To simplify the ipdbg start/stop command and be able to
add additional commands in the future, we introduce the
concept of a hub which has to be created before a
ipdbg server can be started.
The hub was created on the fly in previous versions.

Change-Id: I55f317542d01a7324990b2cacd496a41fa5ff875
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7979
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
5 weeks agoopenocd: dump full command line in the debug log 70/8170/2
Antonio Borneo [Sat, 2 Mar 2024 13:01:07 +0000 (14:01 +0100)]
openocd: dump full command line in the debug log

When receiving an OpenOCD debug log to investigate about errors or
issues, the first question is often about providing the complete
command line to better understand the use context.
Plus, when OpenOCD is lunched by an IDE, its command line is kept
hidden inside the IDE, adding troubles to the user to recover it.

Add the full command line directly inside the debug log.

It could have been useful to also search and add in the log the
full path of the OpenOCD executable, but this is not an immediate
task due to portability among OS's. See, for example:
https://stackoverflow.com/questions/933850
This part could be handled in a future change, if really needed.

Change-Id: Ia6c5b838b9b7208bf1ecac7f95b5efc319aeabf5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8170
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
5 weeks agotarget: aarch64: add support for 32 bit MON mode 69/8169/2
Antonio Borneo [Wed, 28 Feb 2024 12:41:34 +0000 (13:41 +0100)]
target: aarch64: add support for 32 bit MON mode

Extend the existing code to support Monitor mode in AArch32.

Change-Id: Ia43df98d1497baac48aea67b92d81344c24f0635
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8169
Tested-by: jenkins
5 weeks agotarget/adi_v5_swd: fix DP registers banking 54/8154/2
Tomas Vanek [Thu, 15 Feb 2024 09:05:21 +0000 (10:05 +0100)]
target/adi_v5_swd: fix DP registers banking

ADIv6 brought more complicated rules for DP reg 0 banking.
Neither the original implementation [1] nor the later
modification [2] respected that the DP reg 0 is banked
for read only, not for write. Enforcing of an useless
SELECT write before a write to ABORT register may trigger
FAULT (CTRL/STAT bits ORUNDETECT and STICKYORUN are set)
or WAIT (DP is stalled by an outstanding previous operation)
and therefore make ABORT register virtually unusable
on some adapters (bitbang, CMSIS-DAP).

There are DP ABORT specific functions swd_queue_ap_abort()
and swd_clear_sticky_errors() which worked around the problem
using the lowest level swd->write_reg(). Using a specific
write procedure for a single DP register was error prone
(there are other DP_ABORT writes using swd_queue_dp_write_inner())
and also the Tcl command 'xx.dap dpreg 0 value' suffered
from unwanted SELECT write.

Other smaller discords in DP banking probably do not
influence normal DP operation however they may complicate
debugging in corner cases.

Adhere strictly to the DP banking rules for both ADI versions.

Fixes: [1] commit 72fb88613f02 ("adiv6: add low level swd transport")
Fixes: [2] commit ee3fb5a0eacb ("target/arm_adi_v5: fix DP SELECT logic")
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: I3328748c1c3e0661c5ecd6eb070ac519b190ace2
Reviewed-on: https://review.openocd.org/c/openocd/+/8154
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
5 weeks agojtag/drivers/bitbang: limit SWD WAIT retries by timeout 53/8153/2
Tomas Vanek [Sat, 17 Feb 2024 12:14:01 +0000 (13:14 +0100)]
jtag/drivers/bitbang: limit SWD WAIT retries by timeout

The bitbang driver kept retrying a SWD command as long as
the debugged device had been responding by SWD WAIT.
If the DP stalled in WAIT permanently, OpenOCD hanged.

Check 0.5 sec timeout in WAIT retry loop.

While on it insert a short alive_sleep() if the command
is retried 20 or more times.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: I744e56e21a5a2dc2c4494cc0d7bbcb4be14ddb23
Reviewed-on: https://review.openocd.org/c/openocd/+/8153
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
5 weeks agojtag/drivers/bitbang: use LOG_CUSTOM_LEVEL() macro for SWD 52/8152/2
Tomas Vanek [Sat, 17 Feb 2024 11:48:46 +0000 (12:48 +0100)]
jtag/drivers/bitbang: use LOG_CUSTOM_LEVEL() macro for SWD

Log SWD commands with not OK response but WAIT retries at debug level.
For commands responded OK and WAIT retries use debug io level
not to flood the log.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: Idf658e82ed970061c155945df55d06908ed25e09
Reviewed-on: https://review.openocd.org/c/openocd/+/8152
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
5 weeks agohelper/log: add LOG_CUSTOM_LEVEL() macro 51/8151/2
Tomas Vanek [Fri, 16 Feb 2024 16:40:22 +0000 (17:40 +0100)]
helper/log: add LOG_CUSTOM_LEVEL() macro

Allow logging at a changeable level.

Add an example of usage in ftdi driver.
Log SWD commands with not OK response at debug level (3).
For commands which responded OK use debug io level (4)
not to flood the log.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: I67a472b293f7ed9ee84cadb7c081803e9eeb1ad0
Reviewed-on: https://review.openocd.org/c/openocd/+/8151
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
5 weeks agotarget/arm_adi_v5: introduce adiv5_jim_configure_ext() 38/8138/2
Tomas Vanek [Sun, 11 Feb 2024 16:22:38 +0000 (17:22 +0100)]
target/arm_adi_v5: introduce adiv5_jim_configure_ext()

Allow direct pointer to struct adiv5_private_config
for targets with adiv5_private_config inside of a bigger
private config container. Use it instead of the private_config
pointer toggling hack in aarch64.c

Allow optional use of -dap parameter and use it instead
of the static variable hack in xtensa_chip.c

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: I7260c79332940adfa49d57b45cae39325cdaf432
Reviewed-on: https://review.openocd.org/c/openocd/+/8138
Tested-by: jenkins
Reviewed-by: Ian Thompson <ianst@cadence.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
5 weeks agodrivers/cmsis_dap, kitprog: use helper to derive err code from ack 37/8137/2
Tomas Vanek [Fri, 9 Feb 2024 06:35:42 +0000 (07:35 +0100)]
drivers/cmsis_dap, kitprog: use helper to derive err code from ack

Unify the error codes returned by adapter drivers in the case
of the received SWD ACK field differs from OK.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: I29e478390b4b30408054a090ac6a7fac3415ae71
Reviewed-on: https://review.openocd.org/c/openocd/+/8137
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
6 weeks agoflash/nor/nrf5: drop useless for cycle condition 74/8174/2
Tomas Vanek [Sun, 10 Mar 2024 11:12:55 +0000 (12:12 +0100)]
flash/nor/nrf5: drop useless for cycle condition

Commit [1] added a break on error to the nrf5_erase() sector loop
and the checking of the res value became useless in the for loop condition.

Removing nrf5_get_probed_chip_if_halted() later in [2]
dropped res initialization and clang static analyser complains
  "The left operand of '==' is a garbage value"

Drop the useless test!

Fixes: [1] commit 491636c8b832 ("flash/nor/nrf5: check protection before flash erase/write on nRF51")
Fixes: [2] commit 2db325f5395f ("flash/nor/nrf5: drop nrf5_get_probed_chip_if_halted()")
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: Ife6071c509719f8d7dc312fe9a780bdcf2575f69
Reviewed-on: https://review.openocd.org/c/openocd/+/8174
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
6 weeks agotarget/mips32: add dsp access support 67/7867/29
Walter Ji [Fri, 17 Nov 2023 03:27:56 +0000 (11:27 +0800)]
target/mips32: add dsp access support

Add access to dsp registers and a command for dsp related operations.
Checkpatch-ignore: MACRO_ARG_REUSE

Change-Id: I30aec0b9e4984896965edb1663f74216ad41101e
Signed-off-by: Walter Ji <walter.ji@oss.cipunited.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7867
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
6 weeks agogdb_server: fix segfault with GDB command 'flash-erase' 64/8164/2
Antonio Borneo [Sun, 25 Feb 2024 17:36:47 +0000 (18:36 +0100)]
gdb_server: fix segfault with GDB command 'flash-erase'

Running the GDB command 'flash-erase' triggers sending the remote
GDB commands 'vFlashErase' (one per flash bank) followed by one
single 'vFlashDone', with no 'vFlashWrite' commands in between.
This causes the field 'gdb_connection->vflash_image' to be NULL
during the execution of 'vFlashDone', triggering a segmentation
fault in OpenOCD.

While parsing 'vFlashDone', check if any image to flash has been
received.

Change-Id: I443021c7a531255b60f2c44c2685e52e3c34b5c8
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8164
Tested-by: jenkins
6 weeks agomem_ap: fix GDB connections 63/8163/2
Antonio Borneo [Sun, 25 Feb 2024 11:22:44 +0000 (12:22 +0100)]
mem_ap: fix GDB connections

After commit d9b2607ca094 ("gdb_server: support sparse register
maps"), GDB crashes while requesting the value of 'cpsr' because
the fake register is tagged as not existing.

Change the logic and set all register as existing, while still
limiting the list for the initial GDB request at connect.

Change-Id: I1c4e274c06147683db2a59a8920ae5ccd863e15c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8163
Tested-by: jenkins
6 weeks agoflash/nor/nrf5: use BIT() instead of << operator 09/8109/2
Tomas Vanek [Mon, 22 Jan 2024 11:13:46 +0000 (12:13 +0100)]
flash/nor/nrf5: use BIT() instead of << operator

for features flags.

Change-Id: I8bff0f5fac41c50180c847f36c6d2a075eca32ca
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/8109
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
6 weeks agoflash/nor/nrf5: drop nrf5 info command 08/8108/2
Tomas Vanek [Sun, 21 Jan 2024 22:34:30 +0000 (23:34 +0100)]
flash/nor/nrf5: drop nrf5 info command

The command substantially complicates support of nRF53/91
series. It was not even properly ported to nRF52.
The informative value is disputable. Who wants to see
e.g. override trim values for radio or unique device ID?

Drop it and simplify the driver.

Change-Id: Ia7fb20ce2ebf16065705c5d18deaf934e58db426
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/8108
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
6 weeks agoflash/nor/nrf5: drop nrf5_get_probed_chip_if_halted() 07/8107/2
Tomas Vanek [Sun, 21 Jan 2024 17:14:14 +0000 (18:14 +0100)]
flash/nor/nrf5: drop nrf5_get_probed_chip_if_halted()

nrf5_get_probed_chip_if_halted() was somewhat bizarre
combination of functions:
- test if the target is halted is appropriate for flash
  erase/write only, certainly not for getting chip info
- getting chip pointer takes place more frequently
  and using one temporary variable for dereference
  makes no harm
- probing chip is useless at all as the flash
  infrastructure always calls auto_probe() before
  entering a flash operation

Replace the function by ordinary and readable code.

Change-Id: Ic31f4e33d8b7b36687be3f40bfd0fe913d17b75f
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/8107
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
6 weeks agoflash/nor/nrf5: add missing device types 06/8106/2
Tomas Vanek [Sun, 21 Jan 2024 17:08:33 +0000 (18:08 +0100)]
flash/nor/nrf5: add missing device types

from nRF52 family.

Change-Id: I6d2b4586700bb4014c0b77dbf4ea26d1b5dc9715
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/8106
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
6 weeks agoflash/nor/nrf5: add missing package codes 05/8105/2
Tomas Vanek [Sun, 21 Jan 2024 17:00:06 +0000 (18:00 +0100)]
flash/nor/nrf5: add missing package codes

from Product Specification of nRF52805, 810, 811
820, 833 and 840.

While on it, rename the table to make sure the codes
are valid for nRF52 series only.

Change-Id: Id8f78fd214c5d345d1769378ae546a6be5a183ba
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/8105
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
6 weeks agotarget/nrf51: use PAN #16 workaround in reset-init only 04/8104/2
Tomas Vanek [Sun, 21 Jan 2024 15:01:00 +0000 (16:01 +0100)]
target/nrf51: use PAN #16 workaround in reset-init only

After 'reset run' or 'reset halt' the loaded application
is expected to manipulate RAMON register to workaround
the known silicon errata.

Moreover, writing to RAMON register from 'reset-end' event
after 'reset run' may collide with application intentions.

Use the workaround in 'reset-init' event only to ensure
correct function of target algorithms.

Change-Id: I7d2d92e6805a05a83676edb46b3163ef39b9a7e4
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/8104
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
6 weeks agoflash/nor/nrf5, target/nrf51: deprecate nrf51 flash driver 03/8103/2
Tomas Vanek [Sun, 21 Jan 2024 14:55:37 +0000 (15:55 +0100)]
flash/nor/nrf5, target/nrf51: deprecate nrf51 flash driver

Use the newer driver name 'nrf5' instead.

While on it set the unused parameters of flash bank
creation to zero.

While on it remove 2 empty comments.

Change-Id: I9cf0eadc5b696e6c8b7e6aec0ea3345967523e87
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/8103
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
6 weeks agoflash/nor/nrf5: drop unused part of HWIDs table 02/8102/2
Tomas Vanek [Sun, 21 Jan 2024 14:40:37 +0000 (15:40 +0100)]
flash/nor/nrf5: drop unused part of HWIDs table

While on it update table comment and drop
not working URLs.

Change-Id: I9e21c72aa75a908c644460e43c148d3240c49b2d
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/8102
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
7 weeks agogdb_server: don't send unrequested ACK at connection 68/6768/5
Antonio Borneo [Fri, 3 Dec 2021 23:48:23 +0000 (00:48 +0100)]
gdb_server: don't send unrequested ACK at connection

On 2008-03-05, before git's age, commit 6d9501467441 adds sending
an ACK ('+' char) at GDB connection, before receiving any GDB
remote command that requires to be ACK'ed.

Neither the text added in the commit message ("added ACK upon
connection (send +)") nor in the associated comment ("send ACK to
GDB for debug request") provide an exhaustive explanation for
sending this unsolicited ACK.

This code has never been touched since its introduction.

Analysis of GDB code doesn't show it's required, including old GDB
code.
Running gdbserver (from GDB package) and attaching it with "nc"
shows that gdbserver does not send any ACK to a new connection.
Same for lldb-server.

Drop it!

Change-Id: Id68c352ce44dd85a1ea3d67446e17e2a241ef058
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6768
Tested-by: jenkins
Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
Reviewed-by: Anatoly P <anatoly.parshintsev@syntacore.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
7 weeks agotarget/esp_xtensa_smp: don't use coreid as an SMP index 62/8162/2
Erhan Kurubas [Sat, 24 Feb 2024 19:29:41 +0000 (20:29 +0100)]
target/esp_xtensa_smp: don't use coreid as an SMP index

For the sake of https://review.openocd.org/c/openocd/+/7957

Instead of "coreid", 'target smp' command call order used as
an index

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: Iab86b81868d37c0bf8663707ee11367c41f6b96d
Reviewed-on: https://review.openocd.org/c/openocd/+/8162
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 weeks agosrc/jtag/drivers/mpsse: Add support for new FTDI chip types. 34/8134/2
Luca Rufer [Thu, 8 Feb 2024 20:59:47 +0000 (21:59 +0100)]
src/jtag/drivers/mpsse: Add support for new FTDI chip types.

The new FTDI ICs with USB-C Support have different bcdDevice
identifiers. The added bcdDevice identifiers are taken from
the chips datasheet, respectively. The patch was tested with
a FT4232HP IC.
The used bcdDevice IDs can be found in Section 8.1 of the respective
Datasheets:
https://ftdichip.com/wp-content/uploads/2023/09/DS_FT233HP-v1.4.pdf
https://ftdichip.com/wp-content/uploads/2023/09/DS_FT2233HP-v1.4.pdf
https://ftdichip.com/wp-content/uploads/2023/09/DS_FT4233HP-v1.5.pdf

Change-Id: I701083cb72030e398ce1c74310676e13895a77ff
Signed-off-by: Luca Rufer <lucarufer333@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8134
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 months agojtag/commands: fixed buffer overflow 26/8126/3
SydMontague [Fri, 2 Feb 2024 11:12:48 +0000 (12:12 +0100)]
jtag/commands: fixed buffer overflow

When performing a command queue allocation larger than the default page
size of 1MiB any subsequent allocations will run into an integer under-
flow when checking for the remaining memory left in the current page.
Causing the function returning a pointer past the end of the buffer and
thus creating a buffer overflow.

This has been observed to cause some transfers to Efinix FPGAs to fail,
because another buffer can get corrupted in the process, causing its
respective free() to fail.

Change-Id: Ic5a0e1774e2dbd58f1a05127f14816c8251a7d9c
Signed-off-by: SydMontague <sydmontague@phoenix-staffel.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8126
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 months agosrc/target/riscv: Help older compilers 20/8120/2
Sevan Janiyan [Sat, 27 Jan 2024 21:53:11 +0000 (21:53 +0000)]
src/target/riscv: Help older compilers

find members of a union, nested in struct.
Allows file to be compiled with GCC 4.0

Signed-off-by: Sevan Janiyan <venture37@geeklan.co.uk>
Change-Id: Ied68668d3b5f811573a20e11e83aceff268963eb
Reviewed-on: https://review.openocd.org/c/openocd/+/8120
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 months agodriver: Add additional check for count of BYPASS devices 41/7741/3
Kirill Radkin [Fri, 16 Jun 2023 09:09:32 +0000 (12:09 +0300)]
driver: Add additional check for count of BYPASS devices

At least one TAP shouldn't be in BYPASS mode

Change-Id: Ic882acbfc9b6a9f4b0c3bb4741a49f3981503c8c
Signed-off-by: Kirill Radkin <kirill.radkin@syntacore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7741
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 months agoserver/gdb-server: fix type error. 95/8095/6
wangyanwen [Mon, 9 Oct 2023 06:08:59 +0000 (14:08 +0800)]
server/gdb-server: fix type error.

Fix flash operation error when addr-width > 32bit
on any 32-bit OS and some 64-bit OS (windows).

Change-Id: I199f1cc5128c45bd0bb155e37acb2fb6325dff88
Signed-off-by: wangyanwen <wangyanwen@nucleisys.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8095
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2 months agoportability fix: Switch binary literals to hex 23/8123/6
Sevan Janiyan [Sun, 28 Jan 2024 20:34:41 +0000 (20:34 +0000)]
portability fix: Switch binary literals to hex

Allows build with legacy toolchains which do not support
C23 nor GCC extension for binary literals.

Change-Id: I742d3a8a86bf16f81421d11c59d3cb155ee17aed
Signed-off-by: Sevan Janiyan <venture37@geeklan.co.uk>
Reviewed-on: https://review.openocd.org/c/openocd/+/8123
Tested-by: jenkins
Reviewed-by: Jörg Wunsch <openocd@uriah.heep.sax.de>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 months agojep106: update to revision JEP106BI January 2024 32/8132/2
Antonio Borneo [Tue, 6 Feb 2024 21:20:06 +0000 (22:20 +0100)]
jep106: update to revision JEP106BI January 2024

The original documents from Jedec since JEP106BG, do not report
the entry for "21  NXP (Philips)", replaced by "c".
It's clearly a typo.

Keep the line from JEP106BF.01 for "NXP (Philips)".

Change-Id: I293173c4527c2eabebdc33a94cd23d3a557a4618
Signed-off-by: Antonio Borneo <antonio.borneo@st.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8132
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 months agojtag interfaces: Reduce usage of global for jtag queue 45/945/13
Evan Hunter [Wed, 31 Oct 2012 06:51:45 +0000 (17:51 +1100)]
jtag interfaces: Reduce usage of global for jtag queue

Makes driver interface slightly more flexible.

Change-Id: I2c7f5cb6d014e94a0e6122cbe2f4002c77fbabb9
Signed-off-by: Evan Hunter <ehunter@broadcom.com>
Signed-off-by: David Ryskalczyk <david.rysk@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/945
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 months agojtag/drivers: fix reset logic handling in OpenJTAG 21/8121/2
N S [Tue, 23 Jan 2024 05:47:34 +0000 (21:47 -0800)]
jtag/drivers: fix reset logic handling in OpenJTAG

The OpenJTAG driver behaviour always forces a system reset on jtag_init.
The driver was incorrectly assuming that when execute_reset is called
with trst set to 1 - perform a software TAP reset, otherwise perform a
system reset when trst is 0.

The set_state call assumes the that OpenJTAG hardware will perform a
software TLR reset if the target state is TAP_RESET. This is not the
case: the published VHDL will simply find the shortest path to TLR and
not perform a fixed 5 cycle operation with TMS held high.

Fix the code to only perform system resets when srst is 1 in
execute_reset and to force a software TAP reset operation in set_state
when the target state is TAP_RESET.

Change-Id: I7e0f76f8491efefff1ccaeb4b1ae16e722d76df4
Signed-off-by: N S <nlshipp@yahoo.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8121
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 months agojtag/drivers: OpenJTAG standard variant perf improvement 01/8101/2
N S [Mon, 23 Jan 2023 05:34:16 +0000 (21:34 -0800)]
jtag/drivers: OpenJTAG standard variant perf improvement

Calculate exact size of response expected from OpenJTAG device so that
openjtag_buf_read_standard doesn't spend 5 retry cycles waiting for
data that isn't coming.

Change-Id: Icd010d1fa4453d6592a1f9aed93fb1f01e0a19da
Signed-off-by: N S <nlshipp@yahoo.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8101
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 months agojtag: fix jtag configure command containing events 25/8125/2
Antonio Borneo [Thu, 1 Feb 2024 09:55:51 +0000 (10:55 +0100)]
jtag: fix jtag configure command containing events

Commit ea2e26f7d521 ("jtag: rewrite jim_jtag_configure() as
COMMAND_HANDLER") breaks the option -event if it is the last of
the command line.
This can be tested, even without any device connected, through:
#> openocd -f board/ti_cc26x0_launchpad.cfg
wrong # args: should be "-event <event-name> <event-body>"

Fix the check on available arguments after -event.

Change-Id: Iec1522238f906d61a888a09a7685acd9ac6442a7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Lorenz Brun <lorenz@brun.one>
Fixes: ea2e26f7d521 ("jtag: rewrite jim_jtag_configure() as COMMAND_HANDLER")
Reviewed-on: https://review.openocd.org/c/openocd/+/8125
Tested-by: jenkins
Reviewed-by: Lorenz Brun <lorenz@brun.one>
2 months agohelper/log: report the file in `log_output` command 71/8071/3
Evgeniy Naydanov [Wed, 10 Jan 2024 16:23:53 +0000 (19:23 +0300)]
helper/log: report the file in `log_output` command

Prior to the change when calling `log_output` without any arguments it
was unclear where the log was redirected.

Change-Id: Iaa3ecea8166f9c7ec8aad7adf5bd412799f719a1
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8071
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 months agojtag/mpsse: mpsse_flush should not treat LIBUSB_ERROR_INTERRUPTED as an error 69/7769/2
Parshintsev Anatoly [Mon, 10 Jul 2023 13:30:07 +0000 (16:30 +0300)]
jtag/mpsse: mpsse_flush should not treat LIBUSB_ERROR_INTERRUPTED as an error

LIBUSB_ERROR_INTERRUPTED can happen when (among other things) OpenOCD
process receives a signal like SIGHUP or SIGINT during a call to libusb.
Such situations are expected and should not be treated as an error - the
affected request should just be restarted.

Without this patch applied if a signal arrives during FTDI initialization
procedure we can easily end up (if JTAG speed is low) in situations like
https://review.openocd.org/c/openocd/+/4767. This happens because
fpsse_flush fails due to LIBUSB_ERROR_INTERRUPTED .

It should be noted that the current usage of mpsse_flush should be
revised since it seems that we don't always process error codes returned
by the function.

Change-Id: Ifa063ce828068f8d0371e1c2a864bb6174649848
Signed-off-by: Parshintsev Anatoly <anatoly.parshintsev@syntacore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7769
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 months agojtag/drivers: Add vid_pid command to OpenJTAG 00/8100/4
N S [Mon, 22 Jan 2024 01:45:06 +0000 (17:45 -0800)]
jtag/drivers: Add vid_pid command to OpenJTAG

Enable support for USB vid and pid combinations other than 0x0403/0x6001
on OpenJTAG adapters.

Change-Id: Ibb5fb14a6f33abbc011dbf3179df20d79ed74a7a
Signed-off-by: N S <nlshipp@yahoo.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8100
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 months agotarget/cortex_m: fix couple of comments 99/8099/3
Tomas Vanek [Sun, 21 Jan 2024 11:29:14 +0000 (12:29 +0100)]
target/cortex_m: fix couple of comments

Fix obsoleted references to Cortex-M3 from the time
when M3 was the only supported Cortex.

Fix typo.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: I6f93265f1b9328fec063fecd819210deb28aaf2c
Reviewed-on: https://review.openocd.org/c/openocd/+/8099
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 months agotarget/cortex_m: drop useless target_halt() call 98/8098/2
Tomas Vanek [Sun, 21 Jan 2024 11:05:35 +0000 (12:05 +0100)]
target/cortex_m: drop useless target_halt() call

In 2008 the commit 182936125371 ("define resetting
the target into the halted or running state as an atomic operation.")
introduced the target_halt() call to the end of cortex_m3_assert_reset(),

Checkpatch-ignore: GIT_COMMIT_ID

A year later the commit ed36a8d15dfd
("... Updated halt handling for cortex_m3")
prevented cortex_m3_halt() take any action in case of TARGET_RESET state.
This narrowed the target_halt() called from cortex_m3_assert_reset()
to setting target->halt_issued and storing a time stamp.

Introducing ocd_process_reset(_inner) made the setting of halt_issued
and halt_issued_time useless. The Tcl function waits for halt
of all targets if applicable.

cortex_m_halt() and also target_halt() does not work as expected
if the cached target state is TARGET_RESET (although the core could
be out of reset and ready to be halted, just have not been polled).
Explicit Tcl arp_poll must be issued in many scenarios.

Remove the useless hack.

Also remove the explicit error return from cortex_m_halt_one()
in case of RESET_SRST_PULLS_TRST and asserted srst. If the communication
with the target is gated by any reset, cortex_m_write_debug_halt_mask()
fails. Propagate the error return of this call instead.

Change-Id: I0da05b87f43c3d0facb78e54d8f00c1728fe7c46
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/8098
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 months agotarget/cortex_m: prevent asserting reset if examine is deferred 97/8097/2
Tomas Vanek [Sun, 21 Jan 2024 09:15:07 +0000 (10:15 +0100)]
target/cortex_m: prevent asserting reset if examine is deferred

In a corner case when debug_ap is not available,
cortex_m_assert_reset() asserts reset to restore
communication with the target.

Prevent to do so on targets with defer_examine,
as such targets need some special handling to enable them
after reset anyway.

The change makes possible to handle a multicore Cortex-M SoC with
an auxiliary Cortex-M core(s) switched of by default
even with 'reset_config srst_gates_jtag'

Change-Id: I8cec7a816423e588d5e2e4f7904c81c776eddc42
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/8097
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 months agojtag/adapter: retype adapter_gpio_config.{gpio,chip}_num 24/8124/5
Vincent Fazio [Wed, 31 Jan 2024 15:06:20 +0000 (09:06 -0600)]
jtag/adapter: retype adapter_gpio_config.{gpio,chip}_num

Previously, the gpio_num and chip_num members of adapter_gpio_config
were typed as 'int' and a sentinel value of -1 was used to denote
unconfigured values.

Now, these members are typed as 'unsigned int' to better reflect their
expected value range.

The sentinel value now maps to UINT_MAX as all adapters either define an
upper bound for these members or, in the case of bcm2835gpio, only
operate on a specific chip, in which case the value doesn't matter.

Format specifiers have been left as %d since, when configured, valid
values are within the positive range of 'int'. This allows unconfigured
values to display as a more readable value of -1 instead of UINT_MAX.

Change-Id: Ieb20e5327b2e2e443a8e43d8689cb29538a5c9c1
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8124
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 months agojtag/drivers/jlink: make jlink quiet polling target in -d 3 16/8116/2
Tomas Vanek [Mon, 22 Jan 2024 20:25:59 +0000 (21:25 +0100)]
jtag/drivers/jlink: make jlink quiet polling target in -d 3

Jlink driver floods the debug log by a message per one poll interval.

Avoid annoying messages, change their logging level to LOG_DEBUG_IO

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: I84ea6aa9cdfd44b5985c5393519d1efb7de9530a
Reviewed-on: https://review.openocd.org/c/openocd/+/8116
Reviewed-by: zapb <dev@zapb.de>
Tested-by: jenkins
2 months agotarget/esirisc: free memory at OpenOCD exit 94/8094/2
Antonio Borneo [Sun, 14 Jan 2024 16:51:41 +0000 (17:51 +0100)]
target/esirisc: free memory at OpenOCD exit

The target esirisc does not free the allocated memory resources,
causing memory leaks at OpenOCD exit.

Add esirisc_free_reg_cache() and esirisc_deinit_target() and use
them to free all the allocated resources.

Change-Id: I17b8ebff54906fa25a37f2d96c01d010a98cffbd
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8094
Tested-by: jenkins
Reviewed-by: Steven Stallion <sstallion@gmail.com>
2 months agotarget: get_gdb_arch() accepts target via const pointer 93/8093/2
Evgeniy Naydanov [Fri, 12 Jan 2024 13:29:32 +0000 (16:29 +0300)]
target: get_gdb_arch() accepts target via const pointer

The function in question does not need to change target state. It is a
target-type-dependant function, however, IMHO, it is safe to assume that
any target type would not need to change type-independant state of a
target to figure out the arch.

Change-Id: I607cb3aee6529cd5a97bc1200a0226cf6ef43caf
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8093
Tested-by: jenkins
Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 months agotarget: pass target to observers via const pointer 92/8092/2
Evgeniy Naydanov [Thu, 11 Jan 2024 11:02:28 +0000 (14:02 +0300)]
target: pass target to observers via const pointer

There are quite a lot of "getters" in target interface.
They do not change target structure, nevertheless the structure is
passed to these functions via a plain pointer.

The intention is to clarify the purpouse of these functions by passing
the `target` structure as a pointer to constant data.

Change-Id: Ida4a798da94938753b86a293a308d93b091d1bf3
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8092
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 months agotarget/xtensa: add dual-core support 78/8078/5
Ian Thompson [Fri, 19 Jan 2024 00:10:26 +0000 (16:10 -0800)]
target/xtensa: add dual-core support

- Example for configuring multiple non-SMP
  Xtensa cores e.g. for heterogeneous debug
- JTAG only at this time; DAP out of scope
- Dual-Xtensa Palladium example via VDebug
- Update Xtensa core config examples

Signed-off-by: Ian Thompson <ianst@cadence.com>
Change-Id: I6d2b3d13fa8075416dcd383cf256a3e8582ee1c1
Reviewed-on: https://review.openocd.org/c/openocd/+/8078
Tested-by: jenkins
Reviewed-by: Jacek Wuwer <jacekmw8@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 months agojtag/vdebug: add support for DAP6 67/8067/5
Jacek Wuwer [Tue, 9 Jan 2024 13:57:29 +0000 (14:57 +0100)]
jtag/vdebug: add support for DAP6

This change implements the support for the ARM Debug Interface v6.
The DAP-level interface properly selects the DP Banks and AP address.
Sample ARM configuration DAP and JTAG scripts have been updated.

Change-Id: I7df87ef764bca587697c778810443649a7f46c2b
Signed-off-by: Jacek Wuwer <jacekmw8@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8067
Tested-by: jenkins
Reviewed-by: Ian Thompson <ianst@cadence.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 months agojtag/vdebug: fix socket options on CYGWIN 66/8066/2
Jacek Wuwer [Tue, 9 Jan 2024 10:23:56 +0000 (11:23 +0100)]
jtag/vdebug: fix socket options on CYGWIN

the socket option RCVLOWAT is not supported on CYGWIN.
implemented ifdef __CYGWIN not to set this option.

Change-Id: I9f6e81fa98ecf5261ea286deb4675658aae59b8e
Signed-off-by: Jacek Wuwer <jacekmw8@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8066
Tested-by: jenkins
Reviewed-by: Ian Thompson <ianst@cadence.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 months agotarget/xtensa: update COMMAND_HELPER output to use command_print() API 76/8076/3
Ian Thompson [Mon, 8 Jan 2024 18:43:05 +0000 (10:43 -0800)]
target/xtensa: update COMMAND_HELPER output to use command_print() API

- Change LOG_ERROR() and LOG_INFO() output, but
keep DEBUG and WARNING levels for verbosity
- Update command error code return values and
remove unnecessary output.

Signed-off-by: Ian Thompson <ianst@cadence.com>
Change-Id: I4ef0753b3a56be02716f2db43a7d4370a1917237
Reviewed-on: https://review.openocd.org/c/openocd/+/8076
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 months agocontrib/rtos-helpers/uCOS-III-openocd: change license to Apache-2.0 96/7996/3
Antonio Borneo [Thu, 9 Nov 2023 14:18:22 +0000 (15:18 +0100)]
contrib/rtos-helpers/uCOS-III-openocd: change license to Apache-2.0

This file is intended to be included in any user's project that
plans to use OpenOCD awareness for uCOS-III.
It is supposed to be distributed under a license compatible with
the uCOS-III code, that is Apache-2.0 license.

Distribute it under Apache License 2.0.

Change-Id: I51ecd469c8ccdd23a069d21e89b7d90886691395
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7996
Tested-by: jenkins
3 months agoLICENSES: Add the Apache-2.0 license for standalone files 05/8005/3
Antonio Borneo [Sat, 11 Nov 2023 19:10:41 +0000 (20:10 +0100)]
LICENSES: Add the Apache-2.0 license for standalone files

Add the full text of the Apache-2.0 license to the OpenOCD tree.
It has the same content from:

  https://spdx.org/licenses/Apache-2.0.html#licenseText

but reformatted as in the Linux kernel document and added the
required tags for reference and tooling.
While this commit is specific for standalone files, it already
reports the information for dual licensing.

Change-Id: I1fd427256c310ab733fb5d50f344ac52c64a56f5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8005
Tested-by: jenkins
Reviewed-by: Erhan Kurubas <erhan.kurubas@espressif.com>
3 months agojtag/drivers: Correct ANGIE driver and GPIO Extender configuration 79/8079/2
Ahmed BOUDJELIDA [Mon, 15 Jan 2024 14:45:49 +0000 (15:45 +0100)]
jtag/drivers: Correct ANGIE driver and GPIO Extender configuration

Correct GPIO Extender configuration, after reconsideration,
we need to configure the IO extender 0x23 pins as all inputs.

Add more LOG_ERRORs to the code to better track bugs.

Re-organize angie_init function

Change-Id: I1fcf4919ba9ea95576803dd35cce7dafa26853b4
Signed-off-by: Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8079
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 months agojtag/drivers/cmsis_dap_usb_bulk: fix clang warning 45/8045/5
Tomas Vanek [Sun, 10 Dec 2023 14:03:46 +0000 (15:03 +0100)]
jtag/drivers/cmsis_dap_usb_bulk: fix clang warning

Clang static analyzer warnings
"1st function call argument is an uninitialized value"
on the first libusb_free_transfer() parameter (lines 423, 424)
could turn into a real problem in a corner case:
If allocation of a libusb transfer struct fails, the pointers of not yet
allocated transfers remain uninitialized.

Use calloc() to zero whole struct cmsis_dap_backend_data.

Fixes: fd75e9e54270 (jtag/drivers/cmsis_dap_bulk: use asynchronous libusb transfer)
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: I0e489757d82d10ed7416c5e8c215e1facc7f8093
Reviewed-on: https://review.openocd.org/c/openocd/+/8045
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 months agojtag: rewrite jim_jtag_configure() as COMMAND_HANDLER 58/8058/4
Antonio Borneo [Sun, 6 Aug 2023 21:14:15 +0000 (23:14 +0200)]
jtag: rewrite jim_jtag_configure() as COMMAND_HANDLER

The function is used for commands:
- jtag configure
- jtag cget

While there, add the missing .usage field.

Change-Id: I97ddc4898259ddb7fd2d057a997f33a6f4b0e2a8
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8058
Tested-by: jenkins
3 months agocontrib/firmware: Change USB interruption handling for JTAG/I2C communications 74/8074/8
Ahmed BOUDJELIDA [Fri, 22 Dec 2023 09:59:52 +0000 (10:59 +0100)]
contrib/firmware: Change USB interruption handling for JTAG/I2C communications

Before this change, when we send an I2C Bulk data at the same
time while Jtag bitbanging functions execute, the microcontroller
puts JTAG bitbanging on wait and executes all I2C bitbanging
function, which causes problems like loss of Ack in DAP responses
and other errors.

With this commit, When I2C interruption occurs, it sets a variable
to true and continues JTAG bitbanging, when it finish it executes
the I2C bitbang.

Change-Id: Ia80bac21f8a259f4a1176b5346bf74ed0aa6e38b
Signed-off-by: Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8074
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 months agojtag/drivers: Add GPIO extender configuration function to ANGIE driver 72/8072/7
Ahmed BOUDJELIDA [Mon, 11 Dec 2023 13:39:57 +0000 (14:39 +0100)]
jtag/drivers: Add GPIO extender configuration function to ANGIE driver

Add GPIO extender initial configuration that is needed to configure
some important GPIOs and ensure that the dev board is ready to work.

Add i2c_write function that make a write transfer to any slave device.

Give a new Product ID to ANGIE to make it different than the non
programmed ANGIE.

Change-Id: I0a8dacb7fe218145b7d3ed1cb75f106ed6256714
Signed-off-by: Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8072
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 months agojtag/drivers: give ANGIE a new PID after renumeration 91/7991/6
Ahmed BOUDJELIDA [Wed, 6 Dec 2023 14:28:16 +0000 (15:28 +0100)]
jtag/drivers: give ANGIE a new PID after renumeration

Give ANGIE a new PID after renumeration to be able to distinguish
the two cases (programmed and not programmed)

Change-Id: I30a91d8ed2e8e261221488b98d40a027ca41da52
Signed-off-by: Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7991
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 months agojtag/drivers: correct the angie_reset function 90/7990/4
Ahmed BOUDJELIDA [Mon, 4 Dec 2023 09:58:05 +0000 (10:58 +0100)]
jtag/drivers: correct the angie_reset function

remove angie_clear_queue function from executing before the
angie_execute_queued_commands function and making it at the
end of the reset function.

Change-Id: Id8a0664fbd5b8f9730545ce0f8f272ae0b0e7e78
Signed-off-by: Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7990
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 months agocontrib/firmware: Add direction control for 'SCL' i2c signal 89/7989/4
Ahmed BOUDJELIDA [Wed, 29 Nov 2023 14:21:27 +0000 (15:21 +0100)]
contrib/firmware: Add direction control for 'SCL' i2c signal

We want to keep the tri-state buffers located between the FPGA
and the board, in 'Z' state until we launch an i2c connection.

We launch an i2c start condition, make the SCL
direction 'OUT' to start the i2c protocol and at the end
of the i2c connection at the stop condition, we re-make
the tri-state buffers at 'Z' state.

Change-Id: Ic597a70d0427832547f6b539864c24ce20a18c64
Signed-off-by: Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7989
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 months agojtag/drivers: send bitstream size to firmware via libusb 88/7988/4
Ahmed BOUDJELIDA [Tue, 21 Nov 2023 16:45:55 +0000 (17:45 +0100)]
jtag/drivers: send bitstream size to firmware via libusb

Send bitstream size to firmware to initialize the GPIF count registers,
since we're going to send this size via GPIF, we need to give the exact
number of bytes to be sent, then the GPIF counter will decrement with
every clock cycle (every byte sent) until reaching zero and stops.

Change-Id: Ib4e8e0f95a6a4a95ef4888ba8a04a0ea45567f5a
Signed-off-by: Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7988
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 months agocontrib/firmware: update gpif FSM configuration file 76/7976/5
Ahmed BOUDJELIDA [Wed, 15 Nov 2023 10:26:28 +0000 (11:26 +0100)]
contrib/firmware: update gpif FSM configuration file

Change the GPIF state machine, configuring only one of the 4 waveforms
to generate the clock signal (CCLK) used to program the FPGA, and send
one byte every cycle using an 8-bit bus.

Change-Id: I43cf5480b9d5c40cc2f6a62a52ecfe078b76458e
Signed-off-by: Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7976
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
3 months agotarget/mips32: fix false positive from clang 65/8065/3
Antonio Borneo [Sat, 6 Jan 2024 16:54:24 +0000 (17:54 +0100)]
target/mips32: fix false positive from clang

clang build triggers an error for an uninitialized value of the
variable 'instr'.
This is a false positive, as the macro
 #define MIPS32_CONFIG3_ISA_MASK (3 << MIPS32_CONFIG3_ISA_SHIFT)
guarantees the switch/case already covers all the possible values
with cases 0, 1, 2 and 3.

Silent clang by adding a useless default case to the switch.
While there, fix the indentation of the switch/case accordingly to
OpenOCD coding style.

Change-Id: I0ae316754ce7d091dd8366bf314b8e6ee780e313
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 7de4b1202d50 ("target/mips32: add cpu info detection")
Reviewed-on: https://review.openocd.org/c/openocd/+/8065
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 months agotarget/xtensa: enable xtensa algo support 75/8075/2
ianst [Wed, 1 Nov 2023 23:41:43 +0000 (16:41 -0700)]
target/xtensa: enable xtensa algo support

- Add extra error checking
- Cache PS; lower PS.INTLEVEL to allow  breakpoint trigger (LX)
- Xtensa algo support functional on LX per functional flash driver
- Test on NX via manual algo validation

Change-Id: Ie7cff4933979a0551308b382fa33c33c66376f25
Signed-off-by: ianst <ianst@cadence.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8075
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Tested-by: jenkins
3 months agohelper/command: pass command arguments also as Jim_Obj 57/8057/4
Antonio Borneo [Sun, 6 Aug 2023 10:38:54 +0000 (12:38 +0200)]
helper/command: pass command arguments also as Jim_Obj

Some OpenOCD command gets fragment of TCL scripts as command-line
argument, fragments that will be kept and executed later on.
E.g. the command 'configure' gets the body of an OpenOCD event:
$TARGET configure -event halted {TCL code}

These commands store the argument as a Jim_Obj and pass it to the
jimtcl interpreter when the TCL fragment has to be executed.
Using Jim_Obj as storage is relevant to let the jimtcl interpreter
to recover extra info of the TCL fragment, like the file-name and
the line-number that contain the fragment, that will be printed
out in case of run-time errors.

While converting the commands to COMMAND_HANDLER, we should avoid
storing the argument as C strings otherwise we will loose precious
info in case of run-time errors making challenging the debugging
of such TCL fragments.

Extend the struct command_invocation to contain the array that
points to the Jim_Obj of the command arguments.
This will be used while converting commands to COMMAND_HANDLER.

Change-Id: If37c5f20e9a71349f77ba1571baf1e6778e28aa5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8057
Tested-by: jenkins
3 months agohelper/command: inline run_command() in exec_command() 56/8056/4
Antonio Borneo [Sun, 6 Aug 2023 10:26:25 +0000 (12:26 +0200)]
helper/command: inline run_command() in exec_command()

Simplify the command execution by inlining run_command() inside
exec_command().

Change-Id: Id932b006846720cfd867d22d142cd35831dbd1a2
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8056
Tested-by: jenkins
3 months agohelper/command: simplify exec_command() 55/8055/4
Antonio Borneo [Sun, 6 Aug 2023 09:34:28 +0000 (11:34 +0200)]
helper/command: simplify exec_command()

The jimtcl interpreter guarantees that the Jim objects in argv[]
are not deallocated during the command execution. Thus, there is
no need to copy the string content of argv[].

Simplify exec_command() by inlining its two sub-functions and
dropping the strdup().

While there, add a LOG_ERROR() for out of memory.

Change-Id: I3e21ed7da50ca0bd072edbd49fca9740c81f95b0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8055
Tested-by: jenkins
3 months agohelper/command: simplify script_command_args_alloc() 54/8054/4
Antonio Borneo [Sun, 6 Aug 2023 08:32:46 +0000 (10:32 +0200)]
helper/command: simplify script_command_args_alloc()

The output parameter nwords is always equal to the input parameter
argc, when the function succeeds.

Drop the parameter nwords and let the caller use directly the
value in argc.

While there, convert some 'unsigned' to 'unsigned int'.

Change-Id: Ie3d8ce1351792f3c07fe39cdcbcd180fd24dc928
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8054
Tested-by: jenkins
3 months agohelper/command: drop unused variables 53/8053/3
Antonio Borneo [Sun, 6 Aug 2023 08:40:03 +0000 (10:40 +0200)]
helper/command: drop unused variables

In both functions script_debug() and script_command_args_alloc()
the variable len is never used, and Jim_GetString() does not
mandate it.

Drop the variable and pass NULL to Jim_GetString().

Change-Id: I754b27a59c6087cde729496be42609d2a7145b0c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8053
Tested-by: jenkins
3 months agotarget: drop deprecated code for mem2array and array2mem 52/8052/2
Antonio Borneo [Sun, 3 Dec 2023 17:10:45 +0000 (18:10 +0100)]
target: drop deprecated code for mem2array and array2mem

Commit e370e06b724f ("target: Deprecate 'array2mem' and
'mem2array''") has already replaced the deprecated root versions
of commands mem2array and array2mem with TCL proc's that use
'read_memory' and 'write_memory'. It has left the deprecated code
of the target's version of the commands because the effort to code
the TCL replacement was not considered valuable.

To drop the last jim_handler commands, I consider much easier and
less error-prone to code them in TCL instead of converting the
deprecated code to COMMAND_HANDLER.

Drop the code in target.c and extend the TCL proc's.
While there, add the TCL procs to _telnet_autocomplete_skip.

Change-Id: I97d2370d8af479434ddf5af68541f90913982bc0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8052
Tested-by: jenkins
3 months agoLICENSES: drop SPDX tag 'GPL-2.0' and use 'GPL-2.0-only' 64/8064/2
Antonio Borneo [Thu, 4 Jan 2024 21:26:38 +0000 (22:26 +0100)]
LICENSES: drop SPDX tag 'GPL-2.0' and use 'GPL-2.0-only'

The SPDX tag 'GPL-2.0' has been deprecated in
https://spdx.org/licenses/GPL-2.0.html
and the preferred tag is now 'GPL-2.0-only'
https://spdx.org/licenses/GPL-2.0-only.html

Update the LICENSES documents and the SPDX of the only file that
reports the deprecated tag.

Change-Id: I3c3215438bc4378ff470bb9fa8fa962505a9ae50
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8064
Tested-by: jenkins
3 months agotarget/arc: skip over breakpoints in arc_resume() 17/7817/3
Evgeniy Didin [Thu, 30 Jul 2020 21:13:12 +0000 (00:13 +0300)]
target/arc: skip over breakpoints in arc_resume()

When requested by the core code (handle_breakpoints = true),
arc_resume() should be able to advance over a potential breakpoint set
at the resume address instead of getting stuck in one place. This is
achieved by removing the breakpoint, executing one instruction,
resetting the breakpoint, then proceeding forward as normal.

With this patch applied, openocd is now able to resume from a
breakpoint halt when debugging ARCv2 targets via telnet.

This has previously been committed to the Zephyr project's openocd repo
(see https://github.com/zephyrproject-rtos/openocd/pull/31).

Change-Id: I17dba0dcea311d394b303c587bc2dfaa99d67859
Signed-off-by: Evgeniy Didin <didin@synopsys.com>
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Signed-off-by: Artemiy Volkov <artemiy@synopsys.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7817
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
3 months agotarget/arc: restore breakpoints in arc_resume() 16/7816/3
Evgeniy Didin [Thu, 30 Jul 2020 21:13:12 +0000 (00:13 +0300)]
target/arc: restore breakpoints in arc_resume()

Presently, we rely on gdb to restore break/watchpoints upon resuming
execution in arc_resume(). To match this behavior in absence of gdb
(more specifically, when handle_breakpoints is true), this patch
explicitly re-enables all breakpoints and watchpoints in arc_resume().

This has previously been committed to the Zephyr project's openocd repo
(see https://github.com/zephyrproject-rtos/openocd/pull/31).

Change-Id: I59e9c91270ef0b5fd19cfc570663dc67a6022dbd
Signed-off-by: Evgeniy Didin <didin@synopsys.com>
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Signed-off-by: Artemiy Volkov <artemiy@synopsys.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7816
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 months agotarget/xtensa: extra debug info for "xtensa exe" failures 82/7982/3
ianst [Wed, 6 Dec 2023 22:34:09 +0000 (14:34 -0800)]
target/xtensa: extra debug info for "xtensa exe" failures

- Read and display EXCCAUSE on exe error
- Clean up error messages
- Clarify "xtensa exe" documentation

Signed-off-by: ianst <ianst@cadence.com>
Change-Id: I90ed39f6afb6543c0c873301501435384b4dccbe
Reviewed-on: https://review.openocd.org/c/openocd/+/7982
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 months agocortex_m: add detection of MVE feature for Armv8.1-M cores 50/6950/4
Tarek BOCHKATI [Thu, 28 Apr 2022 02:46:35 +0000 (03:46 +0100)]
cortex_m: add detection of MVE feature for Armv8.1-M cores

For Armv8.1-M based cores, detect if the core implements the optional
M-profile vector extension (MVE), using MVFR1 register.

While at there rework armv7m->fp_feature detection based on MVFR0
and MVFR1 registers.

Change-Id: I92d5b1759aea9f7561d285f46acdec51d6efb7b4
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6950
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
3 months agoipdbg: improve ipdbg-host speed 78/7978/6
Daniel Anselmi [Sun, 12 Mar 2023 00:43:32 +0000 (01:43 +0100)]
ipdbg: improve ipdbg-host speed

By queuing multiple jtag transfers the connection speed between
JTAG-Host and JTAG-Hub is improved. This is due to much less
calls to OS functions. An improvement of about x30 has been
measured with ftdi-based jtag adapters

For this to work the JTAG-Host server needs to know if flow control
is enabled on the JTAG-Hub ports. This is possible with newer
JTAG-Hub/JtagCDC. For old JTAG-Hubs the queuing is not enabled so
this change is backwards compatible.

Change-Id: I8a5108adbe2a2c1e3d3620b5c9ff77a546bfc14e
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7978
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 months agojtag/drivers/cmsis_dap: use oocd_libusb_dev_mem_alloc() helper 44/8044/6
Tomas Vanek [Sun, 10 Dec 2023 10:58:43 +0000 (11:58 +0100)]
jtag/drivers/cmsis_dap: use oocd_libusb_dev_mem_alloc() helper

On some systems (at least Windows/CYGWIN and macOS) libusb_dev_mem_alloc()
simply returns NULL. The helper can fall-back to malloc() to allocate
CMSIS-DAP pending command/response buffers.

Fixes: fd75e9e54270 (jtag/drivers/cmsis_dap_bulk: use asynchronous libusb transfer)
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: I89660f6747ad9d494b8192711cbbee5764e058fa
Reviewed-on: https://review.openocd.org/c/openocd/+/8044
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
3 months agodrivers/libusb_helper: introduce oocd_libusb_dev_mem_alloc() helper 59/8059/3
Tomas Vanek [Wed, 20 Dec 2023 12:20:27 +0000 (13:20 +0100)]
drivers/libusb_helper: introduce oocd_libusb_dev_mem_alloc() helper

On some systems (at least Windows/CYGWIN and macOS) libusb_dev_mem_alloc()
simply returns NULL.

Use the result of the very first libusb_dev_mem_alloc() call to decide
if the underlining system supports dev mem allocation or we should
fall-back to plain heap malloc().

From the decision time on, keep using the selected type of memory allocator
and deallocator.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: Ia1f0965cea44b4bb6d936b02ec43f5a16a46f080
Reviewed-on: https://review.openocd.org/c/openocd/+/8059
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 months agotarget/adiv5: probe MEM-AP supported transfer sizes including large data 76/7576/4
Tomas Vanek [Sun, 2 Apr 2023 15:23:46 +0000 (17:23 +0200)]
target/adiv5: probe MEM-AP supported transfer sizes including large data

Based on Daniel Goehring's [1] and Peter Collingbourne's [2] work.

Probe for support of 8, 16 bit and if the large data extension is available
also probe for 64, 128 and 256 bit operations.
Probe for the ability of packing 8 and 16 bit data
(formerly probed in mem_ap_init()). The probe is integrated to
mem_ap_read/write() routines and takes place just before the first memory
access of the specific size.

Add 64, 128 and 256 bit MEM-AP read/writes.

Introduce specific error codes for unsupported transfer size
and for unsupported packing.

Change-Id: I180c4ef17d2fc3189e8e2f14bafd22d857f29608
Link: 7191: target/adiv5: add MEM-AP 64-bit access support | https://review.openocd.org/c/openocd/+/7191
Link: 7436: arm_adi_v5: Support reads wider than 32 bits | https://review.openocd.org/c/openocd/+/7436
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7576
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
3 months agotarget/arm_adi_v5: rework Nuvoton NPCX quirk workaround. 75/7575/3
Tomas Vanek [Sun, 2 Apr 2023 16:49:12 +0000 (18:49 +0200)]
target/arm_adi_v5: rework Nuvoton NPCX quirk workaround.

Prevent packed writes with Nuvoton NPCX quirks because the workaround
uses all byte lanes for one byte or halfword and thus precludes packing.

Eliminate quirk code for size 4 as it is equivalent to the common code.

Make the quirk code for sizes 2 and 1 easier readable.

Change-Id: I72324e56a49b4712bd3769e03dce01427d9fcd73
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7575
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 months agotarget/arm_adi_v5: simplify TI BE 32 quirk workaround 74/7574/6
Tomas Vanek [Sun, 2 Apr 2023 16:27:17 +0000 (18:27 +0200)]
target/arm_adi_v5: simplify TI BE 32 quirk workaround

Introduce ti_be_lane_xor for byte lane correction
and use common code for both quirk and regular conversion.
The same lane correction takes place in both mem_ap_read/write()
- it was obfuscated in original code with different bitwise and arithmetic
operations.

Change-Id: I6a30672b908770323d30813a714e06ab8695fe26
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7574
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 months agoflash/nor/kinetis: add support for NXP S32K series 12/8012/9
David Vidrie Leon [Wed, 27 Apr 2022 18:45:04 +0000 (14:45 -0400)]
flash/nor/kinetis: add support for NXP S32K series

S32K General-Purpose Microcontrollers

Scalable, low-power Arm® Cortex®-M series-based microcontrollers AEC-Q100
qualified with advanced safety and security and software support for
industrial and automotive ASIL B/D applications in body, zone control,
and electrification.

Change-Id: I4143258535437c18b81802436267bfd561de9d31
Signed-off-by: David Vidrie Leon <davidvidrie@geotab.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8012
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
3 months agodoc: `address` is optional in `*_image` commands 61/8061/3
Evgeniy Naydanov [Mon, 25 Dec 2023 10:03:54 +0000 (13:03 +0300)]
doc: `address` is optional in `*_image` commands

Change-Id: I3d4320634bf59be18bbcb22c9e4b13a3ccd7a45a
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8061
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
3 months agotarget/mips32: optimize pracc access 65/7865/26
Walter Ji [Tue, 29 Aug 2023 05:27:49 +0000 (13:27 +0800)]
target/mips32: optimize pracc access

Update mips32 instructions, add barrier and sync related insts.
Add SYNC and barrier instruction blocks for memory access safety.

These instructions are not supported on Lexra and/or MIPSr1 CPUs,
detections were added and they will be executed conditionally.

Rework mips32_pracc_read/write_regs function.
Checkpatch-ignore: MACRO_ARG_REUSE

Change-Id: Ib14112f37ff1f060b1633df73d671a6b09bb2178
Signed-off-by: Walter Ji <walter.ji@oss.cipunited.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7865
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 months agotarget/mips32: add mips ejtag command 06/7906/21
Walter Ji [Fri, 17 Nov 2023 07:13:55 +0000 (15:13 +0800)]
target/mips32: add mips ejtag command

Add mips32 ejtag_reg command for inspecting ejtag status.
Add description for mips32 ejtag_reg command.

Change-Id: Icd173d3397d568b0c004a8cc3f45518d7b48ce43
Signed-off-by: Walter Ji <walter.ji@oss.cipunited.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7906
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
3 months agotarget/mips32: update coprocessor 0 command 05/7905/21
Walter Ji [Fri, 17 Nov 2023 07:13:21 +0000 (15:13 +0800)]
target/mips32: update coprocessor 0 command

Update mips32 cp0 command, it accepts cp0 reg names now.
Updated mips32 cp0 description.

Change-Id: Ib23dd13519def77a657c9c5bb039276746207b9b
Signed-off-by: Walter Ji <walter.ji@oss.cipunited.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7905
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Tested-by: jenkins
3 months agotarget/mips32: add cpu info detection 12/7912/16
Walter Ji [Tue, 26 Sep 2023 09:21:42 +0000 (17:21 +0800)]
target/mips32: add cpu info detection

Add detection for mips cpu types by using prid.
Add cpuinfo command for inspecting more verbose info.
Add MIPS Architecture specs in openocd docs.

Change-Id: I28573b7c51783628db986bad0e226dcc399b4fa6
Signed-off-by: Walter Ji <walter.ji@oss.cipunited.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7912
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)