openocd.git
8 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
8 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>
8 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
8 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>
8 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
8 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>
8 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
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>
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>
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>
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>
4 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
4 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>
4 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
4 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>
4 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>
4 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
4 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>
4 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>
4 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
4 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
4 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>
4 months agodoc: usb_adapters: update the script for unavailable reports 46/8046/4
Antonio Borneo [Sun, 10 Dec 2023 20:35:10 +0000 (21:35 +0100)]
doc: usb_adapters: update the script for unavailable reports

When Linux HID driver binds the USB endpoints of the adapter,
'lsusb' fails to read all the reports and prints
** UNAVAILABLE **

Detect this case and alert the user, providing also the proper
command to unbind the driver before running the script again.
Put this test at the end of the output, so user can easily see it.

Change-Id: Iaca00040e666b62ceebe4b842a24932799bde56a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/8046
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 months agodoc/openocd: Mention APM32F1 and APM32F4 series 18/8018/5
Marc Schink [Tue, 14 Nov 2023 09:55:46 +0000 (10:55 +0100)]
doc/openocd: Mention APM32F1 and APM32F4 series

Change-Id: I2ff28b0fdf4923a58771a44ad6e83ac871d6fa9e
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8018
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
4 months agotcl/target: Add Geehy APM32F1x config 17/8017/5
Marc Schink [Wed, 8 Nov 2023 09:27:36 +0000 (10:27 +0100)]
tcl/target: Add Geehy APM32F1x config

Tested with APM32F103CBT6 using JTAG and SWD transport. All flash
operations, including sector and device protection, work as expected.

Change-Id: Ibefe1a65d710aea87b86ab7ff8a4153512a0ea4f
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8017
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
4 months agotcl/target: Add Geehy APM32F4x config 16/8016/4
Marc Schink [Sun, 14 May 2023 13:03:07 +0000 (15:03 +0200)]
tcl/target: Add Geehy APM32F4x config

Tested with APM32407RGT6 using JTAG and SWD transport. All flash
operations, including sector and device protection, work as expected.

Revision identifier (0x0009) is not updated due to missing documentation.

Change-Id: I33f4630fd00096656369ecc923aea2dcad77c7d3
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8016
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
4 months agotcl/target: Add Geehy APM32F0x config 15/8015/4
Marc Schink [Sat, 13 May 2023 10:37:12 +0000 (12:37 +0200)]
tcl/target: Add Geehy APM32F0x config

Tested with APM32F030C8T using SWD transport. All flash operations,
including sector and device protection, work as expected.

Revision identifier (0x0011) is not updated due to missing documentation.

Introduce a new directory structure that contains the manufacturer for
the sake of clarity.

Change-Id: I679387943b09fef640f8f8b6904e542f4e4b29aa
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8015
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
4 months agoflash/nor/stm32f1x: Add support for Geehy APM32F0 series 14/8014/5
Marc Schink [Sat, 13 May 2023 10:24:04 +0000 (12:24 +0200)]
flash/nor/stm32f1x: Add support for Geehy APM32F0 series

Tested with APM32F030C8T.

Change-Id: I63cd8b66424135dae481a96ba560e6f0b1f9544e
Suggested-by: Christian U <info@cu-tec.de>
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8014
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
4 months agotarget/cortex_m: Add Cortex-M85 part 48/8048/2
Marc Schink [Mon, 11 Dec 2023 15:28:17 +0000 (16:28 +0100)]
target/cortex_m: Add Cortex-M85 part

Change-Id: I91d4c05307d9611ecab11eb52218ab1cb7ed65e3
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8048
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
4 months agobitbang: Add flush before sleep 84/4284/6
Aleksey Shargalin [Tue, 31 Oct 2017 14:23:40 +0000 (17:23 +0300)]
bitbang: Add flush before sleep

Some bitbang interfaces have no speed regulation and work as fast as
they can. Only the sequence of execuded commands is guaranteed but
not the timing. It works most of time with one exception: when the
JTAG_SLEEP command is executed, we expect that all previous commands
already finished so that the sleep interval is guaranteed.
For now  there may be situations when the sleep time has passed but
previous commands are not actually executed.
This patch adds a flush command to the bitbang interface, connects it
to the existing implementation for remote_bitbang, and runs it when
the JTAG_SLEEP command is executed.

Change-Id: If40894a63d29a260a4ded134b008df6dd1e89c46
Signed-off-by: Aleksey Shargalin <myokaski@gmail.com>
Signed-off-by: David Ryskalczyk <david.rysk@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/4284
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
4 months agotcl/target: add Marvell Octeon TX2 CN9130 target 42/8042/11
Henrik Nordström [Sun, 17 Dec 2023 16:39:50 +0000 (17:39 +0100)]
tcl/target: add Marvell Octeon TX2 CN9130 target

This has a quite complex JTAG router chain requiring both a custom
BYPASS instruction to access child taps, and JTAG configuration to
enable individual DAP nodes.

Change-Id: I6f5345764e1566d70c8526a7e8ec5d250185bd2c
Signed-off-by: Henrik Nordström <henrik.nordstrom@addiva.se>
Reviewed-on: https://review.openocd.org/c/openocd/+/8042
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
4 months agojtag: add -ir-bypass option to newtap 41/8041/7
Henrik Nordström [Sun, 17 Dec 2023 22:14:37 +0000 (23:14 +0100)]
jtag: add -ir-bypass option to newtap

Some devices with an internal multi-tap JTAG router require a vendor
specific bypass instruction to bypass the master TAP when addressing
slave taps internal to the same device. On these devices the standard
bypass instruction bypasses the whole device.

Change-Id: I4506f0e67c9e4dfe39b7fa18c63d67900313e594
Signed-off-by: Henrik Nordström <henrik.nordstrom@addiva.se>
Reviewed-on: https://review.openocd.org/c/openocd/+/8041
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
4 months agotarget/armv8: Add more support for decoding memory attributes 43/8043/3
Peter Collingbourne [Fri, 8 Dec 2023 21:57:44 +0000 (13:57 -0800)]
target/armv8: Add more support for decoding memory attributes

Change-Id: I7ac7b06d67ec806a9ebffc26a7c6b9c24f024478
Signed-off-by: Peter Collingbourne <pcc@google.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8043
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
4 months agotarget/adi_v5_swd: optimize sequences in swd_connect_multidrop() 18/7218/9
Tomas Vanek [Wed, 15 Mar 2023 13:12:47 +0000 (14:12 +0100)]
target/adi_v5_swd: optimize sequences in swd_connect_multidrop()

swd_connect_multidrop() sent DORMANT_TO_SWD and called
swd_multidrop_select_inner(). DORMANT_TO_SWD sequence ends
with a LINE_RESET sequence.
swd_multidrop_select_inner() sent LINE_RESET sequence again.
It was useless in this case.

swd_connect_multidrop() emited JTAG_TO_DORMANT and DORMANT_TO_SWD
sequences before connecting each DAP in SWD multidrop bus.
It is sufficient to emit JTAG_TO_DORMANT and DORMANT_TO_SWD
just once and emit the shorter LINE_RESET instead for subsequent DAPs.

Introduce a global variable swd_multidrop_in_swd_state
and use it to control what sequence is emitted.

In case of reconnect after an error, always use the full switch
JTAG_TO_DORMANT and DORMANT_TO_SWD.

Change-Id: Iba21620f6a9680793208bf398960ed0eb59df3b1
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7218
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
4 months agotarget/arm_adi_v5,arm_dap: introduce pre_connect_init() dap operation 42/7542/6
Tomas Vanek [Wed, 15 Mar 2023 12:58:52 +0000 (13:58 +0100)]
target/arm_adi_v5,arm_dap: introduce pre_connect_init() dap operation

SWD multidrop requires some initialization once before connecting
all daps. Provide an optional pre-connect dap operation.

Change-Id: I778215c512c56423a425dda80ab19a739f22f285
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7542
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
4 months agotarget/arm_adi_v5: fix DP SELECT logic 41/7541/7
Tomas Vanek [Tue, 14 Mar 2023 17:40:25 +0000 (18:40 +0100)]
target/arm_adi_v5: fix DP SELECT logic

The original code supported ADIv5 only, just one SELECT register
with some reserved bits - the pseudo value DP_SELECT_INVALID was
just fine to indicate the DP SELECT register is in an unknown state.

Added ADIv6 support required DP SELECT and SELECT1 registers
without reserved bits. Therefore DP_SELECT_INVALID value became
reachable as a (fortunately not really used) ADIv6 AP ADDR.

JTAG DPBANKSEL setting support introduced with ADIv6 does not
honor DP_SELECT_INVALID correctly: required select value
gets compared to DP_SELECT_INVALID value and the most common zero
bank does not trigger DP SELECT write.

DP banked registers need just to set DP SELECT. ADIv6 AP register
addressing scheme may use both DP SELECT and SELECT1. This further
complicates using a single invalid value.

Moreover the difference how the SWD line reset influences
DPBANKSEL field between ADIv5 and ADIv6 deserves better handling
than setting select cache to zero and then to DP_SELECT_INVALID
in a very specific code positions.

Introduce bool flags indicating the validity of each SELECT
register and one SWD specific for DPBANKSEL field.
Use the latter to prevent selecting DP BANK before taking
the connection out of reset by reading DPIDR.

Treat DP SELECT and SELECT1 individually in ADIv6 64-bit mode.

Update comments to reflect the difference between ADIv5 and ADIv6
in SWD line reset.

Change-Id: Ibbb0b06cb592be072571218b666566a13d8dff0e
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7541
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
4 months agohelper/bin2char: drop trailing empty line 51/8051/2
Antonio Borneo [Thu, 14 Dec 2023 21:05:52 +0000 (22:05 +0100)]
helper/bin2char: drop trailing empty line

For unknown reasons, the coreutils tool 'od' on MacOS outputs an
extra empty line, which appears in the new auto-generated files.

Modify the script bin2char.sh to drop every empty line.

Change-Id: Id835fecadb58ad4ddfc11ef9f9a2e8d75c5dffe9
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8051
Reviewed-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Tested-by: jenkins
Reviewed-by: Henrik Nordström <henrik.nordstrom@addiva.se>
4 months agodoc: usb_adapters: fix HID report in lsusb dump of few adapters 47/8047/3
Antonio Borneo [Sun, 10 Dec 2023 21:26:44 +0000 (22:26 +0100)]
doc: usb_adapters: fix HID report in lsusb dump of few adapters

Real dumps from adapters I have access to.
Serial numbers have been manually edited but are still consistent.

While there, rename a file to correct the USB PID.

Change-Id: I4fd0b6661d55294c2ce0ecbead765def1143880c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: e0059dfffae4 ("doc: usb_adapters: add lsusb dump of few adapters")
Reviewed-on: https://review.openocd.org/c/openocd/+/8047
Tested-by: jenkins

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)