openocd.git
2 years agotcl/target: Add support for Renesas R8A779A0 V3U SoC 14/6314/3
Marek Vasut [Sun, 30 May 2021 15:34:10 +0000 (17:34 +0200)]
tcl/target: Add support for Renesas R8A779A0 V3U SoC

The V3U SoC is unique in that it now has 8x CA76 and CR52,
while the previous SoCs had CA57/CA53/CR7 . This can still
be handled without too complex modifications to the gen3
configuration file, so add the logic to handle it there.

Change-Id: I7ab33eacc1fd379d369988d3d6690d2e82346c7e
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Reviewed-on: http://openocd.zylin.com/6314
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotcl/target: Select default boot core on Renesas R-Car Gen2/Gen3 13/6313/3
Marek Vasut [Sat, 12 Jun 2021 18:48:51 +0000 (20:48 +0200)]
tcl/target: Select default boot core on Renesas R-Car Gen2/Gen3

On SMP Renesas R-Car Gen2/Gen3 systems, select the boot core as
the default target using the 'targets' command. This way, the
user can start debugging code running on the boot core without
having to switch to the boot core by explicitly invoking 'targets'
command first, since it is likely the debugged code will run on
the boot core. Note that most of the code is already in place, it
was just not used, so this is more of a fix to make the original
intention work.

Change-Id: I727808adce617c1d9ebd6ffa34f60f5882cdae60
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Reviewed-on: http://openocd.zylin.com/6313
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotarget/riscv: Implement get_gdb_arch() 22/6322/4
Jesse Sheridan [Wed, 16 Jun 2021 17:38:00 +0000 (10:38 -0700)]
target/riscv: Implement get_gdb_arch()

Change-Id: I5f4ab5243104df41031950682f688f2448a09b17
Signed-off-by: Jesse Sheridan <jesse.sheridan@gmail.com>
Reviewed-on: http://openocd.zylin.com/6322
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotcl: Add support for the Digilent Nexys Video board 64/4364/5
Rohit Singh [Fri, 19 Jan 2018 09:54:26 +0000 (20:54 +1100)]
tcl: Add support for the Digilent Nexys Video board

* https://store.digilentinc.com/nexys-video-artix-7-fpga-trainer-board-for-multimedia-applications/
* https://reference.digilentinc.com/_media/nexys-video:nexys_video_sch.pdf

The Nexys Video board has FTDI FT2232 whose channel B is connected to
Artix-7 FPGA's JTAG pins, and can be supported by OpenOCD's
ftdi interface. Tested to be working fine on real hardware.

Change-Id: I2996166dc8c2b6c08a9390958adfcdec8fc2bd37
Signed-off-by: Rohit Singh <rohit91.2008@gmail.com>
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/4364
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoDoc fix: echo writes to the log, and not to stdout 72/6272/3
R. Diez [Sun, 23 May 2021 10:18:36 +0000 (12:18 +0200)]
Doc fix: echo writes to the log, and not to stdout

Fixes bug #202

Change-Id: I855a1b8570af71379891634f405b4cc726917cb2
Signed-off-by: R. Diez <rdiezmail-openocd@yahoo.de>
Reviewed-on: http://openocd.zylin.com/6272
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodoc/openocd: Fix typo 96/6296/5
Marc Schink [Sat, 5 Jun 2021 12:01:10 +0000 (14:01 +0200)]
doc/openocd: Fix typo

Change-Id: I8cf679190d6911de2dee181879c8895b55466835
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6296
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoUse boolean argument for register_get_by_name() 95/6295/2
Marc Schink [Fri, 4 Jun 2021 12:38:17 +0000 (14:38 +0200)]
Use boolean argument for register_get_by_name()

Change-Id: Ie913630c6ab3b600532d8e375e2fc11ca202cf5e
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6295
Tested-by: jenkins
Reviewed-by: Jan Matyas <matyas@codasip.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotarget/register: Minor code cleanup 94/6294/2
Marc Schink [Fri, 4 Jun 2021 12:31:57 +0000 (14:31 +0200)]
target/register: Minor code cleanup

Change-Id: Ie02a112c0339ae5d3b3763483e493370b487be98
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6294
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoflash/stm32fxx.c: do not read CPUID as this info is stored in cortex_m_common 40/6240/7
Tarek BOCHKATI [Thu, 13 May 2021 13:28:24 +0000 (14:28 +0100)]
flash/stm32fxx.c: do not read CPUID as this info is stored in cortex_m_common

In these drivers we read CPUID to check the Cortex-M PARTNO,
but now the PARTNO is stored in struct cortex_m_common.core_info.

Change-Id: I5bb3b95210ab6e23b8e1252686dd81015740bf68
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6240
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agocortex_m: enhance core and arch detection 33/6233/10
Tarek BOCHKATI [Tue, 11 May 2021 13:03:47 +0000 (14:03 +0100)]
cortex_m: enhance core and arch detection

Rework core detection by adding cortex_m_partno enum to detect all CPUs
using the same method.

Instead of checking the core PARTNO then assign the arch, use the stored
information within cortex_m parts[] with the flags inside which can help
simplifying a bit the cortex_m_examine code.

This change fixes:
 - the Cortex-M1 detection as ARMv6-M Core (was managed as ARMv7-M)
 - the displayed CPU name for Cortex-M0+ (was displayed Cortex-M0)

Change-Id: I40b6e03f7cf3664c85e297adfc25323196dfe90b
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6233
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotarget/arm: optimize architecture flags 29/6229/7
Tarek BOCHKATI [Tue, 11 May 2021 08:28:00 +0000 (09:28 +0100)]
target/arm: optimize architecture flags

In target/arm.h the struct arm do contain 3 flags to retain architecture
version for some tweaks.
The proposal is to have only one enumerated flag 'arch' for the same purpose.

Change-Id: Ia5d5accfed8158ca21eb54af2fdea8e36f0266ae
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6229
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agocontrib/itmdump.c: fix implicit declaration warning 12/6312/3
Diego Herranz [Fri, 11 Jun 2021 07:58:04 +0000 (08:58 +0100)]
contrib/itmdump.c: fix implicit declaration warning

atoi used but stdlib.h wasn't included.
Also, include statements reordered alphabetically.

Change-Id: I7fcdbf3fa940a172204ec811399e1a7fdebdc979
Signed-off-by: Diego Herranz <diegoherranz@diegoherranz.com>
Reviewed-on: http://openocd.zylin.com/6312
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotarget: Rename 'linked_BRP' to 'linked_brp' 16/6316/2
Marc Schink [Sun, 13 Jun 2021 08:49:17 +0000 (10:49 +0200)]
target: Rename 'linked_BRP' to 'linked_brp'

Change-Id: I9dd67ac3e8cd5dd9cdeffce56020b387a8f298fa
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6316
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoarmv4_5: do not read/write non-existent registers 64/6064/3
Tarek BOCHKATI [Sun, 14 Feb 2021 12:22:03 +0000 (13:22 +0100)]
armv4_5: do not read/write non-existent registers

Change-Id: I4a0c401a325e57ba5d4d93d83b7e6b71a4d0865e
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6064
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoarm_dpm: do not read/write non-existent registers 63/6063/4
Tarek BOCHKATI [Sun, 14 Feb 2021 12:21:36 +0000 (13:21 +0100)]
arm_dpm: do not read/write non-existent registers

Change-Id: I6a991899bb178ee0c6b41870a45d0a9439d9dc1e
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6063
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 years agoarmv8_dpm: do not read/write non-existent registers 62/6062/3
Tarek BOCHKATI [Sun, 14 Feb 2021 11:39:33 +0000 (12:39 +0100)]
armv8_dpm: do not read/write non-existent registers

Change-Id: I0f3fffa8cf1746569f6acce0233e9544d3862f51
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6062
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoflash/nor: improved API of flash_driver.info & fixed buffer overruns 82/6182/7
Jan Matyas [Fri, 23 Apr 2021 08:47:17 +0000 (10:47 +0200)]
flash/nor: improved API of flash_driver.info & fixed buffer overruns

1) The API of "info" callback in "struct flash_driver" has been
improved. Fixed buffers for strings

2) Removed the calls to snprintf() from the flash_driver.info
implementations. Many of them were used in an unsafe manner
(buffer overruns were possible).

Change-Id: I42ab8a8018d01f9af43c5ba49f650c3cb5d31dcb
Signed-off-by: Jan Matyas <matyas@codasip.com>
Reviewed-on: http://openocd.zylin.com/6182
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agoAdd remote bitbang write buffer. 83/6283/5
Tim Newsome [Fri, 28 May 2021 20:38:50 +0000 (13:38 -0700)]
Add remote bitbang write buffer.

Change 7dd323b26 reduced remote bitbang performance a lot. This change
gets most of that performance back again, by reintroducing a write
buffer.

Performance numbers collected using DebugBreakpoint test from
riscv-tests/debug against a single 64-bit spike (RISC-V simulator)
instance. (Ubuntu 20.04.2, AMD Ryzen 5 3600)
Before Windows support was added: 3.09s
After Windows support was added: 12.67s
After this change: 4.69s

Signed-off-by: Tim Newsome <tim@sifive.com>
Change-Id: I72ff4912cbbf316a30ef065e5b8f461a555f06cc
Reviewed-on: http://openocd.zylin.com/6283
Tested-by: jenkins
Reviewed-by: Jan Matyas <matyas@codasip.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotarget/cortex_a: Use bool data type 89/6289/3
Marc Schink [Thu, 3 Jun 2021 21:11:18 +0000 (23:11 +0200)]
target/cortex_a: Use bool data type

Change-Id: Ieea3dc05809263aa0eba5125d52fef3fe77e9c5a
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6289
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotarget/startup.tcl: Do not use 'Yoda conditions' 84/6284/4
Marc Schink [Sat, 29 May 2021 10:09:28 +0000 (12:09 +0200)]
target/startup.tcl: Do not use 'Yoda conditions'

Change-Id: I5e1bbaf032659dda1b365ef4ec6ea4a635d921ce
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6284
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoAvoid non-standard conditionals with omitted operands. 71/6271/3
R. Diez [Sun, 23 May 2021 10:01:48 +0000 (12:01 +0200)]
Avoid non-standard conditionals with omitted operands.

Fixes bug #257.

Change-Id: I05fc6468306d46399e769098e031e7e588798afc
Signed-off-by: R. Diez <rdiezmail-openocd@yahoo.de>
Reviewed-on: http://openocd.zylin.com/6271
Tested-by: jenkins
Reviewed-by: Xiang W <wxjstz@126.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoAdd target_data_bits(). 49/6249/4
Tim Newsome [Thu, 13 May 2021 23:38:51 +0000 (16:38 -0700)]
Add target_data_bits().

This is used to compute memory block read alignment, and specifically
allows 64-bit targets to ensure that memory block reads are only
requested on 64-bit boundaries.

Signed-off-by: Tim Newsome <tim@sifive.com>
Change-Id: Idb1a27b9fc02c46245556bb0f3d6d94b368c4817
Reviewed-on: http://openocd.zylin.com/6249
Reviewed-by: Marc Schink <dev@zapb.de>
Tested-by: jenkins
Reviewed-by: Jan Matyas <matyas@codasip.com>
Reviewed-by: Xiang W <wxjstz@126.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agocmsis_dap: add support for swo commands 20/5820/19
Adrian Negreanu [Wed, 19 May 2021 10:33:30 +0000 (13:33 +0300)]
cmsis_dap: add support for swo commands

Replaced mixed snake_case_CamelCase with snake_case.
Define variables at first-use location.

CMSIS-DAP SWO specification:

    https://arm-software.github.io/CMSIS_5/DAP/html/group__DAP__swo__gr.html

Change-Id: Ieba79b16efd445143f964b614673d041aae74f92
Signed-off-by: Adrian Negreanu <adrian.negreanu@nxp.com>
Reviewed-on: http://openocd.zylin.com/5820
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotarget: Use 'bool' for 'reset_halt' 62/6262/3
Marc Schink [Mon, 17 May 2021 10:53:16 +0000 (12:53 +0200)]
target: Use 'bool' for 'reset_halt'

Change-Id: I974a6360ea7467067511541ac212f2e9d3de7895
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6262
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodrivers/jlink: Remove trailing dots 74/6274/2
Marc Schink [Tue, 3 Nov 2020 13:09:37 +0000 (14:09 +0100)]
drivers/jlink: Remove trailing dots

This makes the messages consistent with most of the rest of
the OpenOCD output.

Change-Id: I915a01187e7fc317e02483ac0bbd39ec077d6321
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6274
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotarget/renesas_rz_g2: Introduce tcl config file for RZ/G2 devices 50/6250/10
micbis [Mon, 10 May 2021 08:24:49 +0000 (10:24 +0200)]
target/renesas_rz_g2: Introduce tcl config file for RZ/G2 devices

Initial support for Renesas RZ/G2 MPU family

Change-Id: I5ca74cddfd0c105a5307de56c3ade7084f9c28d2
Signed-off-by: micbis <michele.bisogno.ct@renesas.com>
Reviewed-on: http://openocd.zylin.com/6250
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agogdb_server: Log both incoming and outgoing GDB packets 69/6269/4
Jan Matyas [Fri, 21 May 2021 06:02:29 +0000 (08:02 +0200)]
gdb_server: Log both incoming and outgoing GDB packets

- Made sure that also outgoing GDB packets are logged,
  not only the incoming ones.

- Improved the treatment of non-printable characters
  in the packets to make it more robust.

Prior to this change:

- Outgoing packets were not printed unless OpenOCD was
  re-compiled with _DEBUG_GDB_IO_.
- Non-prinable characters were only treated in incoming
  'X' packets.

After this change:

- Both incoming and outgoing GDB packets are logged
  on debug_level >= 3, so that both directions of the
  GDB channel are visible.
- Non-printable characters are checked for in every packet
  so that hey do not interfere with the terminal.

Change-Id: I0613e57ae5059b3279b0abcb71276cf5719a8699
Signed-off-by: Jan Matyas <matyas@codasip.com>
Reviewed-on: http://openocd.zylin.com/6269
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoMakefile: add special target .DELETE_ON_ERROR 35/6235/5
R. Diez [Thu, 13 May 2021 10:36:27 +0000 (12:36 +0200)]
Makefile: add special target .DELETE_ON_ERROR

The special .DELETE_ON_ERROR deletes the target file on recipe error.
Otherwise, an incomplete output file may be considered up to date
the next time around. .DELETE_ON_ERROR provides reasonable
protection at virtually no cost.

Signed-off-by: R. Diez <rdiezmail-openocd@yahoo.de>
Change-Id: I67dca47ae5ddf3786993c87b9991b3046a85f00b
Reviewed-on: http://openocd.zylin.com/6235
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotcl/target/stm32f4x: fix hardcoded chip name 77/6277/2
Tarek BOCHKATI [Wed, 26 May 2021 15:10:39 +0000 (16:10 +0100)]
tcl/target/stm32f4x: fix hardcoded chip name

Fixes: c945d6e61605 ("tcl/target: start using the new TPIU/SWO support")
Change-Id: I4543c9a204f7b4b3b14e6eabc5042653106aff0e
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6277
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 years agohelper/list.h: add mention to the example in contrib 81/6281/3
Antonio Borneo [Thu, 27 May 2021 12:21:13 +0000 (14:21 +0200)]
helper/list.h: add mention to the example in contrib

Without such reference, it could be difficult to find the example.

Change-Id: Ia9ffb06bc1a45446c2c7b53197ab3400e1d8a9e9
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6281
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>
2 years agocontrib: add an example of using list.h 80/6280/2
Andreas Fritiofson [Thu, 27 May 2021 07:45:28 +0000 (09:45 +0200)]
contrib: add an example of using list.h

Change-Id: Ic3d399d7ad2e4d10677cf78d64968040941b74e5
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6280
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>
2 years agohelper/list.h: align file to Linux v5.12 76/6276/3
Antonio Borneo [Wed, 26 May 2021 12:48:10 +0000 (14:48 +0200)]
helper/list.h: align file to Linux v5.12

Main improvement is in the doxygen comments.
Minimize the delta with kernel file.
Skip the functions hlist_unhashed_lockless() and
__list_del_clearprev() that are relevant only in kernel.
Remove gcc extension "omitted conditional operand".

Change-Id: I2e9ddb54cfe2fa5f7cf18f44726acd144e1f98b9
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6276
Reviewed-by: <rdiezmail-openocd@yahoo.de>
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2 years agoserver/telnet: fix autocomplete for jimtcl commands 82/6282/2
Antonio Borneo [Thu, 27 May 2021 13:25:43 +0000 (15:25 +0200)]
server/telnet: fix autocomplete for jimtcl commands

Current autocomplete filters-out some command reported by "info
commands". One of the filter rule concerns the command's private
data.
Every command registered by OpenOCD has its 'struct command' as
private data.

By ignoring commands without private data, we loose several TCL
commands registered by jimtcl, e.g. 'foreach', 'llength'.

By assuming that every command with non-NULL private data has
'struct command' as private data, we risk at best to access
inconsistent data, at worst to trigger a segmentation fault.

Export the already available functions:
- to check if a command has been registered by OpenOCD and
- to get the private data.
While there, rename jimcmd_is_ocd_command() as
jimcmd_is_oocd_command().
Don't filter-out jimtcl commands with no private data.
Check the private data only on OpenOCD commands.

Change-Id: Ib5bf8d2bc5c12440c0cfae438f637c38724a79b7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6282
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agohelper/jim-nvp: comply with coding style [2/2] 84/6184/4
Antonio Borneo [Sat, 24 Apr 2021 22:48:14 +0000 (00:48 +0200)]
helper/jim-nvp: comply with coding style [2/2]

With the API fixed to comply with OpenOCD coding style, fix all
the references in the code.

Patch generated automatically with the script below.
The list is in reverse order to replace a common prefix after the
replacement of the symbols with the same prefix.

%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---
(cat << EOF
Jim_SetResult_NvpUnknown         jim_set_result_nvp_unknown
Jim_Nvp_value2name_simple        jim_nvp_value2name_simple
Jim_Nvp_value2name_obj           jim_nvp_value2name_obj
Jim_Nvp_value2name               jim_nvp_value2name
Jim_Nvp_name2value_simple        jim_nvp_name2value_simple
Jim_Nvp_name2value_obj_nocase    jim_nvp_name2value_obj_nocase
Jim_Nvp_name2value_obj           jim_nvp_name2value_obj
Jim_Nvp_name2value_nocase_simple jim_nvp_name2value_nocase_simple
Jim_Nvp_name2value_nocase        jim_nvp_name2value_nocase
Jim_Nvp_name2value               jim_nvp_name2value
Jim_Nvp                        struct jim_nvp
Jim_GetOpt_Wide                  jim_getopt_wide
Jim_GetOpt_String                jim_getopt_string
Jim_GetOpt_Setup                 jim_getopt_setup
Jim_GetOpt_Obj                   jim_getopt_obj
Jim_GetOpt_NvpUnknown            jim_getopt_nvp_unknown
Jim_GetOpt_Nvp                   jim_getopt_nvp
Jim_GetOpt_Enum                  jim_getopt_enum
Jim_GetOpt_Double                jim_getopt_double
Jim_GetOpt_Debug                 jim_getopt_debug
Jim_GetOptInfo                 struct jim_getopt_info
Jim_GetNvp                       jim_get_nvp
Jim_Debug_ArgvString             jim_debug_argv_string
EOF
) | while read a b; do
    sed -i "s/$a/$b/g" $(find src -type f ! -name jim-nvp.\? )
done
%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---

Change-Id: I10a12bd64bb8b17575fd9150482c989c92b298a2
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6184
Reviewed-by: Marc Schink <dev@zapb.de>
Tested-by: jenkins
2 years agohelper/jim-nvp: comply with coding style [1/2] 83/6183/5
Antonio Borneo [Sat, 24 Apr 2021 22:06:00 +0000 (00:06 +0200)]
helper/jim-nvp: comply with coding style [1/2]

The helper jim-nvp does not comply with OpenOCD coding style due
to typedef of struct and CamelCase symbol names.
While it's trivial fixing the helper and all its current use in
the code, changing these APIs will potentially break a number of
patches pending in gerrit. Gerrit will not trigger any alert, but
the code will generate compile error after the merge.

Add the compile flag "-Wno-error=deprecated-declarations" to keep
as warning (not as error) the use of "deprecated" functions and
types.
Rename all the CamelCase symbols is lowercase and provide struct
prototypes in place of the typedef.
Add a DEPRECATED section to 'jim-nvp.h' where the old CamelCase
symbols and the old typedef are re-declared with compile attribute
'deprecated'.

With this change OpenOCD compiles, but generates warnings.
The remaining changes allover OpenOCD code will be fixed in a
separate patch for easier review.

The patches merged later that still use the old deprecated API
will compile with warnings. This will permit to identify and fix
these cases.

Change-Id: I786385d0f662dbb1be5be313ae42623156d68ce5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6183
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
2 years agotarget/cortex_a: fix memory leak on watchpoints 10/6210/3
Antonio Borneo [Fri, 7 May 2021 14:17:32 +0000 (16:17 +0200)]
target/cortex_a: fix memory leak on watchpoints

The memory allocated to hold the watchpoints is not freed at
OpenOCD exit.

Free the watchpoint memory at OpenOCD exit.

Change-Id: I518c9ce0dc901cde2913d752e3154734f878b854
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6210
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
2 years agotarget/cortex_a: add support for watchpoint length of 1, 2 and 4 bytes 97/6197/3
Antonio Borneo [Thu, 29 Apr 2021 08:49:50 +0000 (10:49 +0200)]
target/cortex_a: add support for watchpoint length of 1, 2 and 4 bytes

Use byte address select for 1 and 2 bytes length.
Use normal mode for 4 bytes length.

Change-Id: I28d182f25145d0635de64d0361d456f1ad96640e
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6197
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
2 years agotarget/cortex_a: fix number of watchpoints 96/6196/3
Antonio Borneo [Thu, 29 Apr 2021 07:22:00 +0000 (09:22 +0200)]
target/cortex_a: fix number of watchpoints

Decrement the available watchpoints only when succeed setting it.
Initialize the available watchpoint with the correct value.

Change-Id: I0f93b347300b8ebedbcd9e718d4ba32b26cf6846
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6196
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
2 years agotarget/cortex_a: add support for watchpoints 13/3913/7
Chengyu Zheng [Wed, 14 Dec 2016 11:18:10 +0000 (12:18 +0100)]
target/cortex_a: add support for watchpoints

The current implementation of OpenOCD does not support watchpoints for
cortex_a architecture. So, I replaced the add_watchpoint and
remove_watchpoint with the specific implementation for the
cortex a and using the breakpoint implementation and the arm
documentation [1] as reference. In particular, I have made the
following changes:

* added the following functions

- cortex_a_add_watchpoint
  This wrapper function check whether there are any watchpoint
  available on the target device by calling cortex_a_set_watchpoint.

- cortex_a_set_watchpoint
  This function is responsible for settings the watchpoint register
  pair. In particular, it sets the WVR and the WCR registers with
  the cortex_a_dap command.

- cortex_a_remove_watchpoint
  This wrapper function the selected watchpoint on the target device
  by calling cortex_a_unset_watchpoint.

- cortex_a_unset_watchpoint
  This function sets both the WVR and the WCR registers to zero, thus
  unsetting the watchpoint.

[1]
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0464f/BCGDHIEJ.html

Change-Id: I86611dab474cb84836662af572b17636dc68e282
Signed-off-by: Chengyu Zheng <chengyu.zheng@polimi.it>
Reviewed-on: http://openocd.zylin.com/3913
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Reviewed-by: Marc Schink <dev@zapb.de>
Tested-by: jenkins
2 years agotarget/arm_adi_v5: Fix clear sticky overrun flag during replay of commands 78/6278/7
micbis [Wed, 26 May 2021 17:11:05 +0000 (19:11 +0200)]
target/arm_adi_v5: Fix clear sticky overrun flag during replay of commands

When a WAIT occurs the commands after the WAIT are replayed and the
STICKYORUN is cleared. However if another WAIT occurs during the
command replay, the command itself is resent but the STICKYORUN bit
shall also be cleared. If this is not done, the MEM-AP hangs.

Change-Id: I14e8340cd5d8f58f4de31509da96cfa2ecb630d1
Signed-off-by: micbis <michele.bisogno.ct@renesas.com>
Reviewed-on: http://openocd.zylin.com/6278
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
2 years agotcl/board: Add ST NUCLEO-8S208RB 68/6268/3
Marc Schink [Thu, 20 May 2021 16:29:10 +0000 (18:29 +0200)]
tcl/board: Add ST NUCLEO-8S208RB

Change-Id: I384c6ad9b4cbabbc004160677f600d8c4bd3eb71
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6268
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agostlink: reorder the flag macro by firmware release 12/6212/2
Antonio Borneo [Tue, 10 Nov 2020 12:49:13 +0000 (13:49 +0100)]
stlink: reorder the flag macro by firmware release

The corresponding bit for each macro is changed, but this is not
relevant in the code.

Change-Id: I7039464f5a3d55d008208f44952aadeb815bd5a3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6212
Tested-by: jenkins
2 years agostlink: add comment of firmware version for each flag bit 11/6211/2
Antonio Borneo [Mon, 9 Nov 2020 22:08:24 +0000 (23:08 +0100)]
stlink: add comment of firmware version for each flag bit

Change-Id: I7f7c7b9c9cfd88125f82662ed864a2c0715140b1
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6211
Tested-by: jenkins
2 years agoLICENSES: Add the MIT license 19/6219/2
Thomas Gleixner [Thu, 28 Dec 2017 15:27:18 +0000 (16:27 +0100)]
LICENSES: Add the MIT license

Add the full text of the MIT license to the kernel tree.  It was copied
directly from:

  https://spdx.org/licenses/MIT.html#licenseText

Add the required tags for reference and tooling.

Change-Id: I94a5dea5ced6421809ea2a3448f8dda19a93f5c9
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6219
Tested-by: jenkins
2 years agohelp: fix line size in 'usage' output 23/6223/2
Antonio Borneo [Sat, 27 Mar 2021 21:23:50 +0000 (22:23 +0100)]
help: fix line size in 'usage' output

The implementation of command 'usage' is broken while checking the
line limit of 76 chars per line (e.g. 'usage load_image') and the
line wrapping is not correct. The same broken code is used for the
first output line of command 'help' too.

When call command_help_show_wrap(), include the command's name in
the string so the whole text would be wrapped.

Change-Id: Idece01ce54994db7e851d8522435ff764b11f3ac
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6223
Tested-by: jenkins
2 years agohelp text: remove trailing space 22/6222/2
Antonio Borneo [Sat, 27 Mar 2021 20:41:30 +0000 (21:41 +0100)]
help text: remove trailing space

Some help text end with a useless space character.
Remove it.

Change-Id: I397e1194fac8042f0fab694222f925f906716de3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6222
Tested-by: jenkins
2 years agotcl: remove remaining deprecated commands 70/6270/3
Antonio Borneo [Fri, 21 May 2021 16:01:59 +0000 (18:01 +0200)]
tcl: remove remaining deprecated commands

There are still few adapter_khz, ftdi_location, jtag_nsrst_delay
and xds110_serial strolling around ...

Change-Id: I3e8503dcc3875e3c92e6536f3d455a5e448d51ff
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6270
Tested-by: jenkins
2 years agortos: use ARRAY_SIZE() and simplify rtos_type.create() 61/6261/3
Antonio Borneo [Sun, 16 May 2021 13:43:28 +0000 (15:43 +0200)]
rtos: use ARRAY_SIZE() and simplify rtos_type.create()

Use the existing macro ARRAY_SIZE().
Rewrite the functions rtos_type.create() to simplify the logic.

Change-Id: I8833354767045d1642801d26944c9087a77add00
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6261
Tested-by: jenkins
2 years agoopenocd: use macro ARRAY_SIZE() 60/6260/2
Antonio Borneo [Mon, 24 Aug 2020 09:42:15 +0000 (11:42 +0200)]
openocd: use macro ARRAY_SIZE()

There are still few cases where the macro ARRAY_SIZE() should be
used in place of custom code.

Use ARRAY_SIZE() whenever possible.

Change-Id: Iba0127a02357bc704fe639e08562a4f9aa7011df
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6260
Reviewed-by: Xiang W <wxjstz@126.com>
Tested-by: jenkins
2 years agodrivers/versaloon: use ARRAY_SIZE() 59/6259/2
Antonio Borneo [Mon, 24 Aug 2020 09:40:13 +0000 (11:40 +0200)]
drivers/versaloon: use ARRAY_SIZE()

Replace the custom macro dimof() with the OpenOCD macro
ARRAY_SIZE().

Change-Id: I2fe638444f6c16f2a78c1fd558b21550f76282d6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6259
Tested-by: jenkins
Reviewed-by: Xiang W <wxjstz@126.com>
2 years agotarget/zynqmp : Add AXI AP access port 63/6263/3
Olivier DANET [Mon, 17 May 2021 12:47:14 +0000 (14:47 +0200)]
target/zynqmp : Add AXI AP access port

The Xilinx Zynq UltraScale+ SoC have an "AXI-AP" access port for direct memory accesses without halting CPUs.

Change-Id: I6303331c217795657575de4759444938e775dee1
Signed-off-by: Olivier DANET <odanet@caramail.com>
Reviewed-on: http://openocd.zylin.com/6263
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoriscv: replace macro DIM() with ARRAY_SIZE() 58/6258/2
Antonio Borneo [Sun, 16 May 2021 12:02:53 +0000 (14:02 +0200)]
riscv: replace macro DIM() with ARRAY_SIZE()

OpenOCD already defines the macro ARRAY_SIZE, while riscv code
uses a local macro DIM.

Prefer using the macro ARRAY_SIZE() instead of DIM().
Not all the riscv code has been upstreamed, yes; this patch only
covers the code already upstreamed.

Change-Id: I89a58a6d91916d85c53ba5e4091b558271f8d618
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6258
Reviewed-by: Xiang W <wxjstz@126.com>
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>
2 years agoriscv: drop unused variable 57/6257/2
Antonio Borneo [Sun, 16 May 2021 09:58:31 +0000 (11:58 +0200)]
riscv: drop unused variable

The array newly_halted[] is assigned but its value is never used.
Drop it!

Change-Id: I678812a31c45a3ec03716e3eee6a30b8e8947926
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6257
Tested-by: jenkins
Reviewed-by: Xiang W <wxjstz@126.com>
Reviewed-by: Tim Newsome <tim@sifive.com>
2 years agomem_ap: fix target arch_info type 13/6213/2
Antonio Borneo [Wed, 6 Jan 2021 17:01:00 +0000 (18:01 +0100)]
mem_ap: fix target arch_info type

The target mem_ap appears as an ARM target, thus it allows the
execution of ARM specific commands causing the crash of OpenOCD.
E.g. 'arm mrc ...' can be executed and segfaults.

Replace the incorrect ARM magic number with a dedicated one.
While there, remove the 'struct arm', that is now holding only the
mem_ap's dap, and replace it with a pointer to the dap.

Change-Id: I881332d3fdf8d8f8271b8711607737b052a5699b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6213
Tested-by: jenkins
2 years agohelper/command: silent debug msg on command register/unregister 20/6220/2
Antonio Borneo [Sat, 8 May 2021 09:02:12 +0000 (11:02 +0200)]
helper/command: silent debug msg on command register/unregister

Commit e216186fab59 ("helper/command: register full-name commands
in jim") and commit a7d68878e4ba ("helper/command: unregister
commands through their full-name") introduce a LOG_DEBUG() message
each for command registration and unregistration.
The messages above are quite noisy and pollute the log when
debug_level is 3 or higher.
They can be useful to debug the command registration logic, but
for the other debug activities on OpenOCD are just noisy.
Already commit a03ac1ba3087 ("helper/command: disable logging of
registered commands [RFC]") was merged to silent the first case
that is now back with additional logs.

Silent both log messages.
Use 'if (false)' to silent them, making easy to re-enable it when
or if someone needs it.

Change-Id: Id8a067e60e822d4ecbddcb036d081298f7e6181f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6220
Tested-by: jenkins
2 years agoconfigure.ac: use a separate folder for Autoconf-generated files 36/6236/3
R. Diez [Thu, 13 May 2021 11:43:09 +0000 (13:43 +0200)]
configure.ac: use a separate folder for Autoconf-generated files

Autoconf generates several files in root folder of the project.
Keep the root folder cleaner by specifying subfolder 'build-aux'.
Align .gitignore accordingly.

Signed-off-by: R. Diez <rdiezmail-openocd@yahoo.de>
Change-Id: Ied87faba495d9eeb8f98e78c2e2b7e7e596febfb
Reviewed-on: http://openocd.zylin.com/6236
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoRemove compatibility macros m4_ifblank and m4_ifnblank 39/6239/2
R. Diez [Thu, 13 May 2021 12:47:44 +0000 (14:47 +0200)]
Remove compatibility macros m4_ifblank and m4_ifnblank

They are at least since Autoconf 2.67 present,
and we are requiring version 2.69.

Change-Id: I41b33d4ebe02198f03cdddcc4a3c1beedd993d78
Signed-off-by: R. Diez <rdiezmail-openocd@yahoo.de>
Reviewed-on: http://openocd.zylin.com/6239
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoWarn on undefined preprocessor symbols 38/6238/2
R. Diez [Thu, 13 May 2021 12:19:13 +0000 (14:19 +0200)]
Warn on undefined preprocessor symbols

Preprocessor directives like "#if SYMBOL" silently replace undefined or
misspelt symbols with 0, which makes configuration bugs hard to spot.
Compiler flag "-Wundef" prevents such errors.

Change-Id: I91b7ba2db02ef0c3c452d334601c53aebda4660e
Signed-off-by: R. Diez <rdiezmail-openocd@yahoo.de>
Reviewed-on: http://openocd.zylin.com/6238
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoDocument the buspirate interface driver. 31/6231/3
R. Diez [Mon, 10 May 2021 16:10:30 +0000 (18:10 +0200)]
Document the buspirate interface driver.

Change-Id: Iaff13fc5187041a840f4f00eb6b4ee52880cf47e
Signed-off-by: R. Diez <rdiezmail-openocd@yahoo.de>
Reviewed-on: http://openocd.zylin.com/6231
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoopenocd: fix some minor typo 18/6218/2
Antonio Borneo [Thu, 28 Jan 2021 12:34:51 +0000 (13:34 +0100)]
openocd: fix some minor typo

Minor typos found by the new checkpatch boosted by the dictionary
provided by 'codespell'.

Change-Id: I7b4cae1798ff5ea048fcbc671a397af763fdc605
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6218
Tested-by: jenkins
2 years agotarget: fix some minor typo 17/6217/2
Antonio Borneo [Thu, 28 Jan 2021 12:32:41 +0000 (13:32 +0100)]
target: fix some minor typo

Minor typos found by the new checkpatch boosted by the dictionary
provided by 'codespell'.

Change-Id: I548581247db72e683249749d1b8725035530b06e
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6217
Tested-by: jenkins
2 years agojtag: fix some minor typo 16/6216/2
Antonio Borneo [Thu, 28 Jan 2021 12:05:53 +0000 (13:05 +0100)]
jtag: fix some minor typo

Minor typos found by the new checkpatch boosted by the dictionary
provided by 'codespell'.

Change-Id: I101c76a638805d77c1ff356cf0f027552389e5d3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6216
Tested-by: jenkins
2 years agoflash: fix some minor typo 15/6215/2
Antonio Borneo [Thu, 28 Jan 2021 11:51:44 +0000 (12:51 +0100)]
flash: fix some minor typo

Minor typos found by the new checkpatch boosted by the dictionary
provided by 'codespell'.

Change-Id: Ia5f134c91beb483fd865df9e4877e0ec3e789478
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6215
Tested-by: jenkins
2 years agotcl: fix some minor typo 14/6214/2
Antonio Borneo [Thu, 28 Jan 2021 11:27:53 +0000 (12:27 +0100)]
tcl: fix some minor typo

Minor typos found by the new checkpatch boosted by the dictionary
provided by 'codespell'.
While there, fix one indentation.

Change-Id: I72369ed26f363bacd760b40b8c83dd95e89d28a4
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6214
Tested-by: jenkins
2 years agotcl/rp2040: remove empty line at end of file 21/6221/2
Antonio Borneo [Sun, 2 May 2021 22:15:20 +0000 (00:15 +0200)]
tcl/rp2040: remove empty line at end of file

Change-Id: I212a96b77282b151a8ecbd46a6436e2bbbda4161
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6221
Tested-by: jenkins
2 years agogithub/action: create a permanent 'latest' release 27/6127/3
Tarek BOCHKATI [Wed, 24 Mar 2021 20:33:36 +0000 (21:33 +0100)]
github/action: create a permanent 'latest' release

this commit extends the existing snapshot action to create a release named
'latest' with the built binaries for windows.

this 'latest' release will be updated after every push to github.

Change-Id: I75a64c598169241743add3ac9aa7a0337fbab7f2
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6127
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoflash/stm32l4x: add missing break statement 48/6248/2
Tarek BOCHKATI [Thu, 13 May 2021 16:44:14 +0000 (17:44 +0100)]
flash/stm32l4x: add missing break statement

this is not a bug fix, this for loop will issue only one match
adding the break will save unnecessary more loops.

Change-Id: Ic1484ea8cdea1b284eb570f9e3e7818e07daf5cd
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6248
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Tested-by: jenkins
2 years agotarget/aarch64: fix watchpoint management 05/6205/3
Antonio Borneo [Wed, 5 May 2021 13:05:21 +0000 (15:05 +0200)]
target/aarch64: fix watchpoint management

The early documentation for armv8a report the debug register WFAR
as containing the address of the instruction that triggered the
watchpoint. More recent documentation report the register EDWAR as
containing the data memory address that triggered the watchpoint.

The name of macros CPUV8_DBG_WFAR0 and CPUV8_DBG_WFAR1 is not
correct as they point to the debug register EDWAR, so reading such
register returns directly the data memory address that triggered
the watchpoint. The code incorrectly passes this address value to
the function armv8_dpm_report_wfar(); this function is supposed to
adjust the PC value, decrementing it to remove the effects of the
CPU pipeline. This pipeline offset, that has no meaning on the
value in EDWAR, caused commit 651b861d5d5f ("target/aarch64: Add
watchpoint support") to add back the offset while comparing the
address with the watchpoint enabled.

The upper 32 bits of EDWAR are not valid in aarch32 mode and have
to be ignored.

Rename CPUV8_DBG_WFAR0/1 as CPUV8_DBG_EDWAR0/1.
Remove the function armv8_dpm_report_wfar().
Remove the offset while searching the matching watchpoint.
Ignore the upper 32 bits of EDWAR in aarch32 mode.
Fix a comment and the LOG text.

Change-Id: I7cbdbeb766fa18e31cc72be098ca2bc501877ed1
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6205
Tested-by: jenkins
Reviewed-by: Liming Sun <limings@nvidia.com>
2 years agotarget/arm_dpm: rename 'wp_pc' as 'wp_addr' 04/6204/3
Antonio Borneo [Wed, 5 May 2021 10:27:11 +0000 (12:27 +0200)]
target/arm_dpm: rename 'wp_pc' as 'wp_addr'

The field 'wp_pc' was originally introduced in commit 55eeea7fceb6
("ARMv7a/Cortex-A8: report watchpoint trigger insn") in end 2009
to contain the address of the instruction which triggered a
watchpoint. Later on with commit 651b861d5d5f ("target/aarch64:
Add watchpoint support") it has been reused in to hold directly
the memory address that triggered a watchpoint.

Rename 'wp_pc' as 'wp_addr' and change its doxygen description.
While there, fix the format string to print the field.

Change-Id: I2e5ced1497e4a6fb6b38f91e881807512e8d8c47
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6204
Tested-by: jenkins
Reviewed-by: Liming Sun <limings@nvidia.com>
2 years agocortex_m: fix VECTRESET detection for ARMv6-M cores 32/6232/4
Tarek BOCHKATI [Tue, 11 May 2021 08:22:01 +0000 (09:22 +0100)]
cortex_m: fix VECTRESET detection for ARMv6-M cores

VECTRESET check should be done after verifying if the core is an ARMv6-M core,
and not before that.

Fixes: 2dc9c1df81b6 ("cortex_m: [FIX] ARMv8-M does not support VECTRESET")
Change-Id: I8306affd332b3a35cea69bba39ef24ca71244273
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6232
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agocortex_m: do not perform soft_reset_halt on targets without VECTRESET 09/6209/4
Tarek BOCHKATI [Fri, 7 May 2021 13:40:14 +0000 (14:40 +0100)]
cortex_m: do not perform soft_reset_halt on targets without VECTRESET

Change-Id: Ib3df457e0afe4e342c82ad1af25e03aad6979d87
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6209
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agocmsis_dap: fix build on macOS 55/6255/2
Antonio Borneo [Sat, 15 May 2021 23:43:44 +0000 (01:43 +0200)]
cmsis_dap: fix build on macOS

Compile fails with error:
src/jtag/drivers/cmsis_dap.c:683:28: error: format specifies type
    'unsigned char' but the argument has type 'int' [-Werror,-Wformat]
                         " received 0x%" PRIx8, CMD_DAP_TFER, resp[0]);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

Fix the format specifier.

Change-Id: I0a5a1a35452d634019989d14d849501fb8a7e93a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6255
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agotarget/armv7m: fix static analyzer warning 56/6256/3
Tomas Vanek [Sun, 16 May 2021 08:05:02 +0000 (10:05 +0200)]
target/armv7m: fix static analyzer warning

Despite of assert(is_packed) clang static analyser complains on use
of the uninitialized offset variable.

Cross compiling with latest x86_64-w64-mingw32-gcc hits warnings
src/target/armv7m.c: In function ‘armv7m_read_core_reg’:
src/target/armv7m.c:337:54: error: ‘reg32_id’ may be used
    uninitialized in this function [-Werror=maybe-uninitialized]

It happens because mingw32 defines assert() without the attribute
"noreturn", whatever NDEBUG is defined or not.

Replace assert(is_packed) by if (is_packed) conditional and call
assert(false) in the else branch.

Change-Id: Id3c7dcccb65106e28be200b9a4d2b642f4d31019
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/6256
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Andrzej Sierżęga <asier70@gmail.com>
2 years agojimtcl: restrict memory leak workaround on Linux only 41/6241/2
Antonio Borneo [Thu, 13 May 2021 14:03:22 +0000 (16:03 +0200)]
jimtcl: restrict memory leak workaround on Linux only

The workaround for jimtcl 0.80 in commit 36ae487ed04b ("jimtcl:
add temporary workaround for memory leak in jimtcl 0.80") issues a
compile time error on macOS:
../src/helper/command.c:157:22: error: aliases are not
supported on darwin
__attribute__((weak, alias("workaround_createcommand")));
The OS is x86_64-apple-darwin19.6.0 and the compiler used is
x86_64-apple-darwin13.4.0-clang.

Restrict the workaround on Linux host only. The fix for 'expr'
syntax change is already merged and the workaround will be dropped
soon.

Change-Id: I925109a9c57c05f8c95b70bc7d6604eb1172cd79
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Adam Jeliński <ajelinski@users.sourceforge.net>
Fixes: 36ae487ed04b ("jimtcl: add temporary workaround for memory leak in jimtcl 0.80")
Fixes: https://sourceforge.net/p/openocd/tickets/304/
Reviewed-on: http://openocd.zylin.com/6241
Tested-by: jenkins
2 years agoserver: gdb_server: Add colon for target extended-remote 37/6237/2
Yasushi SHOJI [Thu, 13 May 2021 12:07:02 +0000 (21:07 +0900)]
server: gdb_server: Add colon for target extended-remote

Both GDB commands "target remote" and "target extended-remote" require
to have ":" right before port number.

e.g.
    (gdb) target extended-remote :3333

Add ":" to the warning message so that users can copy & past it.

Change-Id: Id6d8ec1e4dfd3c12cb7f3b314064f2c35fa7ab55
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
Reviewed-on: http://openocd.zylin.com/6237
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotarget/armv7m.h: [style] replace tab with space between variable type and name 30/6230/2
Tarek BOCHKATI [Mon, 10 May 2021 09:46:20 +0000 (10:46 +0100)]
target/armv7m.h: [style] replace tab with space between variable type and name

Change-Id: I9740c25857295a2a655d3046322a3f23f0ee7f78
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6230
Reviewed-by: Marc Schink <dev@zapb.de>
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agortos: Add support for Zephyr RTOS 88/4988/16
Evgeniy Didin [Tue, 16 Feb 2021 18:53:41 +0000 (21:53 +0300)]
rtos: Add support for Zephyr RTOS

With this patch, the Zephyr[1] RTOS is supported by OpenOCD.

As usual with support for other RTOSes, Zephyr must be compiled with
the DEBUG_THREAD_INFO option. This will generate some symbols
with information needed in order to build the list of threads.

The current implementation is limited to Zephyr running on ARM
Cortex-M processors. This is the only ARM variant supported by Zephyr
at the moment and is used on most of the officially supported boards.

[1] https://www.zephyrproject.org/

Change-Id: I22afdbec91562f3a22cf5b88cd4ea3a7a59ba0b4
Signed-off-by: Evgeniy Didin <didin@synopsys.com>
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
Signed-off-by: Daniel Glöckner <dg@emlix.com>
Reviewed-on: http://openocd.zylin.com/4988
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agocortex_m: add armv8m special registers 16/6016/4
Tarek BOCHKATI [Tue, 12 Jan 2021 19:11:11 +0000 (20:11 +0100)]
cortex_m: add armv8m special registers

Change-Id: I1942f375a5f4282ad1fe4a2ff3b8f3cbc64d8f7f
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6016
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agoflash/nor/xcf: Do not use 'Yoda conditions' 01/6201/2
Marc Schink [Sat, 1 May 2021 14:22:51 +0000 (16:22 +0200)]
flash/nor/xcf: Do not use 'Yoda conditions'

Change-Id: I17308f5237338ce468e5b86289a0634429deaaa9
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6201
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoAdd IPDBG JtagHost functionality to OpenOCD 38/5938/10
Daniel Anselmi [Sun, 11 Oct 2020 13:13:05 +0000 (15:13 +0200)]
Add IPDBG JtagHost functionality to OpenOCD

IPDBG are utilities to debug IP-cores. It uses JTAG for
transport to/from the FPGA. The different UIs use TCP/IP
as transport. The JtagHost makes the bridge between these
two.

Comparable to the bridge between GDB and the in-circuit-
debugging-unit of a micro controller.

Change-Id: Ib1bc10dcbd4ea426e492bb7b2d85c1ed1b7a8d5a
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: http://openocd.zylin.com/5938
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agocoding-style: additional style for C code 03/6203/4
Antonio Borneo [Sun, 2 May 2021 21:03:33 +0000 (23:03 +0200)]
coding-style: additional style for C code

To improve readability and to push more uniform code style.

Prefer 'if (false) {...}' for unused code so it get checked by the
compiler.
Define preferred indentation for 'switch' statement.
Require balanced brackets in 'if/else'.
Report the max line length.
Report the formatting strings for stdint/inttypes types.
Report the type 'target_addr_t'.
Prefer 'unsigned int' to 'unsigned'.

Change-Id: I0192a4ed298f6c6c432764fdd156cffd4b13fc89
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6203
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Marc Schink <dev@zapb.de>
2 years agoEnable adapter "Bus Pirate" by default. 37/5637/4
R. Diez [Mon, 5 Apr 2021 09:13:52 +0000 (11:13 +0200)]
Enable adapter "Bus Pirate" by default.

The Bus Pirate is now listed in the "OpenOCD configuration summary" too.

Change-Id: Ieb7bf9134af456ebe9803f3108a243204fb2a62d
Signed-off-by: R. Diez <rdiezmail-openocd@yahoo.de>
Reviewed-on: http://openocd.zylin.com/5637
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotarget/riscv: Change 'authdata_read' output 99/6199/2
Marc Schink [Fri, 30 Apr 2021 08:51:35 +0000 (10:51 +0200)]
target/riscv: Change 'authdata_read' output

Use a constant output length and remove the line break to make the
authentication data easier to parse.

Change-Id: Iebbf1f171947ef89b0f360a2cb286a4ea15c6ba5
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6199
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tim Newsome <tim@sifive.com>
2 years agotarget/stm8: Make 'stm8_command_handlers' static 00/6200/2
Marc Schink [Fri, 30 Apr 2021 10:01:34 +0000 (12:01 +0200)]
target/stm8: Make 'stm8_command_handlers' static

Change-Id: I5237a8f2a1ecba9383672e37bd56f8ccd17598b6
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6200
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotcl: [3/3] prepare for jimtcl 0.81 'expr' syntax change 61/6161/2
Antonio Borneo [Sat, 10 Apr 2021 16:28:52 +0000 (18:28 +0200)]
tcl: [3/3] prepare for jimtcl 0.81 'expr' syntax change

Jimtcl commit 1843b79a03dd ("expr: TIP 526, only support a single
arg") drops the support for multi-argument syntax for the TCL
command 'expr'.

Fix manually the remaining lines that don't match simple patterns
and would require dedicated boring scripting.
Remove the 'expr' command where appropriate.

Change-Id: Ia75210c8447f88d38515addab4a836af9103096d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6161
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agotcl: [2/3] prepare for jimtcl 0.81 'expr' syntax change 60/6160/2
Antonio Borneo [Sat, 10 Apr 2021 15:37:04 +0000 (17:37 +0200)]
tcl: [2/3] prepare for jimtcl 0.81 'expr' syntax change

Jimtcl commit 1843b79a03dd ("expr: TIP 526, only support a single
arg") drops the support for multi-argument syntax for the TCL
command 'expr'.

Enclose within double quote the argument of 'expr' when there is
the need to concatenate strings.

Change-Id: Ic0ea990ed37337a7e6c3a99670583685b570b8b1
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6160
Tested-by: jenkins
2 years agotcl: [1/3] prepare for jimtcl 0.81 'expr' syntax change 59/6159/2
Antonio Borneo [Fri, 9 Apr 2021 23:23:57 +0000 (01:23 +0200)]
tcl: [1/3] prepare for jimtcl 0.81 'expr' syntax change

Jimtcl commit 1843b79a03dd ("expr: TIP 526, only support a single
arg") drops the support for multi-argument syntax for the TCL
command 'expr'.

In the TCL scripts distributed with OpenOCD there are 1700+ lines
that should be modified before switching to jimtcl 0.81.

Apply the script below on every script in tcl folder. It fixes
more than 92% of the lines

%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---
 #!/usr/bin/perl -Wpi

 my $re_sym = qr{[a-z_][a-z0-9_]*}i;
 my $re_var = qr{(?:\$|\$::)$re_sym};
 my $re_const = qr{0x[0-9a-f]+|[0-9]+|[0-9]*\.[0-9]*}i;
 my $re_item = qr{(?:~\s*)?(?:$re_var|$re_const)};
 my $re_op = qr{<<|>>|[+\-*/&|]};
 my $re_expr = qr{(
     (?:\(\s*(?:$re_item|(?-1))\s*\)|$re_item)
     \s*$re_op\s*
     (?:$re_item|(?-1)|\(\s*(?:$re_item|(?-1))\s*\))
 )}x;

 # [expr [dict get $regsC100 SYM] + HEXNUM]
 s/\[expr (\[dict get $re_var $re_sym\s*\] \+ *$re_const)\]/\[expr \{$1\}\]/;

 # [ expr (EXPR) ]
 # [ expr EXPR ]
 # note: $re_expr captures '$3'
 s/\[(\s*expr\s*)\((\s*$re_expr\s*)\)(\s*)\]/\[$1\{$2\}$4\]/;
 s/\[(\s*expr\s*)($re_expr)(\s*)\]/\[$1\{$2\}$4\]/;
%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---

Change-Id: I0d6bddc6abf6dd29062f2b4e72b5a2b5080293b9
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6159
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agostartup.tcl: prepare for jimtcl 0.81 'expr' syntax change 58/6158/2
Antonio Borneo [Fri, 19 Mar 2021 13:13:07 +0000 (14:13 +0100)]
startup.tcl: prepare for jimtcl 0.81 'expr' syntax change

Jimtcl commit 1843b79a03dd ("expr: TIP 526, only support a single
arg") drops the support for multi-argument syntax for the TCL
command 'expr'.

Modify the script startup.tcl compiled-in OpenOCD binary to comply
with the new jimtcl.

Change-Id: I520dcafacadaa289a815035f93f250447ca66ea0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6158
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agotelnet/auto-complete: hide deprecated and internal commands 95/6195/3
Antonio Borneo [Mon, 26 Apr 2021 12:44:48 +0000 (14:44 +0200)]
telnet/auto-complete: hide deprecated and internal commands

For both:
- TCL proc that redirect deprecated commands to the new commands,
- TCL proc used internally and not supposed to be exposed to user,
add their name to the list of commands that should be hide by the
telnet auto-complete.

Change-Id: I05237c6a79334b7d2b151dfb129fb57b2f40bba6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6195
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agotelnet: allow hiding selected commands during auto-completion 94/6194/3
Antonio Borneo [Mon, 26 Apr 2021 12:22:06 +0000 (14:22 +0200)]
telnet: allow hiding selected commands during auto-completion

We have TCL procedure and commands that we do not want to show in
the list of auto-completion. E.g. TCL wrappers for deprecated
commands, internal procedures that are not supposed to be exposed
to user, or even commands that the user decides to hide.

Create a TCL procedure to be called by telnet auto-complete code
in place of the hard-coded TCL command. The procedure will run the
same command and will filter-out the unwanted command names.

Initialize the list of commands to be filtered-out with the name
of the TCL procedure above, as it is considered as internal.

Change-Id: I2d83bbf8194502368c589c85cccb617e69128c69
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6194
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agocortex_m: use unsigned int for FPB and DWT quantifiers 85/6185/3
Tarek BOCHKATI [Sun, 25 Apr 2021 06:53:26 +0000 (07:53 +0100)]
cortex_m: use unsigned int for FPB and DWT quantifiers

related quantifiers are:
 - fp_num_lit
 - fp_num_code
 - dwt_num_comp
 - dwt_comp_available

Change-Id: I07dec2d4aa21bc0e580be0d9fd0a6809f876c2a8
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6185
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agocortex_m: implement hit_watchpoint function 81/6181/3
Tarek BOCHKATI [Thu, 22 Apr 2021 19:47:23 +0000 (20:47 +0100)]
cortex_m: implement hit_watchpoint function

this change aims to provide a better gdb debugging experience,
by making gdb understand what's really happening.

before this change when hitting a watchpoint
 - openocd reports "T05" to gdb
 - gdb displays: Program received signal SIGTRAP, Trace/breakpoint trap.

after the change
 - openocd reports "T05watch:20000000;" to gdb
 - gdb displays:
   Hardware watchpoint 1: *0x20000000

   Old value = 16000000
   New value = 170000000
   ...

Change-Id: Iac3a85eadd86663617889001dd04513a4211ced9
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6181
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agotcl/board: add pico-debug support 75/6075/9
Peter Lawrence [Tue, 2 Mar 2021 21:21:28 +0000 (15:21 -0600)]
tcl/board: add pico-debug support

pico-debug is not a board; it is a virtual CMSIS-DAP adapter that
runs on the same RP2040 also being debugged.  This is possible due
to pico-debug running on the normally-dormant second Cortex-M0+
core (Core1), providing debugging of the first core (Core0).
As such, it could be used on a variety of RP2040-based boards.

Since a flash driver is useful (if not essential), a flash driver
is included.  This driver code originated on RPi's bespoke OpenOCD
fork; lipstick was added to this particular pig to make it more
presentable on OpenOCD proper.

no new Clang analyzer warnings

Change-Id: I31f98b5ea1664f0adfbc184b57efba963acfb958
Signed-off-by: Peter Lawrence <majbthrd@gmail.com>
Reviewed-on: http://openocd.zylin.com/6075
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agoflash/nor/stm32f1x: Add support for GD32F1x0/3x0 64/6164/4
asier70 [Mon, 12 Apr 2021 12:09:36 +0000 (14:09 +0200)]
flash/nor/stm32f1x: Add support for GD32F1x0/3x0

Nowadays, when it's difficult to buy STM32F030,
the use of GD32F130 seems to be an interesting functional alternative.
This is cortex-M3 and it works with the stm32f1x driver, but unfortunately not fully.
The main difference is another offset of user option bits
(like WDG_SW, nRST_STOP, nRST_STDBY) in option byte register
(FLASH_OBR/FMC_OBSTAT 0x4002201C).
Any use of functions like lock or unlock results in change default values of the those bits stored in flash.
Thus broken microcontroller is malfunctioning, e.g. flash block programming is interrupted
by unexpected active hardware watchog (after 0.4s).
This patch is a simplified version of #4592 done by Dominik Peklo (http://openocd.zylin.com/#/c/4592/).
GigaDevice GD32F1x0 & GD32F3x0 series devices share DEV_ID
with STM32F101/2/3 medium-density line,
however they use a REV_ID different from any STM32 device,
so can be succesfully detected.

Change-Id: I252cdf738d94983b70676a3497326f90c329e292
Signed-off-by: asier70Andrzej Sierżęga <asier70@gmail.com>
Reviewed-on: http://openocd.zylin.com/6164
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agoCleanup of config/includes. 71/6171/10
Tim Newsome [Mon, 19 Apr 2021 20:04:30 +0000 (13:04 -0700)]
Cleanup of config/includes.

Remove a use of AH_BOTTOM from configure.ac. This macro is used by
autoheader to add '#include' of some include file to the end of
config.h.in and then to config.h. OpenOCD can be built with a custom
config.h, so it's preferable to move these '#include' statement directly
in the C files that need them dropping this unneeded dependency.

It also causes problems when I want to use the gnulib library (which
comes with its own Makefile, and does not have the same include path as
the top-level Makefile).

So this change touches a lot of files, but is actually really simple. It
does not affect functionality at all.

Change-Id: I52c70bf15eb2edc1dd10e0fde23b2bcd4caec000
Signed-off-by: Tim Newsome <tim@sifive.com>
Reviewed-on: http://openocd.zylin.com/6171
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodrivers/ftdi: drscan: Skip DR-PAUSE when endstate == IDLE 23/6123/3
Luis de Arquer [Wed, 24 Mar 2021 16:12:14 +0000 (17:12 +0100)]
drivers/ftdi: drscan: Skip DR-PAUSE when endstate == IDLE

Currently, all drscan commands will cycle through DR-PAUSE before reaching
TAP-IDLE. This patch provides a different path on FTDI driver.

This change is required for the ST On Chip Emulator (OnCE), to avoid
re-enabling the OnCE tap after every DRSCAN. This is because the OnCE
TAP (see ST Application Note AN4035) gets disabled if DR-PAUSE is entered
before DR-UPDATE.

With this commit, the current path:

DR-SHIFT -> DR-EXIT1 -> DR-PAUSE -> DR-EXIT2 -> DR-UPDATE -> IDLE

is changed to:

DR-SHIFT -> DR-EXIT1 -> DR-UPDATE -> IDLE

only if IDLE is the endstate (which is the driver default).

Before this patch, once the SHIFT sequence is complete, the driver would
normally move to the nearest stable state, which is DR-PAUSE, by clocking
out a '10' binary sequence. Then it would follow the path provided by
tap_get_tms_path() to reach endstate. It is done this way because
tap_get_tms_path() only supports stable states.

After this patch, the strategy is mostly the same, with the exception that,
if TAP_IDLE is the endstate, a '110' binary sequence is output after completing
the SHIFT sequence. This takes the TAP directly to IDLE, with no further action
required.

A scheme of the DR chain is shown below. A * character is used to mark the
stable states.

 ----------------------------------------------------------------------
 |                                                                    | 0
 v    1         0          0         1        0         1        1    |
IDLE* -> SEL-DR -> CAPTURE -> SHIFT* -> EXIT1 -> PAUSE* -> EXIT2 -> UPDATE
                                          |                           ^
                                        1 |                           |
                                          -----------------------------

Change-Id: Ib413e5c4c0bbf75dae0b4672119bae4ef03d0258
Signed-off-by: Luis de Arquer <luis.dearquer@inertim.com>
Reviewed-on: http://openocd.zylin.com/6123
Tested-by: jenkins
Reviewed-by: Christopher Head <chead@zaber.com>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2 years agotelnet: auto-completion of "registered" commands 95/6095/13
Tarek BOCHKATI [Thu, 11 Mar 2021 02:38:54 +0000 (03:38 +0100)]
telnet: auto-completion of "registered" commands

auto-completion behavior:
- if there is only one matched command complete the user-command
- else if multiple matches add the common part then in second step
  list all matched commands
- sub-commands are handled in the same way
- auto-completion restarts after these characters ';', '[', '{'

Change-Id: I1b81dd19191a5785e68d0bb5cd244e01a4dd0587
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6095
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoudev rules: add OSBDM device 98/6198/5
Jiri Kastner [Fri, 30 Apr 2021 05:43:36 +0000 (07:43 +0200)]
udev rules: add OSBDM device

Change-Id: I7221a6b3fe6fcd4f17ea664c10fd32c645e21d7c
Signed-off-by: Jiri Kastner <cz172638@gmail.com>
Reviewed-on: http://openocd.zylin.com/6198
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agojtag: simplify the calls to Jim_SetResultFormatted() 90/6190/2
Antonio Borneo [Sun, 25 Apr 2021 21:15:36 +0000 (23:15 +0200)]
jtag: simplify the calls to Jim_SetResultFormatted()

The documentation of Jim_SetResultFormatted() reports that the jim
objects passed as arguments would be freed if have zero refcount.

Remove the useless Jim_IncrRefCount()/Jim_DecrRefCount().
Remove the dangerous Jim_FreeNewObj() that should trigger a double
free(). Not tested due to lack of aice adapter.

While there, rename some CamelCase symbol.

Change-Id: Ic56704c83d6391c38f6b0efa6566784d453bc0fb
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6190
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agohelper/command: drop the TCL variable 'ocd_HOSTOS' 89/6189/2
Antonio Borneo [Sun, 25 Apr 2021 18:44:27 +0000 (20:44 +0200)]
helper/command: drop the TCL variable 'ocd_HOSTOS'

Commit 7a731eb63731 ("Added HostOS variable"), merged in 2009,
adds a TCL global variable 'ocd_HostOS' that reports in a string
the OS of the host.
This was proposed as a workaround for jimtcl that didn't define
the standard TCL variable 'tcl_platform(os)'.

With commit 42f3fb7b7f46 ("Determine platform_tcl() settings with
configure"), merged in 2010 and part of jimtcl 0.70 issued in
early 2011, jimtcl provides the requires TCL standard variable
'tcl_platform(os)'.

The variable 'ocd_HostOS' has never been used by any TCL script
distributed with OpenOCD.

Drop the TCL variable 'ocd_HostOS'.

Change-Id: I27858de35cc9d30df97145ca1ccd24877be4af11
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6189
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>

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)