Commit Graph

11932 Commits

Author SHA1 Message Date
cgsfv 55ae2534b3 Handle unavailability when deasserting reset 2024-04-26 17:05:16 -07:00
cgsfv 84ed43ec3a Using progbuf for set_dcsr_break now works 2024-04-25 12:36:37 -07:00
cgsfv b6da5a06e9 Can also use progbuf only for dcsr_ebreak 2024-04-22 20:40:28 -07:00
cgsfv d6cad946db OK if target is unavailble after waiting for halt 2024-03-28 09:42:17 -07:00
cgsfv 6ff5d5d8ce Making halt_set_dcsr_ebreak more robust 2024-03-25 21:11:38 -07:00
cgsfv a4598e4b8b Ensuring target is selected when resuming it 2024-03-25 11:51:07 -07:00
cgsfv 506ebe8fe1 Extending handling of unavailable harts 2024-03-24 17:16:03 -07:00
cgsfv 0e74950144 Handling harts becoming available when halted 2024-03-20 20:14:53 -07:00
cgsfv acef947328 Adding riscv013_halt_current_hart function 2024-03-18 16:15:44 -07:00
cgsfv 6fd980486a Fixing halt_set_dcsr_ebreak not setting hart explicitly enough 2024-03-07 22:49:19 -08:00
cgsfv c428ed72a4 Added cleaner handling of unexamined harts 2024-02-26 17:14:41 -08:00
cgsfv c1c46fbcad Added even more handling of unexamined harts 2024-02-13 20:39:58 -08:00
cgsfv ae53788985 Added more handling of unexamined harts 2024-02-13 18:00:52 -08:00
Jan Matyas 87331a82a2
Merge pull request #1006 from en-sc/en-sc/break-ll-revert
Revert "break from long loops on shutdown request"
2024-01-29 17:51:51 +01:00
Ahmed BOUDJELIDA 0c2d907a5d contrib/firmware: Change USB interruption handling for JTAG/I2C communications
Before this change, when we send an I2C Bulk data at the same
time while Jtag bitbanging functions execute, the microcontroller
puts JTAG bitbanging on wait and executes all I2C bitbanging
function, which causes problems like loss of Ack in DAP responses
and other errors.

With this commit, When I2C interruption occurs, it sets a variable
to true and continues JTAG bitbanging, when it finish it executes
the I2C bitbang.

Change-Id: Ia80bac21f8a259f4a1176b5346bf74ed0aa6e38b
Signed-off-by: Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8074
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-01-29 13:36:27 +03:00
Ahmed BOUDJELIDA ba860abcab jtag/drivers: Add GPIO extender configuration function to ANGIE driver
Add GPIO extender initial configuration that is needed to configure
some important GPIOs and ensure that the dev board is ready to work.

Add i2c_write function that make a write transfer to any slave device.

Give a new Product ID to ANGIE to make it different than the non
programmed ANGIE.

Change-Id: I0a8dacb7fe218145b7d3ed1cb75f106ed6256714
Signed-off-by: Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8072
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-01-29 13:36:27 +03:00
Ahmed BOUDJELIDA f064c670f1 jtag/drivers: give ANGIE a new PID after renumeration
Give ANGIE a new PID after renumeration to be able to distinguish
the two cases (programmed and not programmed)

Change-Id: I30a91d8ed2e8e261221488b98d40a027ca41da52
Signed-off-by: Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7991
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-01-29 13:36:27 +03:00
Ahmed BOUDJELIDA 974e29aef6 jtag/drivers: correct the angie_reset function
remove angie_clear_queue function from executing before the
angie_execute_queued_commands function and making it at the
end of the reset function.

Change-Id: Id8a0664fbd5b8f9730545ce0f8f272ae0b0e7e78
Signed-off-by: Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7990
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-01-29 13:36:27 +03:00
Ahmed BOUDJELIDA da6c0e45a2 contrib/firmware: Add direction control for 'SCL' i2c signal
We want to keep the tri-state buffers located between the FPGA
and the board, in 'Z' state until we launch an i2c connection.

We launch an i2c start condition, make the SCL
direction 'OUT' to start the i2c protocol and at the end
of the i2c connection at the stop condition, we re-make
the tri-state buffers at 'Z' state.

Change-Id: Ic597a70d0427832547f6b539864c24ce20a18c64
Signed-off-by: Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7989
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-01-29 13:36:27 +03:00
Ahmed BOUDJELIDA 311c70405d jtag/drivers: send bitstream size to firmware via libusb
Send bitstream size to firmware to initialize the GPIF count registers,
since we're going to send this size via GPIF, we need to give the exact
number of bytes to be sent, then the GPIF counter will decrement with
every clock cycle (every byte sent) until reaching zero and stops.

Change-Id: Ib4e8e0f95a6a4a95ef4888ba8a04a0ea45567f5a
Signed-off-by: Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7988
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-01-29 13:36:27 +03:00
Ahmed BOUDJELIDA 619a4bbb7b contrib/firmware: update gpif FSM configuration file
Change the GPIF state machine, configuring only one of the 4 waveforms
to generate the clock signal (CCLK) used to program the FPGA, and send
one byte every cycle using an 8-bit bus.

Change-Id: I43cf5480b9d5c40cc2f6a62a52ecfe078b76458e
Signed-off-by: Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7976
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2024-01-29 13:36:27 +03:00
Antonio Borneo 8411330fcc target/mips32: fix false positive from clang
clang build triggers an error for an uninitialized value of the
variable 'instr'.
This is a false positive, as the macro
 #define MIPS32_CONFIG3_ISA_MASK (3 << MIPS32_CONFIG3_ISA_SHIFT)
guarantees the switch/case already covers all the possible values
with cases 0, 1, 2 and 3.

Silent clang by adding a useless default case to the switch.
While there, fix the indentation of the switch/case accordingly to
OpenOCD coding style.

Change-Id: I0ae316754ce7d091dd8366bf314b8e6ee780e313
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 7de4b1202d ("target/mips32: add cpu info detection")
Reviewed-on: https://review.openocd.org/c/openocd/+/8065
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2024-01-29 13:36:27 +03:00
ianst 37d4eaf5b1 target/xtensa: enable xtensa algo support
- Add extra error checking
- Cache PS; lower PS.INTLEVEL to allow  breakpoint trigger (LX)
- Xtensa algo support functional on LX per functional flash driver
- Test on NX via manual algo validation

Change-Id: Ie7cff4933979a0551308b382fa33c33c66376f25
Signed-off-by: ianst <ianst@cadence.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8075
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Tested-by: jenkins
2024-01-29 13:36:27 +03:00
Antonio Borneo a47fae7934 helper/command: pass command arguments also as Jim_Obj
Some OpenOCD command gets fragment of TCL scripts as command-line
argument, fragments that will be kept and executed later on.
E.g. the command 'configure' gets the body of an OpenOCD event:
	$TARGET configure -event halted {TCL code}

These commands store the argument as a Jim_Obj and pass it to the
jimtcl interpreter when the TCL fragment has to be executed.
Using Jim_Obj as storage is relevant to let the jimtcl interpreter
to recover extra info of the TCL fragment, like the file-name and
the line-number that contain the fragment, that will be printed
out in case of run-time errors.

While converting the commands to COMMAND_HANDLER, we should avoid
storing the argument as C strings otherwise we will loose precious
info in case of run-time errors making challenging the debugging
of such TCL fragments.

Extend the struct command_invocation to contain the array that
points to the Jim_Obj of the command arguments.
This will be used while converting commands to COMMAND_HANDLER.

Change-Id: If37c5f20e9a71349f77ba1571baf1e6778e28aa5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8057
Tested-by: jenkins
2024-01-29 13:36:27 +03:00
Antonio Borneo 350f5c3547 helper/command: inline run_command() in exec_command()
Simplify the command execution by inlining run_command() inside
exec_command().

Change-Id: Id932b006846720cfd867d22d142cd35831dbd1a2
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8056
Tested-by: jenkins
2024-01-29 13:36:27 +03:00
Antonio Borneo d645030394 helper/command: simplify exec_command()
The jimtcl interpreter guarantees that the Jim objects in argv[]
are not deallocated during the command execution. Thus, there is
no need to copy the string content of argv[].

Simplify exec_command() by inlining its two sub-functions and
dropping the strdup().

While there, add a LOG_ERROR() for out of memory.

Change-Id: I3e21ed7da50ca0bd072edbd49fca9740c81f95b0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8055
Tested-by: jenkins
2024-01-29 13:36:27 +03:00
Antonio Borneo be81c6ffe0 helper/command: simplify script_command_args_alloc()
The output parameter nwords is always equal to the input parameter
argc, when the function succeeds.

Drop the parameter nwords and let the caller use directly the
value in argc.

While there, convert some 'unsigned' to 'unsigned int'.

Change-Id: Ie3d8ce1351792f3c07fe39cdcbcd180fd24dc928
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8054
Tested-by: jenkins
2024-01-29 13:36:27 +03:00
Antonio Borneo cdf89dcd2e helper/command: drop unused variables
In both functions script_debug() and script_command_args_alloc()
the variable len is never used, and Jim_GetString() does not
mandate it.

Drop the variable and pass NULL to Jim_GetString().

Change-Id: I754b27a59c6087cde729496be42609d2a7145b0c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8053
Tested-by: jenkins
2024-01-29 13:36:27 +03:00
Antonio Borneo 88b8f2a796 target: drop deprecated code for mem2array and array2mem
Commit e370e06b72 ("target: Deprecate 'array2mem' and
'mem2array''") has already replaced the deprecated root versions
of commands mem2array and array2mem with TCL proc's that use
'read_memory' and 'write_memory'. It has left the deprecated code
of the target's version of the commands because the effort to code
the TCL replacement was not considered valuable.

To drop the last jim_handler commands, I consider much easier and
less error-prone to code them in TCL instead of converting the
deprecated code to COMMAND_HANDLER.

Drop the code in target.c and extend the TCL proc's.
While there, add the TCL procs to _telnet_autocomplete_skip.

Change-Id: I97d2370d8af479434ddf5af68541f90913982bc0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8052
Tested-by: jenkins
2024-01-29 13:36:27 +03:00
Antonio Borneo 0425853d7b LICENSES: drop SPDX tag 'GPL-2.0' and use 'GPL-2.0-only'
The SPDX tag 'GPL-2.0' has been deprecated in
https://spdx.org/licenses/GPL-2.0.html
and the preferred tag is now 'GPL-2.0-only'
https://spdx.org/licenses/GPL-2.0-only.html

Update the LICENSES documents and the SPDX of the only file that
reports the deprecated tag.

Change-Id: I3c3215438bc4378ff470bb9fa8fa962505a9ae50
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8064
Tested-by: jenkins
2024-01-29 13:36:27 +03:00
Evgeniy Didin 74c9170b67 target/arc: skip over breakpoints in arc_resume()
When requested by the core code (handle_breakpoints = true),
arc_resume() should be able to advance over a potential breakpoint set
at the resume address instead of getting stuck in one place. This is
achieved by removing the breakpoint, executing one instruction,
resetting the breakpoint, then proceeding forward as normal.

With this patch applied, openocd is now able to resume from a
breakpoint halt when debugging ARCv2 targets via telnet.

This has previously been committed to the Zephyr project's openocd repo
(see https://github.com/zephyrproject-rtos/openocd/pull/31).

Change-Id: I17dba0dcea311d394b303c587bc2dfaa99d67859
Signed-off-by: Evgeniy Didin <didin@synopsys.com>
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Signed-off-by: Artemiy Volkov <artemiy@synopsys.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7817
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2024-01-29 13:36:27 +03:00
Evgeniy Didin 198b39ff45 target/arc: restore breakpoints in arc_resume()
Presently, we rely on gdb to restore break/watchpoints upon resuming
execution in arc_resume(). To match this behavior in absence of gdb
(more specifically, when handle_breakpoints is true), this patch
explicitly re-enables all breakpoints and watchpoints in arc_resume().

This has previously been committed to the Zephyr project's openocd repo
(see https://github.com/zephyrproject-rtos/openocd/pull/31).

Change-Id: I59e9c91270ef0b5fd19cfc570663dc67a6022dbd
Signed-off-by: Evgeniy Didin <didin@synopsys.com>
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Signed-off-by: Artemiy Volkov <artemiy@synopsys.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7816
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2024-01-29 13:36:27 +03:00
ianst 3d37a84b07 target/xtensa: extra debug info for "xtensa exe" failures
- Read and display EXCCAUSE on exe error
- Clean up error messages
- Clarify "xtensa exe" documentation

Signed-off-by: ianst <ianst@cadence.com>
Change-Id: I90ed39f6afb6543c0c873301501435384b4dccbe
Reviewed-on: https://review.openocd.org/c/openocd/+/7982
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-01-29 13:36:27 +03:00
Tarek BOCHKATI 881fd76898 cortex_m: add detection of MVE feature for Armv8.1-M cores
For Armv8.1-M based cores, detect if the core implements the optional
M-profile vector extension (MVE), using MVFR1 register.

While at there rework armv7m->fp_feature detection based on MVFR0
and MVFR1 registers.

Change-Id: I92d5b1759aea9f7561d285f46acdec51d6efb7b4
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6950
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2024-01-29 13:36:27 +03:00
Daniel Anselmi 22b9c47468 ipdbg: improve ipdbg-host speed
By queuing multiple jtag transfers the connection speed between
JTAG-Host and JTAG-Hub is improved. This is due to much less
calls to OS functions. An improvement of about x30 has been
measured with ftdi-based jtag adapters

For this to work the JTAG-Host server needs to know if flow control
is enabled on the JTAG-Hub ports. This is possible with newer
JTAG-Hub/JtagCDC. For old JTAG-Hubs the queuing is not enabled so
this change is backwards compatible.

Change-Id: I8a5108adbe2a2c1e3d3620b5c9ff77a546bfc14e
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7978
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-01-29 13:36:27 +03:00
Tomas Vanek 09f0d04e7f jtag/drivers/cmsis_dap: use oocd_libusb_dev_mem_alloc() helper
On some systems (at least Windows/CYGWIN and macOS) libusb_dev_mem_alloc()
simply returns NULL. The helper can fall-back to malloc() to allocate
CMSIS-DAP pending command/response buffers.

Fixes: fd75e9e542 (jtag/drivers/cmsis_dap_bulk: use asynchronous libusb transfer)
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: I89660f6747ad9d494b8192711cbbee5764e058fa
Reviewed-on: https://review.openocd.org/c/openocd/+/8044
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2024-01-29 13:36:27 +03:00
Tomas Vanek ed00ee9ce0 drivers/libusb_helper: introduce oocd_libusb_dev_mem_alloc() helper
On some systems (at least Windows/CYGWIN and macOS) libusb_dev_mem_alloc()
simply returns NULL.

Use the result of the very first libusb_dev_mem_alloc() call to decide
if the underlining system supports dev mem allocation or we should
fall-back to plain heap malloc().

From the decision time on, keep using the selected type of memory allocator
and deallocator.

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: Ia1f0965cea44b4bb6d936b02ec43f5a16a46f080
Reviewed-on: https://review.openocd.org/c/openocd/+/8059
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-01-29 13:36:27 +03:00
Evgeniy Naydanov 41b5b5471b Revert "break from long loops on shutdown request"
This reverts commits 2e920a212f and
8dbb1250f5.

The reason is, after `openocd_is_shutdown_pending()` becomes true,
arbitrary command may be executed:
* In `target_destroy()` and the corresponding
  `target->type->deinit_target()`.
* In user-specifyed `pre_shutdown_commands` list.

Change-Id: Icd00d1d954cd45e255880a6f76c3a74c098d6a17
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2024-01-26 12:22:11 +03:00
Jan Matyas ec28cf03ae
Merge pull request #997 from en-sc/en-sc/priv-access
target/riscv: move read redirection for `priv` to `riscv-013.c`
2024-01-25 06:53:51 +01:00
Jan Matyas aa4a80dbed
Merge pull request #1002 from en-sc/en-sc/arch-state
target/riscv: report info about target during `poll`
2024-01-25 06:50:42 +01:00
Jan Matyas f6776563bd
Merge pull request #995 from en-sc/en-sc/ctx-fix
target/riscv: cleanup `get_riscv_debug_reg_ctx()`
2024-01-25 06:50:12 +01:00
Evgeniy Naydanov b503fdef02 target/riscv: report info about target during `poll`
Addresses issue #196.

Change-Id: I71146c7bc769cb9727e57da33e9f514eedef9ce4
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2024-01-24 10:43:51 +03:00
Evgeniy Naydanov ca3abcaa06 target/riscv: move read redirection for `priv` to `riscv-013.c`
The reason for the change is a conflict: `dcsr[5]` is `dcsr.v` in
current spec, but it is `dcsr.debugint` in 0.11. This causes `priv`
register to be read incorrectly.

Change-Id: If2d8fdcd8536afa4c7149c453101b00ce0df1ce0
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2024-01-23 17:50:01 +03:00
Jan Matyas 78a719fad3
Merge pull request #992 from en-sc/en-sc/remove-hart-count
target/riscv: remove `riscv_hart_count()`
2024-01-18 09:12:40 +01:00
Jan Matyas 80f219ae89
Merge pull request #990 from en-sc/en-sc/dmi-defines
target/riscv: use defined constants in `dmi_*_t` enums (non-functional change)
2024-01-18 09:11:56 +01:00
Jan Matyas e6e9fbe2eb
Merge pull request #991 from en-sc/en-sc/dm-dmi-address-conversion
target/riscv: fix DM register address checks in `dm_read`/`dm_write`
2024-01-18 09:11:23 +01:00
Evgeniy Naydanov cd07c4447b target/riscv: cleanup `get_riscv_debug_reg_ctx()`
This commit makes the function safe to use throughout the lifetime of a
target.

Change-Id: I7a573e5d3b70daec2cf8f47a2aa1e30e39321549
2024-01-16 21:24:07 +03:00
Evgeniy Naydanov bb4c117d44 target/riscv: fix addressing in `dm_read`/`dm_wirte`
There was an error in `dm_read`/`dm_write`: DMI address was checked
against DM registers disregarding DM base address.

To solve the issue `dmi_address()` function was introduced.

Change-Id: Ia3be619417b5f5b53db5dfe302db05170d6787c9
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2024-01-16 18:14:58 +03:00
Evgeniy Naydanov ecb983a464 target/riscv: remove `riscv_hart_count()`
The motivalion for the change:
* `riscv_hart_count()` is used only once to print the value into the log
  during exmination.
* The returned value is a bit confusing: it's not the total number of
targets on the TAP. It is the number of targets accessable through the
same DM. So the name of the function is misleading.
* This value is already reported on `-d3` level.

So the function seems redundant and can be safely removed.

Change-Id: Iac9021af59ba8dba2cfb6b9dd15eebc98fe42a08
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2024-01-16 16:37:12 +03:00
Jan Matyas 4fc0d86ff0
Merge pull request #989 from en-sc/en-sc/from_upstream
Merge up to adcc8ef87b from upstream.
2024-01-16 08:32:26 +01:00