openocd.git
2 years agodrivers/swd: add support for SWD multidrop 99/6699/3
Tomas Vanek [Fri, 12 Nov 2021 08:49:01 +0000 (09:49 +0100)]
drivers/swd: add support for SWD multidrop

According to ARM IHI0031C+ chapter 2.3.11 "TARGETSEL, Target Selection register"
multidrop capable DPv2 must not drive SWDIO line during the response phase
of a write to TARGETSEL register.

Introduce helper functions swd_cmd_returns_ack() and swd_ack_to_error_code()
to centralize these tests from all drivers to one place.

Introduce distinct error codes for SWD protocol.

Partly inspired by Graham Sanderson's http://review.openocd.org/4935

Change-Id: Ie5f9edb22e066a933a534bf2b29e7e1d3087dad1
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/6699
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 years agotarget/arm_dap: fix memory leak in error path of dap_create() 85/6685/4
Tomas Vanek [Wed, 10 Nov 2021 11:46:42 +0000 (12:46 +0100)]
target/arm_dap: fix memory leak in error path of dap_create()

Change-Id: I91fa5910670161b62a76fc834b6394c5a6c05395
Suggested-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/6685
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agojtag/hla_layout: add #include <target/arm_tpiu_swo.h> 87/6687/2
Tarek BOCHKATI [Thu, 11 Nov 2021 22:55:39 +0000 (23:55 +0100)]
jtag/hla_layout: add #include <target/arm_tpiu_swo.h>

hla_layout.h uses explicitly tpiu_pin_protocol enum defined in
arm_tpiu_swo.h.
To make this header file consistent, add the missing include.

Change-Id: Ibecc279da8d6859ced2b8377e812554c747d81bb
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6687
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodrivers/jtag_vpi: Added "jtag_vpi:" prefixes to log messages 86/6686/2
Jan Matyas [Thu, 11 Nov 2021 15:35:18 +0000 (16:35 +0100)]
drivers/jtag_vpi: Added "jtag_vpi:" prefixes to log messages

Added "jtag_vpi:" prefixes to log messages from the jtag_vpi
driver. The intention is to make it clear what the messages
relate to. Without the prefix, many of the log messages
won't make much sense to the user.

This change does not alter any functionality, just
the printed text.

Example:

Before:
Error: Can't connect to 127.0.0.1 : 5555

After:
Error: jtag_vpi: Can't connect to 127.0.0.1 : 5555

Change-Id: I779c379f52722b094b200d08b25ab0f7280d2845
Signed-off-by: Jan Matyas <matyas@codasip.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6686
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotarget: Use target_addr_t for algorithm addresses. 62/6662/3
Tim Newsome [Tue, 12 Oct 2021 18:06:44 +0000 (11:06 -0700)]
target: Use target_addr_t for algorithm addresses.

Otherwise 64-bit addresses can't work.

Signed-off-by: Tim Newsome <tim@sifive.com>
Change-Id: Id9f92ff8a1602153cc06810bcf515a9d0a89c81b
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/6662
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoriscv: Clear type 6 triggers on connecting. 84/6684/3
Tim Newsome [Tue, 5 Oct 2021 17:03:19 +0000 (10:03 -0700)]
riscv: Clear type 6 triggers on connecting.

I missed this when I first add mcontrol6 support.

https://github.com/riscv/riscv-openocd/pull/648

Change-Id: I1a2706c7ea3a6757ed5083091cd2c764a8b0267c
Signed-off-by: Tim Newsome <tim@sifive.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6684
Tested-by: jenkins
Reviewed-by: Jan Matyas <matyas@codasip.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoriscv: Regenerated debug_defines.h and encoding.h 82/6682/4
Jan Matyas [Thu, 4 Nov 2021 16:48:23 +0000 (17:48 +0100)]
riscv: Regenerated debug_defines.h and encoding.h

The main intention is to get access to some of the CSRs
that were so far unknown to OpenOCD (tinfo, mcountinhibit, ...).

https://github.com/riscv/riscv-openocd/pull/659

Signed-off-by: Tim Newsome <tim@sifive.com>
Change-Id: I824fdb558d5c1f73432b0f56f3b0b4d865eceeba
Reviewed-on: https://review.openocd.org/c/openocd/+/6682
Tested-by: jenkins
Reviewed-by: Jan Matyas <matyas@codasip.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agojimtcl: update to master branch 20211108 74/6674/2
Antonio Borneo [Mon, 8 Nov 2021 08:42:41 +0000 (09:42 +0100)]
jimtcl: update to master branch 20211108

Today's version of jimtcl includes a fix for autoconf >= 2.70 and
a minor fix for warnings with GCC 11.
To prepare for next jimtcl 0.81, let's merge and test the updated
master branch.

Change-Id: I455cc708f7d4786461978e38b6ac71816e2c9825
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6674
Tested-by: jenkins
2 years agoadi_v5_swd: add comment to describe debug flag 'do_sync' 96/6696/2
Antonio Borneo [Thu, 11 Nov 2021 22:48:10 +0000 (23:48 +0100)]
adi_v5_swd: add comment to describe debug flag 'do_sync'

Change-Id: I1f7f0eed7a6e3626f5fde841ec7fa1d29906db29
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6696
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agoftdi: add support to switch to/from dormant state 93/6693/3
Antonio Borneo [Thu, 11 Nov 2021 21:29:32 +0000 (22:29 +0100)]
ftdi: add support to switch to/from dormant state

Partially extracted from https://review.openocd.org/4935

Change-Id: Ia3f197b257434a1a7979fdbc08936c7c541db1e2
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: graham sanderson <graham.sanderson@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6693
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2 years agojlink: add support to switch to/from dormant state 92/6692/3
Antonio Borneo [Thu, 11 Nov 2021 21:13:55 +0000 (22:13 +0100)]
jlink: add support to switch to/from dormant state

Change-Id: Ifeda21ab7a40926166045f211b9e772aedff715d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6692
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agodrivers/bitbang: add support to switch to/from dormant state 91/6691/3
Antonio Borneo [Thu, 11 Nov 2021 15:44:27 +0000 (16:44 +0100)]
drivers/bitbang: add support to switch to/from dormant state

While there, replace the SWD_CMD_PARK macro to the magic number.

Change-Id: Id9094dcb2b010b9e894a5ed9e4a99d2287e5969c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6691
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agocmsis_dap: add support for dormant-to-jtag 90/6690/3
Antonio Borneo [Thu, 11 Nov 2021 15:42:51 +0000 (16:42 +0100)]
cmsis_dap: add support for dormant-to-jtag

Change-Id: I4a51f3772cd94d7dda5a66a1d13acd24d0d0c63c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6690
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agoarm_adi_v5: add missing enum DORMANT_TO_JTAG 89/6689/2
Antonio Borneo [Thu, 11 Nov 2021 15:39:39 +0000 (16:39 +0100)]
arm_adi_v5: add missing enum DORMANT_TO_JTAG

Add the value DORMANT_TO_JTAG in the enum listing the SWJ-DP
switching sequences.
The corresponding bit-sequence is already available.

Change-Id: I6f1ffd29a8f5729ec70ce0303248bc251409d37d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6689
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2 years agocortex_m: Restore fast register reads if no polling is needed 78/6678/2
Andreas Fritiofson [Mon, 8 Nov 2021 17:09:56 +0000 (18:09 +0100)]
cortex_m: Restore fast register reads if no polling is needed

If the target is in a state where S_REGRDY polling is necessary (slow
clock, low power state...?), OpenOCD will continue to use the slow
path even if the condition is temporary and the target at a later
point would be capable of fast reads again.

Revert to fast reads if a full register dump can be made without need
for polling any of the registers; presumably it will succeed the next
time too.

Change-Id: I557f0d90b7ce6f9d81aa409b6400fc9c83d16008
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6678
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agotarget/cortex_m: faster reading of all CPU registers 21/5321/7
Tomas Vanek [Tue, 5 Feb 2019 08:39:11 +0000 (09:39 +0100)]
target/cortex_m: faster reading of all CPU registers

Without the change cortex_m_debug_entry() reads all registers
calling cortex_m_load_core_reg_u32() for each register with
a poor usage of JTAG/SWD queue.
It is time consuming, especially on an USB FS based adapter.
Moreover if target_request debugmsgs are enabled, DCB_DCRDR
is saved and restored on each register read.

This change introduces cortex_m_fast_read_all_regs()
which queues all register reads and a single dap_run() transaction
does all work.

cortex_m_fast_read_all_regs() reads all registers unconditionally
regardless register cache is valid or not. This is a difference
from the original cortex_m_debug_entry() code.

cortex_m_debug_entry times from -d3 log, Cortex-M4F and CMSIS-DAP
(Kinetis K28F-FRDM kit)

target_request |                time [ms]
debugmsgs      | without the change | with the change
---------------+--------------------+-----------------
disable        |        186         |       27
enable         |        232         |       29

Added checking of DHCSR.S_REGRDY flag. If "not ready" is seen,
cortex_m->slow_register_read is set and fallback to the old
register read method cortex_m_slow_read_all_regs() is used
instead of cortex_m_fast_read_all_regs().

Change-Id: I0665d94b97ede217394640871dc451ec93410254
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/5321
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agocortex_m: poll S_REGRDY on register r/w 19/5319/7
Antonio Borneo [Mon, 14 Oct 2019 17:03:48 +0000 (19:03 +0200)]
cortex_m: poll S_REGRDY on register r/w

Accordingly to arm documentation [1], chapter C1.6.4, the
operation to read/write from/to core registers can require time,
and the specific flag DHCSR.S_REGRDY has to be polled to verify
that the operation has been completed.
The lack of check on S_REGRDY causes OpenOCD to fail handling
correctly the core registers on a Cortex-M4 emulated in a slow
FPGA, and it could also fail on devices clocked at very low speed
while using a fast adapter.

Poll S_REGRDY as specified in [1] while either reading or writing
the core registers.
A timeout of 0.5s is added. This could still be too small in some
extremely slow cases, but at least now we log the timeout event,
which can help tracking down such odd issue.
During register read include in the polling loop the read of DCRSR
and to flush the JTAG queue only once.
During register write, relax the write in DCRSR by removing the
atomicity that is now useless since followed by the atomic read to
S_REGRDY.
During register read include the read of DCRSR inside the polling
loop to relax the read of S_REGRDY since followed by the atomic
read to DCRSR.

This change has the drawback of adding other transfers to the
adapter while reading/writing the registers, so it is expected to
introduce some speed degradation during step-by-step.

[1] DDI0403E - "ARMv7-M Architecture Reference Manual"

Change-Id: I61f454248f11a3bec6dcf4c58a50c5c996d7ef81
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/5319
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agotarget/cortex_m: cumulate DHCSR sticky bits 80/6180/6
Tomas Vanek [Thu, 22 Apr 2021 08:41:50 +0000 (10:41 +0200)]
target/cortex_m: cumulate DHCSR sticky bits

DCB DHCSR register contains S_RETIRE_ST and S_RESET_ST bits cleared
on a read.

The change introduces a helper function cortex_m_cumulate_dhcsr_sticky().
Call this function each time DHCSR is read to preserve S_RESET_ST state
in the case of a reset event was detected.

Introduce cortex_m_read_dhcsr_atomic_sticky() convenience helper to
read DHCSR, store it to cortex_m->dcb_dhcsr and cumulate sticky bits.

The cumulated state of S_RESET_ST is read and cleared in cortex_m_poll()

Change-Id: Ib679599f850fd219fb9418c6ff32eed7cf5740da
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/6180
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agotarget/cortex_m: use cortex_m->dcb_dhcsr in cortex_m_soft_reset_halt() 77/6677/2
Tomas Vanek [Mon, 8 Nov 2021 14:40:24 +0000 (15:40 +0100)]
target/cortex_m: use cortex_m->dcb_dhcsr in cortex_m_soft_reset_halt()

cortex_m->dcb_dhcsr caches status of DHCSR register.
Use it instead of local variable in cortex_m_soft_reset_halt()
like in other code.

Extracted from [1].

[1] Antonio Borneo: 6207: cortex_m: rework handling of dcb_dhcsr

Link: https://review.openocd.org/c/openocd/+/6207
Change-Id: I9a0aeba0b6b0b4969f05f4a32fc2fc8d244f56ca
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/6677
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agocortex_m: use cortex_m_write_debug_halt_mask() in cortex_m_single_step_core() 76/6676/2
Tomas Vanek [Mon, 8 Nov 2021 13:24:33 +0000 (14:24 +0100)]
cortex_m: use cortex_m_write_debug_halt_mask() in cortex_m_single_step_core()

cortex_m_single_step_core() used mem_ap_write_atomic_u32() to manipulate
dhcsr bits unlike the rest of code, where a specialized function
cortex_m_write_debug_halt_mask() takes place.

Unify setting of dhcsr bits and use cortex_m_write_debug_halt_mask() here as well.

Extracted from [1].

[1] Antonio Borneo: 6207: cortex_m: rework handling of dcb_dhcsr

Link: https://review.openocd.org/c/openocd/+/6207
Change-Id: I9ef05ce88a9dce42e1d3d5404a4fe87ec86b5fe8
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/6676
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agoflash/nor/at91samd: Add SAMR35J18B support 64/6664/3
Janco Kock [Fri, 22 Oct 2021 14:06:22 +0000 (16:06 +0200)]
flash/nor/at91samd: Add SAMR35J18B support

Add support for the mcu SAMR35J18B

Signed-off-by: Janco <janco@factorylab.nl>
Change-Id: I45d801485ad1c16d1b3086516a2b6d71d13f3fc7
Reviewed-on: https://review.openocd.org/c/openocd/+/6664
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2 years agoflash/nor/stm32f1x: Add support for GD32E23x 27/6527/6
asier70 [Wed, 1 Sep 2021 20:00:51 +0000 (22:00 +0200)]
flash/nor/stm32f1x: Add support for GD32E23x

GD32E23x from GigaDevice is cortex-M23 microcontroller and it can work with the stm32f1x driver.
Modifications are similar to this done for GD32F1x0 in #6164 (https://review.openocd.org/c/openocd/+/6164).
Configuration file is added because its cortex-M23 CPU ID is different.
I think that GigaDevice microcontrollers should be handled in an independent unit to separate them from STM32,
but nowadays quick solution is welcome.

Signed-off-by: asier70Andrzej Sierżęga <asier70@gmail.com>
Change-Id: I91f31f5f66808bc50a8f607ac2c107e6b7c5e2b8
Reviewed-on: https://review.openocd.org/c/openocd/+/6527
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agojtagspi: fix build on MacOS 01/6701/2
Antonio Borneo [Sat, 13 Nov 2021 13:38:21 +0000 (14:38 +0100)]
jtagspi: fix build on MacOS

Commit be57b0ab847e ("Update jtagspi driver for 1-, 2- and 4-byte
addresses") introduces two incorrect format string for uint32_t
data types.
This cause build failure on MacOS:

src/flash/nor/jtagspi.c:474:35: error: format specifies type 'unsigned char'
but the argument has type 'uint32_t' (aka 'unsigned int') [-Werror,-Wformat]
        LOG_DEBUG("status=0x%02" PRIx8, *status);
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~

src/flash/nor/jtagspi.c:513:65: error: format specifies type 'unsigned char'
but the argument has type 'uint32_t' (aka 'unsigned int') [-Werror,-Wformat]
        LOG_ERROR("Cannot enable write to flash. Status=0x%02" PRIx8, status);
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~

Fix the format string.

Change-Id: I209053317c8b26c35c6f11be0553ccccc698c551
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: be57b0ab847e ("Update jtagspi driver for 1-, 2- and 4-byte addresses")
Reviewed-on: https://review.openocd.org/c/openocd/+/6701
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2 years agoflash/stm32h7x: don't read flash size using the H74/H75x CPU2 70/6670/2
Tarek BOCHKATI [Wed, 20 Oct 2021 11:13:01 +0000 (12:13 +0100)]
flash/stm32h7x: don't read flash size using the H74/H75x CPU2

CPU2 (Cortex-M4) cannot read flash size register.
assume the maximum flash size without triggering an error message

Change-Id: I5c3328b7cc42e3aa57165075021227d7936f3d26
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6670
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoflash/stm32h7x: avoid using magic numbers for device ids 69/6669/2
Tarek BOCHKATI [Wed, 20 Oct 2021 11:10:44 +0000 (12:10 +0100)]
flash/stm32h7x: avoid using magic numbers for device ids

Change-Id: I4d682ee828404974abd9a42f98b840d77835cfe0
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6669
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 years agostlink (tcp): manage scattered stlink-server responses 71/6671/3
Tarek BOCHKATI [Wed, 3 Nov 2021 15:22:22 +0000 (16:22 +0100)]
stlink (tcp): manage scattered stlink-server responses

detected in ubuntu 20.04
sometimes, the stlink-server response could be segmented on multiple
packets.

this causes stlink_tcp_send_cmd to fail with the following msg:
Error: failed to receive USB CMD response
because the received_size < expected size

to fix the issue, do recv in a loop till all data is received
or timeout is reached.

Change-Id: I46cc60c231b4cc52f150ead268f843bc60c41149
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6671
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 years agohelper/log: Add macros for target-related errors/warnings/... 67/6667/3
Jan Matyas [Mon, 1 Nov 2021 14:28:28 +0000 (15:28 +0100)]
helper/log: Add macros for target-related errors/warnings/...

This commit introduces macros for target related log entries
(error, warning, ...) which is a very common operation in OpenOCD:

* LOG_TARGET_ERROR
* LOG_TARGET_WARNING
* LOG_TARGET_INFO
* LOG_TARGET_DEBUG
* LOG_TARGET_DEBUG_IO

The goal is to have one macro for this common operation and to
make such log entries look the same way - to make it more readable
for humans as well easier for parsing via scripts.

Change-Id: I6166565fc9040b03d3fca5c3aa44a1ccbcf96ad2
Signed-off-by: Jan Matyas <matyas@codasip.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6667
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agojtag/adapter: fix memory leak on usb location 46/6646/2
Antonio Borneo [Thu, 7 Oct 2021 16:13:21 +0000 (18:13 +0200)]
jtag/adapter: fix memory leak on usb location

At exit, free the memory allocated to hold the USB location.

Change-Id: I050701f4dc8be14fd40e8add9d0b047461fa0d1c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6646
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agojtag: remove file driver.h 45/6645/2
Antonio Borneo [Thu, 7 Oct 2021 13:07:57 +0000 (15:07 +0200)]
jtag: remove file driver.h

The only purpose of include file driver.h was to expose the API
to register the adapter's commands.

Move the prototype in adapter.h, already used by openocd.c.

Change-Id: Ie1090c60ef9e5bac5ea187c87bed6e7b08d9671c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6645
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agojtag: align adapter speed code to new structure 44/6644/2
Antonio Borneo [Thu, 7 Oct 2021 12:59:29 +0000 (14:59 +0200)]
jtag: align adapter speed code to new structure

Rename the jtag_XXX functions as adapter_XXX.
Rename internal variables.
Adapt log messages and comments text.

Change-Id: I67f209c67074899cd58bad495055def03f0d1bcf
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6644
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agojtag: move prototype of adapter init/quit and speed to adapter.h 43/6643/2
Antonio Borneo [Thu, 7 Oct 2021 12:30:43 +0000 (14:30 +0200)]
jtag: move prototype of adapter init/quit and speed to adapter.h

After moved the code, align the include files.

Change-Id: I514a3020648816810d69f76c2ec4f6e52a1c57ab
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6643
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agojtag/adapter: move config vars in struct adapter_config 42/6642/2
Antonio Borneo [Thu, 7 Oct 2021 10:21:18 +0000 (12:21 +0200)]
jtag/adapter: move config vars in struct adapter_config

Move the static variables used to configure the adapter in
the struct adapter_config.

Change-Id: I1639e2bd39d0cbb12c71dfa347025558879d8b1d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6642
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agojtag: move adapter init/quit and speed to adapter.c 41/6641/2
Antonio Borneo [Thu, 7 Oct 2021 10:13:28 +0000 (12:13 +0200)]
jtag: move adapter init/quit and speed to adapter.c

The configuration code for adapter parameters is spread around.

Move in adapter.c the code that handles the configuration of
adapter speed.
For convenience, move also the functions adapter_init() and
adapter_quit(), that anyway have no reason to be in file core.c

To simplify the review, the code moved is not modified. It will be
cleaned and adapted in the following changes.

Change-Id: I2b38975a0cd2e74d3d2de6c56ea17818ff225fd8
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6641
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agojtag/adapter: move 'usb location' code in adapter.c 40/6640/2
Antonio Borneo [Wed, 6 Oct 2021 21:17:30 +0000 (23:17 +0200)]
jtag/adapter: move 'usb location' code in adapter.c

The configuration code for adapter parameters is spread around.

Add a struct in adapter.c aimed at containing all the adapter's
configuration data.
Move in adapter.c the code related to configuring 'usb location'
and the copyright tag.
Add adapter.h to export the functions.
While there:
- rework the copyright and the SPDX tag;
- rename the 'usb location' functions;
- remove the JTAG_SRC variable in Makefile.am.

Change-Id: I4fe0d32991a8a30e315807180688035ae9ee01ce
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6640
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agojtag/core: get rid of variable 'jtag' 39/6639/2
Antonio Borneo [Thu, 7 Oct 2021 08:37:06 +0000 (10:37 +0200)]
jtag/core: get rid of variable 'jtag'

The variable 'jtag' is set to 'adapter_driver' during adapter
initialization and is used:
- to check if adapter has been initialized;
- as local copy of adapter_driver.

Introduce a static flag to check if the adapter has been already
initialized and a convenience test function.
Use the test function and the original value of adapter_driver in
the code and drop the variable 'jtag'.

Change-Id: I1b1c54d3b36d7b60390985d787c8449432788141
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6639
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agoUpdate jtagspi driver for 1-, 2- and 4-byte addresses 76/4876/14
Andreas Bolsch [Mon, 28 Jan 2019 09:37:53 +0000 (10:37 +0100)]
Update jtagspi driver for 1-, 2- and 4-byte addresses

jtagspi driver always used 3-byte addresses regardless of actual
device capcity. Now select 1- to 4-byte addresses depending on
device capacity.
Some devices need a special command to activate the 4-byte address
mode, a special command to accomplish this, and a further command
for setting device properties are added.
Additionally, restriction (start of range had to be page aligned)
removed.
Tested with XCS6SLX16 board and W25Q256FV in 3- and 4-byte address
modes.

Change-Id: I88b2877517a18dac460253ae6d97f3dded054e6c
Signed-off-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/4876
Reviewed-by: Jan Matyas <matyas@codasip.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: zapb <dev@zapb.de>
Tested-by: jenkins
2 years agojimtcl: revert temporary workaround for memory leak in jimtcl 0.80 28/6228/3
Antonio Borneo [Sun, 11 Apr 2021 22:04:19 +0000 (00:04 +0200)]
jimtcl: revert temporary workaround for memory leak in jimtcl 0.80

By using jimtcl from latest master branch, the workaround added in
commit 36ae487ed04b ("jimtcl: add temporary workaround for memory
leak in jimtcl 0.80") is not needed anymore.

Revert the workaround.

Change-Id: Ia1b5804be15362d0400740c375455ee19ac09f04
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6228
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 years agoMakefile: remove workaround for jimtcl 0.80 27/6227/3
Antonio Borneo [Sun, 11 Apr 2021 21:58:57 +0000 (23:58 +0200)]
Makefile: remove workaround for jimtcl 0.80

Commit 266a945ad3e8 ("jimtcl: update to version 0.80 (2020-10-29)")
adds a workaround to permit 'make distcheck' with jimtcl 0.80.
This has been fixed in jimtcl with commit d224c9a2b7b2 ("Makefile:
remove examples.api/Makefile while 'distclean'").

By using jimtcl from latest master branch, the workaround is not
required anymore.

Remove the workaround.

Change-Id: I10d91371b5a89d2a3c8599bce766f97eac44f0d9
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6227
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 years agortos: use struct member names instead of comments 59/6659/3
Tim Newsome [Mon, 11 Oct 2021 16:56:39 +0000 (09:56 -0700)]
rtos: use struct member names instead of comments

This is more readable, and as a bonus the compiler will help out if the
definition of the struct changes.

Change-Id: Ibf660134d9900173f6592407d5cc2203654a4a1b
Signed-off-by: Tim Newsome <tim@sifive.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6659
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agojtag: drivers: bcm2835gpio: don't allow GPIOs > 31 58/6658/2
Paul Fertser [Sat, 9 Oct 2021 20:32:01 +0000 (23:32 +0300)]
jtag: drivers: bcm2835gpio: don't allow GPIOs > 31

Current code assumes all the GPIO signals are manipulated via a single
32-bit register so using higher GPIOs silently fails.

Fix the check instead of trying to handle additional GPIOs (available on
Raspberry Pi Compute Modules) as that would slow the driver down.

Change-Id: Ib3b5864afb3b972d952f9b74665201cd93924959
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6658
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoRemove remaining references to FTD2XX driver 60/6660/2
Andreas Fritiofson [Tue, 12 Oct 2021 06:28:34 +0000 (08:28 +0200)]
Remove remaining references to FTD2XX driver

This includes a USB blaster configuration that only worked with that
low-level access and some obsolete build-tests.

Change-Id: I53d27cbf782ebbd131b1af25e358adf35f2b4500
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6660
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agodrivers/linuxgpiod: add support for opendrain trst 98/6598/2
Alex Crawford [Sat, 25 Sep 2021 15:52:50 +0000 (08:52 -0700)]
drivers/linuxgpiod: add support for opendrain trst

This is a follow-up to 2f424b7eb, which added support for opendrain
srst, finishing up support for opendrain reset signals.

Signed-off-by: Alex Crawford <openocd@code.acrawford.com>
Change-Id: Ib79b2e12f2a9469fd6c53bb839c0d2e8e46103a4
Reviewed-on: https://review.openocd.org/c/openocd/+/6598
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agostlink: skip rw-misc commands with TCP server 08/6608/3
Antonio Borneo [Sat, 14 Aug 2021 12:48:50 +0000 (14:48 +0200)]
stlink: skip rw-misc commands with TCP server

The main purpose of TCP server is to allow multiple clients to
connect and share the same physical stlink.
The commands RW MISC don't lock the communication between command
and answer, thus cannot prevent another client to break this
sequence. The commands are not supposed to be used in shared mode.

Prevent the use of RW MISC commands on a (possibly) shared TCP
backend.
This degrades the overall performance, but the shared mode already
adds its own overhead, so this is not really an issue.

Change-Id: I713d912a269664859c8142932a9905d24b6d3caa
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6608
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agostlink: add support for rw-misc commands 07/6607/3
Antonio Borneo [Thu, 29 Jul 2021 15:54:31 +0000 (17:54 +0200)]
stlink: add support for rw-misc commands

Firmware versions V2J32 and V3J2 introduce the commands RW-MISC
to put in a single USB packet a sequence of mem_ap read/write.
These commands provide a significant speed improvement while
accessing the debug unit at scattered addresses.

Add the low level commands and extend high level implementation.

Skip for the moment the command to read the max number of items
allowed by the firmware and use some hardcoded values.

Change-Id: I8adc630cc0de733511e9d94533cbfe9f3b301a83
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6607
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agostlink: dequeue CSW write only if it doesn't change csw_default 06/6606/2
Antonio Borneo [Thu, 29 Jul 2021 16:38:20 +0000 (18:38 +0200)]
stlink: dequeue CSW write only if it doesn't change csw_default

The stlink commands for buffer read/write carry the associated CSW
value that has to be used. We can dequeue any CSW write request
and add the CSW in the following buffer read/write.

In preparation to next patch that uses stlink commands misc-rw
(commands that don't handle CSW value), let's dequeue only those
CSW write that don't change csw_default.

Keep a local cache of last csw_default.
Tag the queued CSW writes that change csw_default.
Dequeue only the un-tagged CSW writes.

On buffer read/write commands, limiting the dequeued CSW write
surely adds a performance penalty. But csw_default is not changed
often so the penalty is not significant.

Change-Id: I538d257fe3c434fc97587846d759951384327f02
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6606
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agostlink: add support for native no_addr_incr commands 05/6605/2
Antonio Borneo [Sun, 25 Jul 2021 21:46:55 +0000 (23:46 +0200)]
stlink: add support for native no_addr_incr commands

Firmware versions V2J26 and V3J1 introduce the command
STLINK_DEBUG_WRITEMEM_32BIT_NO_ADDR_INC
Firmware versions V2J32 and V3J2 introduce the command
STLINK_DEBUG_READMEM_32BIT_NO_ADDR_INC

These new commands can provide speed improvement to Cortex-A
memory download (its debug port use a FIFO for data transfer).

Add the low level commands and extend high level implementation.

Change-Id: I3b65acbeaec3bd305f5568b9ee4bc9495b113448
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6605
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agostlink: collapse consecutive mem AP r/w in a single command 04/6604/2
Antonio Borneo [Sun, 25 Jul 2021 15:31:53 +0000 (17:31 +0200)]
stlink: collapse consecutive mem AP r/w in a single command

Detect a sequence of memory AP operations that can be issued as a
single stlink command.
This improves the data throughput during memory transfer.

Change-Id: Ifa4488513346fc7cd0c9317b7d24ef510ccfd959
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6604
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agostlink: detect mem_ap R/W and dequeue set TAR and CSW 03/6603/2
Antonio Borneo [Thu, 22 Jul 2021 21:50:33 +0000 (23:50 +0200)]
stlink: detect mem_ap R/W and dequeue set TAR and CSW

By using the stlink commands for memory read write we can gain
some performance, but only when TAR and/or CSW are changed.
During long transfers with constant CSW and TAR auto-incremented
there is no gain, since the same amount of USB/TCP packet is used.
Plus, by dropping ADIv5 packed transfers the performance is lower
on 8 and 16 bits transfers.
This changes opens the opportunity for collapsing memory burst
accesses in a single stlink USB/TCP packet.

Initialize the values of enum queue_cmd to easily extract the word
size through a macro, even if this is not used here.

Change-Id: I6661a00d468a1591a253cba9feb3bdb3f7474f5a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6603
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agostlink: expose ap number and csw in memory r/w 02/6602/2
Antonio Borneo [Wed, 5 Feb 2020 15:20:37 +0000 (16:20 +0100)]
stlink: expose ap number and csw in memory r/w

Recent versions of stlink firmware allow accessing access port
other than zero and setting the CSW.

Modify the internal API to provide ap_num and csw.
There is no interest to modify HLA to use ap_num and csw, so set
and use some backward compatible defaults.

Change-Id: I3f6dfc6c670d19467d9f5e717c6c956db6faf7f3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6602
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agostlink: add queue in dap-direct mode 01/6601/2
Antonio Borneo [Thu, 22 Jul 2021 13:08:36 +0000 (15:08 +0200)]
stlink: add queue in dap-direct mode

Implement a minimalist queue for DP/AP commands and reorganize the
code to use it.
There is no performance improvement; the queue elements are still
sent one-by-one on USB or on TCP during dap_run().

Change-Id: I8353563e59f883624bcc0fbe8b54955e4f27ccfa
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6601
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agostlink: check buffer size on 16 and 32 bit memory transfer 00/6600/2
Antonio Borneo [Sun, 25 Jul 2021 15:51:49 +0000 (17:51 +0200)]
stlink: check buffer size on 16 and 32 bit memory transfer

Both HLA and ADIv5 layers limit the memory transfer within blocks
whose boundaries are aligned at 1024 or 4096 bytes.
New stlink firmware handle the ADIv5 TAR autoincrement, making
possible to send memory transfers across the boundary of 1024 or
4096 byte. OpenOCD doesn't use this feature yet.

Use the correct buffer size in the code, even if it is not used.
While there, split SWIM buffer size from JTAG/SWD case; stlink has
a dedicated command to retrieve SWIM buffer size, but currently
not implemented in OpenOCD.

Change-Id: Id46c0356ef21cead08726c044a1cd9725fd4f923
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6600
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agoflash/nor/stm32lx: fixed writes at high adapter speeds 98/5598/3
Jimmy [Thu, 23 Apr 2020 10:58:58 +0000 (18:58 +0800)]
flash/nor/stm32lx: fixed writes at high adapter speeds

The busy flag must be polled after each half-page write.
At low clock speeds, no issue is observed when the poll
is omitted, because the writes complete before the next
write begins. But at high clock speeds the subsequent
writes would overlap and cause the operation to fail.

The status polls are done on the target for efficiency,
since the half-pages are very small.

Change-Id: Ia1e9b4a6a71930549b3d84a902744ce6e596301b
Signed-off-by: Jimmy <nhminus@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/5598
Tested-by: jenkins
Reviewed-by: Jelle De Vleeschouwer
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Andrzej Sierżęga <asier70@gmail.com>
2 years agojtag/core: remove unused variable 38/6638/2
Antonio Borneo [Thu, 7 Oct 2021 10:04:46 +0000 (12:04 +0200)]
jtag/core: remove unused variable

Commit e3f3f60a02ab ("adapter speed: require init script setting
and centralize activation from drivers to core.c") has already
dropped the only use of variable 'jtag_speed'.

Remove the variable.

Change-Id: Iff096df0022982cf90795aa62d6b3406203f7b14
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6638
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agojtag/aice: remove unused exported struct aice_interface_param_s 37/6637/2
Antonio Borneo [Fri, 8 Oct 2021 16:15:12 +0000 (18:15 +0200)]
jtag/aice: remove unused exported struct aice_interface_param_s

The struct aice_interface_param_s is declared but is never
referenced.
Drop it.

Change-Id: I4e6493d4baf292bb55dbd40228d4fa7c9e2afab5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6637
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agohla: improve readability of struct hl_interface_s initialization 36/6636/2
Antonio Borneo [Mon, 16 Sep 2019 08:50:04 +0000 (10:50 +0200)]
hla: improve readability of struct hl_interface_s initialization

The initialization is barely readable, while actually only few
fields are set with value nor zero nor NULL.

Rewrite the initialization using C99 struct designations.

Change-Id: I4d288e6536ebe7110a184db6540223fc67361ec3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6636
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agoriscv: use relative path to include contrib's data 35/6635/2
Antonio Borneo [Fri, 8 Oct 2021 16:43:06 +0000 (18:43 +0200)]
riscv: use relative path to include contrib's data

Doxygen cannot resolve the path of the files in folder contrib.
Use a path relative to current folder, as done in other files.

Change-Id: If39b416ed422b4854dd108777fa32dd4c809450a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6635
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>
2 years agoopenocd: remove 'src' prefix from #include path 34/6634/2
Antonio Borneo [Wed, 6 Oct 2021 21:27:16 +0000 (23:27 +0200)]
openocd: remove 'src' prefix from #include path

There is no reason to add the 'src' prefix.
Remove it.

Change-Id: Id7d7ee8b3807fb90381cc1d6d545321020bc06c1
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6634
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agoUpstream a whole host of RISC-V changes. 29/6529/4
Tim Newsome [Wed, 1 Sep 2021 22:00:46 +0000 (15:00 -0700)]
Upstream a whole host of RISC-V changes.

Made no attempt to separate this out into reviewable chunks, since this
is all RISC-V-specific code developed at
https://github.com/riscv/riscv-openocd

Memory sample and repeat read functionality was left out of this change
since it requires some target-independent changes that I'll upstream
some other time.

Change-Id: I92917c86d549c232cbf36ffbfefc93331c05accd
Signed-off-by: Tim Newsome <tim@sifive.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6529
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotcl/stm32mp15x: freeze watchdog, recover SWD after power cycle 99/6599/2
Antonio Borneo [Wed, 7 Apr 2021 17:21:27 +0000 (19:21 +0200)]
tcl/stm32mp15x: freeze watchdog, recover SWD after power cycle

Freeze the IWDG watchdog when cores are halted to prevent a reset
while debugging.

The PMIC present on some board senses the nsrst and forces a power
cycle to the target. The power cycle causes the SWJ-DP to restart
in JTAG mode. If the debugger is using SWD, the mismatch triggers
an error after the reset command.
Ignore the error detected by 'dap init' and proceed executing the
handler. The error in 'dap init' will force a reconnect during the
following 'dap apid', restoring the SWD functionality.

Change-Id: I04fcda6a5b8a1b080ab4e8890ecd0754d5ed12d9
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6599
Tested-by: jenkins
2 years agoflash/nor/psoc6: fix doxygen comment 20/6620/2
Antonio Borneo [Sat, 2 Oct 2021 12:22:06 +0000 (14:22 +0200)]
flash/nor/psoc6: fix doxygen comment

Commit 64c2e03b23d9 ("flash/nor: improved API of flash_driver.info
& fixed buffer overruns") changes the prototype of the function
psoc6_get_info() but didn't update the list of parameters in the
doxygen comment.

Fix the doxygen comment.

Change-Id: I1dce018b60d080973c5e351490d4d7baba422d74
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 64c2e03b23d9 ("flash/nor: improved API of flash_driver.info & fixed buffer overruns")
Reviewed-on: https://review.openocd.org/c/openocd/+/6620
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2 years agocommand: document enum command_mode 93/6593/3
Antonio Borneo [Wed, 22 Sep 2021 21:14:22 +0000 (23:14 +0200)]
command: document enum command_mode

Add the description to doxygen documentation.

Change-Id: Iec04b4a37088e1b3b52ca84102820f450528b5b9
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6593
Tested-by: jenkins
2 years agomips64_pracc: fix three dead assignments 92/6592/2
Antonio Borneo [Wed, 22 Sep 2021 17:21:39 +0000 (19:21 +0200)]
mips64_pracc: fix three dead assignments

Clang scan-build complains for three dead assignments:
Although the value stored to 'data' is used in the
enclosing expression, the value is never actually read
from 'data'

Value stored to 'address' is never read

Remove the useless assignment and the variable 'data'.

Change-Id: Ie8dcb74b1c1aa5eea1acd06b3c45c5b44954c9e7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6592
Tested-by: jenkins
2 years agotarget/lakemont: fix dead assignment 91/6591/2
Antonio Borneo [Wed, 22 Sep 2021 17:14:29 +0000 (19:14 +0200)]
target/lakemont: fix dead assignment

Clang scan-build complains for a dead assignment:
Value stored to 'tapstatus' is never read

Remove the assignment and add a comment to point for a potential
removal of the line.

Change-Id: Iad2fdc7e6faf650e24cc086ee74c745acb0d1c73
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6591
Tested-by: jenkins
2 years agoarmv8: fix five dead assignments 90/6590/2
Antonio Borneo [Wed, 22 Sep 2021 17:09:29 +0000 (19:09 +0200)]
armv8: fix five dead assignments

Clang scan-build complains for five dead assignments:
Value stored to 'retval' is never read

Check the returned value and propagate the error.

Change-Id: I01172887a056d6f39ddcf2807848423970db1e89
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6590
Tested-by: jenkins
2 years agoarm_semihosting: fix two dead assignments 89/6589/2
Antonio Borneo [Wed, 22 Sep 2021 16:59:38 +0000 (18:59 +0200)]
arm_semihosting: fix two dead assignments

Clang scan-build complains for two dead assignments:
Value stored to 'r' is never read

Use the variable in the following line, instead of re-computing
the pointer.

Change-Id: I5d4069872be9da85fb28bbe0a82020b90f1efe46
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6589
Tested-by: jenkins
2 years agoarm_tpiu_swo: fix two dead assignments 88/6588/2
Antonio Borneo [Wed, 22 Sep 2021 16:51:26 +0000 (18:51 +0200)]
arm_tpiu_swo: fix two dead assignments

Clang scan-build complains for two dead assignments:
Value stored to 'retval' is never read

Since the timer callback should not return error, print an error
message if the data cannot be send out. Add a FIXME comment
because in current code there is no string/name to report which
connection has failed.

In command tpiu enable check the returned value and propagate the
error.

Change-Id: I9a89e4c4f7b677e8222b2df09a31b2478ac9ca4f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6588
Tested-by: jenkins
2 years agojtag/core: fix unused assignment 87/6587/2
Antonio Borneo [Wed, 22 Sep 2021 16:39:57 +0000 (18:39 +0200)]
jtag/core: fix unused assignment

Clang scan-build complains about a variable assigned but never
used.
Although the value stored to 'val' is used in the
enclosing expression, the value is never actually read
from 'val'

Remove the dead assignment. While there, reduce the scope of the
variable by declaring the variable at the point of first use.

Change-Id: Ibe2b55a7d70597833cfa7f3d843e7c3d2407f2df
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6587
Tested-by: jenkins
2 years agogitignore: Add GNU Global tag files 41/6541/3
Yasushi SHOJI [Sun, 5 Sep 2021 12:59:57 +0000 (21:59 +0900)]
gitignore: Add GNU Global tag files

This commit adds GNU Global[1] tag files to .gitignore.

[1]: https://www.gnu.org/software/global/

Change-Id: Ia09fb359cfdfeadd9538cf6352d353e6475e85c7
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6541
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agohelper: Remove src/helper from include dirs 07/6507/4
Yasushi SHOJI [Sun, 29 Aug 2021 09:18:01 +0000 (18:18 +0900)]
helper: Remove src/helper from include dirs

The header files under src/helper/ can currently be included with
either

    #include <bits.h>
    or
    #include <helper/bits.h>

This is because we specify both "src/" and "src/helper/" directories
as include directories.  Some files name under "src/helper/", such as
types.h, log.h, and util.h are too generic and could be ambiguous
depending on the search path.

This commit remove "src/helper/" from our include dir and make C files
include explicitly.

Change-Id: I38fc9b96ba01a513d4a72757d40007e21b502f25
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6507
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agouint64_t->target_addr_t for stack pointers. 86/6586/3
Tim Newsome [Tue, 21 Sep 2021 18:43:21 +0000 (11:43 -0700)]
uint64_t->target_addr_t for stack pointers.

This might be incomplete. It's just a quick attempt to reduce some of
the difference between riscv-openocd and mainline. Other stack pointers
can be updated as I come across them.

Change-Id: Id3311b8a1bb0667f309a26d36b67093bfeb8380a
Signed-off-by: Tim Newsome <tim@sifive.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6586
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agostlink-dap: add 'cmd' to send arbitrary commands 64/6564/3
Antonio Borneo [Tue, 16 Mar 2021 23:02:16 +0000 (00:02 +0100)]
stlink-dap: add 'cmd' to send arbitrary commands

Either for testing new commands and to retrieve information that
don't fit in any specific place of OpenOCD, for example monitoring
the target's VDD power supply from a TCL script.

Change-Id: Id43ced92c799b115bb1da1c236090b0752329051
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6564
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agoudev: add ASIX Presto programmer 63/6563/2
Antonio Borneo [Sun, 19 Sep 2021 19:52:44 +0000 (21:52 +0200)]
udev: add ASIX Presto programmer

The driver is in OpenOCD since 2007, but the USB VID/PID have
never been listed in udev rules.

Change-Id: I77df469929dd7f6b6483678c0e76f22c30a7614c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6563
Tested-by: jenkins
2 years agotarget: reset target examined flag if target::examine() fails 48/6548/4
Tarek BOCHKATI [Tue, 7 Sep 2021 13:25:32 +0000 (14:25 +0100)]
target: reset target examined flag if target::examine() fails

For example: before this change in cortex_m_examine, if we fail reading CPUID
we return a failure code but target was set to examined which is not consistent.

Change-Id: I9f0ebe8f811849e54d1b350b0db506cb3fdd58f4
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6548
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotarget/cortex_m: enhance multi-core examine logs 53/6553/2
Tarek BOCHKATI [Wed, 8 Sep 2021 11:49:50 +0000 (12:49 +0100)]
target/cortex_m: enhance multi-core examine logs

Giving the example of STM32WL55x the examine log is the following:
  Info : stm32wlx.cpu0: hardware has 6 breakpoints, 4 watchpoints
  Info : stm32wlx.cpu1: hardware has 4 breakpoints, 2 watchpoints

After this change the examine log becomes:
  Info : stm32wlx.cpu0: Cortex-M4 r0p1 processor detected
  Info : stm32wlx.cpu0: target has 6 breakpoints, 4 watchpoints
  Info : stm32wlx.cpu1: Cortex-M0+ r0p1 processor detected
  Info : stm32wlx.cpu1: target has 4 breakpoints, 2 watchpoints

Change-Id: I1873a75eb76f0819342c441129427b38e984f0df
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6553
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotcl/stm32wlx.cfg: comply with new jimtcl expr syntax 57/6557/3
Tarek BOCHKATI [Tue, 14 Sep 2021 20:26:47 +0000 (21:26 +0100)]
tcl/stm32wlx.cfg: comply with new jimtcl expr syntax

Change-Id: I2e9fd528817b14396c7643801aeea5c8dde668e0
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6557
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 years agodriver/linuxgpiod: add support for opendrain srst 59/6559/2
Alex Crawford [Thu, 16 Sep 2021 17:00:25 +0000 (10:00 -0700)]
driver/linuxgpiod: add support for opendrain srst

Some MCUs (e.g. the STM32F3) directly expose the internal reset line to
an external pin. When this signal is driven by a push/pull line, it can
actually be inhibited by the external driver. This results in a setup
where the MCU cannot reset itself, for example, by a watchdog timeout or
a sysreset request. To fix this condition, support for open drain output
on the SRST line is required.

Note that because `reset_config srst_open_drain` is the default, all
users of this adapter will switch over to an open drain output unless
explicitly configured otherwise.

Signed-off-by: Alex Crawford <openocd@code.acrawford.com>
Change-Id: I89b39b03aa03f826ed3c45793412780448940bcc
Reviewed-on: https://review.openocd.org/c/openocd/+/6559
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoSpeed up remote bitbang. 34/6534/3
Tim Newsome [Thu, 2 Sep 2021 18:11:30 +0000 (11:11 -0700)]
Speed up remote bitbang.

1. Use TCP_NODELAY, which makes things twice as fast.
2. Get rid of a bunch of unnecessary socket block/non-block calls, which
improves speed another 10% or so.

Change-Id: I415db5746d55374a14564b1973b81e3517f5cb67
Signed-off-by: Tim Newsome <tim@sifive.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6534
Tested-by: jenkins
Reviewed-by: Jan Matyas <matyas@codasip.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoopenocd: prevent jimtcl error message while testing commands 62/6562/2
Antonio Borneo [Fri, 17 Sep 2021 16:37:41 +0000 (18:37 +0200)]
openocd: prevent jimtcl error message while testing commands

The jimtcl API Jim_GetCommand() sets an error message when the
command is not found and flag JIM_ERRMSG is set.
OpenOCD is checking if the command has already been registered,
thus 'command not found' is the desired case.

Pass flag JIM_NONE to prevent jimtcl from setting the error
message.

Change-Id: I3329c2f8722eda0cc9a5f9cbd888a37915b46107
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6562
Tested-by: jenkins
2 years agoarm_tpiu_swo: fix support for deprecated 'tpiu' command before 'init' 61/6561/2
Antonio Borneo [Fri, 17 Sep 2021 16:47:20 +0000 (18:47 +0200)]
arm_tpiu_swo: fix support for deprecated 'tpiu' command before 'init'

Commit dc7b32ea4a00 ("armv7m_trace: get rid of the old tpiu code")
is not handling correctly the old 'tpiu' command if it is run
during the config phase (before command 'init').

Move the call to the old event handler 'trace-config' in function
jim_arm_tpiu_swo_enable(), so it is correctly executed after
'init'.

Add the call to the old event handler 'trace-config' also during
jim_arm_tpiu_swo_disable(), to match the old behaviour.

Add more information while alerting that the event 'trace-config'
is deprecated.

Change-Id: If831d9159b4634c74e19c04099d041a6e2be3f2a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: dc7b32ea4a00 ("armv7m_trace: get rid of the old tpiu code")
Reviewed-on: https://review.openocd.org/c/openocd/+/6561
Tested-by: jenkins
Reviewed-by: Karl Palsson <karlp@tweak.net.au>
2 years agoarm_adi_v5: drop ANY_ID from table dap_part_nums 54/6454/3
Antonio Borneo [Fri, 20 Aug 2021 22:35:32 +0000 (00:35 +0200)]
arm_adi_v5: drop ANY_ID from table dap_part_nums

The initial version of the table dap_part_nums contains only the
part number of the device and not the manufacturer ID.
This causes collisions between devices with same part number but
from different manufacturer.
The table has been extended to include the manufacturer JEDEC code
in commit 2f131d3c3004 ("ARM ADIv5: CoreSight ROM decode part
number and designer id").
For two old/legacy table's entries reported without manufacturer
code it was defined a special ANY_ID manufacturer, meaning skip
the check for manufacturer!
The two legacy entries report the comment "from OMAP3 memmap", and
thanks to the associated string has been possible through Google
to identify a Master Report [1] about using OpenOCD with the OMAP3
in a BeagleBoard. The ROM table is printed with OpenOCD command
"dap info 1" at page 8 and reports the Peripheral ID required to
extract the manufacturer ID that, out of any surprise, belong to
Texas Instruments.

Set the two missing manufacturer ID to Texas Instruments JEDEC
code.

Remove the now redundant definition and use of ANY_ID.

While revisiting this old code, remove also the useless comment
"0x113: what?". It was introduced in commit ddade10d4a93 ("ARM
ADIv5: "dap info" gets more readable") and from the same dump in
[1] it's clearly another element in OMAP3. It is listed as entry
0x8 in the ROM table and there is no further info available.
OpenOCD will anyway list it as:
Designer is 0x017, Texas Instruments
Part is 0x113, Unrecognized
Another link https://elinux.org/BeagleBoardOpenOCD reports the
text "Part number 0x113: This is ????", which sounds familiar!
No public document from Texas Instruments reports what is this
device at address 0x54012000.

[1] Warren Clay Grant - University of Texas at Austin
    "Implementation of an Open Source JTAG Debugging Development
    Chain for the BeagleBoard ARM® Cortex A-8" - May 2012
Link: https://repositories.lib.utexas.edu/bitstream/handle/2152/ETD-UT-2012-05-5478/GRANT-MASTERS-REPORT.pdf
Change-Id: I7e007addbb5c6e90303e4e8c110c7d27810fbe9c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6454
Tested-by: jenkins
Reviewed-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
2 years agoarm_adi_v5: add arm Neoverse N2 part numbers 53/6453/3
Antonio Borneo [Thu, 19 Aug 2021 16:02:14 +0000 (18:02 +0200)]
arm_adi_v5: add arm Neoverse N2 part numbers

Change-Id: Ib7a8c9d460f12762f6d106e9331e84b6d2dec213
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6453
Tested-by: jenkins
Reviewed-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agoarm_adi_v5: add arm Neoverse N1 part numbers 52/6452/3
Kevin Burke [Thu, 19 Aug 2021 15:44:38 +0000 (17:44 +0200)]
arm_adi_v5: add arm Neoverse N1 part numbers

Split from change https://review.openocd.org/6077/

Change-Id: I5e3d3736beb741de3940ea6e23b0ccbf47e8dec7
Signed-off-by: Kevin Burke <kevinb@os.amperecomputing.com>
Signed-off-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6452
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agoarm_adi_v5: add arm Cortex-R52 part numbers 51/6451/3
Antonio Borneo [Thu, 19 Aug 2021 16:22:28 +0000 (18:22 +0200)]
arm_adi_v5: add arm Cortex-R52 part numbers

Extract new part numbers from Arm Cortex-R52 Processor Technical
Reference Manual Revision r1p3 and add them to the array
dap_partnums.

Change-Id: I8020f36de587951af60422ef33d7e438dc7d9d53
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6451
Tested-by: jenkins
Reviewed-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agoarm_adi_v5: add arm SoC-600 part numbers 50/6450/3
Antonio Borneo [Mon, 16 Aug 2021 22:13:05 +0000 (00:13 +0200)]
arm_adi_v5: add arm SoC-600 part numbers

Extract new part numbers from ARM CoreSight System-on-Chip SoC-600
Technical Reference Manual Revision r4p1 and add them to the array
dap_partnums.

Change-Id: I88d8aa3c084f6e832b75032e75bfb6d377a08360
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6450
Tested-by: jenkins
Reviewed-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agoarm_adi_v5: add helper to search for part number 49/6449/3
Antonio Borneo [Mon, 16 Aug 2021 23:05:39 +0000 (01:05 +0200)]
arm_adi_v5: add helper to search for part number

Improve code readability and prepare to re-use the helper.

Change-Id: Iee5e01047c82be3dd86707f5c283f0b20cc4070d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6449
Tested-by: jenkins
Reviewed-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agoarm_adi_v5: move in a separate function devtype decode/display 48/6448/5
Kevin Burke [Tue, 10 Aug 2021 14:26:42 +0000 (16:26 +0200)]
arm_adi_v5: move in a separate function devtype decode/display

For readability, move in a separate function the decoding and the
display of devtype register.
The function will be reused with ADIv6.

Split from change https://review.openocd.org/6077/

Change-Id: I7a26a2c9759d5db5f9acfae5c169b90b3deb2f18
Signed-off-by: Kevin Burke <kevinb@os.amperecomputing.com>
Signed-off-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6448
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agoarm_adi_v5: simplify handling of AP type 47/6447/5
Antonio Borneo [Tue, 10 Aug 2021 16:09:28 +0000 (18:09 +0200)]
arm_adi_v5: simplify handling of AP type

The complete AP type should include 'class' and 'manufacturer'.

Cleanup the definition of AP type from AP_REG_IDR register.
Include the check of 'class', together with manufacturer and type.
Add the new MEM-AP from ARM IHI0074C.

Change-Id: Ic8db7c040108ba237b54f73b1abe24b8b853699b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6447
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
2 years agoarm_coresight: add include file and use it 46/6446/5
Antonio Borneo [Sun, 8 Aug 2021 14:46:30 +0000 (16:46 +0200)]
arm_coresight: add include file and use it

Several magic numbers related to ARM CoreSight specification
IHI0029E are spread around OpenOCD code.

Define through macros the ARM CoreSight magic numbers and collect
them in a single include file.
Use the new macros wherever possible.

Change-Id: I9b0c1c651ce4ffbaf08d31791ef16e95983ee4cb
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6446
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
2 years agoarmv7m.h: relax dependency from 'arm_adi_v5.h' 68/6468/4
Antonio Borneo [Mon, 16 Aug 2021 17:08:23 +0000 (19:08 +0200)]
armv7m.h: relax dependency from 'arm_adi_v5.h'

The include file 'armv7m.h' includes 'arm_adi_v5.h' only to get
the definition of 'struct adiv5_ap', but doesn't need the struct
content.

Reducing the cross dependencies speeds-up the compile time during
code development by avoiding re-compiling file.

Relax the dependency by locally declaring 'struct adiv5_ap' in
'armv7m.h' and remove the include of 'arm_adi_v5.h'.
Fix the other files that have now lost the includes file that
'arm_adi_v5.h' depends from.

Change-Id: Ic0d40b17db6045fa43f348bda83eaf211a6b347d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6468
Tested-by: jenkins
Reviewed-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agoPartially Revert "flash/stm32l4x: introduce flash programming without loader" 69/6569/5
Oleksij Rempel [Wed, 15 Sep 2021 09:34:21 +0000 (10:34 +0100)]
Partially Revert "flash/stm32l4x: introduce flash programming without loader"

This partially reverts commit 1247eee4e6e5.

There is no reasonable use cases where work-area should be enabled
and working, and it can't be used for the flash loader.

Instead of introducing driver specific property, users can disable
flash load by disabling work-area, for example by setting it to 0.

But still we keep the function stm32l4_write_block_without_loader
to be used when workarea is not available (no sufficient size or zero)

Change-Id: Ibb046c74df354c6067bac978e8ef7efb47d9fd2b
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6569
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2 years agoflash/stm32l4x: fix dual bank support for STM32L552xC devices 38/6538/4
Tarek BOCHKATI [Thu, 2 Sep 2021 11:03:59 +0000 (12:03 +0100)]
flash/stm32l4x: fix dual bank support for STM32L552xC devices

For STM32L552xC devices with 256K flash:
  dual bank mode is activated if DB256 is set
  page size is 2KB if DBANK is set

For parts with 512K (aka STM32L5x2xE):
  DBANK controls both of dual/single bank mode and page size as well.

Change-Id: I8be668d5552fefe81acffaf2e3e35ef5e938162e
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reported-by: Patrik Bachan <diggit@users.sourceforge.net>
Fixes: https://sourceforge.net/p/openocd/tickets/317/
Reviewed-on: https://review.openocd.org/c/openocd/+/6538
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 years agohelper/command: fix echo return values 49/6549/2
Tarek BOCHKATI [Wed, 11 Aug 2021 00:14:21 +0000 (01:14 +0100)]
helper/command: fix echo return values

the echo command is managed through command handler and not jim_handler
to be consistent rename the handler from jim_echo to handle_echo
and update the return values

Fixes: 4747af362de0 (JIM: document "echo" command)
Change-Id: I5ae87ea802d8430b573fb83daa6b35490b5d5775
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6549
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agojep106.inc: Update to revision JEP106BC 51/6551/4
Florian Zaruba [Tue, 7 Sep 2021 16:22:13 +0000 (18:22 +0200)]
jep106.inc: Update to revision JEP106BC

Signed-off-by: Florian Zaruba <florian@openhwgroup.org>
Change-Id: I566eb331b2884de3df5ad3f02c2ec7961539257b
Reviewed-on: https://review.openocd.org/c/openocd/+/6551
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agostlink: Add PID for V3 device without MSD 55/6555/3
Andreas Sandberg [Wed, 8 Sep 2021 22:09:51 +0000 (23:09 +0100)]
stlink: Add PID for V3 device without MSD

Add the 0x3754 PID used by some STLINK-V3 devices when MSD has been
disabled. This PID has been observed on a Nucleo-G431RB board.

Signed-off-by: Andreas Sandberg <andreas@sandberg.uk>
Change-Id: Idb85874fa5a9dff5940bae7e95426a956693b976
Reviewed-on: https://review.openocd.org/c/openocd/+/6555
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agohla: Increase HLA_MAX_USB_IDS 54/6554/2
Andreas Sandberg [Wed, 8 Sep 2021 22:14:34 +0000 (23:14 +0100)]
hla: Increase HLA_MAX_USB_IDS

We are already at the limit for the number of VID/PID pairs declared
in stlink.cfg and stlink-dap.cfg. Increase the maximum number of pairs
from 8 to 16 to make room for a few more devices.

Signed-off-by: Andreas Sandberg <andreas@sandberg.uk>
Change-Id: Ifad8e7ef67b930edbb5421730f00eb3390812f06
Reviewed-on: https://review.openocd.org/c/openocd/+/6554
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotarget: do not cast NULL in assignment 40/6540/2
Antonio Borneo [Sat, 4 Sep 2021 21:22:27 +0000 (23:22 +0200)]
target: do not cast NULL in assignment

NULL is defined as 'void *'.
There is no need to cast NULL while assigning it to a pointer.

Change-Id: Ibaf18e5d47329707ec9c1c184cd4bba2e8e702ff
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6540
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Tested-by: jenkins
2 years agoopenocd: remove last NULL comparisons 39/6539/2
Antonio Borneo [Sat, 4 Sep 2021 21:01:09 +0000 (23:01 +0200)]
openocd: remove last NULL comparisons

The NULL pointers preceded by cast where not detected by the
scripting tools looking for NULL pointer comparison.

Remove them and, while there, further simplify the code and apply
the other coding style rules.

Change-Id: Ia7406122e07ef56ef311579ab0ee7ddb22c8e4b5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6539
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agogerrit url: update the gerrit server address to https://review.openocd.org 81/6481/3
Tarek BOCHKATI [Thu, 26 Aug 2021 09:41:35 +0000 (10:41 +0100)]
gerrit url: update the gerrit server address to https://review.openocd.org

change the gerrit server address from http://openocd.zylin.com to the new
address in order to avoid re-directions.

Change-Id: I76e128c277f63783d1a6f63a6a387aa838f51f80
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6481
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodoc: add a note to use 'stm32l4x option_load' after changing option bytes 33/6533/2
Tarek BOCHKATI [Thu, 2 Sep 2021 14:56:50 +0000 (15:56 +0100)]
doc: add a note to use 'stm32l4x option_load' after changing option bytes

Change-Id: I502be27da892e393731d11e02203c736e77033d0
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6533
Tested-by: jenkins
Reviewed-by: Karl Palsson <karlp@tweak.net.au>
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agotcl/target/stm32(f7/h7)x: do not assume presence of the reset 06/6506/3
Tarek BOCHKATI [Sun, 29 Aug 2021 21:09:46 +0000 (22:09 +0100)]
tcl/target/stm32(f7/h7)x: do not assume presence of the reset

do not force the presence of the reset line, since some custom boards
may do not contain the reset line.

Change-Id: I031ab34012b34a1b49def9db16461f9de0ae29cc
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reported-by: Fleck <fleckz@users.sourceforge.net>
Fixes: https://sourceforge.net/p/openocd/tickets/316/
Reviewed-on: https://review.openocd.org/c/openocd/+/6506
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
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)