openocd.git
10 months agotarget: espressif: apptrace: declare a local function as static 76/7676/3
Antonio Borneo [Sat, 6 May 2023 20:26:06 +0000 (22:26 +0200)]
target: espressif: apptrace: declare a local function as static

The function esp32_cmd_apptrace_generic() is not used outside the
file.

Declare it as static.
Detected through 'sparse' tool.

Change-Id: I08c6b92fb01594320bc3ae6b16067ac4eb51ca12
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7676
Tested-by: jenkins
10 months agotarget/espressif: add system level tracing feature 06/7606/6
Erhan Kurubas [Thu, 13 Apr 2023 22:07:18 +0000 (00:07 +0200)]
target/espressif: add system level tracing feature

Produces traces compatible with SEGGER SystemView tool.

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: If1057309edbb91ed2cf1ebf9137c378d3deb9b88
Reviewed-on: https://review.openocd.org/c/openocd/+/7606
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
10 months agoRevert "target/image: zero-initialize ELF segments up to p_memsz" 58/7658/2
Antonio Borneo [Sat, 6 May 2023 09:44:53 +0000 (11:44 +0200)]
Revert "target/image: zero-initialize ELF segments up to p_memsz"

This reverts commit 047b1a8fc237af480e3bab66a9827a358afd7547.

Commit 047b1a8fc237 ("target/image: zero-initialize ELF segments
up to p_memsz") breaks the backward compatibility introducing some
problem:
- an empty bss segment with paddr in SRAM gets zero filled at load
  but does not survive after a reset, causing verify to fail;
- an empty bss segment with paddr in FLASH causes excessive flash
  usage, which can exceed flash size (causing error) and makes
  flash aging faster.

Revert it while looking for a better implementation.

Change-Id: Iaaf926dafce46a220a5bbe20c8576eb449996d76
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/7658
Reviewed-by: Bohdan Tymkiv <bohdan200@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Nemui Trinomius <nemuisan_kawausogasuki@live.jp>
Reviewed-by: Peter Collingbourne <pcc@google.com>
Tested-by: jenkins
10 months agoflash/nor/stm32f2x: Show error message when unprotecting OTP 15/7615/2
Matthijs Kooijman [Thu, 27 Apr 2023 16:34:44 +0000 (18:34 +0200)]
flash/nor/stm32f2x: Show error message when unprotecting OTP

Trying to disable OTP write protection by running e.g. `flash protect
1 0 1 off` would already be rejected with an error code, but that would
result in a generic "failed setting protection for blocks 0 to 1"
message. Now a more specific error message is also printed, telling the
user why it failed.

Change-Id: I6d4974eb0bcd23a0a6cf68ff955d9e59b8b1b06a
Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Reviewed-on: https://review.openocd.org/c/openocd/+/7615
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
10 months agoflash/nor/stm32f2x: Fix typos in log messages 14/7614/3
Matthijs Kooijman [Thu, 27 Apr 2023 14:05:02 +0000 (16:05 +0200)]
flash/nor/stm32f2x: Fix typos in log messages

Change-Id: I0f27e1c64972a58ac146c391761008cdca610afe
Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Reviewed-on: https://review.openocd.org/c/openocd/+/7614
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
10 months agotarget/riscv-013: clear sticky error when DMI operation fails 88/7688/2
Amaury Pouly [Wed, 17 May 2023 11:09:32 +0000 (12:09 +0100)]
target/riscv-013: clear sticky error when DMI operation fails

When a DMI operation does not succeed (either because of a timeout
or an error), the specification says that the error in the `op`
field is sticky and needs to cleared by writing `dmireset` in `dtmcs`.
This is already done for timeouts in increase_dmi_busy_delay
but not for errors.

Change-Id: I7c5f27a5cf145511a1a8b64a45a586521e1cbe41
Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
Reviewed-on: https://review.openocd.org/c/openocd/+/7688
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
10 months agoflash/stm32l4x: support STM32C0x devices 74/6874/6
Tarek BOCHKATI [Fri, 3 Dec 2021 11:58:33 +0000 (12:58 +0100)]
flash/stm32l4x: support STM32C0x devices

this new STM32 series family introduces 2 devices:
STM32C011xx (0x443) and STM32C031xx (0x453)

both devices have 32 Kbytes single flash bank.

Change-Id: I4e890789e44e3b174c0e9c0e1068383ecdbb865f
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6874
Reviewed-by: Nemui Trinomius <nemuisan_kawausogasuki@live.jp>
Tested-by: jenkins
Reviewed-by: zapb <dev@zapb.de>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
10 months agojtag/drivers/bcm2835gpio: add peripheral_mem_dev config command 50/7350/5
Tomas Vanek [Sat, 13 May 2023 04:39:48 +0000 (06:39 +0200)]
jtag/drivers/bcm2835gpio: add peripheral_mem_dev config command

The bcm2835gpio driver preferred /dev/gpiomem for access to
memory mapped GPIO control and used /dev/mem as a fallback
only if it couldn't open /dev/gpiomem.

/dev/mem usually requires elevated rights or specific capabilities
of the opening process, so the fallback failed anyway.

Although /dev/gpiomem is the strongly preferred option with respect
to security, there could be also use cases which require /dev/mem
even if /dev/gpiomem is available (e.g. changing the GPIO pad
settings is necessary or testing/debugging OpenOCD).
It was difficult to handle such cases because they required
to block globally the system device /dev/gpiomem
(remove, rename or chmod).

Drop the fallback feature and select the memory device
by 'bcm2835gpio peripheral_mem_dev' configuration command.
Use /dev/gpiomem as a default.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: I60e427bda795d7a13d55d61443590dd31d694832
Reviewed-on: https://review.openocd.org/c/openocd/+/7350
Tested-by: jenkins
Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
10 months agojtag/drivers/bcm2835gpio: extend peripheral_base to off_t 85/7685/2
Tomas Vanek [Fri, 12 May 2023 10:04:22 +0000 (12:04 +0200)]
jtag/drivers/bcm2835gpio: extend peripheral_base to off_t

Raspberry Pi 4 with 64-bit kernel and arm_peri_high=1 config.txt
parameter needs peripheral_base 0x47e000000, uint32_t is not enough.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: Icedd084e2916657fa4478d452a5eb1e84a45c281
Reviewed-on: https://review.openocd.org/c/openocd/+/7685
Tested-by: jenkins
Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
10 months agojtag/drivers/bcm2835gpio: don't touch pad setting on /dev/gpiomem 84/7684/2
Tomas Vanek [Tue, 15 Nov 2022 08:47:43 +0000 (09:47 +0100)]
jtag/drivers/bcm2835gpio: don't touch pad setting on /dev/gpiomem

The pads were configured at a wrong memory address
if /dev/gpiomem was mapped.

The pad setting registers are not accessible in mapped /dev/gpiomem,
disable the pads setting if the driver doesn't open /dev/mem.

While on it, do not fail the driver initialization if pad mapping fails
- just emit a warning and work with unchanged pad setting.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: I0bce76cade8f7efd75efd9087a7d9ba6511a6239
Reviewed-on: https://review.openocd.org/c/openocd/+/7684
Tested-by: jenkins
Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
11 months agotcl/target: Add support for TMS570LC43xx 82/7682/5
Phil Kirkpatrick [Tue, 9 May 2023 09:04:24 +0000 (11:04 +0200)]
tcl/target: Add support for TMS570LC43xx

Added support for TMS570LC43xx series parts.  This uses the pre-existing
ti_tms570.cfg parent config.  In ti_tms570.cfg, dbgbase was changed.
Note 1: Based on the following TI E2E post, the previous dbgbase was wrong
and the new value isn't due to a difference in parts.
Link: https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1106954/tms570ls3137-debugging-with-openocd
Note 2: Both the previous dbgbase and the one suggested in the TI E2E post
have the 2 LSB set. In the current version of OpenOCD, this will cause
cortex_a_read_cpu_memory_fast and cortex_a_write_cpu_memory_fast to fail
due to an alignment checks in
mem_ap_<read/write>_buf_noincr()->mem_ap_<read/write>().
In all other uses of dbgbase for arm cortex parts, the 2 LSB are masked
and ignored.

Change-Id: Ic936722e5a4cfc7161b0df1fe3325ee12fd901c6
Signed-off-by: Phil Kirkpatrick <p.kirkpatrick@reflexaerospace.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7682
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
11 months agoflash/jtagspi: handle error return values where needed 22/7422/7
Daniel Anselmi [Thu, 29 Dec 2022 19:02:39 +0000 (20:02 +0100)]
flash/jtagspi: handle error return values where needed

Change-Id: Id46c2799f954fb1d4353f652ba3115796c88936d
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7422
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
11 months agopld/virtex2: check error propagated by virtex2_read_stat() 57/7657/2
Antonio Borneo [Sat, 6 May 2023 08:34:13 +0000 (10:34 +0200)]
pld/virtex2: check error propagated by virtex2_read_stat()

Commit dd9137dc0e0c ("pld/virtex2: add missing error checks") adds
checks on the return value of several functions, allowing also
virtex2_read_stat() to propagate such returned values.
This triggers an error with clang, as it is now able to identify a
possible execution path that makes uninitialized the variable
status.

Check for the returned value of virtex2_read_stat() before using
the variable status and propagate the returned value.
While there, drop a useless empty string.

Change-Id: I7a23d3f904d4e07cdb6f6dfdf1179889b6b8afb8
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7657
Reviewed-by: Daniel Anselmi <danselmi@gmx.ch>
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
11 months agoHACKING: add info on usage of sparse 79/7679/2
Antonio Borneo [Sun, 7 May 2023 14:15:46 +0000 (16:15 +0200)]
HACKING: add info on usage of sparse

Add short example on how to run the static analyser 'sparse' on
OpenOCD code.

Change-Id: Ieba8ae926d0e02ca9e6ac619b13b0832136f82cb
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7679
Tested-by: jenkins
11 months agortos: uCOS-III: split struct ucos_iii_params 78/7678/2
Antonio Borneo [Sun, 7 May 2023 13:50:26 +0000 (15:50 +0200)]
rtos: uCOS-III: split struct ucos_iii_params

The static analyser 'sparse' complains about using sizeof() on a
struct that has variable size:
src/rtos/uCOS-III.c:267:32: warning: using sizeof on a flexible structure
src/rtos/uCOS-III.c:269:41: warning: using sizeof on a flexible structure
src/rtos/uCOS-III.c:275:66: warning: using sizeof on a flexible structure
The struct ucos_iii_params contains either constants values for
different target type and variable fields. The last field is an
variable size array, always allocated to UCOS_III_MAX_THREADS
items. It's not practical to fix this size because we would get
too huge initialization in data segment.

Split away from struct ucos_iii_params all the variable fields and
put them in struct ucos_iii_private. Add in the new struct a
pointer to the selected element of ucos_iii_params_list[] and fix
the size of array threads[] to its maximum value; this would be
allocated at run-time, avoiding impacts to data segment.

Change-Id: I569011a257783d35a8795adbda06e942b4157f2a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7678
Tested-by: jenkins
11 months agortos: move prototype of rtos_thread_packet() in rtos.h 77/7677/2
Antonio Borneo [Sun, 7 May 2023 12:35:51 +0000 (14:35 +0200)]
rtos: move prototype of rtos_thread_packet() in rtos.h

The function rtos_thread_packet() is used across rtos and declared
locally as extern.

Move the prototype of the function in common include rtos.h

Change-Id: I50d311b583148a2de628de0997ef1afc9103a70e
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7677
Tested-by: jenkins
11 months agotarget: arm_adi_v5: move in include file the declaration of dap_ops 75/7675/2
Antonio Borneo [Sat, 6 May 2023 20:17:36 +0000 (22:17 +0200)]
target: arm_adi_v5: move in include file the declaration of dap_ops

The struct containing SWD and JTAG operations are declared as
extern in the C file.

Mode them in include file arm_adi_v5.h to silent 'sparse' error
for global variable definition without declaration in an include
file.

Change-Id: I59088512c052d5a120c38404a882ed512a68ca02
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7675
Tested-by: jenkins
11 months agoflash: nand: move in include file the declaration of 'nand_devices' 74/7674/2
Antonio Borneo [Sat, 6 May 2023 20:09:06 +0000 (22:09 +0200)]
flash: nand: move in include file the declaration of 'nand_devices'

The pointer nand_devices is used in two file.

Move the extern prototype in code.h

Detected through 'sparse' tool.

Change-Id: I7237359fd1a008770a624725cd0b3d8632b4166e
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7674
Tested-by: jenkins
11 months agoserver: gdb: export gdb_actual_connections through a function 73/7673/2
Antonio Borneo [Sat, 6 May 2023 19:59:31 +0000 (21:59 +0200)]
server: gdb: export gdb_actual_connections through a function

The internal variable 'gdb_actual_connections' is used by log and
by semihosting to determine if there are active GDB connections.

Keep the variable local in server's code and only export its value
through a dedicated function.

This solves the issue detected by 'parse' of the variable defined
as global but not declared in any include file.

Change-Id: I6e14f4cb1097787404094636f8a2a291340222dd
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7673
Tested-by: jenkins
11 months agojtag: move declaration outside function 72/7672/2
Antonio Borneo [Sat, 6 May 2023 19:28:51 +0000 (21:28 +0200)]
jtag: move declaration outside function

The function jtag_debug_state_machine_() is only used by a static
inline function and declared inside it as private.
The static analyser 'sparse' complains that the function is
defined as global but not cross checked against a prototype in an
include file.

Move the declaration outside the inline function so it get visible
by interface.c, which already includes interface.h
While there, change the argument type from 'unsigned' to 'unsigned
int' to pass checkpatch check.

Change-Id: Ia5dfb92dc4bc6d52ead4f0cb8c68319c83ff85b0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7672
Tested-by: jenkins
11 months agohello: include hello.h 71/7671/2
Antonio Borneo [Sat, 6 May 2023 16:49:46 +0000 (18:49 +0200)]
hello: include hello.h

Let source file to include its file .h to validate the exported
prototypes.

Detected through 'sparse' tool.

Change-Id: I6197f21c857833dafc3d6e3b750c764bf4610abd
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7671
Tested-by: jenkins
11 months agohelper: types: rework h_u32_to_le() and similar for sparse 70/7670/2
Antonio Borneo [Sat, 6 May 2023 14:35:57 +0000 (16:35 +0200)]
helper: types: rework h_u32_to_le() and similar for sparse

The static analyser 'sparse' complains about values bigger that
255 that gets cast-ed and/or stored in an 8 bit variable.

Rework the functions:
- h_u32_to_le()
- h_u32_to_be()
- h_u24_to_le()
- h_u24_to_be()
- h_u16_to_le()
- h_u16_to_be()
to avoid all the related warnings, without adding any functional
change. Any modern compiler should not be impacted by this.

Change-Id: I0b84043600a41c72d0e4ddb3dd195d69e3b2896b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7670
Tested-by: jenkins
11 months agotarget: arm_dpm: with pointers, use NULL instead of 0 69/7669/2
Antonio Borneo [Sat, 6 May 2023 14:24:04 +0000 (16:24 +0200)]
target: arm_dpm: with pointers, use NULL instead of 0

Don't assign pointer to 0, use NULL.

Detected through 'sparse' tool.

Change-Id: I34551112ddab9dedf8537c8111d32356c170e7d5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7669
Tested-by: jenkins
11 months agopld: fix new warnings from sparse 68/7668/2
Antonio Borneo [Sat, 6 May 2023 14:19:55 +0000 (16:19 +0200)]
pld: fix new warnings from sparse

The new committed files add some warning from the static analyser
'sparse':
- Don't assign pointer to 0, use NULL.
- switch with no cases.

Fix them.

Change-Id: I2c02d629bd80b71c8e42553be5d9388bb9b6bcd0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7668
Tested-by: jenkins
11 months agohelper: replacements: rework including replacements.h 67/7667/2
Antonio Borneo [Sat, 6 May 2023 14:14:15 +0000 (16:14 +0200)]
helper: replacements: rework including replacements.h

The static analyser 'sparse' complains that the functions
clear_malloc() and fill_malloc() are defined global but not cross
checked against a prototype in an include file.

Rework replacements.h and replacements.c to let the former be
included by the latter.

Change-Id: I536393a9c3718dcd7e144cde8f02e169f64c88e0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7667
Tested-by: jenkins
11 months agonand: declare exported function in core.h 66/7666/2
Antonio Borneo [Sun, 30 Apr 2023 22:55:15 +0000 (00:55 +0200)]
nand: declare exported function in core.h

Don't use 'extern' in a C file, but declare the exported function
in a H file.
This helps validating the function prototype across declaration
and use.

Detected through 'sparse' tool.

Change-Id: I2c22b084fb513f4b3b1b1db96dfbc8fa4bfe7238
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7666
Tested-by: jenkins
11 months agojtag: move in interface.h the adapter_driver's declaration 65/7665/2
Antonio Borneo [Sun, 30 Apr 2023 22:40:18 +0000 (00:40 +0200)]
jtag: move in interface.h the adapter_driver's declaration

The static analyser 'sparse' complains, while compiling a jtag
driver, that the struct adapter_driver is declared in the file as
non static, but it is not exposed through an include file.
The message is:
warning: symbol 'XXX' was not declared. Should it be static?

Move the list of adapter_driver's declaration in interface.h
Drop the preprocessor #ifdef/#endif around the declaration, as it
has no effect when the declaration is not used and/or the symbol
does not exist.

Change-Id: I5b8f5fe48a89ff0ffce38d547c551cd196379fbf
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7665
Tested-by: jenkins
11 months agopld: validate exported functions by including its own .h 64/7664/2
Antonio Borneo [Sun, 30 Apr 2023 22:29:11 +0000 (00:29 +0200)]
pld: validate exported functions by including its own .h

Let source files to include its file .h to validate the exported
prototypes.

Detected through 'sparse' tool.

Change-Id: I217c2903fdb19e1a2cce39d2536a903c3d72f3f7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7664
Tested-by: jenkins
11 months agopld: move in pld.h the pld_driver's declaration 63/7663/2
Antonio Borneo [Sun, 30 Apr 2023 22:24:37 +0000 (00:24 +0200)]
pld: move in pld.h the pld_driver's declaration

The static analyser 'sparse' complains, while compiling a pld
driver, that the struct pld_driver is declared in the file as
non static, but it is not exposed through an include file.
The message is:
warning: symbol 'XXX' was not declared. Should it be static?

Move the list of pld_driver's declaration in pld.h

Change-Id: I0f917aecc7534c1b51af0afa9b32ccfd33db3511
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7663
Tested-by: jenkins
11 months agonor: move in driver.h the flash_driver's declaration 62/7662/2
Antonio Borneo [Sun, 30 Apr 2023 22:17:23 +0000 (00:17 +0200)]
nor: move in driver.h the flash_driver's declaration

The static analyser 'sparse' complains, while compiling a nor
driver, that the struct flash_driver is declared in the file as
non static, but it is not exposed through an include file.
The message is:
warning: symbol 'XXX' was not declared. Should it be static?

Move the list of flash_driver's declaration in driver.h
Fix some incorrect non-const declaration and remove redundant
forward declarations.

Change-Id: I5e41d094307aac4a57dfa9a70496ff3cf180bd92
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7662
Tested-by: jenkins
11 months agonand: move in driver.h the nand_flash_controller's declaration 61/7661/2
Antonio Borneo [Sun, 30 Apr 2023 22:08:32 +0000 (00:08 +0200)]
nand: move in driver.h the nand_flash_controller's declaration

The static analyser 'sparse' complains, while compiling a nand
driver, that the struct nand_flash_controller is declared in the
file as non static, but it is not exposed through an include file.
The message is:
warning: symbol 'XXX' was not declared. Should it be static?

Move the list of nand_flash_controller's declaration in driver.h
While there, drop the unused/commented boundary scan controller.

Change-Id: I7dc32cef55be13ba537abe0f4c47b135d837126c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7661
Tested-by: jenkins
11 months agortos: move in rtos.h the rtos_type's declaration 60/7660/2
Antonio Borneo [Sun, 30 Apr 2023 21:54:44 +0000 (23:54 +0200)]
rtos: move in rtos.h the rtos_type's declaration

The static analyser 'sparse' complains, while compiling a rtos'
file, that the struct rtos_type is declared in the file as non
static, but it is not exposed through an include file.
The message is:
warning: symbol 'XXX' was not declared. Should it be static?

Move the list of rtos_type's declaration in rtos.h

Change-Id: Ia96dff077407a6653b11920519c1724e4c1167a3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7660
Tested-by: jenkins
11 months agotarget: move in target_type.h the target_type's declaration 59/7659/2
Antonio Borneo [Sun, 30 Apr 2023 22:00:47 +0000 (00:00 +0200)]
target: move in target_type.h the target_type's declaration

The static analyser 'sparse' complains, while compiling a target's
file, that the struct target_type is declared in the file as non
static, but it is not exposed through an include file.
The message is:
warning: symbol 'XXX' was not declared. Should it be static?

Move the list of target_type's declaration in target_type.h
While there, fix a name clash in stm8.c

Change-Id: Ia9c681e0825cfd04d509616dbc04a0cf4944f379
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7659
Tested-by: jenkins
11 months agojtag: tcl: show error message when attempting manual "drscan" on a bypassed tap 54/7654/3
Paul Fertser [Tue, 2 May 2023 12:15:21 +0000 (15:15 +0300)]
jtag: tcl: show error message when attempting manual "drscan" on a bypassed tap

To perform any meaningful manipulations with DR the corresponding IR should
be set to a relevant instruction, not BYPASS, so warn the user accordingly.

Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Change-Id: I42580ecd75ae824a4145f6f17f0df9bcf825b50f
Reviewed-on: https://review.openocd.org/c/openocd/+/7654
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
11 months agojtag: tcl: change drscan usage to show at least one value is required 53/7653/3
Paul Fertser [Tue, 2 May 2023 12:10:11 +0000 (15:10 +0300)]
jtag: tcl: change drscan usage to show at least one value is required

It's customary to use [] brackets to mean the argument is optional, but
drscan requires at least one pair of "num_bits value" so change it to ().
In common regular expressions * means 0 or more, and + means 1 or more,
so change that too.

Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Change-Id: Ib15d833bda2aa398ad1345a042f97d91c98dbf66
Reviewed-on: https://review.openocd.org/c/openocd/+/7653
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
11 months agotarget: rewrite command 'arp_reset' as COMMAND_HANDLER 59/7559/2
Antonio Borneo [Mon, 27 Mar 2023 09:11:46 +0000 (11:11 +0200)]
target: rewrite command 'arp_reset' as COMMAND_HANDLER

While there, add the missing .usage field and move in target.c the
enum nvp_assert.

Change-Id: Ia4f2f962887b5a35faeaa4eae128fa2865569b24
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7559
Tested-by: jenkins
11 months agotarget: rewrite command 'arp_halt' as COMMAND_HANDLER 58/7558/2
Antonio Borneo [Mon, 27 Mar 2023 08:43:30 +0000 (10:43 +0200)]
target: rewrite command 'arp_halt' as COMMAND_HANDLER

While there, add the missing .usage field.

Change-Id: I748382cafe08443c458ff1d4e47819610cfbf85c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7558
Tested-by: jenkins
11 months agotarget: rewrite command 'arp_poll' as COMMAND_HANDLER 57/7557/2
Antonio Borneo [Mon, 27 Mar 2023 08:34:14 +0000 (10:34 +0200)]
target: rewrite command 'arp_poll' as COMMAND_HANDLER

While there, add the missing .usage field.

Change-Id: I16e0aeacdaaada09fa77ad29552fa4025eff0c45
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7557
Tested-by: jenkins
11 months agojtag: rewrite command 'pathmove' as COMMAND_HANDLER 56/7556/2
Antonio Borneo [Mon, 2 Jan 2023 21:32:53 +0000 (22:32 +0100)]
jtag: rewrite command 'pathmove' as COMMAND_HANDLER

Change-Id: I1f8c6722021f392b1f065484b63a19964db69ad5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7556
Tested-by: jenkins
11 months agojtag: rewrite command 'drscan' as COMMAND_HANDLER 55/7555/2
Antonio Borneo [Mon, 2 Jan 2023 21:16:46 +0000 (22:16 +0100)]
jtag: rewrite command 'drscan' as COMMAND_HANDLER

Reorganize the code to parse the command line only once.
Add check for successful memory allocation.

Change-Id: Ibf6068e177c09e93150d11aecfcf079348c47c21
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7555
Tested-by: jenkins
11 months agoopenocd: trivial replace of jim-nvp with new nvp 53/7553/2
Antonio Borneo [Mon, 26 Dec 2022 21:46:19 +0000 (22:46 +0100)]
openocd: trivial replace of jim-nvp with new nvp

For some trivial case only, replace calls to jim-nvp with calls
to the new OpenOCD nvp.

Change-Id: Ifd9aff32b67748af8ab808e6a6b6e64f5271b888
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7553
Tested-by: jenkins
11 months agoxtensa: fix build with gcc 13.1.1 81/7681/2
Antonio Borneo [Mon, 8 May 2023 08:45:25 +0000 (10:45 +0200)]
xtensa: fix build with gcc 13.1.1

New gcc does not understand that the variable 'restore_ms' is set
to 'true' only when the variable 'ms' is assigned in
static int xtensa_write_dirty_registers(...)
{
xtensa_reg_val_t ms;
bool restore_ms = false;
...
if (...) {
ms = regval;
restore_ms = true;
...
}
...
if (restore_ms) {
USE(ms);
}
...
}
and complains about possible use of uninitialized variable 'ms'.

Sadly initialize 'ms' to zero to hide this false positive.

Change-Id: I1fb3949070c8abbf4aa45a740f0ca2fdb753d4fa
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7681
Reviewed-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Reviewed-by: Ian Thompson <ianst@cadence.com>
Tested-by: jenkins
11 months agotarget: etm: fix check trace status 99/7599/2
Antonio Borneo [Sat, 8 Apr 2023 23:00:15 +0000 (01:00 +0200)]
target: etm: fix check trace status

Current code tests a function pointer against a numeric value that
is the same enum type as returned by the pointed function.
Clearly the author was willing to call the function and check its
returned value.

Fix the check by calling the function.

Detected through 'sparse' tool.

Change-Id: I27d18d26c2c797160a397daa32835c199014b70b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Checkpatch-ignore: GIT_COMMIT_ID
Fixes: 237e894805dd ("reworked etm/etb into a generic etm part with trace capture")
Reviewed-on: https://review.openocd.org/c/openocd/+/7599
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
11 months agojtag: xds110: fix check on malloc() returned pointer 56/7656/2
Antonio Borneo [Sat, 6 May 2023 08:16:08 +0000 (10:16 +0200)]
jtag: xds110: fix check on malloc() returned pointer

Commit 07e1ebcc12cd ("jtag: drivers: with pointers, use NULL
instead of 0") incorrectly inverts the check, making the driver's
pathmove operation not functional and triggering two clang errors.

Fix the check on malloc() returned pointer.

Change-Id: If1f220aca67452adbcd3a1c9cf691fc984b16b27
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 07e1ebcc12cd ("jtag: drivers: with pointers, use NULL instead of 0")
Reviewed-on: https://review.openocd.org/c/openocd/+/7656
Tested-by: jenkins
11 months agopld/virtex2: add missing error checks 33/7633/2
Daniel Anselmi [Wed, 12 Apr 2023 23:55:10 +0000 (01:55 +0200)]
pld/virtex2: add missing error checks

Add error checks after allocating memory.
Add error checks for calls to jtag_execute_queue().

Change-Id: I3b63b3d836170244ad3b0566d5bd9d9aabb8e238
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7633
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
11 months agopld: gatemate: fix memory leak 32/7632/2
Antonio Borneo [Sun, 30 Apr 2023 20:57:59 +0000 (22:57 +0200)]
pld: gatemate: fix memory leak

When gatemate_set_instr() fails, the array pointed by
bit_file.raw_file.data is not freed.
Issue identified by OpenOCD Jenkins clang build.

Free the array while propagating the error.

Change-Id: I2f7fadee903f9c65cdc9ab9b52ccb5803b48a59d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 682f927f8e4e ("pld: add support for cologne chip gatemate fpgas")
Reviewed-on: https://review.openocd.org/c/openocd/+/7632
Tested-by: jenkins
Reviewed-by: Daniel Anselmi <danselmi@gmx.ch>
11 months agotarget: with pointers, use NULL instead of 0 04/7604/2
Antonio Borneo [Sat, 8 Apr 2023 23:40:51 +0000 (01:40 +0200)]
target: with pointers, use NULL instead of 0

Don't assign pointer to 0, use NULL.
Don't pass 0 ad pointer argument, pass NULL.

Detected through 'sparse' tool.

Change-Id: I806031d2ae505fa5f0accc6be1936d48cd365ca4
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7604
Tested-by: jenkins
11 months agotarget: rtt: include rtt.h 02/7602/2
Antonio Borneo [Sat, 8 Apr 2023 23:37:11 +0000 (01:37 +0200)]
target: rtt: include rtt.h

Let source file to include its file .h to validate the exported
prototypes.

Detected through 'sparse' tool.

Change-Id: I8ae2f8f1fdaea5683e157247463533b17237e464
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7602
Tested-by: jenkins
11 months agotarget: use 'ULL' suffix for long constants 01/7601/2
Antonio Borneo [Sat, 8 Apr 2023 23:36:04 +0000 (01:36 +0200)]
target: use 'ULL' suffix for long constants

On 32 bit hosts, gcc should consider constants without suffix as
32 bits values.

Use the suffix 'ULL' to guarantee it is a 64 bit.

Detected through 'sparse' tool.

Change-Id: I205ca986968fef9a536f87492d1f6c80e41829f3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7601
Tested-by: jenkins
11 months agortos: with pointers, use NULL instead of 0 98/7598/2
Antonio Borneo [Sat, 8 Apr 2023 22:33:38 +0000 (00:33 +0200)]
rtos: with pointers, use NULL instead of 0

Don't compare pointers with 0, use NULL when needed.
Don't assign pointer to 0, use NULL.

Detected through 'sparse' tool.

Change-Id: Ifa81ba961c0d490cc74880b4a46b620e6358f779
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7598
Tested-by: jenkins
11 months agohelper: with pointers, use NULL instead of 0 97/7597/2
Antonio Borneo [Sat, 8 Apr 2023 22:16:28 +0000 (00:16 +0200)]
helper: with pointers, use NULL instead of 0

Don't compare pointers with 0, use NULL when needed.
Don't assign pointer to 0, use NULL.
Don't pass 0 ad pointer argument, pass NULL.

Detected through 'sparse' tool.

Change-Id: I3f867cb9c0903f6e396311e7b3970ee5fb3a4231
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7597
Tested-by: jenkins
11 months agohelper: util: include util.h 96/7596/2
Antonio Borneo [Sat, 8 Apr 2023 22:14:45 +0000 (00:14 +0200)]
helper: util: include util.h

Let source file to include its file .h to validate the exported
prototypes.

Detected through 'sparse' tool.

Change-Id: I5de107b4f8a468f0e37f06171f5f0c3c0546db1a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7596
Tested-by: jenkins
11 months agoflash: with pointers, use NULL instead of 0 95/7595/3
Antonio Borneo [Sat, 8 Apr 2023 22:00:37 +0000 (00:00 +0200)]
flash: with pointers, use NULL instead of 0

Don't compare pointers with 0, use NULL when needed.
Don't pass 0 ad pointer argument, pass NULL.

Detected through 'sparse' tool.

Change-Id: I118554fffde41c94cea9e1201ea941ff3c1ee762
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7595
Tested-by: jenkins
11 months agoflash: nor: add static to local symbols 94/7594/2
Antonio Borneo [Sat, 8 Apr 2023 21:59:42 +0000 (23:59 +0200)]
flash: nor: add static to local symbols

Add static type to symbols that are not used elsewhere.

Detected through 'sparse' tool.

Change-Id: I2bdac5d2b06a6dbed5c27bfdb1cf36eee90ad823
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7594
Tested-by: jenkins
11 months agoflash: nor: use 'ULL' suffix for long constants 93/7593/2
Antonio Borneo [Sat, 8 Apr 2023 21:50:00 +0000 (23:50 +0200)]
flash: nor: use 'ULL' suffix for long constants

On 32 bit hosts, gcc should consider constants without suffix as
32 bits values. Adding a cast to convert it to 64 bits should not
be enough.

Use the suffix 'ULL' to guarantee it is a 64 bit.

Detected through 'sparse' tool.

Change-Id: If6be35bd3cbbc7c3a83e0da1407e611f07ff6e06
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7593
Tested-by: jenkins
11 months agojtag: drivers: with pointers, use NULL instead of 0 92/7592/3
Antonio Borneo [Sat, 8 Apr 2023 21:21:33 +0000 (23:21 +0200)]
jtag: drivers: with pointers, use NULL instead of 0

Don't compare pointers with 0, use NULL when needed.
Don't assign pointer to 0, use NULL.
Don't pass 0 ad pointer argument, pass NULL.

While there, check for return value from malloc(), replace an
assert() with a LOG_ERROR(), drop a useless cast.

Detected through 'sparse' tool.

Change-Id: Ia7cf52221b12198aba1a07ebdfaf57ce341d5699
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7592
Tested-by: jenkins
11 months agojtag: drivers: add static to local symbols 91/7591/2
Antonio Borneo [Sat, 8 Apr 2023 21:19:50 +0000 (23:19 +0200)]
jtag: drivers: add static to local symbols

Add static type to symbols that are not used elsewhere.

Detected through 'sparse' tool.

Change-Id: I00e151d2466868a5dce028444d326defb80d4826
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7591
Tested-by: jenkins
11 months agopld: add support for cologne chip gatemate fpgas 65/7565/10
Daniel Anselmi [Fri, 24 Feb 2023 14:57:30 +0000 (15:57 +0100)]
pld: add support for cologne chip gatemate fpgas

Change-Id: I0bf5a52ee6a7f0287524619114eba0cfccf6ac81
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7565
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
11 months agopld: add support for gowin devices 68/7368/19
Daniel Anselmi [Mon, 12 Dec 2022 08:49:51 +0000 (09:49 +0100)]
pld: add support for gowin devices

Change-Id: Idd1a09514bbbbe0a7b54d69010f6c2f91215fd1d
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7368
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
11 months agopld: add support for altera/intel devices 55/7355/18
Daniel Anselmi [Mon, 12 Dec 2022 08:49:51 +0000 (09:49 +0100)]
pld: add support for altera/intel devices

Change-Id: I7977d39c9037ae71139f78c8d381f5f925dc3489
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7355
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
11 months agopld: add support for efinix devices 88/7288/28
Daniel Anselmi [Mon, 12 Dec 2022 08:49:51 +0000 (09:49 +0100)]
pld: add support for efinix devices

Change-Id: Ie520e761c255ba1335d5aab9c6825f160a6151d9
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7288
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
11 months agopld: add support for lattice certus devices 98/7398/16
Daniel Anselmi [Mon, 12 Dec 2022 08:49:51 +0000 (09:49 +0100)]
pld: add support for lattice certus devices

Change-Id: Ic50a724e5793000fca11f35ba848c2d317c3cbab
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7398
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
11 months agopld: add support for lattice ecp5 devices 97/7397/16
Daniel Anselmi [Mon, 12 Dec 2022 08:49:51 +0000 (09:49 +0100)]
pld: add support for lattice ecp5 devices

Change-Id: Ib2f0933da3abe7429abca86d6aaa50ad85ce72c7
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7397
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
11 months agopld: add support for lattice ecp2 and ecp3 devices 96/7396/14
Daniel Anselmi [Mon, 12 Dec 2022 08:49:51 +0000 (09:49 +0100)]
pld: add support for lattice ecp2 and ecp3 devices

Change-Id: I29c227c37be464f7ecc97a30d9cf3da1442e2b7f
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7396
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
11 months agotarget/espressif: fix clang report on list use 08/7608/2
Antonio Borneo [Fri, 14 Apr 2023 22:25:54 +0000 (00:25 +0200)]
target/espressif: fix clang report on list use

It looks like a false positive.
Scan-build considers as possible to:
- have list_empty() return false;
- list_for_each_safe() to not execute any loop, thus not assigning
  a non-NULL value to 'block';
- the NULL pointer 'block' is passed to list_del().
This is not possible because with list_empty(), the loop runs at
least once.

Rewrite the function to simplify the code and making it easier for
scan-build to check it.

This also drops an incorrect use of list_for_each_safe(), where
the 'safe' version was not required.

Change-Id: Ia8b1d221cf9df73db1196e3f51986023dcaf78eb
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 8d1dcf293a0c ("target/espressif: add application tracing functionality over JTAG")
Reviewed-on: https://review.openocd.org/c/openocd/+/7608
Reviewed-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Tested-by: jenkins
11 months agotarget/espressif: fix clang report on use of garbage value 07/7607/2
Antonio Borneo [Fri, 14 Apr 2023 22:21:42 +0000 (00:21 +0200)]
target/espressif: fix clang report on use of garbage value

When the function xtensa_queue_dbg_reg_read() returns error, the
array 'tmp' remains not initialized and scan-build complains while
computing buf_get_u32() that:
Result of operation is garbage or undefined

Check the returned value of xtensa_queue_dbg_reg_read() and
propagate it.

Change-Id: If0aaad068b97ef0a76560e262d16429afd469585
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 8d1dcf293a0c ("target/espressif: add application tracing functionality over JTAG")
Reviewed-on: https://review.openocd.org/c/openocd/+/7607
Tested-by: jenkins
Reviewed-by: Erhan Kurubas <erhan.kurubas@espressif.com>
11 months agosrc: fix clang15 compiler warnings 69/7569/3
Erhan Kurubas [Sat, 1 Apr 2023 22:26:51 +0000 (00:26 +0200)]
src: fix clang15 compiler warnings

Below warnings are fixed.

1- A function declaration without a prototype is deprecated in all
versions of C [-Werror,-Wstrict-prototypes]

2- error: variable set but not used [-Werror,-Wunused-but-set-variable]

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: I1cf14b8e5e3e732ebc9cacc4b1cb9009276a8ea9
Reviewed-on: https://review.openocd.org/c/openocd/+/7569
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
11 months agoserver/ipdbg: add error checks after allocating memory 05/7605/2
Daniel Anselmi [Tue, 11 Apr 2023 08:18:33 +0000 (10:18 +0200)]
server/ipdbg: add error checks after allocating memory

Change-Id: Icf18a855eb66d2b09789a9ee27f5fbc4cd9afc89
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7605
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
11 months agotcl/target: renesas gen3 Set target to armv8r for Cortex-R52 05/6805/4
Julien Massot [Wed, 12 Jan 2022 08:53:06 +0000 (09:53 +0100)]
tcl/target: renesas gen3 Set target to armv8r for Cortex-R52

Cortex-R52 is an ARMv8-R processor supporting only
AArch32 Profile.

Signed-off-by: Julien Massot <julien.massot@iot.bzh>
Change-Id: I663ae4bf1d3026d7c9e4c5950a79e7ddf1bd6564
Reviewed-on: https://review.openocd.org/c/openocd/+/6805
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
11 months agoaarch64: Add support for ARMv8-R 43/6843/2
Julien Massot [Tue, 1 Feb 2022 12:44:05 +0000 (13:44 +0100)]
aarch64: Add support for ARMv8-R

ARMv8-R platforms are similar to ARMv8-A regarding
JTAG and most cpu registers. ARMv8-R doesn't has MMU
but has MPU instead.

ARMv8-R platforms can be AArch32 only such as Cortex-R52,
or AArch64 capable like Cortex-R82.

Signed-off-by: Julien Massot <julien.massot@iot.bzh>
Change-Id: Ib086f71685d1e3704b396d478ae9399dd8a391e1
Reviewed-on: https://review.openocd.org/c/openocd/+/6843
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
11 months agotarget:armv8: aarch32 do not try to restore same EL 07/6807/3
Julien Massot [Wed, 12 Jan 2022 13:10:36 +0000 (14:10 +0100)]
target:armv8: aarch32 do not try to restore same EL

While debugging a Cortex-R52 OpenOCD fail to restore context
on line
retval = dpm->instr_write_data_r0(dpm,
ARMV8_MSR_GP_xPSR_T1(1, 0, 15), cpsr);

which trigger this exception:

aarch64.c:1206 aarch64_restore_context(): r8a779a0.r52
armv8_dpm.c:560 armv8_dpm_modeswitch(): restoring mode, cpsr = 0x0000011f
1262753 armv8_dpm.c:598 armv8_dpm_modeswitch(): target_el = 1, last_el = 1
armv8_dpm.c:611 armv8_dpm_modeswitch(): SPSR = 0x0000011f
armv8_dpm.c:260 dpmv8_exec_opcode(): Opcode 0x8f00f390, DSCR.ERR=1, DSCR.EL=1

and finally OpenOCD doesn't succeed to restore the processor.

This check 'dpm->last_el != target_el' exist for aarch64,
so might be correct for aarch32 too.

Signed-off-by: Julien Massot <julien.massot@iot.bzh>
Change-Id: I41d1006233251dcaf6d69bda580488b204b7eb63
Reviewed-on: https://review.openocd.org/c/openocd/+/6807
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
12 months agopld: move file sanity checks to pld.c 88/7388/8
Daniel Anselmi [Wed, 14 Dec 2022 08:27:38 +0000 (09:27 +0100)]
pld: move file sanity checks to pld.c

Change-Id: Id64b1165b25a03634949ac22b8af16eb0e24c1fa
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7388
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
12 months agoflash/rsl10: fix typo 84/7584/2
Mark Zhuang [Mon, 10 Apr 2023 02:57:55 +0000 (10:57 +0800)]
flash/rsl10: fix typo

Change-Id: I11af37309fe4684fcb340a00fcc7b2096b8dad76
Signed-off-by: Mark Zhuang <mark.zhuang@spacemit.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7584
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
12 months agortos/linux.c: Fix Linux user space border check 70/7570/3
panciyan [Sun, 2 Apr 2023 05:17:17 +0000 (05:17 +0000)]
rtos/linux.c: Fix Linux user space border check

Linux kernel and user space border is 0xc0000000 not 0xc000000

Signed-off-by: panciyan <panciyan@eswincomputing.com>
Change-Id: I6b487cce62ac31737deca97d5f5f7bbc081280f4
Reviewed-on: https://review.openocd.org/c/openocd/+/7570
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
12 months agosrc/server: Fix memory leak of reg_list 66/7566/3
panciyan [Fri, 31 Mar 2023 15:12:08 +0000 (15:12 +0000)]
src/server: Fix memory leak of reg_list

memory leak of reg_list when local_list realloc fail.

Signed-off-by: panciyan <panciyan@eswincomputing.com>
Change-Id: I6b09137ecd132ab326205f5a575a38bcc82e8469
Reviewed-on: https://review.openocd.org/c/openocd/+/7566
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
12 months agotarget/espressif: add application tracing functionality over JTAG 63/7163/20
Erhan Kurubas [Thu, 25 Aug 2022 12:38:34 +0000 (15:38 +0300)]
target/espressif: add application tracing functionality over JTAG

This feature allows to transfer arbitrary data between host and
ESP32 via JTAG.

The main use cases:

1- Collecting application specific data
2- Lightweight logging to the host
3- System behaviour analysis with SEGGER SystemView
4- Source code coverage

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: I95dee00ac22891fa326915a3fcac3c088cbb2afc
Reviewed-on: https://review.openocd.org/c/openocd/+/7163
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
12 months agodoc: drop "resume will wait 5 seconds" 79/7579/3
Tomas Vanek [Tue, 4 Apr 2023 11:03:59 +0000 (13:03 +0200)]
doc: drop "resume will wait 5 seconds"

Checkpatch-ignore: GIT_COMMIT_ID

Waiting for running state was removed from handle_resume_command()
in commit a92d27afb073 ("very long and bad structured commit msg
without anything relevant to resume") around year 2008.
Update the doc accordingly.

Silent checkpatch or we have to copy 10 or more lines
of the old commit msg.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: I3296cb2c29cf80aeed63eddd8fbf352edec778c1
Reviewed-on: https://review.openocd.org/c/openocd/+/7579
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
12 months agotcl: cpld/xilinx-xc7: remove virtex-7 devices with ir-length > 6 87/7387/5
Daniel Anselmi [Wed, 30 Nov 2022 03:05:44 +0000 (04:05 +0100)]
tcl: cpld/xilinx-xc7: remove virtex-7 devices with ir-length > 6

They have an ir length of 22, 24 or 38 bit and different command codes.

Change-Id: I488e8613f1c4d017e1590111f60b2725ec62964b
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7387
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
12 months agotcl: zynq_7000: add missing id codes 86/7386/6
Daniel Anselmi [Wed, 30 Nov 2022 02:42:18 +0000 (03:42 +0100)]
tcl: zynq_7000: add missing id codes

Add missing ID codes and ignore the version in the ID.

Change-Id: Idd2d3a5eddb6995f3af1c45afd2adf76ce3442bf
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7386
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
12 months agohelper/compiler fix build with gcc on MacOS 71/7571/2
Antonio Borneo [Sun, 2 Apr 2023 12:24:23 +0000 (14:24 +0200)]
helper/compiler fix build with gcc on MacOS

On MacOS libc includes files from MacOSX.sdk that define the macro
#define __nonnull
without arguments, causing compile error.

Extend the existing check for clang on MacOS and undefine the
macro for gcc too.

Change-Id: Ic99de78348c6aa86561212a3aded9342e5d32e02
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7571
Reviewed-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Tested-by: jenkins
12 months agoipdbg: whitespaces 99/7399/3
Daniel Anselmi [Wed, 14 Dec 2022 11:51:48 +0000 (12:51 +0100)]
ipdbg: whitespaces

Change-Id: I9294c551cf2e795ad5e3e92dc3926c564424e067
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7399
Tested-by: jenkins
Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
12 months agohelper/list: re-align with Linux kernel 6.3-rc1 68/7568/2
Antonio Borneo [Tue, 14 Mar 2023 14:20:14 +0000 (15:20 +0100)]
helper/list: re-align with Linux kernel 6.3-rc1

Minor changes due to kernel switch to 100 char/line.
Added four new functions.

Silent checkpatch; we don't want to diverge from Linux reference
code.
Checkpatch-ignore: MACRO_ARG_REUSE, UNNECESSARY_PARENTHESES
Checkpatch-ignore: MACRO_ARG_PRECEDENCE

Change-Id: I1d2ff25bf3bab8cd0f5c9be55c7501795490ea75
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7568
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
12 months agohelper/list: remove unused hlist_* 67/7567/2
Antonio Borneo [Tue, 14 Mar 2023 14:01:18 +0000 (15:01 +0100)]
helper/list: remove unused hlist_*

The file list.h is taken from Linux and includes two similar
implementation of double linked lists:
- with single linked list's head (hlist_*), and
- with double linked list's head (list_*).
While the former offers a minor memory footprint improvement,
keeping two implementations makes harder for newbie developers
to approach them.

So far only the latter implementation has been used and no new
patches in gerrit is going to change that.

Drop the support for lists with single linked head.
It can be easily taken back from git history, if needed.

Change-Id: I420e5de38ab755fdfbeb2115538c61818308ec2b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7567
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
12 months agosrc/target/mips_m4k : add fast read method 64/7564/9
François LEGAL [Wed, 29 Mar 2023 15:46:38 +0000 (17:46 +0200)]
src/target/mips_m4k : add fast read method

Add the fast read method to speed up flash verification
after programming. Works the same as fast write already
implemented.

Signed-off-by: François LEGAL <devel@thom.fr.eu.org>
Change-Id: I74611a3542a88212f0483ec8ee368aba3d1f03c7
Reviewed-on: https://review.openocd.org/c/openocd/+/7564
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
12 months agosrc/target/mips_m4k : fix condition on overlapping workspace data area 63/7563/2
François LEGAL [Wed, 29 Mar 2023 12:19:48 +0000 (14:19 +0200)]
src/target/mips_m4k : fix condition on overlapping workspace data area

The condition to check if the workspace area (used by actual MIPS code
executed on target) and data area (sandbox to put data to be read/written
to/from flash) is wrong, thus preventing the use of FAST_* commands to
program/verify FLASH.

Signed-off-by: François LEGAL <devel@thom.fr.eu.org>
Change-Id: Ic68424b7f42d44e550433a120093db5e7980fd56
Reviewed-on: https://review.openocd.org/c/openocd/+/7563
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
12 months agortos/FreeRTOS: some optimization of freertos_update_threads() 49/7549/3
Chao Du [Wed, 22 Mar 2023 06:51:51 +0000 (06:51 +0000)]
rtos/FreeRTOS: some optimization of freertos_update_threads()

1.
update the rtos->thread_count in time, to make sure the allocated
thread_name_str and extra_info_str could be freed by
rtos_free_threadlist(). Otherwise the abnormal return may cause a
memory leak.
2.
remove a redundant assignment to threadid.

Signed-off-by: Chao Du <duchao@eswincomputing.com>
Change-Id: Ifabc59d501c925b3d6aec8b04b2856d2c31cc4e2
Reviewed-on: https://review.openocd.org/c/openocd/+/7549
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
12 months agogithub/workflow: build libjaylink from source 52/7552/3
Erhan Kurubas [Sat, 25 Mar 2023 00:00:51 +0000 (03:00 +0300)]
github/workflow: build libjaylink from source

Libjaylink submodule disabled by default at
https://review.openocd.org/c/openocd/+/7129

--enable-internal-libjaylink config option will be deprecated soon.

So, building the source is a permanent solution.

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: Id06654d806a3a49f35e3ba41e9e4cc58c1a0d388
Reviewed-on: https://review.openocd.org/c/openocd/+/7552
Tested-by: jenkins
Reviewed-by: zapb <dev@zapb.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
12 months agogithub/workflow: increase delete-tag-and-release version 51/7551/6
Erhan Kurubas [Fri, 24 Mar 2023 23:56:19 +0000 (02:56 +0300)]
github/workflow: increase delete-tag-and-release version

During setup job in the GH actions, GH tries to resolve
all actions before starting to run the scripts.
It can not find 0.2.0 version inside
'dev-drprasad/delete-tag-and-release 'repo and action fails.

This patch fixes that error.
Also, switched to the latest ubuntu image
Hidapi version updated to 0.13.1

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: I02af41f6189d5a28f874c9b008073d74de46b4ca
Reviewed-on: https://review.openocd.org/c/openocd/+/7551
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
12 months agoflash/nor: missing fileio_close. 46/7546/4
panciyan [Mon, 20 Mar 2023 02:26:58 +0000 (02:26 +0000)]
flash/nor: missing fileio_close.

If the file read abnormally, need to close it which was opened before.

Signed-off-by: panciyan <panciyan@eswincomputing.com>
Change-Id: I6142f154741dcd38088b7add2793219ee4dd2ae9
Reviewed-on: https://review.openocd.org/c/openocd/+/7546
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
12 months agotcl/board: add Calao USB-A9G20 24/7524/7
Wolfram Sang [Sun, 5 Mar 2023 07:38:14 +0000 (08:38 +0100)]
tcl/board: add Calao USB-A9G20

Add a basic config.

Signed-off-by: Wolfram Sang <wsa@kernel.org>
Change-Id: Ie68e5fbb26b1c2f3028e561af0255fa71ec61828
Reviewed-on: https://review.openocd.org/c/openocd/+/7524
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
12 months agotcl/board/calao-usb-a9260: fix and refactor broken support 22/7522/5
Wolfram Sang [Fri, 3 Mar 2023 11:26:46 +0000 (12:26 +0100)]
tcl/board/calao-usb-a9260: fix and refactor broken support

The old configuration files did not work because of a missing
'at91sam9260minimal.cfg' file. Also, the config files were placed
wrongly. Update them, put them to the proper location, merge the two
supported boards into one, remove now superfluous include, remove
defunct web page, etc.. Tested with a Calao USB-A9G20 and a hacked
'device_desc' to match. Native support for it will come next.

Signed-off-by: Wolfram Sang <wsa@kernel.org>
Change-Id: Iec578c8777c5a6134e132dbac17c2988c7634742
Reviewed-on: https://review.openocd.org/c/openocd/+/7522
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
12 months agotarget: rewrite command 'target smp' as COMMAND_HANDLER 11/7511/2
Antonio Borneo [Mon, 19 Dec 2022 23:11:41 +0000 (00:11 +0100)]
target: rewrite command 'target smp' as COMMAND_HANDLER

This also fixes an incorrect return ERROR_xx from a jim command,
propagated from return value of rtos_smp_init().

Change-Id: Icf4893c00aabd8fadd60077c5e8a2e926f687518
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7511
Tested-by: jenkins
12 months agotarget: rewrite command 'target names' as COMMAND_HANDLER 10/7510/2
Antonio Borneo [Mon, 19 Dec 2022 22:58:01 +0000 (23:58 +0100)]
target: rewrite command 'target names' as COMMAND_HANDLER

Print one entry per line.
While there add the mandatory 'usage' field.

Change-Id: Ia832684817f3bdbfa4cb943cd97e3f9fb2605902
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7510
Tested-by: jenkins
12 months agotarget: rewrite command 'target types' as COMMAND_HANDLER 09/7509/2
Antonio Borneo [Mon, 19 Dec 2022 22:54:10 +0000 (23:54 +0100)]
target: rewrite command 'target types' as COMMAND_HANDLER

Print one entry per line.
While there add the mandatory 'usage' field.

Change-Id: I135556e12154e33fdbd0f71d89f6fe37c69813b7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7509
Tested-by: jenkins
12 months agotarget: rewrite command 'target current' as COMMAND_HANDLER 08/7508/2
Antonio Borneo [Mon, 19 Dec 2022 22:50:23 +0000 (23:50 +0100)]
target: rewrite command 'target current' as COMMAND_HANDLER

While there add the mandatory 'usage' field.

Change-Id: I3e5b826ca58f7ade30a443ada0cb4a9cd9ea35c2
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7508
Tested-by: jenkins
12 months agotarget: rewrite command 'arp_halt_gdb' as COMMAND_HANDLER 07/7507/2
Antonio Borneo [Mon, 19 Dec 2022 22:44:04 +0000 (23:44 +0100)]
target: rewrite command 'arp_halt_gdb' as COMMAND_HANDLER

While there add the mandatory 'usage' field.

Change-Id: I5389881dac25877dc32930ec36ee546e48ecc14d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7507
Tested-by: jenkins
12 months agotarget: rewrite command 'examine_deferred' as COMMAND_HANDLER 06/7506/2
Antonio Borneo [Mon, 19 Dec 2022 22:41:22 +0000 (23:41 +0100)]
target: rewrite command 'examine_deferred' as COMMAND_HANDLER

Check for empty command line, add the mandatory 'usage' field.

Change-Id: I9c3606242ec3dda9026fe19222162a110e618bff
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7506
Tested-by: jenkins
12 months agotarget: rewrite command 'was_examined' as COMMAND_HANDLER 05/7505/2
Antonio Borneo [Mon, 19 Dec 2022 22:37:07 +0000 (23:37 +0100)]
target: rewrite command 'was_examined' as COMMAND_HANDLER

Check for empty command line, add the mandatory 'usage' field.

Change-Id: I3f59448458fe01268bf5f4293aea5adcbd6d8279
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7505
Tested-by: jenkins
12 months agotarget: rewrite command 'target curstate' as COMMAND_HANDLER 04/7504/2
Antonio Borneo [Mon, 19 Dec 2022 22:25:21 +0000 (23:25 +0100)]
target: rewrite command 'target curstate' as COMMAND_HANDLER

While there, add the mandatory 'usage' field.

Change-Id: Ibfda6f56a1450e2eb9ad3092d756de0778f4a092
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7504
Tested-by: jenkins
12 months agotarget: rewrite command 'read_memory' as COMMAND_HANDLER 03/7503/2
Antonio Borneo [Mon, 19 Dec 2022 22:15:54 +0000 (23:15 +0100)]
target: rewrite command 'read_memory' as COMMAND_HANDLER

While there, fix typo on 'exceeds'.
In a following patch, the output could be formatted and split in N
values per line to make it easier to read by humans.

Change-Id: I295111a80934393011e46311f6cf6c13f2bdc0a3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7503
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)