openocd.git
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>
2 years agohelper/command: fix memory leak on malloc() fail 88/6188/2
Antonio Borneo [Sun, 25 Apr 2021 18:38:58 +0000 (20:38 +0200)]
helper/command: fix memory leak on malloc() fail

If malloc() fails, the just allocated Jim_Obj will leaks.

Move Jim_IncrRefCount() before the malloc() and deallocate the Jim
object with Jim_DecrRefCount() on malloc() fail.

While there, add the 'out of memory' log and fix the CamelCase
name of the symbol tclOutput.

Change-Id: Ic733db229d5aa5d477d758ea9cb88cd81d7542cd
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6188
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agohelper/jim-nvp: remove unused function Jim_nvpInit() 87/6187/2
Antonio Borneo [Sun, 25 Apr 2021 18:07:35 +0000 (20:07 +0200)]
helper/jim-nvp: remove unused function Jim_nvpInit()

The files jim-nvp.[ch] were originally inside jimtcl, then in 2011
they were dropped by jimtcl and integrated in OpenOCD.
The initial purpose was to make them as an independent library,
thus the presence of an 'init' function. Being now part of OpenOCD
do not require the 'init' function anymore, that is still empty
and unused, plus its name is in violation of the coding style.

Drop the function Jim_nvpInit().

Change-Id: I429e10444c86a26dbdc22aa071315324dc5edc3e
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6187
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agohelper/types: remove type '_Bool' 86/6186/2
Antonio Borneo [Sun, 25 Apr 2021 13:47:28 +0000 (15:47 +0200)]
helper/types: remove type '_Bool'

Accordingly to OpenOCD coding style, both typedef and Camelcase
symbols are forbidden.
The type '_Bool' is not used in the code, having 'bool' as
preferred choice.

Remove the definition of '_Bool' from 'types.h'.

Change-Id: I8863f9836ccd9166e0c69fa5d75d6fef79ae7bfb
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6186
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agohelper/replacements: remove unused typedef's 78/6178/2
Antonio Borneo [Thu, 22 Apr 2021 10:06:04 +0000 (12:06 +0200)]
helper/replacements: remove unused typedef's

The ELF typedef's 'Elf32_Sword' and 'Elf32_Hashelt' are not used
within OpenOCD. Plus, being their name in CamelCase require extra
effort to include them in the exceptions for checkpatch.

Remove the unused typedef's.

Change-Id: I18f039567edd5b24dbb41df5406c154f31022ae7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6178
Tested-by: jenkins
Reviewed-by: Christian Hoff <christian.hoff@advantest.com>
2 years agotarget/image: report error if ELF file contains no loadable sections 72/6172/2
Christian Hoff [Tue, 20 Apr 2021 17:14:30 +0000 (19:14 +0200)]
target/image: report error if ELF file contains no loadable sections

The existing code asserted in that case, which is not correct. This
would allow the user to crash OpenOCD with a bad ELF file, which is
not what we want. A proper error should be reported in that case and
OpenOCD should not crash.

Change-Id: Ied5a6a6fd4ee0fd163f3fe850d304a121ecbe33a
Signed-off-by: Christian Hoff <christian.hoff@advantest.com>
Reviewed-on: http://openocd.zylin.com/6172
Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li>
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotarget/image: allow loading of 64-bit ELF files 04/5204/10
Florian Meister [Wed, 5 Jun 2019 08:19:52 +0000 (10:19 +0200)]
target/image: allow loading of 64-bit ELF files

Change-Id: I9b88edacf5ffcc3c1caeab8c426693de0d92a695
Signed-off-by: Florian Meister <florian.meister@advantest.com>
Signed-off-by: Christian Hoff <christian.hoff@advantest.com>
Reviewed-on: http://openocd.zylin.com/5204
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Ooi, Cinly <cinly.ooi@intel.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agolibusb: don't use typedef's 65/6165/2
Antonio Borneo [Wed, 14 Apr 2021 21:44:57 +0000 (23:44 +0200)]
libusb: don't use typedef's

Libusb defines both the struct and a typedef to the struct using
the same struct name. It's then possible to use either 'struct x'
and 'x'. E.g.:
typedef struct libusb_device libusb_device;

OpenOCD is not consistent and uses a mix of 'struct x' and 'x'.

To make OpenOCD code uniform, stick at project's coding style and
use 'struct x' in place of the typedef'd name.

Change-Id: I901458b680e42830d3f371e47997157f91b7f675
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6165
Tested-by: jenkins
Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li>
Reviewed-by: Marc Schink <dev@zapb.de>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agohelper/command: fix build with jimtcl 0.79 or older 91/6191/2
Antonio Borneo [Mon, 26 Apr 2021 07:48:25 +0000 (09:48 +0200)]
helper/command: fix build with jimtcl 0.79 or older

Commit a7d68878e4ba ("helper/command: unregister commands through
their full-name") introduces for the first time in OpenOCD the use
of jimtcl API Jim_DeleteCommand().
The prototype of Jim_DeleteCommand() has changed with jimtcl 0.80
and the current code doesn't build with jimtcl 0.79 or older. This
is an issue for those distributions, like Debian, that provide
jimtcl as a separate package/library and have not switched yet to
the new jimtcl version.

Add a compile-time condition to cope with the jimtcl API change.

Change-Id: Ic813ab7c0ebd3c8772f27775ba3912a47d5c275c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: a7d68878e4ba ("helper/command: unregister commands through their full-name")
Reviewed-on: http://openocd.zylin.com/6191
Tested-by: jenkins
2 years agocortex_m: mark FPU register as non-existent instead of playing with num_regs 15/6015/3
Tarek BOCHKATI [Tue, 12 Jan 2021 19:10:23 +0000 (20:10 +0100)]
cortex_m: mark FPU register as non-existent instead of playing with num_regs

Change-Id: Iac7c5bfbb95c8d9a8c6d65104d138692a44eca78
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6015
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agodoc/openocd.texi: fix warning 79/6179/2
Tarek BOCHKATI [Thu, 22 Apr 2021 13:34:14 +0000 (14:34 +0100)]
doc/openocd.texi: fix warning

fix the warning below by adding a '.' after xref in line 10184:
./doc/openocd.texi:10184: warning: `.' or `,' must follow @xref, not c

Change-Id: Ibd976ae61cf6845e925b839321444dcb25a3c04a
Reported-by: Tomas Vanek <vanekt@fbl.cz>
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6179
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agodoc/openocd.texi: fix warning 74/6174/2
Tarek BOCHKATI [Wed, 21 Apr 2021 09:18:04 +0000 (10:18 +0100)]
doc/openocd.texi: fix warning

fix the warning below by adding a '.' after xref in line 4517:
../code/doc/openocd.texi:4517: warning: `.' or `,' must follow @xref, not )

Change-Id: I6e529c7e83c9f912e1dd899abf5f630c90b583d9
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6174
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agotarget/armv7m: change FPv4_SP and FPv5_SP/DP identifiers to uppercase 77/6177/3
Tomas Vanek [Thu, 22 Apr 2021 06:40:02 +0000 (08:40 +0200)]
target/armv7m: change FPv4_SP and FPv5_SP/DP identifiers to uppercase

Change-Id: Ia421a973e5fb4767715c9f95c91745f8ca1de1da
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/6177
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotarget/arm_adi_v5: move DP register definitions to one block 38/6138/2
Tomas Vanek [Tue, 6 Apr 2021 11:46:07 +0000 (13:46 +0200)]
target/arm_adi_v5: move DP register definitions to one block

DP and MEM-AP definitions were mixed.

Change-Id: I2f691b2274c01e9090c1e5160c6903d3207e35c2
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/6138
Tested-by: jenkins
3 years agotarget/adi_v5_swd: remove double space from swd_cmd() parameters 37/6137/2
Tomas Vanek [Mon, 5 Apr 2021 04:32:47 +0000 (06:32 +0200)]
target/adi_v5_swd: remove double space from swd_cmd() parameters

Change-Id: I6b68868947010512c4de76e5d37142f067e27b06
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/6137
Tested-by: jenkins
3 years agodrivers/cmsis-dap: add multidrop capability 17/6117/5
Peter Lawrence [Fri, 19 Mar 2021 15:26:52 +0000 (16:26 +0100)]
drivers/cmsis-dap: add multidrop capability

Uses CMSIS-DAP v 1.2 or higher protocol command DAP_SWD_Sequence
to write to DP TARGETSEL register. This write is not acknowledged
by device so we cannot use standard DAP_Transfer

Change-Id: Ib252d09570bcc2282be5f854e0ab9a0dfda06189
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/6117
Tested-by: jenkins
Reviewed-by: Peter Lawrence <majbthrd@gmail.com>
3 years agotarget/arm_adi_v5: add JTAG_TO_DORMANT sequence 36/6136/2
Tomas Vanek [Mon, 5 Apr 2021 06:44:39 +0000 (08:44 +0200)]
target/arm_adi_v5: add JTAG_TO_DORMANT sequence

Change-Id: Ie9e32e42a84cf88bf779e691a67c114eef1bb457
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/6136
Tested-by: jenkins
3 years agotcl/at91/sam9_smc: fix syntax errors 57/6157/3
Antonio Borneo [Sat, 10 Apr 2021 13:58:22 +0000 (15:58 +0200)]
tcl/at91/sam9_smc: fix syntax errors

This file has been added to OpenOCD 0.5.0 in 2011, before gerrit
gets in use, with commit ba71e8c521a7 ("at91: add chip register
definition and generic init support").
The only procedure in the file has never been referenced in any
other part of OpenOCD. This procedure has syntax errors while uses
its argument 'cs' and several unmatched parenthesis, which clearly
highlights that it has never been used so far.
Gerrit does not report any patch aimed at fixing it.

Even if the file seems unused and could be removed, let's fix it
in the hope it could get used.
While there, remove some useless parenthesis and format it using
the new simplified syntax required by jimtcl 0.81.

Change-Id: Ied26456262e7b99de37667a8ce418f4f12e237bd
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: ba71e8c521a7 ("at91: add chip register definition and generic init support")
Reviewed-on: http://openocd.zylin.com/6157
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agoboard: imx53: fix l2 cache initialization 56/6156/2
Antonio Borneo [Sat, 10 Apr 2021 13:31:39 +0000 (15:31 +0200)]
board: imx53: fix l2 cache initialization

Both http://openocd.zylin.com/542/ and http://openocd.zylin.com/543/
introduce the same typo in the bitfield for initializing the l2
cache of imx53.
One year later, http://openocd.zylin.com/1461/ copy-pastes the same
typo.
The comment above the code show that it's really an error and not
the expected behaviour.

Fix the typo replacing the incorrect comparison '<' with a left
shift.

Change-Id: I43725731a2228e28a676215f76936fa289d9395e
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: e3b327343394 ("cfg: add imx53loco board config")
Fixes: 108a458ab888 ("cfg: add icnova_imx53_sodimm board config")
Fixes: e608ced33001 ("ftdi/board: Add support for DENX M53EVK")
Reviewed-on: http://openocd.zylin.com/6156
Tested-by: jenkins
Reviewed-by: Adrian M Negreanu <adrian.negreanu@nxp.com>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agodoc: command 'ftdi_layout_signal' can run after config 55/6155/3
Antonio Borneo [Wed, 7 Apr 2021 13:25:37 +0000 (15:25 +0200)]
doc: command 'ftdi_layout_signal' can run after config

The mode of command 'ftdi_layout_signal' is set to COMMAND_ANY in
[1] and the command has no constraints that limits its use to the
config phase only.
But [2] documents it as '{Config Command}'.

Update the documentation to report the correct mode '{Command}'.

[1] commit f5e97b5e1b62 ("Add FTDI JTAG driver using MPSSE layer")
[2] commit 76afadeb7b4e ("doc: Add documentation for the ftdi driver")

Change-Id: I6b14aebb98e48f7080c585f3df881714bb188af0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6155
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
3 years agodoc: do not document commands that are already deprecated 54/6154/2
Antonio Borneo [Wed, 7 Apr 2021 13:18:04 +0000 (15:18 +0200)]
doc: do not document commands that are already deprecated

The command 'ftdi_location' is deprecated and a TCL procedure is
in place to direct the user to the replacement command.
There is no need to document the deprecated command.

Remove 'ftdi_location' from the documentation.

Change-Id: Ia431c6b0e7444d3f3288c088429bfb47089ff1b5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6154
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
3 years agodoc: annotate configuration commands 53/6153/2
Antonio Borneo [Wed, 7 Apr 2021 12:42:36 +0000 (14:42 +0200)]
doc: annotate configuration commands

Some command that is only valid during configuration is documented
as generic command.
Annotate them as {Config Command} in the documentation.

Change-Id: Ifdbb6ec89b945e3d7adce94af379d94f511a64b6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6153
Tested-by: jenkins
Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li>
3 years agosmp: move command deprecation to startup.tcl 77/5677/11
Antonio Borneo [Wed, 13 May 2020 15:22:12 +0000 (17:22 +0200)]
smp: move command deprecation to startup.tcl

Commit 246782229f8f ("smp: replace commands smp_on/smp_off with
"smp [on|off]"") deprecates some multi-word comments, when openocd
was unable to properly handle mixes of multi-word commands and tcl
procedures having a common initial word.
This limitation is over, so move in startup.tcl the multi-word
commands deprecation, making it easy to remove them after a grace
period.

Change-Id: Icb550d1fa7559b95692d2a1244880da6c90ec0b2
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5677
Tested-by: jenkins
3 years agoremote_bitbang: Add Windows support 96/6096/7
Yun Liu [Fri, 12 Mar 2021 07:07:13 +0000 (15:07 +0800)]
remote_bitbang: Add Windows support

Windows socket descriptor is not file descriptor, so when
using remote_bitbang on Windows, it fails with "fdopen:
failed to open write stream".

This patch removes the file write stream, replaces it
with socket write calls.

Change-Id: Ifd7c8a4139a5ac51ecd2846835a7a947a90fe16c
Signed-off-by: Yun Liu <liuyun.97@gmail.com>
Reviewed-on: http://openocd.zylin.com/6096
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agotarget/imx8qm: Initial support 42/5042/3
Leonard Crestez [Thu, 4 Apr 2019 12:44:25 +0000 (15:44 +0300)]
target/imx8qm: Initial support

Chip is similar to imx8x series but has different cores at different
addresses.

Support for reduced versions is not yet available.

Tested on imx8qm-mek board

Change-Id: Ia34a80d561ab2849a570d8c375b936a45cbf45ca
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Oliver Graute <oliver.graute@kococonnector.com>
Reviewed-on: http://openocd.zylin.com/5042
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agoflash/nor/nrf5: Fix data types and const correctness 63/6163/4
Marc Schink [Mon, 12 Apr 2021 16:54:16 +0000 (18:54 +0200)]
flash/nor/nrf5: Fix data types and const correctness

Change-Id: I8c5bac7098d92e9b3bd1b045735879cf32ac218d
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6163
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
3 years agoflash/nor/numicro: Use 'bool' data type 62/6162/2
Marc Schink [Sun, 11 Apr 2021 19:36:00 +0000 (21:36 +0200)]
flash/nor/numicro: Use 'bool' data type

Change-Id: Ib4ee64dec9c1253ae45bc58e9f175ab36964180a
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6162
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agodrivers/cmsis-dap: flush read 35/6135/3
Tomas Vanek [Tue, 6 Apr 2021 16:55:22 +0000 (18:55 +0200)]
drivers/cmsis-dap: flush read

Some CMSIS-DAP adapters keep buffered packets over
USB close/open so we need to flush up to 64 old packets
to be sure all buffers are empty.

Flush just after cmsis_dap_open() and in the case of command mismatch.

Change-Id: If21a118639e64d90635b4ecf81013d29a7b9f78d
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/6135
Tested-by: jenkins
Reviewed-by: Adrian M Negreanu <adrian.negreanu@nxp.com>
3 years agodrivers/cmsis-dap: improve error checking 21/6121/3
Tomas Vanek [Sat, 20 Mar 2021 18:04:15 +0000 (19:04 +0100)]
drivers/cmsis-dap: improve error checking

Check returned HID report number (or the first byte of returned
bulk packet) which should be equal to the issued command or 0xff
in case of the command is not implemented.

Fix error return paths in cmsis_dap_init() to clean up the adapter
connection.

Don't fail cmsis_dap_init() when an unimportant function fails
(for the case the adapter doesn't implement some parts of protocol).

Change-Id: Ief8382aabe9915346b2273702fb2ff17bbb5eb1b
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/6121
Tested-by: jenkins
Reviewed-by: Peter Lawrence <majbthrd@gmail.com>
3 years agohelper/command: rename s/command_unknown/jim_command_dispatch/ 91/5791/8
Antonio Borneo [Mon, 3 Aug 2020 21:03:46 +0000 (23:03 +0200)]
helper/command: rename s/command_unknown/jim_command_dispatch/

The function's name was consistent with its purpose to handle
commands that were not at root level, thus not directly 'known'
by jimtcl.

Rename it as jim_command_dispatch() to highlight that now it is
a jim_handler and its purpose is to dispatch the call to the
proper command handler.

Change-Id: I9491a6d6459b8eb37a6c402abcae08388c693764
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5791
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agohelper/command: make script_debug() static 76/5676/9
Antonio Borneo [Wed, 13 May 2020 14:51:00 +0000 (16:51 +0200)]
helper/command: make script_debug() static

Now that all commands are executed through the common handler
command_unknown(), the message about command execution is logged
by command_unknown(). There is no need, for "native" commands
(.jim_handler) at root level to log the message (again) by itself.

Remove calls to script_debug() apart from command_unknown().
Make script_debug() static as only used in command.c.

Change-Id: I9b2728b69e7643d6121c4b35a96bc825bcb5488d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5676
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agohelper/command: get rid of the tree of struct command 75/5675/9
Antonio Borneo [Mon, 25 May 2020 14:09:12 +0000 (16:09 +0200)]
helper/command: get rid of the tree of struct command

There is no need anymore to keep alive the tree of struct command.

Remove it and let jim to free() the command's struct command that
is referenced through command's private data.

Change-Id: I2cd84e0274a969ce200320e3a177ac20c7823da0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5675
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agohelper/command: unregister commands through their full-name 74/5674/9
Antonio Borneo [Wed, 13 May 2020 13:35:19 +0000 (15:35 +0200)]
helper/command: unregister commands through their full-name

While keeping the struct command in place, unregister the jim
commands by scanning the list of jim commands through their
full-name.

Change-Id: I0e903fbc31172858b703d67ccd471809c7949e86
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5674
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agohelper/command: simplify jim_command_mode() 73/5673/9
Antonio Borneo [Sun, 10 May 2020 15:48:25 +0000 (17:48 +0200)]
helper/command: simplify jim_command_mode()

Now that every command has struct command as private data, use jim
to get access to the struct command to read the command mode,
instead of running through the tree of struct command.

Change-Id: Iddacdbac604714f6abe38a050daad245bdcfd20c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5673
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agohelper/command: simplify run_command() 72/5672/9
Antonio Borneo [Wed, 13 May 2020 00:30:11 +0000 (02:30 +0200)]
helper/command: simplify run_command()

Now that the commands are registered using their full-name, the
full-name is in argv[0].

Don't rebuild the full-name but use directly argv[0].

Change-Id: Ic9e469ac39276367b8c47527e70791ff470fefbc
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5672
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agohelper/command: register full-name commands in jim 71/5671/9
Antonio Borneo [Tue, 12 May 2020 23:59:59 +0000 (01:59 +0200)]
helper/command: register full-name commands in jim

While still keeping the tree of struct command, stop registering
commands in jim by the root "word" only.

Register the full-name of the command and pass as private data the
struct command of the command itself.

Still use the tree of struct command to un-register the commands.

Some "native" commands (.jim_handler) share the same handler, then
the handler checks the command name to run the right code.
Now argv[0] returns the full-name of the command, so check the
name by looking in the struct command passed as private data.

Change-Id: I5623c61cceee8a75f5d5a551ef3fbf5a303af6be
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5671
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agohelp: re-implement 'help' independent from tree of struct command 70/5670/7
Antonio Borneo [Sat, 27 Mar 2021 15:12:11 +0000 (16:12 +0100)]
help: re-implement 'help' independent from tree of struct command

The current implementation of "help" related commands is tightly
connected to the tree of struct command.
The TCL commands 'add_usage_text' and 'add_help_text' have to add
fake commands in the tree of struct command to handle the help of
TCL procs.

Move all the help texts in a list accessible from the struct
command_context and register the commands through their full name.
Keep the list sorted alphabetically by the command name, so the
result of commands 'help' and 'usage' will be sorted too.

Remove the associated help and usage during commands un-register,
but call help_del_all_commands() for the text added through TCL
commands 'add_usage_text' and 'add_help_text'.

The resulting help and usage output is not changed by this patch
(tested on all the help and usage strings in current master
branch).

Change-Id: Ifd37bb5bd374cba1a22cd7aac208505b4ae1e6fc
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5670
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agocommand mode: return "any" for tcl proc 69/5669/6
Antonio Borneo [Sat, 9 May 2020 00:00:45 +0000 (02:00 +0200)]
command mode: return "any" for tcl proc

A tcl proc can be executed anytime, in any command mode.

Let the command "command mode" to detect a tcl proc and return the
string "any".

Change-Id: I0559076c3063632ee0ea9a57a25f91060209b77f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5669
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agohelper/command: pass command prefix to command registration 68/5668/3
Antonio Borneo [Sun, 10 May 2020 17:35:56 +0000 (19:35 +0200)]
helper/command: pass command prefix to command registration

Replace the "struct command *parent" parameter with a string that
contains the command prefix.
This abstracts the openocd code from the knowledge of the tree of
struct command.
This also makes unused the function command_find_in_context(), so
remove it.

Change-Id: I598d60719cfdc1811ee6f6edfff8a116f82c7ed6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5668
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agohelper/command: override target only on target prefixed cmds 67/5667/3
Antonio Borneo [Tue, 12 May 2020 09:52:56 +0000 (11:52 +0200)]
helper/command: override target only on target prefixed cmds

In current code the current target is overridden whenever
jim_handler_data is not NULL. This happens not only with target
prefixed commands, but also with cti, dap and swo/tpiu prefixed
commands.
While this is not causing any run-time issue, by now, the
behaviour is tricky and makes the code cryptic.

Add a specific field to struct command for the target override so
the content of jim_handler_data can be restricted to command
specific data only (today only cti, dap and swo/tpiu).

Extend the API register_commands() to specify the presence of
either the command data or the override target.

The new API makes obsolete calling command_set_handler_data() to
set jim_handler_data, so remove it.

Change-Id: Icc323faf754b0546a72208f90abd9e68ff2ef52f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5667
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agohelper/command: get current target from dedicated API 66/5666/3
Antonio Borneo [Tue, 12 May 2020 00:36:56 +0000 (02:36 +0200)]
helper/command: get current target from dedicated API

Now that target override is uniformly implemented for all types of
commands, there is no need for target-prefixed "native" commands
(.jim_handler) to sneakily extract the overridden target from the
struct command.

Modify the commands to use the standard API get_current_target().

Change-Id: I732a09c3261e56524edd5217634fa409eb97a8c6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5666
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agohelper/command: use one single handler for all the commands 65/5665/3
Antonio Borneo [Mon, 11 May 2020 23:59:06 +0000 (01:59 +0200)]
helper/command: use one single handler for all the commands

Today openocd registers the commands to jim with three methods:
1) "native" commands (.jim_handler) at root level are registered
   directly as jim commands;
2) "simple" commands (.handler) at root level are registered
   through the handler script_command();
3) all other commands not at root level are registered through the
   handler command_unknown().

Apart from using different handler, other inconsistencies are
present:
a) command in 1) are not checked for their "mode", so are run with
   no check about current mode (COMMAND_CONFIG or COMMAND_EXEC);
b) target_call_timer_callbacks_now() is called only for "simple"
   commands and not for "native" commands;
c) target override is performed only for "simple" commands and not
   for "native" commands.

Drop script_command() and extend command_unknown() to uniformly
handle all the cases above, fixing all the inconsistencies already
mentioned.
The handler's name command_unknown() is probably not anymore
appropriate, but will be renamed in a separate change.

Note: today all the commands in a) have mode CONFIG_ANY, apart for
"mem2array" and "array2mem" that have mode COMMAND_EXEC. But the
latter commands are registered during target init, so do not exist
during COMMAND_CONFIG and no issue is present.

Change-Id: I67bd6e47eb2c575107251b9192c676c27d4aabae
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5665
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agohelper/command: always pass struct command as jim private data 64/5664/3
Antonio Borneo [Mon, 11 May 2020 22:22:13 +0000 (00:22 +0200)]
helper/command: always pass struct command as jim private data

While registering a new command, jim accepts a pointer to command's
private data that will be accessible during the command execution.

Today openocd is not consistent and passes different private data
depending on the command, and then even overwrites it:
- "simple" commands (.handler) are registered with their own
  struct command pointer as command private data;
- "native" commands (.jim_handler) at root level are registered
  with NULL command private data;
- "native" commands (.jim_handler) not at root level are
  registered with the struct command pointer of their root command
  as command private data but, when executed, the command private
  data is overwritten by the value in field jim_handler_data taken
  from their struct command.

Uniform the usage of command private data by always set it to the
struct command pointer while registering the new commands.
Note: for multi-word commands only the root command is registered,
so command private data will be set to the struct command of the
root command. This will change later in this series when the full-
name of the command will be registered.

Don't overwrite the command private data, but let the commands that
needs jim_handler_data to get it directly through struct command.

For sake of uniformity, let function command_set_handler_data() to
set the field jim_handler_data also for "group" commands, even if
such value will not be used.

Now Jim_CmdPrivData() always returns a struct command pointer, so
wrap it in the inline function jim_to_command() to gain compile
time check on the returned type.
While there, uniform the code to use the macro Jim_CmdPrivData()
to access the command's private data pointer.

Change-Id: Idba16242ba1f6769341b4030a49cdf35a5278695
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5664
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
3 years agoAarch64:Switch to EL1 from EL0 before manipulate MMU 51/6051/5
Cheng-Shiun Tsai [Sat, 6 Feb 2021 23:04:14 +0000 (23:04 +0000)]
Aarch64:Switch to EL1 from EL0 before manipulate MMU

If current core is in EL0, it cannot use 'msr sctlr_el1, x0'

Change-Id: I04e60e39e4c84f9d9de7cc87a8e438f5d2737dc3
Signed-off-by: Cheng-Shiun Tsai <cheng.shiun.tsai@gmail.com>
Reviewed-on: http://openocd.zylin.com/6051
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
3 years agodoc: [3/3] uniform the texinfo syntax for commands definition 52/6152/2
Antonio Borneo [Tue, 6 Apr 2021 21:44:37 +0000 (23:44 +0200)]
doc: [3/3] uniform the texinfo syntax for commands definition

To avoid errors in the documentation, like the one fixed by change
http://openocd.zylin.com/6134/ , use a uniform notation across the
file so simple copy-paste will work.

Enclose every command within curly-brackets '{...}', even single
word commands.
Patch generated through:
sed -i 's/^\(@deffn {[^{]*} \)\([^{][^ ]*\)/\1{\2}/' doc/openocd.texi
sed -i 's/^\(@deffnx {[^{]*} \)\([^{][^ ]*\)/\1{\2}/' doc/openocd.texi

Change-Id: I41a8447d487ec8f6f32c2babcbc73ac21c769344
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6152
Tested-by: jenkins
3 years agodoc: [2/3] uniform the texinfo syntax for commands definition 51/6151/2
Antonio Borneo [Tue, 6 Apr 2021 21:31:32 +0000 (23:31 +0200)]
doc: [2/3] uniform the texinfo syntax for commands definition

To avoid errors in the documentation, like the one fixed by change
http://openocd.zylin.com/6134/ , use a uniform notation across the
file so simple copy-paste will work.

Enclose every Command within curly-brackets '{...}', even single
word commands.
Patch generated through:
sed -i 's/^\(@deffn {Command} \)\([^{][^ ]*\)/\1{\2}/' doc/openocd.texi
sed -i 's/^\(@deffnx {Command} \)\([^{][^ ]*\)/\1{\2}/' doc/openocd.texi

Change-Id: I797e8d9f5ab0aa1936f350b340d3bdd52373f5aa
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6151
Tested-by: jenkins
3 years agodoc: [1/3] uniform the texinfo syntax for commands definition 50/6150/2
Antonio Borneo [Tue, 6 Apr 2021 21:24:49 +0000 (23:24 +0200)]
doc: [1/3] uniform the texinfo syntax for commands definition

To avoid errors in the documentation, like the one fixed by change
http://openocd.zylin.com/6134/ , use a uniform notation across the
file so simple copy-paste will work.

Both 'Command' and '{Command}' are in use, with the following
statistics:
  0 @deffnx {Command}
 45 @deffn {Command}
 31 @deffnx Command
382 @deffn Command

While 'Command' is the most popular, prefer the version within
curly-brackets that has to be used for multi-word definition like
'{NAND Driver}', '{Config Command}', '{FPGA Driver}', ...

Patch generated through:
sed -i 's/^\(@deffn \)\(Command\)/\1{\2}/' doc/openocd.texi
sed -i 's/^\(@deffnx \)\(Command\)/\1{\2}/' doc/openocd.texi

Change-Id: If692bbf7e546c5287f466a6aa6940d42b3d4655d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6150
Reviewed-by: Yasushi SHOJI <yashi@spacecubics.com>
Tested-by: jenkins
3 years agodoc: Group adapter sub-commands 34/6134/2
Yasushi SHOJI [Tue, 6 Apr 2021 09:51:57 +0000 (18:51 +0900)]
doc: Group adapter sub-commands

The commit 5280eb618a8cab46 fixed all `adapter_khz` and
`adapter_nsrst_*` commands in the doc but missed grouping them.  This
let the commands `adapter speed`, `adapter srst pulse_width`, and
`adapter srst delay` not indexed.

Tell texinfo about adapter sub-commands by grouping them in one.

Change-Id: Ida53c4f5cfe28827320c145c8d501d53e831623c
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
Reviewed-on: http://openocd.zylin.com/6134
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agomem_ap: allow GDB connections 34/6034/7
Antonio Borneo [Sun, 20 Dec 2020 20:13:58 +0000 (21:13 +0100)]
mem_ap: allow GDB connections

The target mem_ap is a convenient way to access buses, memory and
peripherals behind an ARM AP.
The current implementation provides only access through OpenOCD
commands, because GDB remote protocol has to interact with a CPU
and has to operate on CPU states and registers.
Using GDB to access the memory is welcome, because GDB can resolve
the symbol's address from an ELF file and can nicely display the
content of complex struct and data types.

Extend mem_ap target with the bare minimal support for a remote
GDB connection, by emulating a fake basic ARM core. It means that
only a GDB that has support for ARM can be used (either 'aarch64',
'arm' or 'multiarch' GDB). This is not seen as a big limitation,
because the mem_ap target is mainly used on ARM based devices.

Add a minimalist register description for the fake CPU.
Fill the field 'debug_reason' as expected by GDB server.
Call the target halted event to reply to GDB halt requests.

For backward compatibility, don't open the GDB port by default. If
needed, it has to be specified at 'target create' or 'configure'
with the flag '-gdb-port'.

Change-Id: I5a1b7adb749746516f5d4ffc6193c47b70132364
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6034
Tested-by: jenkins
3 years agotarget/aarch64: Add watchpoint support 61/4761/8
Liming Sun [Fri, 9 Nov 2018 21:17:25 +0000 (16:17 -0500)]
target/aarch64: Add watchpoint support

There are some breakpoint/watchpoint related code in armv8_dpm.c,
but seems not working for aarch64. Target aarch64 has its own
breakpoint implementation in aarch64.c. This commit follows the
same logic to add watchpoint support for target aarch64.

This commit also increases the size of stop_reason[] in function
gdb_signal_reply() since the old size is too small to fit in a
64-bit address, such as ffff8000115e6980.

Change-Id: I907dc0e648130e36b434220f570c37d0e8eb5ce1
Signed-off-by: Liming Sun <lsun@mellanox.com>
Signed-off-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Reviewed-on: http://openocd.zylin.com/4761
Tested-by: jenkins
Reviewed-by: Liming Sun <limings@nvidia.com>
Reviewed-by: Kevin Burke <kevinb@os.amperecomputing.com>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agodoc/manual/style: Fix comments 33/6133/2
Marc Schink [Mon, 5 Apr 2021 13:40:35 +0000 (15:40 +0200)]
doc/manual/style: Fix comments

The comments currently used are not rendered.

Change-Id: I3fcfb6aee4dea9c4f9186a7aec70d382a1abd634
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6133
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
3 years agodoc/manual/style: Do not use 'Yoda conditions' 32/6132/2
Marc Schink [Fri, 2 Apr 2021 09:17:00 +0000 (11:17 +0200)]
doc/manual/style: Do not use 'Yoda conditions'

For more details, see:
https://en.wikipedia.org/wiki/Yoda_conditions
https://sektorvanskijlen.wordpress.com/2019/05/16/conditional-inversion-very-harmful-myth/

Change-Id: If1a8a5f1d0fd345b7cc0c7b5dee6d0d47f9d7fc2
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6132
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
3 years agoLICENSES: add 'license-rules.txt' 73/5973/4
Antonio Borneo [Sat, 12 Dec 2020 10:50:56 +0000 (11:50 +0100)]
LICENSES: add 'license-rules.txt'

Add a file to the LICENSES directory to describe how file licenses
should be described in all the OpenOCD files, using the SPDX
identifier, as well as where all licenses should be in the source
tree for people to refer to (LICENSES/).

This file is mainly copied from the Linux kernel file in
Documentation/process/license-rules.rst
originally written by Thomas Gleixner <tglx@linutronix.de>, with
specific adaptations for OpenOCD.

Change-Id: I7a98fc756df90dc86dbc6e0c47c009a610a0318d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5973
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>

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)