gdb_server: fix GDB_BUFFER_SIZE usage, fix unaligned access during bulk transfers
Currently size of the GDB buffer is 16384 bytes but it is treated as
nul-terminated string in most of the code, so effective size of the
buffer is actually 16383 bytes. OpenOCD responds with `PacketSize=3fff`
to qSupported request. Result of GDB's `m` command is encoded in hex so
each data byte uses two bytes in the buffer. As a result GDB will split
bulk read requests into chunks 0x1fff bytes each. This causes troubles
on targets (or memory regions) which support only aligned, word-sized
access (such as MMIO buffers).
OpenOCD:
Error: Failed to read memory at 0x40321ffe
Error: Failed to read memory at 0x40321000
Error: Failed to read memory at 0x40323000
Error: Failed to read memory at 0x40325ffe
Error: Failed to read memory at 0x40329ffa
Error: Failed to read memory at 0x40329ffc
Error: Failed to read memory at 0x4032bffc
Error: Failed to read memory at 0x4032dffa
Consolidate GDB_BUFFER_SIZE usage: ensure size of each buffer is
(GDB_BUFFER_SIZE + 1), add explicit comment that additional byte is used
for nul-termination. Report correct size of the buffer to GDB (0x4000)
as recommended in GDB's docummentation: `if the stub stores packets in a
NUL-terminated format, it should allow an extra byte in its buffer for
the NUL`
Checked with clang-asan, clang-analyzer, valgrind - no new errors.
Antonio Borneo [Sun, 7 Apr 2019 10:18:05 +0000 (12:18 +0200)]
helper/command: remove dead code in command_unknown()
Commit 89fa493a3bc34d22eeca06fa4e78523ac3b766a8 removes the top
level command "unknown" and adds in command_unknown() some unclear
code that should detect a user-implemented "unknown" command.
But, all the commands that trigger the execution of the function
command_unknown() are registered in register_command_handler() and
have the command name prefixed with "ocd_".
Due to such "ocd_" prefix in cmd_name, the condition
if (strcmp(cmd_name, "unknown") == 0) { ... }
is always false.
Nobody complained for almost 10 years so we can proceed to remove
this dead code, before merging any change that obsoletes the
prefix "ocd_" and potentially makes the condition true.
Remove the dead code guarded by the condition above.
Change-Id: Icf11a956bb2d68fc84e6eb5779edf8e35db8fa53 Fixes: 89fa493a3bc3 ("remove unknown handler") Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5096 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Steven Stallion [Tue, 21 May 2019 18:29:27 +0000 (11:29 -0700)]
doc/openocd.texi: fix bad aarch64 merge
The documentation added for commit b3d29cb5441ee5d38e8f7b561a58f03eb269dbe4
was merged after the end of the eSi-RISC section rather than AARCH64.
This patch relocates this hunk to the correct location.
Antonio Borneo [Wed, 15 May 2019 14:27:26 +0000 (16:27 +0200)]
helper/command: print the command output in case of error
In case of error, a command should use command_print() to report
the error message, so it get printed only on the session that run
the command itself, and the message can be intercepted with the
tcl command catch if it has to be handled differently.
Current code drops the command output when the command returns
error, claiming that it's the command that *should* have printed
it already. This is true only if we *abuse* of the LOG functions,
but accepting the side issue of having the LOG printed in every
session and being unable to catch{} the error message.
Since we have switched to command_print(), change the code to
propagate the command output also in case of error.
Change-Id: I95de424a65e63702bdb3b2277749a0ac6aaaa503 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5178 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Jan Matyas [Wed, 15 May 2019 05:38:51 +0000 (07:38 +0200)]
jtag/drivers/imx_gpio: fixed calls to command_print
Two calls to command_print() in imx_gpio fixed - the first parameter
adjusted (CMD_CTX -> CMD) per the changes from this commit: 6cb5ba6f1136df2986850f5c176cb38e34ca1795
Change-Id: I6cb0909439a632d3109edfc68070b9b561f86d49 Signed-off-by: Jan Matyas <matyas@codasip.com>
Reviewed-on: http://openocd.zylin.com/5176 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
Antonio Borneo [Tue, 14 May 2019 21:38:29 +0000 (23:38 +0200)]
drivers/bcm2835gpio: fix build for ARM host
The commit 84ca4995adfa ("drivers/bcm2835gpio: fix usage messages")
has been merged before commit 6cb5ba6f1136 ("helper/command: change
prototype of command_print/command_print_sameline") introducing two
new call to command_print() that were not modified by the second
commit.
This triggers a compile error on ARM host.
Fix the incorrect function call.
Change-Id: I2736bae24141685b7590fd6b4aa5e6a29b2cab29 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5174 Tested-by: jenkins
Jan Matyas [Mon, 6 May 2019 05:20:33 +0000 (07:20 +0200)]
jtag_vpi: fixed state transitions in "stableclocks"
In jtag_vpi_stableclocks() the TMS line needs to be set properly
based on the current JTAG TAP state (TMS=1 in TAP_RESET state vs.
TMS=0 in other cases).
Change-Id: Id49622ba83015f97b61b6a896edde4448f1fbdc6 Signed-off-by: Jan Matyas <matyas@codasip.com>
Reviewed-on: http://openocd.zylin.com/5151 Tested-by: jenkins Reviewed-by: Franck Jullien <franck.jullien@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Antonio Borneo [Sun, 12 May 2019 12:09:51 +0000 (14:09 +0200)]
helper/command: fix printing usage for incomplete commands
The commit "helper/command: do not replace new commands with
ocd_ prefix" breaks the print of usage text when a multi-word
command is typed incompletely.
Fix it by explicitly running the "usage" command.
Change-Id: I46f8e521d9b6ac617bff8938cf8fc96f0ade45c8 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5166 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Antonio Borneo [Sun, 7 Apr 2019 03:12:31 +0000 (05:12 +0200)]
helper/command: send command output only to the right server
When opening multiple telnet connections, the command output on
one console is broadcast to all the other console.
Send the command output only to the output handler that has been
set for that context.
For the moment, still broadcast the errors.
Note that contexts which doesn't explicitly set the output handler
(e.g. gdb_server), will inherit the global output handler
configuration_output_handler() that will broadcast the output.
Change-Id: I1f2d6e6a3bbf730f5fa77246730fce1445742a1e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5093 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Paul Fertser [Thu, 4 Apr 2019 07:40:27 +0000 (09:40 +0200)]
helper/command: do not replace new commands with ocd_ prefix
The TCL return values are now consistent, no need anymore for the
hack of registering the commands with "ocd_" prefix and override
them with proc ocd_bouncer.
Clean-up the command registration and remove the proc ocd_bouncer.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: I2a467e73ecb068686ea3fda91bf961aba6db6427 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5086 Tested-by: jenkins
1. There's logging output and there're return values;
2. If a function should return something, it should do it explicitly,
same for logging;
3. Interactive interfaces (telnet, Gdb and Tcl RPC) must always return
the result of the evaluation for the given expression. You can
suppress this output by adding ``; after 0'' to the end of your
expression.
4. Some commands "throw an exception" and if you want to be able to
collect both the return value (when it succeeds) and the log output
(when something goes wrong) you can use do like this:
set log_output [capture "catch {reset_config} return_value"]
So what I'm proposing is following:
1. Every jim_handler command should set the return value the standard
JimTcl way, without any tricks. If it needs to print some logging
output, it should use LOG_* functions.
2. The usual commands (COMMANDS) can easily construct their return
value by appending strings with command_print() and
command_print_sameline(). This required changing "struct
command_invocation" and passing a pointer to it to command_print*
functions.
The code is already functional, please test and comment.
TODO items:
1. Modify all jim_handler commands to properly return or log values
(some of them are commented out for now in this patch).
2. Properly document "capture" command and provide a convenience
function to automate log_output + return_value gathering.
3. Add appropriate Doxygen comments.
4. Add Tcl RPC interface description to the manual, all the example
clients in different languages (from the mailing list) to contrib/.
This change is the core part of http://openocd.zylin.com/1815 from
Paul Fertser. It has been extracted and rebased to simplify the
review and provided again as 1815.
Change-Id: I675c91aa9da1e4e7c6f0a8fe6112a00550b9e4db Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/1815 Tested-by: jenkins
Antonio Borneo [Wed, 3 Apr 2019 08:37:24 +0000 (10:37 +0200)]
helper/command: change prototype of command_print/command_print_sameline
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should switch to CMD as
first parameter.
Change prototype of command_print() and command_print_sameline()
to pass CMD instead of CMD_CTX.
Since the first parameter is currently not used, the change can be
done though scripts without manual coding.
This patch is created using the command:
sed -i PATTERN $(find src/ doc/ -type f)
with all the following patters:
's/\(command_print(cmd\)->ctx,/\1,/'
's/\(command_print(CMD\)_CTX,/\1,/'
's/\(command_print(struct command_\)context \*context,/\1invocation *cmd,/'
's/\(command_print_sameline(cmd\)->ctx,/\1,/'
's/\(command_print_sameline(CMD\)_CTX,/\1,/'
's/\(command_print_sameline(struct command_\)context \*context,/\1invocation *cmd,/'
This change is inspired by http://openocd.zylin.com/1815 from Paul
Fertser but is now done through scripting.
Change-Id: I3386d8f96cdc477e7a2308dd18269de3bed04385 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/5081 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Paul Fertser [Mon, 1 Apr 2019 03:54:15 +0000 (05:54 +0200)]
jlink: change prototype of show_config*() functions
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of show_config*() functions to pass CMD instead
of CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: I131a904774bf60ad1bf9d90dbc65927c246ac23a Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5080 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 03:42:24 +0000 (05:42 +0200)]
target/esirisc_trace: change prototype of trace dump functions
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of esirisc_trace_dump*() functions to pass CMD
instead of CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: Ia43bff112372cbb76e1aea9f59f4a9b6df05c15d Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5079 Tested-by: jenkins Reviewed-by: Steven Stallion <sstallion@gmail.com>
Paul Fertser [Mon, 1 Apr 2019 03:37:24 +0000 (05:37 +0200)]
target/esirisc_trace: change prototype of trace analyse functions
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of esirisc_trace_analyze*() functions to pass CMD
instead of CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: Ie7cfd323fe591a987ea648a20be2bb9c7273dde8 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5078 Tested-by: jenkins Reviewed-by: Steven Stallion <sstallion@gmail.com>
Paul Fertser [Mon, 1 Apr 2019 03:22:35 +0000 (05:22 +0200)]
target: change prototype of binprint()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of binprint() to pass CMD instead of CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: I5ebdc50417d97c791c98ac0cfe2218319809eb7f Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5077 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 03:19:21 +0000 (05:19 +0200)]
target: change prototype of handle_bp_command_set()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of handle_bp_command_set() to pass CMD instead of
CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: If00f9cfb784b53bb3df92d4469178e2f930a146a Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5076 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 03:17:07 +0000 (05:17 +0200)]
target: change prototype of handle_bp_command_list()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of handle_bp_command_list() to pass CMD instead
of CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: Ibff636d476bcd59784ce3da5409d930225cfe637 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5075 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 03:14:26 +0000 (05:14 +0200)]
target: change prototype of handle_md_output()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of handle_md_output() to pass CMD instead of
CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: I2150201fad3fd3bc0be89249dcbd314b38a6f860 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5074 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 03:10:56 +0000 (05:10 +0200)]
target/arm_adi_v5: change prototype of dap_rom_display()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of dap_rom_display() and dap_info_command() to
pass CMD instead of CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: Idb97b20759c03fcecbac1184c354966f469caa5f Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5073 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 03:03:21 +0000 (05:03 +0200)]
target/etm: change prototype of etmv1_analyze_trace()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of etmv1_analyze_trace() to pass CMD instead of
CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: Ic923af5480a54c7272d2ff1abbe235ba941cf1a0 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5072 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 02:53:19 +0000 (04:53 +0200)]
target/x86_32_common: change prototype of handle_iod_output()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of handle_iod_output() to pass CMD instead of
CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: I67f594c80d6bbbbf6c9567069a545f16877b1e94 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5071 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 02:27:58 +0000 (04:27 +0200)]
target/armv7a_cache_l2x: change prototype of arm7a_handle_l2x_cache_info_command()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of arm7a_handle_l2x_cache_info_command() to pass
CMD instead of CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: Ib926cd7380ac8b6fb89f64e0a85d81d124633315 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5070 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 02:50:47 +0000 (04:50 +0200)]
target/armv7a: change prototype of armv7a_handle_cache_info_command()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of armv7a_handle_cache_info_command() to pass CMD
instead of CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: I27f507869cb41c74722a759e69dfd45658fcd4be Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5069 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 02:42:23 +0000 (04:42 +0200)]
target/armv4_5_cache: change prototype of armv4_5_handle_cache_info_command()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of armv4_5_handle_cache_info_command() to pass
CMD instead of CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: Ib6ab3ec2fc6504c2a0635b654697a4b6e12a3750 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5068 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 02:24:33 +0000 (04:24 +0200)]
target/dsp563xx: change prototype of handle_md_output()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of handle_md_output() to pass CMD instead of
CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: Ib0b84c933689ac8c940c9bbe62d9c95fd015c4f5 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5067 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 02:16:34 +0000 (04:16 +0200)]
target/armv8: change prototype of display_cache_info()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of display_cache_info(),
armv8_handle_inner_cache_info_command() and
armv8_handle_cache_info_command() to pass CMD instead of CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: I13519c79af82cdba57d5205ba84a5a27fce65a36 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5066 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 02:06:58 +0000 (04:06 +0200)]
target/xscale: change prototype of xscale_display_instruction()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of xscale_display_instruction() and of
xscale_analyze_trace() to pass CMD instead of CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: I8420f19c1b2ff0d2a2f2a8d3627767f7acda437c Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5065 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 01:56:26 +0000 (03:56 +0200)]
target/xscale: change prototype of xscale_verify_pointer()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of xscale_verify_pointer() to pass CMD instead of
CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: Id047fab41ec4f673a46756b0ab901e659e088544 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5064 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 02:58:56 +0000 (04:58 +0200)]
target/mips_m4k: change prototype of mips_m4k_verify_pointer()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of mips_m4k_verify_pointer() to pass CMD instead
of CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: I9fa3e883d2ca9cc858caaefd33586f78638702f5 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5063 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 02:57:01 +0000 (04:57 +0200)]
target/mips32: change prototype of mips32_verify_pointer()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of mips32_verify_pointer() to pass CMD instead of
CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: Ic4a4de10518ee009d6df420e7278fd028e1f22ca Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5062 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 02:55:27 +0000 (04:55 +0200)]
target/cortex_m: change prototype of cortex_m_verify_pointer()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of cortex_m_verify_pointer() to pass CMD instead
of CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: Icf6d1e5f8b4a3ce115c4253e49769df19a5211ae Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5061 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 02:46:29 +0000 (04:46 +0200)]
target/arm946e: change prototype of arm946e_verify_pointer()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of arm946e_verify_pointer() to pass CMD instead
of CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: Ib7119e2b009d05eec47b50c3b9d32feaebc97538 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5060 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 02:44:43 +0000 (04:44 +0200)]
target/arm720t: change prototype of arm720t_verify_pointer()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of arm720t_verify_pointer() to pass CMD instead
of CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: I7fa0628fabacd9ceb62ce921192f88edca659c15 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5059 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 02:37:05 +0000 (04:37 +0200)]
target/arm966e: change prototype of arm966e_verify_pointer()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of arm966e_verify_pointer() to pass CMD instead
of CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: I92745591256ad56a588b6386842028e0b18dec96 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5058 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 02:35:04 +0000 (04:35 +0200)]
target/arm926ejs: change prototype of arm926ejs_verify_pointer()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of arm926ejs_verify_pointer() to pass CMD instead
of CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: Ibbb03429a7fe8b9979f9bb9e513f9eb86aee3b5b Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5057 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 02:32:12 +0000 (04:32 +0200)]
target/arm920t: change prototype of arm920t_verify_pointer()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of arm920t_verify_pointer() to pass CMD instead
of CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: I9a603d7c032df91b3913aadb242de89dbed0358e Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5056 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 01:50:38 +0000 (03:50 +0200)]
nor/at91sam4: change prototype of get_current_sam4()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of get_current_sam4() to pass CMD instead of
CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: I8dfa66f3f6be318d6ba89649279b1b4502f375d9 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5055 Tested-by: jenkins
Paul Fertser [Mon, 1 Apr 2019 01:45:54 +0000 (03:45 +0200)]
nor/at91sam3: change prototype of get_current_sam3()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of get_current_sam3() to pass CMD instead of
CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: Ia1e7af79d0fc89d229b4e10df37317a374bbab62 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5054 Tested-by: jenkins
Paul Fertser [Sun, 31 Mar 2019 16:34:25 +0000 (18:34 +0200)]
nand/tcl: pass CMD to nand_list_walker()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Pass CMD instead of CMD_CTX as parameter to nand_list_walker().
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: Ia11887dfc6dc58d5458a88ba84780cd895b8c253 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5053 Tested-by: jenkins
Paul Fertser [Sun, 31 Mar 2019 16:18:01 +0000 (18:18 +0200)]
nand/fileio: change prototype of nand_fileio_start()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of nand_fileio_start() to pass CMD instead of
CMD_CTX.
This change was part of http://openocd.zylin.com/1815 from Paul
Fertser and has been extracted and rebased to simplify the review.
Change-Id: I7993f6aba997a2d2917949563651c8d0c213730d Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5052 Tested-by: jenkins
Antonio Borneo [Wed, 3 Apr 2019 08:14:29 +0000 (10:14 +0200)]
target_request: replace command_print() with command_output_text()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
When dumping traces or semihosting text, the command that enabled
it is already completed, so CMD is not a valid value.
Plus, we want the dump to be printed in the command context where
the enable command was executed.
Replace command_print() with command_output_text().
Change-Id: I297a2b799a914233499641062407cf6e8b9fe012 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5051 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Antonio Borneo [Tue, 2 Apr 2019 14:25:52 +0000 (16:25 +0200)]
target: unify memory read/write commands
Current code provides two independent implementations for the
memory read/write commands:
a) jim_target_md()/jim_target_mw() for the target specific
commands "<target> m[dw][bhw]"
b) handle_md_command()/handle_mw_command() for the current target
commands "m[dw][bhwd]"
The case a) misses the handling of doubleword and calls functions
command_print_sameline() with first parameter NULL because defined
as jim handler.
Remove the code in jim_target_md()/jim_target_mw() and use the
same code in b) for the target specific memory read/write.
This approach also provides support for 64-bit data size, not
present in the implementation in a).
The only drawback is that the implementation of memory read in b)
prints the data also as human readable ASCII characters, feature
missing in the implementation in a). This could introduced later
if it's really needed.
Update the documentation to:
- add 64-bit support
- add phys parameter
- add the count parameter
Add attribute "unused" to target_buffer_get_u8(), now not used
anymore.
Change-Id: Ib11ff924c409ad87e77fe708d628b2cc82b74d6a Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5050 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Antonio Borneo [Mon, 1 Apr 2019 08:34:25 +0000 (10:34 +0200)]
target: use LOG_USER to print errors in events
Events are supposed to be executed asynchronously and not linked
with any command, so it's incorrect printing out an eventual error
using command_print().
Even in the case of events triggered by the command
<target> invoke-event <event-name>
the eventual error in the event handler is not propagated to the
command, so the command_print() is still not appropriate.
Replace command_print() with LOG_USER() in target_handle_event().
Add further info in the log to identify which event has generated
the error and its associated target.
Before return, clean-up the error message and the stacktrace from
the error already displayed, to avoid propagate them.
Change-Id: I5966aa25e7c81348f4ad4d6e7ce5d4dee44ea4c8 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5049 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Antonio Borneo [Mon, 1 Apr 2019 06:44:26 +0000 (08:44 +0200)]
target: change prototype of target_process_reset()
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should be ready to switch
to CMD as first parameter.
Change prototype of target_process_reset() to pass CMD instead of
CMD_CTX.
Replace NULL parameter of command_print().
Remove extra newline, already added by command_print().
Change-Id: Ieb820c2586e1ff74a0c2b63a9c8693ca7710dfb7 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5048 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Antonio Borneo [Sun, 31 Mar 2019 15:55:43 +0000 (17:55 +0200)]
helper/command: add macro CMD
Accessing the variable "cmd" in a COMMAND_HANDLER is confusing
because the variable definition is not visible in the prototype,
thus "cmd" can be identified by the reader as a global variable
defined somewhere else.
Add the new macro CMD to make more evident it is a part of the
COMMAND_HANDLER.
Change-Id: I8f63da593a931045cc404323f143b88c5c80ab5e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5047 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tomas Vanek [Wed, 13 Mar 2019 20:31:57 +0000 (21:31 +0100)]
target: rewrite jim_target_event_list to handle_target_event_list
jim_target_event_list handler used command_print() in jim handler.
Rewriting the jim handler to the OpenOCD command is easy
as get_current_target() returns proper target for prefixed commands since bb9d9c60264a905926e0d15f84842858d0de80b7
Change-Id: I3e937249386ca5dbd7a5dd6ebb0ccde0911325d8 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4993 Tested-by: jenkins
Christopher Head [Thu, 25 Apr 2019 00:26:40 +0000 (17:26 -0700)]
stm32h7x: fix incorrect indentation
Change-Id: I5dc16031c38576d853774b6123c93be1e1b4aa96 Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/5133 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tarek BOCHKATI [Thu, 7 Feb 2019 17:30:10 +0000 (18:30 +0100)]
flash/nor/stm32h7x: use of wait queue flag instead of the busy flag
Based on RM0433.rev5 > Section 3.3.9 : Flash program operations:
QW1/2: this bit indicates that a write, erase or option byte change
operation is pending in the write queue or command queue buffer.
It remains high until the write operation is complete.
It supersedes the BSY1/2 status bit.
On this basis, stm32x_wait_status_busy is renamed accordingly to be
'stm32x_wait_flash_op_queue'
Note : In this commit there is a fix of SR_ERROR_MASK value in flash loader algo
Note : This modification is mandatory for revision X, and backward compatible
with old revisions
Change-Id: I59d2973317d76b01fbb0fb5e4a472a47d0a7a5b5 Signed-off-by: Laurent LEMELE <laurent.lemele@st.com> Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/4883 Tested-by: jenkins Reviewed-by: Christopher Head <chead@zaber.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Leonard Crestez [Wed, 3 Apr 2019 16:07:56 +0000 (19:07 +0300)]
target/imx8m: Cleanup defaults
* Add mem_ap for direct access to axi bus (without halting cpu)
* Mark m4 core with -defer-examine because it's not used by default
* Make a53.0 default target since it's the boot core
Antonio Borneo [Sat, 6 Apr 2019 07:40:18 +0000 (09:40 +0200)]
doc/openocd.texi: fix cross referencing
Commit b04c7c2ca587feebd6506716cd84297212350608 adds the cross
reference target "adapter_usb_location", but references it with
the command @xref inside a text, where command @ref should be
used. This triggers a compile warning:
doc/openocd.texi:2517: warning: `.' or `,' must follow @xref, not c
Replace @xref with @ref and adapt both the text and the command
syntax.
Change-Id: I1520ffecb7d1d375f924492b1884d5b47f399007 Fixes: b04c7c2ca587 ("ftdi: use "adapter usb location" instead of
ftdi_location command") Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5045 Tested-by: jenkins Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Alexander Kurz [Tue, 24 Jan 2017 12:34:38 +0000 (13:34 +0100)]
tcl/board: Add config for the Amazon Kindle 2 and DX
Add a config to access the Amazon Kindle Model No. D00701 and D00801.
Both ebook readers are based on a Freescale i.MX31. A JTAG interface is
included in a 40 pin FFC connector marked "J9" on both variants.
Change-Id: I58bb1ded3d6706bc3798af488ca8bafb7dc45225 Signed-off-by: Alexander Kurz <akurz@blala.de>
Reviewed-on: http://openocd.zylin.com/3956 Tested-by: jenkins Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Antonio Borneo [Mon, 15 Apr 2019 20:32:32 +0000 (22:32 +0200)]
target/cortex_a: check dscr before timeout
In function cortex_a_wait_dscr_bits() the last read on dscr gets
ignored in case of timeout, even if it finally provides the value
that would trigger a successful return.
Check the returned value before testing the timeout.
Also, print a message on failure reading dscr.
Antonio Borneo [Mon, 15 Apr 2019 21:47:50 +0000 (23:47 +0200)]
target/cortex_a: fix waiting for target halted after step
Depending on adapter speed, the function cortex_a_poll() can take
time to execute and can complete successfully when the timeout is
already expired. Checking the timeout at function return causes a
timeout error while that could be avoided.
Check the target status at cortex_a_poll() return, before checking
for the timeout.
`maskisr steponly` disables interrupts during single-stepping but
enables them during normal execution. This can be used as a partial
workaround for 702596 erratum in Cortex-M7 r0p1. See "Cortex-M7 (AT610)
and Cortex-M7 with FPU (AT611) Software Developer Errata Notice" from
ARM for further details.
Change-Id: I797a14e4d43f6dcb3706528ee4ab452846ebf133 Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/4673 Tested-by: jenkins Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
Mete Balci [Sat, 30 Mar 2019 11:51:03 +0000 (12:51 +0100)]
fix for sanitizer errors in left shifts
The modified lines cause "runtime error: left shift of <X> by <Y>
places cannot be represented in type 'int'", because integer
literal is cast to int by default.
Change-Id: Ie38119b5eb46ee470e0d149959e523b48ac4d66d Signed-off-by: Mete Balci <metebalci@gmail.com>
Reviewed-on: http://openocd.zylin.com/5005 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Antonio Borneo [Sat, 30 Mar 2019 07:47:38 +0000 (08:47 +0100)]
helper/command: log an error for commands without usage
Every command has been fixed with proper usage field.
Change LOG_DEBUG with LOG_ERROR so a developer will get a visible
alert for missing usage field when adds a new command.
Change-Id: I077c3745fd6265aded8e54b3f9d202d4d6516966 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5026 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Leonard Crestez [Fri, 10 Aug 2018 13:06:43 +0000 (16:06 +0300)]
target/imx6: Add -ignore-version
Looking through imx6 manuals all of them claim that "In follow-on
silicon revisions the ID value is subject to change by incrementing the
first nibble".
Handle this by passing -ignore-version to jtag newtap command.
In Texinfo, a comma inside an @url separates parameters to the @url
function rather than being included as part of a parameter. Use @comma{}
instead to resolve this.
Change-Id: I8b38939462cf4452e5bc2582ee484220aaf83ae0 Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/5028 Tested-by: jenkins Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>