openocd.git
2 days agoDocumentation: fix warning "unbalanced square brackets" 61/8261/2 master
R. Diez [Sun, 12 May 2024 16:45:16 +0000 (18:45 +0200)]
Documentation: fix warning "unbalanced square brackets"

Change-Id: I17b716533f5c9371600f0d932bf9b81c95c349e7
Signed-off-by: R. Diez <rdiezmail-openocd@yahoo.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8261
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 days agoDocumentation: Fix 2 warnings "Underfull \hbox (badness 10000)" 64/8264/2
R. Diez [Sun, 12 May 2024 20:03:08 +0000 (22:03 +0200)]
Documentation: Fix 2 warnings "Underfull \hbox (badness 10000)"

The link to product GW16042 was broken, so it has been reduced to
the manufacturer's website, which fixes the warning as a side effect.

The link to Raisonance RLink was broken, and the new one is shorter,
which fixes the warning as a side effect.

Change-Id: I4df9acf2d994d51cd8f375bdac6c803270029506
Signed-off-by: R. Diez <rdiezmail-openocd@yahoo.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8264
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 days agoChangeLog: fix warning "Wide character in print" from git2cl 62/8262/2
R. Diez [Sun, 12 May 2024 18:50:34 +0000 (20:50 +0200)]
ChangeLog: fix warning "Wide character in print" from git2cl

Change-Id: Iaefd989413753fb59642c3887807abd6ddac4b53
Signed-off-by: R. Diez <rdiezmail-openocd@yahoo.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8262
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2 days agoconfigure.ac: show the dummy adapter in the configuration summary 40/7340/3
R. Diez [Sun, 21 Apr 2024 20:58:21 +0000 (22:58 +0200)]
configure.ac: show the dummy adapter in the configuration summary

The dummy adapter now uses the same config logic as most adapters.
Its name has changed from "dummy port driver" to "Dummy Adapter".

Change-Id: Ic9ee617aab1f54215835d4d8db03f6637b797082
Signed-off-by: R. Diez <rdiezmail-openocd@yahoo.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/7340
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 days agoopenocd: drop include of target_type.h 60/8260/2
Antonio Borneo [Mon, 8 Apr 2024 23:29:34 +0000 (01:29 +0200)]
openocd: drop include of target_type.h

Few files include target_type.h even if it is not needed.
Drop the include.

Other files access directly to target type's name instead of using
the proper API target_type_name().
Use the API and drop the include.

Change-Id: I86c0e0bbad51db93500c0efa27b7d6f1a67a02c2
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8260
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 days agoFix build with clang even if it sets __GNUC__ to >= 4.4 58/8258/2
Bernhard Rosenkränzer [Thu, 9 May 2024 13:30:13 +0000 (15:30 +0200)]
Fix build with clang even if it sets __GNUC__ to >= 4.4

clang doesn't support the gnu_printf attribute that OpenOCD uses if
__GNUC__ and __GNUC_MINOR__ indicates gcc >= 4.4.

Most clang builds set __GNUC__/__GNUC_MINOR__ to 4.2 for historical
reasons, so they don't trigger this condition; however, some builds set
it to something much higher to work around code using __GNUC__ to
determine if a feature that does exist in clang (but not gcc 4.2) is
available, causing OpenOCD to use attribute gnu_printf.

The problem can be reproduced without a special clang build by adding
-fgnuc-version=14.1 to CFLAGS.

Change-Id: I3c0832d4201578b116c5214203f95b6153dad30e
Signed-off-by: Bernhard Rosenkränzer <bero@baylibre.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8258
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 days agotarget/semihosting: Fix double free() 57/8257/5
Marc Schink [Wed, 1 May 2024 08:24:32 +0000 (10:24 +0200)]
target/semihosting: Fix double free()

Do not free the service in 'connection_closed_handler' because it is
free'd by the server infrastructure.

Checkpatch-ignore: COMMIT_LOG_LONG_LINE

This error was detected with valgrind:

==272468== Invalid free() / delete / delete[] / realloc()
==272468==    at 0x484B27F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==272468==    by 0x1F34C7: remove_service (server.c:374)
==272468==    by 0x2ED3D5: semihosting_tcp_close_cnx (semihosting_common.c:1819)
==272468==    by 0x2ED3D5: handle_common_semihosting_redirect_command (semihosting_common.c:1926)
==272468==    by 0x1FC703: exec_command (command.c:520)
==272468==    by 0x1FC703: jim_command_dispatch (command.c:931)
==272468==    by 0x36980F: JimInvokeCommand (in /home/marc/openocd/build/src/openocd)
==272468==    by 0x1FFFFFFFFF: ???
==272468==    by 0x53ED09F: ???
==272468==    by 0x300000001: ???
==272468==    by 0x1FFEFFF7FF: ???
==272468==    by 0x3D3984: ??? (in /home/marc/openocd/build/src/openocd)
==272468==    by 0x2: ???
==272468==  Address 0x5fff650 is 0 bytes inside a block of size 24 free'd
==272468==    at 0x484B27F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==272468==    by 0x2ECA42: semihosting_service_connection_closed_handler (semihosting_common.c:1807)
==272468==    by 0x1F2E39: remove_connection.isra.0 (server.c:164)
==272468==    by 0x1F349E: remove_connections (server.c:350)
==272468==    by 0x1F349E: remove_service (server.c:364)
==272468==    by 0x2ED3D5: semihosting_tcp_close_cnx (semihosting_common.c:1819)
==272468==    by 0x2ED3D5: handle_common_semihosting_redirect_command (semihosting_common.c:1926)
==272468==    by 0x1FC703: exec_command (command.c:520)
==272468==    by 0x1FC703: jim_command_dispatch (command.c:931)
==272468==    by 0x36980F: JimInvokeCommand (in /home/marc/openocd/build/src/openocd)
==272468==    by 0x1FFFFFFFFF: ???
==272468==    by 0x53ED09F: ???
==272468==    by 0x300000001: ???
==272468==    by 0x1FFEFFF7FF: ???
==272468==    by 0x3D3984: ??? (in /home/marc/openocd/build/src/openocd)
==272468==  Block was alloc'd at
==272468==    at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==272468==    by 0x2ED326: handle_common_semihosting_redirect_command (semihosting_common.c:1931)
==272468==    by 0x1FC703: exec_command (command.c:520)
==272468==    by 0x1FC703: jim_command_dispatch (command.c:931)
==272468==    by 0x36980F: JimInvokeCommand (in /home/marc/openocd/build/src/openocd)
==272468==    by 0x1FFFFFFFFF: ???
==272468==    by 0x53ED09F: ???
==272468==    by 0x400000002: ???
==272468==    by 0x1FFEFFF7FF: ???
==272468==    by 0x3D3984: ??? (in /home/marc/openocd/build/src/openocd)
==272468==    by 0x2: ???
==272468==

Change-Id: I3e5323f145a98d1ff9ea7d03f87ed96140f49a18
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8257
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 days agotcl/target/nrf52: Configure trace port speed 56/8256/4
Marc Schink [Sun, 5 May 2024 13:28:20 +0000 (15:28 +0200)]
tcl/target/nrf52: Configure trace port speed

Configure the TRACECONFIG.TRACEPORTSPEED register depending on the
trace clock speed. Also catch invalid trace clock speeds.

Change-Id: I1ece1cc59da539732d2d71f296fd55799c195387
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8256
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 days agotcl/target/nrf52: Use 'error' instead of 'echo' 55/8255/3
Marc Schink [Sun, 5 May 2024 13:20:07 +0000 (15:20 +0200)]
tcl/target/nrf52: Use 'error' instead of 'echo'

Use 'error' instead of 'echo' for error messages. Otherwise, capturing
is always started, for example with an unsupported device.

While at it, make the error messages more consistent and clear.

Change-Id: I83c9abfb4514e6b638c4be14651e67f768af8bad
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8255
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: <post@frankplowman.com>
2 days agotarget/arm_tpiu_swo: Handle errors in pre/post-enable events 54/8254/3
Marc Schink [Wed, 1 May 2024 10:58:18 +0000 (12:58 +0200)]
target/arm_tpiu_swo: Handle errors in pre/post-enable events

Currently, errors in pre/post-enable events are ignored and capturing is
always started, even if necessary device configuration fails. This
behaviour is confusing to users. Also, the TPIU must be disabled before
re-configuration is possible.

Start capturing and enable TPIU only if no errors in pre/post-enable
events occurred.

Change-Id: I422033e36ca006e38aa4504d491b7947def1237a
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8254
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 days agoserver/gdb: Use 'bool' data type where appropriate 53/8253/3
Marc Schink [Fri, 3 May 2024 07:18:00 +0000 (09:18 +0200)]
server/gdb: Use 'bool' data type where appropriate

Change-Id: Ic23c5469334337963185b69fcabeedf70c2c7ae9
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8253
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 days agotarget/arm_tpiu_swo: Fix division by zero 24/8224/4
Marc Schink [Sun, 28 Apr 2024 10:47:42 +0000 (12:47 +0200)]
target/arm_tpiu_swo: Fix division by zero

When external capturing is configured (default), the SWO pin frequency
is required. Enforce this to avoid a division by zero error.

While at it, ensure that the 'out_filename' variable always contains a
valid string. This saves a few checks and makes the code more clean and
readable.

Change-Id: If8c1dae9549dd10e2f21d5b896414d47edac9fc2
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8224
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 weeks agotarget/xtensa: avoid IHI for writes to non-executable memory 80/8080/2
Ian Thompson [Wed, 31 Jan 2024 23:14:25 +0000 (15:14 -0800)]
target/xtensa: avoid IHI for writes to non-executable memory

For MPU configs, determine memory access rights
by probing protection TLB.  Issuing IHI without execute
permissions can trigger an exception.

No new clang static analyzer warnings.

Change-Id: Iea8eab5c2113df3f954285c3b9a79e96d41aa941
Signed-off-by: Ian Thompson <ianst@cadence.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8080
Reviewed-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 weeks agogdb_server: enable keep-alive packets for qCRC packet 27/8227/3
Parshintsev Anatoly [Thu, 2 May 2024 21:28:33 +0000 (00:28 +0300)]
gdb_server: enable keep-alive packets for qCRC packet

Change-Id: Ia384179bb83ad6b70bf385cc9d575e9ec58f76c7
Signed-off-by: Parshintsev Anatoly <anatoly.parshintsev@syntacore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8227
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 weeks agocortex_a: drop cortex_a_dap_write_memap_register_u32() 31/8231/2
Antonio Borneo [Sat, 4 May 2024 17:13:51 +0000 (19:13 +0200)]
cortex_a: drop cortex_a_dap_write_memap_register_u32()

Historically, the function cortex_a_dap_write_memap_register_u32()
was used to discriminate the register write in APB-AP CPU debug
against the complex memory access in AHB-AP memory bus.

It has no sense to keep the function and its comment.
Plus, by forcing atomic write it impacts the debug performance.

Drop it!
A further rework to enqueue sequence of atomic writes is needed.

Change-Id: I2f5e9015f0e27fa5a6d8337a1ae25e753e2e1d26
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8231
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Tested-by: jenkins
2 weeks agocortex_a: drop the command 'cache auto' 30/8230/2
Antonio Borneo [Sat, 4 May 2024 18:09:51 +0000 (20:09 +0200)]
cortex_a: drop the command 'cache auto'

The command 'cache auto' was introduced with commit cd440bd32a12
("add armv7a_cache handlers") in 2015 to allow disabling the cache
handling done automatically by OpenOCD.
This was probably a way to test the cache handling when there were
still the two independent accesses for APB-AP CPU debug and for
AHB-AP memory bus.

The handling of cache for cortex_a is robust and there is no more
reason to disable it.
The command 'cache auto' is not used in any upstream script.
On target aarch64 this command has never been introduced as the
cache is always handled automatically by OpenOCD.

Drop the command 'cache auto' and add it in the deprecated list.
Drop the flag 'auto_cache_enabled' by considering it as true.
Rename the function 'armv7a_cache_auto_flush_all_data()' as
'armv7a_cache_flush_all_data()' and, while there, fix the error
propagation in SMP case.

Change-Id: I0399f1081b08c4929e0795b76f4a686630f41d56
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8230
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 weeks agocortex_a: drop useless cache invalidate on mem write 29/8229/2
Antonio Borneo [Thu, 2 May 2024 13:24:57 +0000 (15:24 +0200)]
cortex_a: drop useless cache invalidate on mem write

The initial OpenOCD code for Cortex-A (ARMv7a) [1] was merged in
2009 but, due to lack of public documentation for ARMv7a, it was
almost a simple copy/paste from the existing code for Cortex-M
(ARMv7m).

On Cortex-M the same AP provides access to both CPU debug and CPU
memory. This feature is not present on ARMv7a.
To still keep some communality with ARMv7m code, the change [2]
splits the CPU debug access from the CPU memory access by using
two independent AP; this is copied from the system architecture of
TI OMAP3530 which provides to DAP a direct AHB-AP memory bus on
AP#0, separated from AP#1 for the APB-AP CPU debug.
But the direct memory access through the system bus breaks the
coherency between memory and CPU caches, so change [3] added some
cache invalidation to avoid issues.

The code to allow ARMv7a CPU to really read/write in CPU memory
was added by change [4] in 2011. Such still not optimized
implementation was very slow, so it did not replace the access
through the system bus. A selection through DAP's 'apsel" command
was used to select between the two modes.

Only in 2015, with change [5], the speed of CPU read/write was
improved using the DCC_FAST_MODE. But the direct access to the
memory through the system bus remained.

Finally, with change [6] in 2018 the system bus access was dropped
for good, as the new virtual target "mem_ap" could implement such
access in a more clean way.
Only memory access through CPU remained for ARMv7a.
Nevertheless, a useless cache invalidation remained in the code,
decreasing the speed of the write access.

Drop the useless cache invalidate on CPU memory write and the
associated comment, not anymore valid.
Drop the now unused function armv7a_cache_auto_flush_on_write().

This provides a speedup of between 4 and 8, depending on adapter
and JTAG/SWD speed.

Link: [1] 7a93100c2dfe ("Add minimalist Cortex A8 file")
Link: [2] 1d0b276c9f75 ("The rest of the Cortex-A8 support from Magnus: ...")
Link: [3] d4e4d65d284f ("Cache invalidation when writing to memory")
Link: [4] 05ab8bdb813a ("cortex_a9: implement read/write memory through APB-AP")
Link: [5] 0228f8e8274d ("Cortex A: fix extra memory read and non-word sizes")
Link: [6] fac9be64d944 ("target/cortex_a: remove buggy memory AP accesses")

Change-Id: Ifa3c7ddf2698b2c87037fb48f783844034a7140e
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8229
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 weeks agoipdbg: fix double free of virtual-ir data 85/8085/3
Daniel Anselmi [Sun, 17 Mar 2024 00:15:16 +0000 (01:15 +0100)]
ipdbg: fix double free of virtual-ir data

Fix possible double free and possible
memory leak while creating an ipdbg hub.

Change-Id: I6254663c27c4f38d46008c4dbff11aa27b84f399
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/8085
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 weeks agotcl/target: Add helpers for booting Xilinx ZynqMP from JTAG 33/8133/5
Sean Anderson [Thu, 22 Feb 2024 17:18:36 +0000 (12:18 -0500)]
tcl/target: Add helpers for booting Xilinx ZynqMP from JTAG

Add some helpers for booting ZynqMPs over JTAG. Normally, the CSU ROM
will load boot.bin from the boot medium. However, when booting from JTAG
we have to do this ourselves. There are generally two parts to this.
First, we need to load the PMU firmware. Xilinx's tools do this by
attaching to the PMU (a Microblaze CPU) over JTAG. However, the TAP is
undocumented and we don't have any microblaze support in-tree. So
instead we do it the same way FSBL does it:

- We ask the PMU to halt
- We load the firmware into the PMU RAM
- We ask the PMU to resume

The second thing we need to do is start one of the APU cores. When an
APU is released from reset, it starts executing at the value of its
RVBARADDR. While we could load the APU firmware over the AXI target,
it is faster to load it over the APU target. To do this, we put the APU
into an infinite loop before halting it. As an aside, I chose to use the
"APU" terminology as opposed to "core" to make it clear that these
commands operate on the A53 cores and not the R5F cores.

Typical usage of these commands could look something like

targets uscale.axi
boot_pmu /path/to/pmu-firmware.bin
boot_apu /path/to/u-boot-spl.bin

But of course there is always the option to call lower-level commands
individually if your boot process is more unusual.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Change-Id: I816940c2022ccca0fabb489aa75d682edd0f6138
Reviewed-on: https://review.openocd.org/c/openocd/+/8133
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
3 weeks agosmp: fix SIGSEGV for "smp off" during target examine 16/8216/2
Antonio Borneo [Mon, 15 Apr 2024 15:42:12 +0000 (17:42 +0200)]
smp: fix SIGSEGV for "smp off" during target examine

The gdb subsystem is initialized after the first target examine,
so the field struct target::gdb_service is NULL during examine.

A command "smp off" in the examine event handler causes a SIGSEGV
during OpenOCD startup.

Check for pointer not NULL before dereferencing it.

Change-Id: Id115e28be23a957fef1b97ab66d7273f0ea0dce4
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8216
Tested-by: jenkins
3 weeks agotarget: cortex_a: fix regs invalidation when -defer-examine 15/8215/2
Antonio Borneo [Sat, 13 Apr 2024 16:54:12 +0000 (18:54 +0200)]
target: cortex_a: fix regs invalidation when -defer-examine

The code for cortex_a allocates the register cache during the very
first examine of the target.
To prevent a segmentation fault in assert_reset(), the call to
register_cache_invalidate() is guarded by target_was_examined().

But for targets with -defer-examine, the target is set as not
examined in handle_target_reset() just before entering in
assert_reset().

This causes registers to not be invalidated while reset a target
examined but with -defer-examine.

Change the condition and invalidate the register cache if it has
been already allocated.

Change-Id: I81ae782ddce07431d5f2c1bea3e2f19dfcd6d1ce
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8215
Tested-by: jenkins
3 weeks agotarget: aarch64: fix regs invalidation when -defer-examine 14/8214/2
Antonio Borneo [Sat, 13 Apr 2024 16:46:11 +0000 (18:46 +0200)]
target: aarch64: fix regs invalidation when -defer-examine

The code for aarch64 allocates the register cache during the very
first examine of the target.
To prevent a segmentation fault in assert_reset(), the call to
register_cache_invalidate() is guarded by target_was_examined().

But for targets with -defer-examine, the target is set as not
examined in handle_target_reset() just before entering in
assert_reset().

This causes registers to not be invalidated while reset a target
examined but with -defer-examine.

Change the condition and invalidate the register cache if it has
been already allocated.

Change-Id: Ie13abb0ae2cc28fc3295d678c4ad1691024eb7b8
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8214
Tested-by: jenkins
3 weeks agocortex_m: don't try to halt not-examined targets 13/8213/2
Antonio Borneo [Mon, 8 Apr 2024 15:40:09 +0000 (17:40 +0200)]
cortex_m: don't try to halt not-examined targets

Prevent a segmentation fault by preventing to try to halt a target
that has not been examined yet.

Change-Id: I5d344e7fbdb5422f7c5e2c39bdd48cbc6c2a3e58
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8213
Tested-by: jenkins
3 weeks agotarget/target: Add 'debug_reason' to current target 21/8021/2
Marc Schink [Sat, 18 Nov 2023 11:48:33 +0000 (12:48 +0100)]
target/target: Add 'debug_reason' to current target

Change-Id: Ie35b13b3e06411b4866ffeada47b3262493dbf2e
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8021
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 weeks agotarget: cortex_m: fix display of DWT registers 98/8198/2
Antonio Borneo [Fri, 5 Apr 2024 22:26:38 +0000 (00:26 +0200)]
target: cortex_m: fix display of DWT registers

Commit 16b4b8cf5453 ("Cortex-M3: expose most DWT registers") added
the DWT registers to the list of CPU registers.
The commit message from 2009 reports the reason behind this odd
mixing of CPU and DWT registers.
This feature got broken in 2017 with the introduction of the field
struct reg::exist and its further use in the code. As result, the
command 'reg' on a target Cortex-M reports only the core registers
and then the header line
===== Cortex-M DWT registers
not anymore followed by the DWT registers.

Fix it by tagging each DWT registers as existing.

Change-Id: Iab026e7da8d6b8ba052514c3fd3b5cdfe301f330
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: b5964191f0d2 ("register: support non-existent registers")
Reviewed-on: https://review.openocd.org/c/openocd/+/8198
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
3 weeks agojtag: linuxgpiod: minor alignment to coding style 00/8200/2
Antonio Borneo [Sun, 7 Apr 2024 10:28:55 +0000 (12:28 +0200)]
jtag: linuxgpiod: minor alignment to coding style

Avoid double TAB in 'then' block by increasing indentation of the
multi-line condition.

Change-Id: I7f5a4437fe4f74228f1b0d98e5c5921af4fd36b8
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8200
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 weeks agodoc: style: report indentation of multi-line condition 99/8199/2
Antonio Borneo [Sun, 7 Apr 2024 10:41:48 +0000 (12:41 +0200)]
doc: style: report indentation of multi-line condition

To help readability and discriminate the 'then' block from the
multi-line condition, suggest to increase the indentation of the
condition.

Change-Id: I02e3834be3001e7ecf24349ad3cefe94b27b79c8
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8199
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
7 weeks agojtag: linuxgpiod: drop extra parenthesis 87/8187/2
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
7 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>
7 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>
7 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>
7 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>
7 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
8 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>
2 months 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
2 months 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
2 months 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
2 months 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
2 months 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
2 months 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>
2 months 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
2 months 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
2 months 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>
2 months 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
2 months 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>
2 months 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
2 months 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>
2 months 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
2 months 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>
2 months 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
2 months 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>
2 months 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>
2 months 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
2 months 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
2 months 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
2 months 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>
2 months 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>
2 months 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
2 months 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>
2 months 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>
2 months 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
2 months 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
2 months 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>
2 months 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>
2 months 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>
3 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
3 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>
3 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>
3 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
3 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>
3 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>
3 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
3 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
3 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
3 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>
3 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>
3 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
3 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>
3 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>
3 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>
3 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>
3 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>
3 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
3 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>
3 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>
3 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>
3 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>
4 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>
4 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>
4 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>
4 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
4 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>
4 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>
4 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>
4 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
4 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>
4 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>
4 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>
4 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>
4 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>

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)