openocd.git
3 years agotarget: do not print an error on shutdown in target events 10/5710/2
Antonio Borneo [Tue, 2 Jun 2020 12:43:29 +0000 (14:43 +0200)]
target: do not print an error on shutdown in target events

Before commit b3ce5a0ae545 ("target: use LOG_USER to print errors
in events") an error in an event handler was silently lost, while
now the associated message is printed out.

A "shutdown" command in a target event (e.g. in gdb-detach) causes
the event to end with error code ERROR_COMMAND_CLOSE_CONNECTION,
that triggers the error message:
shutdown command invoked
Error executing event <event-name> on target <target-name>:

The error code returned by the command "shutdown" is required to
stop the execution in a script/proc and avoid executing any
further command in the script/proc.
It is then normal to get an error code from the "shutdown" command
and it should not be printed out.

Intercept the return code of the event in case of "shutdown", then
skip scheduling other target events and return without printing
the incorrect error message.

Change-Id: Ia3085fb46beacb90a5e4bf0abf7c6e28bb9e6a9b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Laurent Lemele <laurent.lemele@st.com>
Reviewed-on: http://openocd.zylin.com/5710
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Tested-by: jenkins
3 years agojtag: drivers: xlnx-pcie-xvc: Add support for SWD mode. 47/5447/5
Moritz Fischer [Sun, 9 Feb 2020 00:09:04 +0000 (16:09 -0800)]
jtag: drivers: xlnx-pcie-xvc: Add support for SWD mode.

Add support for SWD debug to the Xilinx XVC/PCIe driver.

This is possible since the device is essentially a shift-register.
So doing SWD vs JTAG is a matter of wiring things correctly on the
RTL side (use TMS for SWDI, TDO for SWDO).

The clang static checker doesn't find any new problems with this change.

Change-Id: I3959e21440cd1036769e8e56a55e601d3e4aee9a
Signed-off-by: Moritz Fischer <moritzf@google.com>
Reviewed-on: http://openocd.zylin.com/5447
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotarget/arc: Introduce L1I,L1D,L2 caches support 88/5688/5
Evgeniy Didin [Fri, 15 May 2020 20:04:01 +0000 (23:04 +0300)]
target/arc: Introduce L1I,L1D,L2 caches support

With this commit we introduce L1 and L2 cache
flush and invalidate operations which are necessary for
getting/setting actual data during memory r/w operations.

We introduce L2 cache support, which is not presented
on currently support EMSK board. But L2 is presented
on HSDK board, which soon will be introduced.

Change-Id: I2fda505a47ecb8833cc9f5ffe24f6a4e22ab6eb0
Signed-off-by: Evgeniy Didin <didin@synopsys.com>
Reviewed-on: http://openocd.zylin.com/5688
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoaarch64: Add support for debugging in HYP mode on ARMv8-A cores 55/5255/4
Lucas [Sun, 17 May 2020 15:42:39 +0000 (16:42 +0100)]
aarch64: Add support for debugging in HYP mode on ARMv8-A cores

When debugging an ARMv8-A/AArch32 target running HYP mode, OpenOCD would
throw the following error to GDB on most operations (step, set breakpoint):

cannot read system control register in this mode

The mode in question is 0x1A, a privilege level 2 mode available on cores
that have the virtualization extensions (such as the Raspi 3).

Note: this mode is only used when running in AArch32 compatibility mode.

Signed-off-by: Lucas Jenss <public@x3ro.de>
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Change-Id: Ia8673ff34c5b3eed60e24d8da57c3ca8197a60c2
Reviewed-on: http://openocd.zylin.com/5255
Tested-by: jenkins
Reviewed-by: Lucas Jenß <lucas.jenss@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agolibjaylink: Update to latest Git version 23/5723/2
Marc Schink [Sun, 14 Jun 2020 19:57:35 +0000 (21:57 +0200)]
libjaylink: Update to latest Git version

This update is for testing the upcoming 0.2.0 release.

Change-Id: I400b09eb3ead4306c83c7980c621124101aaef7e
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5723
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
3 years agotarget/armv7m_trace: Calculate prescaler for external capture devices 10/5610/3
Marc Schink [Sun, 26 Apr 2020 17:28:15 +0000 (19:28 +0200)]
target/armv7m_trace: Calculate prescaler for external capture devices

This fixes a regression introduced in "2dc88e1479f29ef0141b05bfcd907ad9a3e2d54c"

Change-Id: I04dc19ed30118a4c499b83732700b2ee0fdb67b6
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5610
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
3 years agotarget/icepick.cfg: Add support for Test TAPs in ICEPick C 15/5715/2
Edward Fewell [Wed, 3 Jun 2020 19:55:07 +0000 (14:55 -0500)]
target/icepick.cfg: Add support for Test TAPs in ICEPick C

In addition to the debug TAPs, the ICEPick C also supports
a bank of Test TAPs (limited functionality intended for
non-debuggable targets). Added support for Test TAPs to
the icepick_c_tapenable routine. Port numbers of 0 to 15
will continue to be handled as a debug TAP number. Test
TAPs will be port numbers of 16 to 31.

This functionality will be needed for doing a flash
mass erase on CC26xx/CC13xx targets. It is possible
for user application to block even adding the Cortex M
TAP to the scan chain, so the only way to unbrick the
target and erase the flash is using a component on a
test TAP of the device's ICEPick router.

Change-Id: I0aa52a08d43a00cbd396efdeadd504fc31c98510
Signed-off-by: Edward Fewell <efewell@ti.com>
Reviewed-on: http://openocd.zylin.com/5715
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoflash/nor/stm32l4x: Fix check for number of arguments 16/5716/2
Marc Schink [Fri, 15 May 2020 08:06:07 +0000 (10:06 +0200)]
flash/nor/stm32l4x: Fix check for number of arguments

The current version erroneously allows any number of arguments >= 1.

Change-Id: I64156c11b48d411c72bebbf866954818cd036ff2
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5716
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agostlink: code factorization by introducing stlink_usb_exit_mode 12/5612/3
Tarek BOCHKATI [Mon, 27 Apr 2020 12:09:27 +0000 (13:09 +0100)]
stlink: code factorization by introducing stlink_usb_exit_mode

Change-Id: I4abd6432c4ef969e382bfed96cd19a49d9610000
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5612
Tested-by: jenkins
3 years agoopenocd: fix issue in WIN32 with TCP adapters 56/5456/5
Tarek BOCHKATI [Thu, 23 Apr 2020 10:00:31 +0000 (11:00 +0100)]
openocd: fix issue in WIN32 with TCP adapters

Issue: server_quit is called before adapter_quit:
  In WIN32 only in server_quit we do an WSACleanup,
  which terminates/closes all active sockets.
  So if the adapter is TCP based, the adapter.quit handler
  will fail if it will need to send some commands through TCP.

Example: close_socket in jtag_vpi_quit will fail in WIN32
  because the socket is already closed
  and the errno is set as "Bad File Descriptor"

To fix that we introduced new functions called server_host_os_entry/quit
to manage specific OS setup (hence WSA for sockets in WINDOWS) in order
to delay WSACleanup after adapter_quit().

Change-Id: Ie4afacafe123857f6ae300e376bdfcf0d8c027ac
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5456
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoboard: Add the HiFive1 revB board configuration 80/5680/2
Alistair Francis [Wed, 13 May 2020 22:04:16 +0000 (15:04 -0700)]
board: Add the HiFive1 revB board configuration

Change-Id: If186afcfd2c87414b9323569a16aed9a6054c883
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-on: http://openocd.zylin.com/5680
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tim Newsome <tim@sifive.com>
3 years agoflash: Add the Freedom E310-G002 SPI Flash 79/5679/2
Alistair Francis [Wed, 13 May 2020 22:03:44 +0000 (15:03 -0700)]
flash: Add the Freedom E310-G002 SPI Flash

Change-Id: Id9f4a209a6eacf186931b142e70a5b0458517be0
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-on: http://openocd.zylin.com/5679
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tim Newsome <tim@sifive.com>
3 years agocoding style: fix multi-line dereferencing 29/5629/4
Antonio Borneo [Mon, 6 May 2019 17:31:00 +0000 (19:31 +0200)]
coding style: fix multi-line dereferencing

Issue identified by checkpatch script from Linux kernel v5.1 using
the command

find src/ -type f -exec ./tools/scripts/checkpatch.pl \
-q --types MULTILINE_DEREFERENCE -f {} \;

Change-Id: Icba05613e22a72ecc3e6a0aad7cb6b479496146f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5629
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
3 years agojtag/tcl: fix memory leak in command 'irscan' 92/5692/2
Antonio Borneo [Thu, 21 May 2020 14:03:17 +0000 (16:03 +0200)]
jtag/tcl: fix memory leak in command 'irscan'

If the function parse_u64() fails, we jump to return, thus leaking
the memory just allocated in 'v'.
Issue identified by clang.

Move earlier the call to parse_u64() and the associated test,
before memory allocation.

While there, fix a possible NULL pointer dereferencing in case the
calloc() fails, by testing for allocation failure.

Change-Id: I6a77ee17aceb282bbdfefe7cdafeba2e0e7012f1
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5692
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
3 years agotarget/cortex_a: fix memory leak of register cache 93/5693/3
Antonio Borneo [Fri, 22 May 2020 16:55:34 +0000 (18:55 +0200)]
target/cortex_a: fix memory leak of register cache

There is no method to free the register cache, allocated in
armv4_5, so we get a memory leak.
Issue identified by valgrind.

Implement the method arm_free_reg_cache() and call it in cortex_a
deinit and to exit for error during arm_dpm_setup().
Tested on dual cortex-A stm32mp15x.
This change is inspired from similar fix in commit b01b5fe13a67
("armv7m: Fix memory leak in register caching.").

The same allocation is also used by target types "arm7tdmi",
"arm9tdmi", "arm11" and "xscale" but they all lack the deinit
method and I do not have relevant HW to test the fix. For such
reasons they are not addressed in this patch.

Change-Id: I4da1e1f12e36ec245d1f3b11a4eafcbd9a1d2e25
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5693
Tested-by: jenkins
3 years agotarget/mem_ap: fix two memory leaks 00/5700/2
Antonio Borneo [Fri, 22 May 2020 16:08:55 +0000 (18:08 +0200)]
target/mem_ap: fix two memory leaks

The target mem_ap misses the method 'deinit_target' and does not
free the memory allocated during 'target create' and 'configure'.

Add the missing method and free the allocated memory.
Issue identified with valgrind.

Change-Id: If0d0114a75dd76a8b65c2d46d96c6085fd31a09d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5700
Tested-by: jenkins
3 years agolibusb_helper: fix memory leak when no adapter is found 01/5701/2
Antonio Borneo [Mon, 25 May 2020 19:37:12 +0000 (21:37 +0200)]
libusb_helper: fix memory leak when no adapter is found

When jtag_libusb_open() fails to find the adapter, it returns
error but left libusb initialized causing memory leak of libusb
internal data.
Issue found with valgrind when no adapter or board is connected to
the host, e.g.
valgrind openocd -f board/st_nucleo_f4.cfg

Close the libusb operations if jtag_libusb_open() has to return
error.

Change-Id: Ieb2f110be15705dafe80c099e7d83c07056c2a41
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5701
Tested-by: jenkins
3 years agotarget/cortex-m: enable C_DEBUGEN during examine 02/5702/2
Antonio Borneo [Tue, 26 May 2020 22:03:45 +0000 (00:03 +0200)]
target/cortex-m: enable C_DEBUGEN during examine

Current code for Cortex M does not set C_DEBUGEN as soon as
possible, (which means during target examine), but later-on either:
1) at command 'halt' (e.g. for 'gdb-attach' event);
2) at command 'soft_reset_halt';
3) at commands 'reset', 'reset halt' or 'reset init';
4) during polling, but only if the target:
    = enter in 'double fault', or
    = exit from a reset, or
    = halts (not possible if C_DEBUGEN is not set)

Plus, if commands in 1) or 2) are executed before the very first
poll of the target, the value of 'cortex_m->dcb_dhcsr' is used not
initialized while writing it back in DCB_DHCSR.

Another side effect of this situation is that it's possible to set
a HW breakpoint with the target running, while C_DEBUGEN is not
set. Accordingly to [1], C1.3.1 "Debug authentication":
    When DGBEN is LOW and DHCSR.S_HALT == 0:
    ...
    FPB breakpoints do not generate an entry to Debug state and,
    if no DebugMonitor exception is generated, will escalate to
    HardFault, Lockup, or be ignored.
On STM32MP15x I get HW breakpoint ignored, while on STM32F411 I
get HardFault.
E.g. following these steps:
- power-on a pre-flashed board that starts running the firmware;
- connect openocd, without halting or resetting the board;
- set a HW breakpoint to some address often executed;
- wait, but the board doesn't halt ...;
- type the command 'halt';
- if the Cortex-M has HardFault it would be visible and the fault
  is at the breakpoint address;
- if no HardFault then type the command 'resume';
- wait and the board will finally halt at the HW breakpoint.

A similar issue has been detected on Cortex-A code and fixed by
commit bff87a7f28fb ("target/cortex_a: enable DSCR_HALT_DBG_MODE
during examine").
Follow the same approach and set C_DEBUGEN during examine.
Also, initialize 'cortex_m->dcb_dhcsr' during examine.

[1] ARM DDI 0403E "ARM v7-M Architecture Reference Manual"

Change-Id: I5b0b23403634f7dfce38f104bba9f59c33eb3e99
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5702
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Moritz Fischer <moritzf@google.com>
3 years agolog: fix kept_alive() and report expired timeout 05/5705/3
Antonio Borneo [Fri, 29 May 2020 10:00:35 +0000 (12:00 +0200)]
log: fix kept_alive() and report expired timeout

The kept_alive() function is called to inform the keep-alive code
that a keep-alive as been just kicked through some other path.
But kept_alive() erroneously resets the timeout counter without
checking if it has already expired, thus masking a potential
timeout.

Check if timeout counter has expired during kept_alive().
While there, put the timeout values in macros and explicit the
units in the timeout messages.

Change-Id: Iaf6368b44e5b5352b1cc4e7efbb2368575dcfa08
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5705
Reviewed-by: <jonatan_zeidler@gmx.de>
Tested-by: jenkins
3 years agonor/kinetis: add keep-alive during flash write 03/5703/2
Antonio Borneo [Fri, 29 May 2020 08:42:43 +0000 (10:42 +0200)]
nor/kinetis: add keep-alive during flash write

Flashing Kinetis MCU MK22FX512VLH12 takes longer than one second,
thus gdb connection can timeout. Before commit 7f260f5009a7
("helper/command: Handle Tcl return values consistently") the
openocd timeout warning was masked by a bug in gdb_put_packet()
that resets the timeout counter if any message is logged out.
The commit above removes one log message and the timeout warning
is now triggered.

While the bug in gdb_put_packet() is still to be fixed, the reason
of the timeout is the lack of keep_alive() calls in kinetis flash
driver.

Add keep_alive() call at every iteration in function
kinetis_write_sections(), that is reported as core write function
in chunks of 1024 bytes in the log from the reporter.
Add also a keep_alive() call at every iteration in function
kinetis_write_inner(). This part is not present in the log but, by
code analysis, it represents another critical loop.

Change-Id: I38e631b36c7eb2f1e21cef68710ce47c03d3edda
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Jonatan Hatakeyama Zeidler <jonatan.zeidler@medineering.de>
Reviewed-on: http://openocd.zylin.com/5703
Tested-by: jenkins
Reviewed-by: <jonatan_zeidler@gmx.de>
3 years agoarm_adi_v5: dap_ti_be_32_quirks_command minor simplification 08/5708/2
Tarek BOCHKATI [Sun, 31 May 2020 10:46:56 +0000 (11:46 +0100)]
arm_adi_v5: dap_ti_be_32_quirks_command minor simplification

use handle_command_parse_bool within dap_ti_be_32_quirks_command to make
it shorter and simpler.

Change-Id: Ice179cc477933b27e27235dc2ade23fe655e233d
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5708
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoarm_adi_v5: enhance command error reporting 54/5654/5
Tarek BOCHKATI [Sun, 31 May 2020 10:12:05 +0000 (11:12 +0100)]
arm_adi_v5: enhance command error reporting

avoid the usage of ERROR_COMMAND_SYNTAX_ERROR when
ERROR_COMMAND_ARGUMENT_INVALID is more adequate.

Change-Id: Ic9aaedb93fedd45efee1b39f8ea20185f01af2da
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5654
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agojtag/drivers/bcm2835gpio: bcm2835gpio_init has been updated 68/5568/3
tscn92 [Mon, 6 Apr 2020 14:05:08 +0000 (16:05 +0200)]
jtag/drivers/bcm2835gpio: bcm2835gpio_init has been updated

For jtag/drivers/bcm2835gpio dev_mem_fd has been updated within
bcm2835gpio_init with the add on of gpio to mem. This permits the
access to memory of GPIO without the need for root access.
For failed attempt, a fallback to original memory follows.
It should be noted that any printed error is relative to original
memory ("dev/mem").
Tested on EFM32GG12B390F board

Change-Id: I4540bdf62fb3b91a51221e277881adfae138dcc5
Signed-off-by: tscn92 <tscn@kamstrup.com>
Reviewed-on: http://openocd.zylin.com/5568
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotcl/boards: Rename 'ek-tm4c1294xl.cfg' to 'ti_ek-tm4c1294xl.cfg' 78/5478/4
Marc Schink [Wed, 26 Feb 2020 11:58:27 +0000 (12:58 +0100)]
tcl/boards: Rename 'ek-tm4c1294xl.cfg' to 'ti_ek-tm4c1294xl.cfg'

The new filename has a proper vendor prefix. Keep the old
configuration file for now but show a "deprecated" warning
at runtime.

Change-Id: If7465a752f47f3292e430c8b311148badfd384cd
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5478
Tested-by: jenkins
Reviewed-by: Karl Palsson <karlp@tweak.net.au>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotcl/boards: Rename 'ek-tm4c123gxl.cfg' to 'ti_ek-tm4c123gxl.cfg' 77/5477/4
Marc Schink [Wed, 26 Feb 2020 11:56:33 +0000 (12:56 +0100)]
tcl/boards: Rename 'ek-tm4c123gxl.cfg' to 'ti_ek-tm4c123gxl.cfg'

The new filename has a proper vendor prefix. Keep the old
configuration file for now but show a "deprecated" warning
at runtime.

Change-Id: I13871ec13709055843e23b1b6da90694fd60505e
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5477
Tested-by: jenkins
Reviewed-by: Karl Palsson <karlp@tweak.net.au>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotcl/boards: Rename 'dk-tm4c129.cfg' to 'ti_dk-tm4c129.cfg' 76/5476/5
Marc Schink [Wed, 26 Feb 2020 11:51:35 +0000 (12:51 +0100)]
tcl/boards: Rename 'dk-tm4c129.cfg' to 'ti_dk-tm4c129.cfg'

The new filename has a proper vendor prefix. Keep the old
configuration file for now but show a "deprecated" warning
at runtime.

Change-Id: I30fcb8f291d401acaa1fe665db0eeabc250d24b6
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5476
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoUpdate Autotools Mythbuster link to avoid multiple redirects. 09/5709/2
Diego Elio Pettenò [Tue, 2 Jun 2020 10:52:01 +0000 (11:52 +0100)]
Update Autotools Mythbuster link to avoid multiple redirects.

While I'm hoping to maintain the chain of redirects for the foreseeable
future, it makes sense to point at the final URL now that Autotools
Mythuster has had its domain for a long while.

Change-Id: I6d912e3be0f81b25bec14746ebfee58f29f144b6
Signed-off-by: Diego Elio Pettenò <flameeyes@flameeyes.com>
Reviewed-on: http://openocd.zylin.com/5709
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
3 years agohelper/command: remove unused functions and make static local ones 63/5663/2
Antonio Borneo [Sun, 10 May 2020 08:57:59 +0000 (10:57 +0200)]
helper/command: remove unused functions and make static local ones

The function command_find_in_parent() is never used in OpenOCD, so
remove it.

The functions command_name() and [un]register_command() are only
used internally in command.c, so make them static.

Change-Id: Ide9842659796f4884fb6c1fcf5979b3b71b67abb
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5663
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
3 years agoopenocd: properly use jim data types 62/5662/2
Antonio Borneo [Tue, 12 May 2020 00:52:30 +0000 (02:52 +0200)]
openocd: properly use jim data types

The jim library exports all the data types through typedef, so
there is no need to use the internal struct types.

Fix the few remaining inconsistencies in the code.

Change-Id: Id4ae0083563ea7a371833374e7b39f17158f66a4
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5662
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
3 years agohelper/command: fix check on value returned by jim API 61/5661/2
Antonio Borneo [Tue, 12 May 2020 22:47:17 +0000 (00:47 +0200)]
helper/command: fix check on value returned by jim API

Either Jim_CreateCommand() and register_command_handler() return
the jim error code JIM_OK/JIM_ERR.

Fix the check and the initialization of retval.

Change-Id: I3073c66764670128706ad979a43bb3edbbeb0ab0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5661
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
3 years agohelper/command: strip replicated command name in log 60/5660/2
Antonio Borneo [Sun, 20 Oct 2019 17:40:28 +0000 (19:40 +0200)]
helper/command: strip replicated command name in log

After commit 0840414f0e57 ("helper/command: do not replace new
commands with ocd_ prefix"), the command name is present in
argv[0], so there is no need to pass it directly. The current code
causes the command name to be logged twice, once explicitly and
then from the content of argv[0]:
openocd -c 'debug_level 3; echo hello; shutdown'
<snip>
Debug: 13 3 command.c:142 script_debug(): command - echo echo hello
<snip>
Debug: 16 4 command.c:142 script_debug(): command - shutdown shutdown

Remove the command name from the arguments of the function
script_debug().

Change-Id: I57860774f450ff717ee71ef9dc07590549a84319
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5660
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
3 years agostlink: fix open AP for v2j37 and v3j7 91/5691/3
Antonio Borneo [Thu, 21 May 2020 11:24:32 +0000 (13:24 +0200)]
stlink: fix open AP for v2j37 and v3j7

The new stlink firmware requires opening the AP before issuing
any operation.
In the current code we have a 'questionable' check about the core
model to set the TAR autoincrement, that is issued without opening
the AP, thus causing a STLINK_BAD_AP_ERROR.

Modify the AP open API to handle this case and open AP#0 before
the memory access to check the core model.

Change-Id: I576955b5094bd41d63ff1fbad7b4fd9433253321
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-on: http://openocd.zylin.com/5691
Tested-by: jenkins
Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com>
3 years agostlink: fix incorrectly returned error on v2j28 83/5683/2
Antonio Borneo [Fri, 15 May 2020 12:55:42 +0000 (14:55 +0200)]
stlink: fix incorrectly returned error on v2j28

Firmware v2j28 introduces the API to open and close the AP, but
closing AP always returns error 0x1d (STLINK_BAD_AP_ERROR).

Ignore the error returned by the bogus firmware on closing AP.

Change-Id: I992ddbf7acb10f1d376ed8f781eeb3344605b85d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5683
Tested-by: jenkins
3 years agostlink: default dapdirect to SWD instead of JTAG 38/5538/5
Antonio Borneo [Mon, 23 Mar 2020 14:58:01 +0000 (15:58 +0100)]
stlink: default dapdirect to SWD instead of JTAG

When the transport is not specified, OpenOCD uses the first listed
by the selected adapter driver.
The old HLA driver for stlink lists SWD as first. The new driver
dapdirect instead lists JTAG, making more difficult a fallback to
HLA when dapdirect is not available due to old stlink FW.
Plus, in case of JTAG wiring, SWD is still possible, while the
opposite is not.

Reorder the list of transports to grant the default to SWD.

Change-Id: Id9c529e921b148d5b352d4603a9028c2a5f15d83
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Suggested-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5538
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
3 years agostm8 target: make adapter speed settings work 48/5548/4
Ake Rehnman [Sun, 29 Mar 2020 19:57:53 +0000 (21:57 +0200)]
stm8 target: make adapter speed settings work

Previously the adapter speed settings were hard-coded to
connect with low speed then switch over to high speed
regardless what was mentioned in the cfg files. Now the
stm8 target intercept adapter speed settings and configure
the stm8 control registers accordingly.

Change-Id: I7419514e5214e4b43b9d51253cf5b7f04a233533
Signed-off-by: Ake Rehnman <ake.rehnman@gmail.com>
Reviewed-on: http://openocd.zylin.com/5548
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotcl/board: add board ST nucleo-8l152r8 43/5543/4
Antonio Borneo [Thu, 26 Mar 2020 09:49:04 +0000 (10:49 +0100)]
tcl/board: add board ST nucleo-8l152r8

The transport SWIM is selected twice, in board and in target, thus
a warning is generated at run-time. It should be fixed by remove a
line in the target file, but does not harm so let's keep it there
for the time being.

Change-Id: I479004dc16005a330d552c8dbd5def61690f9b9f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5543
Tested-by: jenkins
3 years agoRevert "adapter: expose HLA interface in struct adapter_driver" 33/5533/6
Antonio Borneo [Thu, 19 Mar 2020 11:12:20 +0000 (12:12 +0100)]
Revert "adapter: expose HLA interface in struct adapter_driver"

No reason to keep longer this temporary hack.
Remove it by reverting the original commit.

Change-Id: I5c6dcdb1f4755b7dba4c03a5033913ef8db35e18
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5533
Tested-by: jenkins
3 years agostlink: simplify handling of SWIM 32/5532/6
Antonio Borneo [Tue, 28 Jan 2020 14:53:06 +0000 (15:53 +0100)]
stlink: simplify handling of SWIM

Now that SWIM is not accessed through HLA anymore, decouple the
SWIM code and remove the conditional execution.

Fix the inconsistency of the return type for stlink_usb_state() in
case of SWIM (returns ERROR_OK while type is enum target_state)
introduced by commit 3de6b5f6e52f ("jtag/drivers/stlink_usb :
implemented and repaired SWIM support").
The code added by commit above in stlink_usb_state() is an hack to
reuse existing HLA API to perform a reconnect.
Move the SWIM specific code from stlink_usb_state() to a dedicated
stlink_swim_op_reconnect() that provides consistent data type.

Change-Id: I3fe175fef00b0735bea6139b057f217a080c9d38
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 3de6b5f6e52f ("jtag/drivers/stlink_usb : implemented and repaired SWIM support")
Reviewed-on: http://openocd.zylin.com/5532
Tested-by: jenkins
3 years agostlink: simplify mem R/W with SWIM 31/5531/7
Antonio Borneo [Tue, 4 Feb 2020 11:53:54 +0000 (12:53 +0100)]
stlink: simplify mem R/W with SWIM

Thanks to API separation between SWIM and the other transports, we
can easily split the memory read/write for SWIM from the rest of
the code.
While there, use the macro STLINK_DATA_SIZE as size of data chunks
that can be read/write in SWIM. This was not implemented before.

Change-Id: I7d913c92539007e4d914480bacc0126a8f0e9705
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5531
Tested-by: jenkins
3 years agoswim: add new transport 30/5530/6
Antonio Borneo [Mon, 27 Jan 2020 17:45:10 +0000 (18:45 +0100)]
swim: add new transport

Add SWIM and STM8 to documentation and update TODO file.
Introduce transport "swim" and command "swim newtap".
Switch in swim.c from HLA API to the new SWIM API.
Implement in stlink driver the SWIM APIs as wrappers of existing
HLA functions.
Remove any SWIM related reference from HLA files.
Update stm8 config files and stlink-dap interface config file.

Change-Id: I2bb9f58d52900f6eb4df05f979f7ef11fd439c24
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5530
Tested-by: jenkins
3 years agoswim: fix adapter speed handling 29/5529/6
Antonio Borneo [Tue, 4 Feb 2020 10:07:01 +0000 (11:07 +0100)]
swim: fix adapter speed handling

SWIM transport only supports two adapter speeds:
- "low speed"  equal to 363 kHz (8 MHz / 22)
- "high speed" equal to 800 kHz (8 MHz / 10)

Replace the previous convention that use "0" or "1" for "low" or
"high" speed with the effective speed in kHz.
Rework the implementation of stlink_speed_swim().
Set low speed in the stm8 config files, because only low speed is
permitted at debug connection; the previous code ignores the
initial value.

Change-Id: I2484c9419a2c554c59eb6b9216339393ab0b54f3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5529
Tested-by: jenkins
3 years agoswim: abstract the transport in stm8 target 28/5528/6
Antonio Borneo [Sun, 26 Jan 2020 16:00:55 +0000 (17:00 +0100)]
swim: abstract the transport in stm8 target

SWIM is implemented by (ab)using the HLA API. This was acceptable
when OpenOCD code did not provided a clear separation between
transports and related APIs. Still today SWIM in OpenOCD is only
supported by STLink, so the decision to re-use the HLA API was the
simpler way to implement it.
After commit efd1d642220a ("adapter: switch from struct
jtag_interface to adapter_driver") the transports API are better
split and SWIM can be implemented as a separate set of API. This
would open the possibility to extend OpenOCD for other adapters
that provide SWIM, e.g. versaloon, or through SPI emulation [1].

Introduce a new set of files swim.[ch] to handle the SWIM API.
Beside the API that almost match the transport low-level data
communication (system_reset, read_mem, write_mem), add a further
API reconnect. Today, inside HLA STLink code, the reconnect is
implemented by hacking the HLA API state(). Please notice that
due to this hack the return type is incorrect; stlink_usb_state()
returns ERROR_OK in SWIM mode, while its return type is enum
target_state. Ignore the type mismatch and still call the HLA API
state in the new SWIM API reconnect. Further commit will fix it.

[1] http://kuku.eu.org/?projects/stm8spi/stm8spi

Change-Id: I52018e1e2200cbd41af8e5031f7b35dc761b61d6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5528
Tested-by: jenkins
3 years agoadapter: expose HLA interface in struct adapter_driver 27/5527/6
Antonio Borneo [Sun, 26 Jan 2020 15:30:14 +0000 (16:30 +0100)]
adapter: expose HLA interface in struct adapter_driver

The transition of STM8/SWIM out of HLA will require a new struct
swim_ops in struct adapter_driver.
To simplify the development, make the HLA interface temporarily
accessible through the struct adapter_driver.
This commit will be reverted after the swim rework.

Change-Id: I1e4f370cf64641164d7bcaa22f75ac58c9240052
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5527
Tested-by: jenkins
3 years agostlink: reduce use of hla specific enum hl_transports 26/5526/6
Antonio Borneo [Wed, 18 Mar 2020 21:35:26 +0000 (22:35 +0100)]
stlink: reduce use of hla specific enum hl_transports

In the driver's code it's widely used the enum hl_transports for
any check concerning the current transport, even for the non-hla
transport dapdirect.
The driver already provides a stlink specific enum stlink_mode
that can be used in place of the hla one.

Replace the hla enum with the stlink one allover the code.
Introduce a hla specific wrapper stlink_usb_hl_open() to cope with
the only API that requires the hla specific enum.

The overall behaviour is not changed, with exception for a debug
message in stlink_usb_open() than now prints the numeric value of
stlink enum in place of the numeric value of the corresponding hla
one.

This change prepares the road for moving SWIM transport out of hla
by removing any reference to the macro HL_TRANSPORT_SWIM from the
stlink driver.

Change-Id: Ieeea34f312245a94bfc1333087afdb8eb9f77139
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5526
Tested-by: jenkins
3 years agoflash/nor/sh_qspi: Fix dead assignment 45/5645/2
Marc Schink [Mon, 4 May 2020 14:56:14 +0000 (16:56 +0200)]
flash/nor/sh_qspi: Fix dead assignment

Change-Id: I6a99076fea30062535e615244895698e51107441
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5645
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoarm_disassembler: fix typo 'ARM_UNKNOWN_INSTUCTION' to '.._INSTRUCTION' 57/5657/2
Tarek BOCHKATI [Tue, 12 May 2020 20:00:18 +0000 (21:00 +0100)]
arm_disassembler: fix typo 'ARM_UNKNOWN_INSTUCTION' to '.._INSTRUCTION'

Change-Id: I3a3d566fe96fb1497cf8337389e993e0f728a64b
Signed-off-by: Laurent LEMELE <laurent.lemele@st.com>
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5657
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agonor/flash: Add keep_alive() during flash write handler 82/5682/2
Edward Fewell [Thu, 14 May 2020 20:49:15 +0000 (15:49 -0500)]
nor/flash: Add keep_alive() during flash write handler

Added keep_alive() call inside main flash write loop. Large
files where causing a gdb timeout warning.

Change-Id: I525dad2d644e248dd9ecf678e4d8e33c22eefdf2
Signed-off-by: Edward Fewell <efewell@ti.com>
Reviewed-on: http://openocd.zylin.com/5682
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agoflash/nor/jtagspi: propagate error from jtag_execute_queue() 84/5684/3
Tomas Vanek [Sun, 17 May 2020 06:17:25 +0000 (08:17 +0200)]
flash/nor/jtagspi: propagate error from jtag_execute_queue()

Change-Id: Ib985bdf3d60345a1e701f9cc98f89a47ff74d3e2
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5684
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agortos/ChibiOS: Fix some coding styles 89/4989/3
Marc Schink [Wed, 6 Mar 2019 11:16:53 +0000 (12:16 +0100)]
rtos/ChibiOS: Fix some coding styles

Change-Id: I2648479df1a2dd95f8a57868c4ed4259e0fbbe11
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4989
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agocontrib: Add HiFive1 to udev rules 78/5678/2
Alistair Francis [Wed, 13 May 2020 22:03:14 +0000 (15:03 -0700)]
contrib: Add HiFive1 to udev rules

Change-Id: I4ba9219e1c673d650931f8f9426d554de8322abf
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-on: http://openocd.zylin.com/5678
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoflash: nor: jtagspi: make read_status report errors 83/4383/2
Paul Fertser [Tue, 30 Jan 2018 09:17:33 +0000 (12:17 +0300)]
flash: nor: jtagspi: make read_status report errors

This is a follow-up to 3c9bd7c6f30a34e3930e44dd2e8ce5f5a877b4eb.

Change-Id: If430f7fcfbba084d9cd74b32344ad43508a96a77
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4383
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agotarget/arc: fix build with clang 55/5655/2
Antonio Borneo [Tue, 12 May 2020 14:21:13 +0000 (16:21 +0200)]
target/arc: fix build with clang

Commit da41bce3aee9 ("target/arc: introduce breakpoint
functionality") introduces a mismatch between the format string
and one int constant.

Change the format string to match the int constant.

Change-Id: I0d59552205551b90e165c0a2e3fef247ad0c7701
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: da41bce3aee9 ("target/arc: introduce breakpoint functionality")
Reviewed-on: http://openocd.zylin.com/5655
Tested-by: jenkins
Reviewed-by: Evgeniy Didin <didin@synopsys.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
3 years agocortex_m: make bit fields in cortex_m unsigned. 83/5583/6
iosabi [Thu, 9 Apr 2020 16:23:34 +0000 (16:23 +0000)]
cortex_m: make bit fields in cortex_m unsigned.

Expression like (0xffff << 16) evaluate to type int, which is not able
to hold that value, producing a warning when compiling with
-fsanitize=undefined. This patch makes most of the cortex_m constants
unsigned using the BIT() macro or appending "ul" when possible to fix
the undefined behavior warning.

Signed-off-by: iosabi <iosabi@protonmail.com>
Change-Id: I7af194305ef612d7a32e74eaf9f11dd85fa87f32
Reviewed-on: http://openocd.zylin.com/5583
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Christopher Head <chead@zaber.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agoflash/nor/bluenrg-x: Minor code cleanups 62/5462/4
Marc Schink [Thu, 20 Feb 2020 20:55:53 +0000 (21:55 +0100)]
flash/nor/bluenrg-x: Minor code cleanups

Change-Id: I7844eb30d58b0a23ca5bcc94181066cca6fa0861
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5462
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agocoding style: open function's brace at beginning of new line 28/5628/3
Antonio Borneo [Mon, 6 May 2019 16:32:02 +0000 (18:32 +0200)]
coding style: open function's brace at beginning of new line

Issue identified by checkpatch script from Linux kernel v5.1 using
the command

find src/ -type f -exec ./tools/scripts/checkpatch.pl \
-q --types OPEN_BRACE -f {} \;

Change-Id: I6d1356ed11e2699525f384efb7556bc2efdc299f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5628
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
3 years agocoding style: wrap lines longer than 120 chars 26/5626/3
Antonio Borneo [Mon, 6 May 2019 13:07:19 +0000 (15:07 +0200)]
coding style: wrap lines longer than 120 chars

The coding style is quite permissive allowing 120 chars per line,
but abuses are still present.
Fix them, wrapping the lines.

Change-Id: I94d66b651d759a60ec35f7ba115c43933e70ed69
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5626
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agocoding style: join consecutive string fragments 25/5625/3
Antonio Borneo [Mon, 6 May 2019 12:37:19 +0000 (14:37 +0200)]
coding style: join consecutive string fragments

The re is no need to split a long string, apart for fitting the
predefined line width.
Join the consecutive string fragments.

Issue identified by checkpatch script from Linux kernel v5.1 using
the command

find src/ -type f -exec ./tools/scripts/checkpatch.pl \
-q --types STRING_FRAGMENTS -f {} \;

Change-Id: I8de52d572b0e3d4788c1d4d2b0cf8f94c7f08409
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5625
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agocoding style: let "else" follow the close brace 23/5623/2
Antonio Borneo [Mon, 6 May 2019 10:56:38 +0000 (12:56 +0200)]
coding style: let "else" follow the close brace

The statement "else" should not be on a new line when follows a
close brace '}'. Fix it!

Issue identified by checkpatch script from Linux kernel v5.1 using
the command

find src/ -type f -exec ./tools/scripts/checkpatch.pl \
-q --types ELSE_AFTER_BRACE -f {} \;

Change-Id: I8af247ec3f75a69713d7cb1e73881254d16c189e
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5623
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
3 years agocoding style: remove useless return statement from void functions 22/5622/2
Antonio Borneo [Mon, 6 May 2019 10:41:22 +0000 (12:41 +0200)]
coding style: remove useless return statement from void functions

For void functions, a return as last statement is useless.
Remove it.

Issue identified by checkpatch script from Linux kernel v5.1 using
the command

find src/ -type f -exec ./tools/scripts/checkpatch.pl \
-q --types RETURN_VOID -f {} \;

Change-Id: Ie0616fe98623f30d2d7b04ac9517d669774092de
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5622
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
3 years agocoding style: prototype of functions with no parameters 21/5621/2
Antonio Borneo [Mon, 6 May 2019 10:31:57 +0000 (12:31 +0200)]
coding style: prototype of functions with no parameters

Functions that have no parameters should use "void" as parameter
in the function declaration.

Issue identified and fixed by script checkpatch from Linux kernel
v5.1 using the command

find src/ -type f -exec ./tools/scripts/checkpatch.pl \
-q --types FUNCTION_WITHOUT_ARGS --fix-inplace -f {} \;

Change-Id: If104ac75b44e939ec86155ff7b5720f2e33c6b39
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5621
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
3 years agocoding style: add missing space when split strings 20/5620/2
Antonio Borneo [Mon, 6 May 2019 10:18:30 +0000 (12:18 +0200)]
coding style: add missing space when split strings

Long strings are split across few lines; usually split occurs at
the white space between two words.
Check that the space between the two words is still present.
While there, adjust the amount of space between words.

Issue identified by checkpatch script from Linux kernel v5.1 using
the command

find src/ -type f -exec ./tools/scripts/checkpatch.pl \
-q --types MISSING_SPACE -f {} \;

Change-Id: I28b9a65564195ba967051add53d1c848c7b8fb30
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5620
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
3 years agocoding style: avoid unnecessary line continuations 19/5619/2
Antonio Borneo [Sun, 5 May 2019 23:03:52 +0000 (01:03 +0200)]
coding style: avoid unnecessary line continuations

Line continuation, adding a backslash as last char of the line, is
requested in multi-line macro definition, but is not necessary in
the rest of C code.

Remove it where present.

Identified by checkpatch script from Linux kernel v5.1 using the
command

find src/ -type f -exec ./tools/scripts/checkpatch.pl \
-q --types LINE_CONTINUATIONS -f {} \;

Change-Id: Id0c69e93456731717a7b290b16580e9f8ae741bc
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5619
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
3 years agocoding style: add parenthesis around the argument of sizeof 18/5618/2
Antonio Borneo [Sun, 5 May 2019 22:35:52 +0000 (00:35 +0200)]
coding style: add parenthesis around the argument of sizeof

The script checkpatch available in new Linux kernel offers an
experimental feature for automatically fix the code in place.
While still experimental, the feature works quite well for simple
fixes, like parenthesis.

This patch has been created automatically with the script under
review for inclusion in OpenOCD, using the command:

find src/ -type f -exec ./tools/scripts/checkpatch.pl \
-q --types SIZEOF_PARENTHESIS --fix-inplace -f {} \;

Change-Id: I8adb325bdb0e13211f8bae8b4770ec1979c176bf
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5618
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
3 years agocoding style: remove useless break after a goto or return 17/5617/2
Antonio Borneo [Sun, 5 May 2019 22:03:03 +0000 (00:03 +0200)]
coding style: remove useless break after a goto or return

In a switch/case statement, a break placed after a goto or return
is never executed.
The script checkpatch available in Linux kernel v5.1 issues a
warning for such unused break statements.
In the process of reviewing the new checkpatch for its inclusion
in OpenOCD, let's get rid of these warnings.

The script checkpatch is unable to fixup automatically this case.
Thanks to having "break" command using a single code line, this
patch has been generated using the script below:

find src/ -type f -exec ./tools/scripts/checkpatch.pl -q \
 --types UNNECESSARY_BREAK -f {} \; \
| sed -n '/^#/{s/^.*FILE: //;s/:$//;s/:/ /;p}' \
| awk 'function P() {print "sed -i '\''"b"'\'' "a};
       {
         if ($1!=a) {
           if (a) {P()};
           a=$1;
           b=$2"{d}";
         } else {
           b=b";"$2"{d}"
         }
       };
       END {P()}'

Change-Id: I56ca098faa5fe8d1e3f712dc0a029a3f10559d99
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5617
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
3 years agotcl: remove trailing whitespace 16/5616/2
Antonio Borneo [Sat, 25 Apr 2020 23:07:27 +0000 (01:07 +0200)]
tcl: remove trailing whitespace

The script checkpatch available in new Linux kernel offers an
experimental feature for automatically fix the code in place.
While still experimental, the feature works quite well for simple
fixes, like spacing.

This patch has been created automatically with the script under
review for inclusion in OpenOCD, using the command:
find tcl/ -type f -exec ./tools/scripts/checkpatch.pl \
-q --types TRAILING_WHITESPACE --fix-inplace -f {} \;

The patch only changes amount and position of whitespace, thus
the following commands show empty diff
git diff -w
git log -w -p
git log -w --stat

Change-Id: Ie7e3a236f4db9c70019e3b3c7e851edbd3a9dd84
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5616
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
3 years agotcl: fix typo and spelling 15/5615/2
Antonio Borneo [Sat, 25 Apr 2020 23:25:32 +0000 (01:25 +0200)]
tcl: fix typo and spelling

Identified by checkpatch script from Linux kernel v5.7-rc1 using
the command
find tcl/ -type f -exec ./tools/scripts/checkpatch.pl \
-q --types TYPO_SPELLING --strict -f {} \;

Change-Id: I7b523f0ab5ec047ff167742a44c29984ac672cf4
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5615
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
3 years agodoc: fix typo and spelling 14/5614/2
Antonio Borneo [Sat, 25 Apr 2020 23:39:16 +0000 (01:39 +0200)]
doc: fix typo and spelling

Identified by checkpatch script from Linux kernel v5.7-rc1 using
the command
find doc/ -type f -exec ./tools/scripts/checkpatch.pl \
-q --types TYPO_SPELLING --strict -f {} \;

Change-Id: I1269ac966027439e16eb6e63179e43925bec37fa
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5614
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
3 years agodoc: fix texinfo warning on @deffn not at the line beginning 13/5613/2
Antonio Borneo [Mon, 27 Apr 2020 14:52:31 +0000 (16:52 +0200)]
doc: fix texinfo warning on @deffn not at the line beginning

Commit 87a4158acf56 ("drivers: xds110: Clean up command syntax and
documentation") does not follow the documentation structure that
lists the adapters in cpt 2 "Debug Adapter Hardware" then lists
the adapter commands in cpt 8.2 "Interface Drivers"; it puts all
in cpt 2.
While doing that, uses an incorrect texinfo syntax that causes the
following warnings at compile time:
doc/openocd.texi:543: warning: @deffn should only appear at the beginning of a line
doc/openocd.texi:547: warning: @deffn should only appear at the beginning of a line
doc/openocd.texi:552: warning: @deffn should only appear at the beginning of a line

Move the documentation of xds110 commands in the proper chapter
and fix the texinfo syntax.

Change-Id: I0b3f0fe0c687f194bb02e2d81aca86fcd4fdd718
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 87a4158acf56 ("drivers: xds110: Clean up command syntax and documentation")
Reviewed-on: http://openocd.zylin.com/5613
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-by: Edward Fewell <efewell@ti.com>
3 years agohelper/ioutil: silence gcc-8 on strncpy 31/5631/3
Antonio Borneo [Mon, 27 Apr 2020 21:19:14 +0000 (23:19 +0200)]
helper/ioutil: silence gcc-8 on strncpy

Starting from version 8, gcc issues a warning if strncpy could be
able to truncate a string (so without adding the zero-termination
char in destination) by copying exactly "size" char from a source
string not shorter than "size".
Such truncation from strncpy could actually be the desired code
behaviour, but the way to silent gcc only locally (without global
disabling with -Wno-stringop-truncation) through pragma has other
side effects on portability.

In current code, the source string is always "eth0", because has
been checked right above. So this is a false positive from gcc,
being always strlen("eth0") < 16, the sizeof(ifreq.ifr_name).

Silent gcc by decrementing the "size" and remove:
error: ‘strncpy’ specified bound 16 equals destination
size [-Werror=stringop-truncation]

This file is only optionally compiled together with ZY1000 driver
with --enable-zy1000 --enable-ioutil. This combination is not
checked in jenkins, so the error passed unnoticed.
Plus, the configure flags above are both deprecated!

Change-Id: I229e66227cfd3513139feeaffa47a6e1ec00767b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5631
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
3 years agohelper/command: register all commands through register_commands() 44/5644/2
Antonio Borneo [Fri, 1 May 2020 16:30:00 +0000 (18:30 +0200)]
helper/command: register all commands through register_commands()

The commands "ocd_find" and "capture" are registered directly
through the jim API, instead of the common way to describe them
in a struct command_registration that is then passed to the helper
register_commands().
This cause the two commands above to not have either "help" nor
"usage" string nor a properly identified "mode".

Since the following line registers the commands listed in struct
command_builtin_handlers, simply add the two commands above in the
same struct.

Change-Id: Id6ee11dac3b18364deeed65ee8e18ad80152750a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5644
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agotcl: stm32mp15x: fix "reset halt" on CM4 in engineering boot 49/5649/2
Antonio Borneo [Tue, 5 May 2020 16:11:47 +0000 (18:11 +0200)]
tcl: stm32mp15x: fix "reset halt" on CM4 in engineering boot

The state machine of cortex-m have to pass through a set of state
before it get in "halted".

Add one more "arp_poll" to achieve the proper state during a
"reset halt" command in engineering boot.

Change-Id: I90828bf20ef75bd4018f8b911f727ae69c4d6e8f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5649
Tested-by: jenkins
Reviewed-by: Richard Braun <rbraun@sceen.net>
3 years agoflash/nor/efm32: Some small code cleanups 20/5420/3
Marc Schink [Tue, 28 Jan 2020 20:40:37 +0000 (21:40 +0100)]
flash/nor/efm32: Some small code cleanups

Change-Id: I547970ce31435f75bae01d6d2cc96ebc9c15588c
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5420
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoserver/telnet: Fix history output 14/3414/3
Marc Schink [Wed, 13 Apr 2016 11:36:26 +0000 (13:36 +0200)]
server/telnet: Fix history output

Restore the prompt after the "history" command is invoked.

Change-Id: I3d0744abbc58e82b039e06f21675efa180e8e1b0
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/3414
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agohla: remove unused hl_interface_param_s.api 11/5611/2
Tarek BOCHKATI [Sun, 26 Apr 2020 19:21:16 +0000 (20:21 +0100)]
hla: remove unused hl_interface_param_s.api

Change-Id: I90a23293c7e3a6067d56e56d186f9f452af7c15e
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5611
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
3 years agoflash/nor/avrf: Minor code cleanups 61/5461/2
Marc Schink [Thu, 20 Feb 2020 20:54:18 +0000 (21:54 +0100)]
flash/nor/avrf: Minor code cleanups

Change-Id: I64aa8e41f336584b524445e0ee7f986a0032852a
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5461
Tested-by: jenkins
Reviewed-by: Lars Poeschel <poeschell+openocd@mailbox.org>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoflash/nor/kinetis: Minor code cleanups 59/5459/2
Marc Schink [Thu, 20 Feb 2020 20:49:17 +0000 (21:49 +0100)]
flash/nor/kinetis: Minor code cleanups

Change-Id: Id74cb6c238b803d1a1566fc615e22ea478f2e15e
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5459
Tested-by: jenkins
Reviewed-by: Lars Poeschel <poeschell+openocd@mailbox.org>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotarget/arc: introduce breakpoint functionality 41/5641/3
Evgeniy Didin [Mon, 16 Mar 2020 17:38:00 +0000 (20:38 +0300)]
target/arc: introduce breakpoint functionality

With this patch we introduce set/unset breakpoints
routines and add/remove bp handlers.
Currently soft breakpoints are only supported.

Changes since v1:
* Change if-statement in arc_remove_breakpoint
* Squash changes from http://openocd.zylin.com/#/c/5641/
  in this commit to fix build.

Change-Id: Ib10ccdb02fd1606e4f407f012b1bee106a8ffccd
Signed-off-by: Evgeniy Didin <didin@synopsys.com>
Reviewed-on: http://openocd.zylin.com/5641
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agotarget/arc: introduce arc_read/write_instruction functions 40/5640/2
Evgeniy Didin [Mon, 16 Mar 2020 12:00:16 +0000 (15:00 +0300)]
target/arc: introduce arc_read/write_instruction functions

This commit introduces helper instruction read/write functions
for further bp functionality.

Change-Id: I619fbe2870ef6365c29ed1618bb83b6f7eb84690
Signed-off-by: Evgeniy Didin <didin@synopsys.com>
Reviewed-on: http://openocd.zylin.com/5640
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agotarget/arc: Add initial stepping functions 43/5643/2
Evgeniy Didin [Wed, 18 Mar 2020 13:12:04 +0000 (16:12 +0300)]
target/arc: Add initial stepping functions

Change-Id: I84845f2ec6f1cff975990f0a495165a02de33227
Signed-off-by: Evgeniy Didin <didin@synopsys.com>
Reviewed-on: http://openocd.zylin.com/5643
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agoAdd get_thread_reg() and set_reg() for hwthread 24/5324/3
Tim Newsome [Thu, 17 Oct 2019 22:12:55 +0000 (15:12 -0700)]
Add get_thread_reg() and set_reg() for hwthread

get_thread_reg() allows gdb to request the register value of a specific
"thread."
set_reg() allows register writes without getting a giant list of
registers first.

Signed-off-by: Tim Newsome <tim@sifive.com>
Change-Id: I87faa1c8793916b9ee476dd696f0695a07ca2b41
Reviewed-on: http://openocd.zylin.com/5324
Tested-by: jenkins
3 years agoloaders/flash/nrf5: add CPU type to loader source 88/5588/2
Tomas Vanek [Mon, 13 Apr 2020 15:33:10 +0000 (17:33 +0200)]
loaders/flash/nrf5: add CPU type to loader source

Change-Id: Ia65ac21bd99d76c8dace4e9ede060e870cad14de
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5588
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoflash/stm32l4x: always use stm32l4_get_flash_reg 08/5508/2
Tarek BOCHKATI [Mon, 9 Mar 2020 18:10:56 +0000 (19:10 +0100)]
flash/stm32l4x: always use stm32l4_get_flash_reg

this change is a preparation for STM32L5 support on top of L4 driver
STM32L5 flash is quite similar to L4 flash, mainly register names
and offsets and some bits are changed.
a table with register offset will be introduced, thus correct register
addresses will be obtained using this table and the driver internal
function 'stm32l4_get_flash_reg' will be responsible of this.

Change-Id: I74bf61a83fe53575623640af0328b3253ecc796f
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5508
Tested-by: jenkins
Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-by: Michael Jung <mijung@gmx.net>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agorevision id for STM32L4P5/Q5 corrected 21/5521/3
Andreas Bolsch [Sun, 15 Mar 2020 11:21:37 +0000 (12:21 +0100)]
revision id for STM32L4P5/Q5 corrected

According to RM0432 rev. 6, only 0x1001 "Z" rev. applies for STM32L4P5/Q5.
Verified on real device. Whether other revisions exist is unclear.

Change-Id: I761ae077d089b06925fc0fe1ff2b1e478b8a66fa
Signed-off-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-on: http://openocd.zylin.com/5521
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agotarget/armv7m: cosmetic refactorization 26/5326/2
Tomas Vanek [Sun, 20 Oct 2019 08:08:07 +0000 (10:08 +0200)]
target/armv7m: cosmetic refactorization

Introduce a variable 'size' and reduce the number of dereferencing
*reg_list_size by using the variable.

Change-Id: I3bdf1485a4ed8e34435e8acb3efd0df8d802508c
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5326
Tested-by: jenkins
Reviewed-by: Christopher Head <chead@zaber.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agojtag: remove unused function adapter_driver_modules_load() 01/5601/2
Antonio Borneo [Wed, 22 Apr 2020 20:39:07 +0000 (22:39 +0200)]
jtag: remove unused function adapter_driver_modules_load()

Commit c2cecc74b0ac ("Move JTAG interface list to new files.")
merged in mid 2009 introduces an unused and empty function that
the developer expects to use for loading adapter drivers from
shared libraries. This have never happened and the function is
still empty and unused.

Remove it.

Change-Id: I7c88dbf8a9747e96e5ca4e6e7038ac0f232604fd
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5601
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
3 years agoserver: set tcp port and bind address before init 95/5595/2
Antonio Borneo [Mon, 20 Apr 2020 21:54:38 +0000 (23:54 +0200)]
server: set tcp port and bind address before init

All the servers open the listening socket during openocd "init";
it's not possible to change the tcp port or the bind address
after "init".

In current code, the call order during "init" permits to change
the port and bind address of tcl and telnet server if the related
command is issued after "init" in the same script or on openocd
command line. This is not guaranteed to work if the call order
during "init" changes, so it's incorrect.

Change the commands "bindto" and "*_port" to COMMAND_CONFIG.

Change-Id: Id88f225a67a872b4bcaf3b799466bddedc248015
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Christopher Head <chead@zaber.com>
Fixes: https://sourceforge.net/p/openocd/tickets/264/
Reviewed-on: http://openocd.zylin.com/5595
Reviewed-by: Christopher Head <chead@zaber.com>
Tested-by: jenkins
3 years agocoding style: contrib: remove empty lines at end of text files 73/5173/6
Antonio Borneo [Sun, 12 May 2019 10:57:49 +0000 (12:57 +0200)]
coding style: contrib: remove empty lines at end of text files

Empty lines at end of text files are useless.
Remove them.

Change-Id: I4efbd9af5be7e16213dcc7cb95de936ecde2fcef
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5173
Tested-by: jenkins
3 years agocoding style: src: remove empty lines at end of text files 72/5172/6
Antonio Borneo [Sun, 12 May 2019 10:55:18 +0000 (12:55 +0200)]
coding style: src: remove empty lines at end of text files

Empty lines at end of text files are useless.
Remove them.

Change-Id: Ibac9b36682d58f81e34ca2b51e6260e7d472fb0e
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5172
Tested-by: jenkins
3 years agocoding style: tcl: remove empty lines at end of text files 71/5171/6
Antonio Borneo [Sun, 12 May 2019 10:53:56 +0000 (12:53 +0200)]
coding style: tcl: remove empty lines at end of text files

Empty lines at end of text files are useless.
Remove them.

Change-Id: I503cb0a96c7ccb132f4486c206a48831121d7abd
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5171
Tested-by: jenkins
3 years agobitbang: Fix FTBFS with GCC 10 92/5592/2
Andreas Fritiofson [Fri, 17 Apr 2020 11:49:28 +0000 (13:49 +0200)]
bitbang: Fix FTBFS with GCC 10

GCC 10 defaults to -fno-common which breaks the sharing of bitbang_swd
struct between bitbang drivers due to a missing extern.

Change-Id: I2b4122f7939cec91a72284006748f99a23548324
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/5592
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li>
3 years agoflash/nor/stm32l4x: cast wrpxxr_mask to uint16_to to print 90/5590/2
Ilya Kharin [Wed, 15 Apr 2020 23:21:30 +0000 (03:21 +0400)]
flash/nor/stm32l4x: cast wrpxxr_mask to uint16_to to print

Fix build error on Mac OS X Catalina (10.15.4) caused by formatting
stm32l4_info->wrpxxr_mask, which is uint32_t, as uint16_t in the debug
log message. Adding casting to uint16_t before substitution because only
lower 16 bits are significant for debug purposes.

Change-Id: Iddb87cd156dfc84ab1f91cd15a1ddee6b646d412
Signed-off-by: Ilya Kharin <akscram@gmail.com>
Reviewed-on: http://openocd.zylin.com/5590
Tested-by: jenkins
Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agoftdi: Report an error if no ftdi_vid_pid is specified 40/5440/2
Leonard Crestez [Thu, 6 Feb 2020 14:13:25 +0000 (16:13 +0200)]
ftdi: Report an error if no ftdi_vid_pid is specified

By default the list of VID/PID is empty so if ftdi_vid_pid is not called
then no matches are attempted. The only message is at -d3:

Command 'init' failed with error code -100"

Check for this condition explicitly to make life easier for people
configuring adapters.

Change-Id: If0f93370c9e9ddc9700aae7c346c1c6dd319152e
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-on: http://openocd.zylin.com/5440
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotarget/armv8: Add ARM target name on halt status 71/5571/2
Kevin Burke [Mon, 4 Nov 2019 20:11:06 +0000 (20:11 +0000)]
target/armv8: Add ARM target name on halt status

The CPU target name is added to the HALT status message so the user
can see which target halted at the designated program counter.

Tested on an Ampere eMAG8180 and Quicksilver silicon

Change-Id: I51e6f21296c85a822df28c5b7c4068e8ff66f29e
Signed-off-by: Kevin Burke <kevinb@os.amperecomputing.com>
Signed-off-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Reviewed-on: http://openocd.zylin.com/5571
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotarget/armv7m: minor fixes of target algo exit point check 29/5329/2
Tomas Vanek [Sun, 20 Oct 2019 13:03:44 +0000 (15:03 +0200)]
target/armv7m: minor fixes of target algo exit point check

Introduce a new ERROR_TARGET_ALGO_EXIT as currently used
ERROR_TARGET_TIMEOUT should be reserved for the timeout only.

Do not load PC directly from CPU HW as the register value
has already been cached.

Change-Id: I0d3630da41fd021676789dc12b52545cc0432ba8
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5329
Tested-by: jenkins
Reviewed-by: Christopher Head <chead@zaber.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
3 years agoflash/nor: add flash mdw/h/b commands 76/4776/5
Tomas Vanek [Thu, 22 Nov 2018 18:05:04 +0000 (19:05 +0100)]
flash/nor: add flash mdw/h/b commands

Some flash banks are not mapped in the target memory
(e.g. SPI flash, some special pages).

Add flash version of mdw/h/b which reads data using
the flash driver.

Change-Id: I66910e0a69cf523fe5ca1ed6ce7b9e8e176aef4a
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4776
Tested-by: jenkins
Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotcl/target/nrf52.cfg: detect AP lock and add command to recover 84/4984/3
Tomas Vanek [Fri, 1 Mar 2019 12:35:31 +0000 (13:35 +0100)]
tcl/target/nrf52.cfg: detect AP lock and add command to recover

Change-Id: I8d2e29ed88a957d412473255e42b022a00dfb9cb
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4984
Tested-by: jenkins
3 years agonrf5: Comment the flash loader 72/5272/3
Aurélien Martin [Tue, 6 Aug 2019 20:08:18 +0000 (22:08 +0200)]
nrf5: Comment the flash loader

Change-Id: Ia84b5b8ede53f59299a02dc6163d6bbaa31e0fbd
Signed-off-by: Aurélien Martin <martaurel@gmail.com>
Reviewed-on: http://openocd.zylin.com/5272
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agonrf5: Refresh the watchdog while flashing 66/5266/7
Aurélien Martin [Mon, 22 Jul 2019 21:13:29 +0000 (23:13 +0200)]
nrf5: Refresh the watchdog while flashing

If watchdog is enabled, there's no way we can disable it while the flashing firmware
is running. (Halt disables it, but software reset doesn't.) So let's have the flashing
firmware refresh the watchdog regularly, in case it has been enabled by previously
running software. Failure to do so could lead to a watchdog reset in the middle of
the chip bieng programmed.

Change-Id: I79d41593948aae0080480e891552e1c2ee3ccbd0
Signed-off-by: Aurélien Martin <martaurel@gmail.com>
Reviewed-on: http://openocd.zylin.com/5266
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agonrf5: Include generated loader code 67/5267/5
Aurélien Martin [Tue, 23 Jul 2019 19:21:39 +0000 (21:21 +0200)]
nrf5: Include generated loader code

Dump legacy hexadecimal machine code

Change-Id: I336efa461058bccc3894131cb22473785b68479c
Signed-off-by: Aurélien Martin <martaurel@gmail.com>
Reviewed-on: http://openocd.zylin.com/5267
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agoRemove BUILD_TARGET64 40/5240/4
Florian Fainelli [Mon, 17 Jun 2019 22:46:11 +0000 (15:46 -0700)]
Remove BUILD_TARGET64

BUILD_TARGET64 creates a larger test matrix and mostly gates the
building of the aarch64/armv8 target, make that unconditional, which
would help fixing any issues with 64-bit address types anyway.

Rebased by Antonio Borneo after commit 1fbe8450a9dd ("mips: Add
MIPS64 support")

Change-Id: I219f62b744d540d9dde9a42e6b63fd7d91df3dbb
Suggested-by: Matthias Welwarsky <matthias@welwarsky.de>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5240
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)