Commit Graph

12385 Commits

Author SHA1 Message Date
Parshintsev Anatoly ba8c1eef5a target/riscv: allow hexadecimal values to expose_csr-like commands
hexadecimal values are often used in the documentation. Forcing user to
convert CSRs addresses to decimal is unnecessary.
2024-11-19 22:28:57 +03:00
Evgeniy Naydanov f51900b4a2
Merge pull request #1165 from aap-sc/aap-sc/resume_debug_errors
target/riscv: detailed error messages for cases when resume operation fails
2024-11-18 13:17:25 +03:00
Evgeniy Naydanov 463d1b0866
Merge pull request #1157 from zqb-all/support-disable-auto-fence
target/riscv: support disable auto fence
2024-11-18 13:16:54 +03:00
Evgeniy Naydanov c53f9319c8
Merge pull request #1163 from en-sc/en-sc/from_upstream
Merge up to fd62626dff from  upstream
2024-11-18 13:16:18 +03:00
Evgeniy Naydanov a2f5da3289
Merge pull request #1161 from en-sc/en-sc/deassert-reset
target/riscv: avoid updating `target` if `ackhavereset` fails
2024-11-14 13:23:42 +03:00
Parshintsev Anatoly faffae0493 target/riscv: detailed error messages for cases when resume operation fails
This change aims to provide more context in case if resume operation
fails. Before the change messages were quite confusing.
2024-11-14 12:23:47 +03:00
Evgeniy Naydanov f7ea8245e6
Merge pull request #1160 from zqb-all/reduce-log
[NFC] target/riscv: remove LOG_ERROR when COMMAND check ARGC fail
2024-11-12 17:45:57 +03:00
Evgeniy Naydanov cabb6000df Merge up to fd62626dff from upstream
Conflicts are related to `unsigned`->`unisgned int` cleanup:
* `src/jtag/drivers/ftdi.c` -- between
  6749c70a3a and
  a64dc23bf1.
* `src/rtos/hwthread.c` -- between
  ef3e61bebc and
  436e6f1770.
* `src/target/target.c` and `.h` -- between
  53ec10b61d and
  e72733d590.
* `src/target/riscv/*` -- due to
  957eb741a0 and
  fec3b22421.
  Resolved by:
    * Changing the return type of `riscv_batch_get_dmi_read_op()` to
      `uint32_t`.
    * Using RISC-V OpenOCD's version in other cases.

Change-Id: Ia6e2129c6fddb1dec26adcd936506af2539412ef
2024-11-12 17:25:33 +03:00
Evgeniy Naydanov fd62626dff target/breakpoints: fix types in `watchpoint_add_internal()`
There was a conflict:
1. commit 2cd8ebf44d ("breakpoints: use 64-bit type for watchpoint mask
   and value")
2. commit 0bf3373e80 ("target/breakpoints: Use 'unsigned int' for
   length")

The second commit was created erlier, but merged later so the types of
`mask` and `value` became `uint32_t` in `watchpoint_add_internal()`.

This created a bug:
`WATCHPOINT_IGNORE_DATA_VALUE_MASK` is defined as `(~(uint64_t)0)`.
Truncation to uint32_t makes it so the comparisons with the constant
don't work.

Change-Id: I19c414c351f52aff72a60330d83c29db7bbca375
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8500
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
Tested-by: jenkins
Reviewed-by: zapb <dev@zapb.de>
Reviewed-by: Karl Palsson <karlp@tweak.au>
2024-11-11 17:33:56 +00:00
Marek Kraus b68d23da3c tcl/target/bl702: implement full software reset
In previous implementation, it was known that it does not perform
full reset, and that some peripherals, such as GLB core,
which handles among other stuff GPIOs, was not reset.

It was presumed, that full reset by software is not possible,
although, by accident, even when comment says that
CTRL_PWRON_RESET is set to 1, it is not
(value written into 0x40000018 supposed to be 0x7, not 0x6).

CTRL_PWRON_RESET indeed triggers full "power-on like" reset,
so this method is implemented in this commit.
There are some workarounds to make reset seamless, without any
error messages, which are described in comments of TCL script.

Only down-side of this reset is, that chip is halted after reset
bit later in BootROM than previous implementation,
but it's still good.

Change-Id: Ife2cdcc6a2d96a2e24039bfec149705baf046318
Signed-off-by: Marek Kraus <gamelaster@outlook.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8529
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2024-11-09 21:06:05 +00:00
Mark Zhuang bcebc84882 contrib: convert 'unsigned' to 'unsigned int'
Conversion done with
        checkpatch --fix-inplace -types UNSPECIFIED_INT

Change-Id: I0e31f87d437fcf3503736474f10a63f9c6be242b
Signed-off-by: Mark Zhuang <mark.zhuang@spacemit.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8368
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2024-11-09 21:05:18 +00:00
Evgeniy Naydanov 784687d781 target/riscv: avoid updating `target` if `ackhavereset` fails
`target`'s `state` and `debug_reason` should not be updated in
`deassert_reset` if sending reset acknowledgment fails.

Change-Id: I86136fe829e7a7c6b69f718f0cf32322e40341b0
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2024-11-08 16:36:25 +03:00
Mark Zhuang e024f112e3 [NFC] target/riscv: remove LOG_ERROR when COMMAND check ARGC fail
Per current OpenOCD conventions, LOG_ERROR should not be printed
when ERROR_COMMAND_SYNTAX_ERROR is returned. OpenOCD will print
the command syntax to the user on its own.
2024-11-06 19:32:20 +08:00
Mark Zhuang 340e38a9ed target/riscv: support disable auto fence
Support disable automatic fence, it's useful for
debug some cache related issue.
2024-11-06 17:15:57 +08:00
MicBiso 40d58ce529 tcl/target/renesas_rz_g2: Rename to renesas_rz and add RZ/V2L-G3S
Rename file to get it more generic and add more targets belonging
to the same family.
Add support for two new devices: RZ/V2L and RZ/G3S

Change-Id: Idb7f4d81d2f95ad15ef686e940f43ed29f49f343
Signed-off-by: MicBiso <michele.bisogno.ct@renesas.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8211
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2024-11-02 21:06:37 +00:00
Marc Schink 3b261fb155 adapter/parport: Coding style changes
Apply some coding style changes according to the C style guide. The
patch is tested for regression with the 'wiggler' parallel port cable.

Change-Id: I43774f596831d8c46f90f18893418178041a930b
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8516
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2024-11-02 21:06:05 +00:00
Marc Schink 337db329c9 adapter/bitbang: Use 'bool' data type for blink()
Change-Id: I187f8944ad5fd92f28cbd32e447f9ec1a97e16d6
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8515
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2024-11-02 21:05:37 +00:00
Marc Schink f4d81cd4d4 tcl/interface: Restructure parport config files
Provide cable specific configuration files like for the FTDI interface.
Depcrecate the old configuration files but keep them until the next
release for compatibility reasons.

Change-Id: I436bd60779a107120c9e1b1f0b8a69a39a240ad4
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8514
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2024-11-02 21:04:44 +00:00
Mark Zhuang 99f60d5e59 jtag: convert 'unsigned' to 'unsigned int'
Conversion done with
        checkpatch --fix-inplace -types UNSPECIFIED_INT

Change-Id: I2c2d56aa98e89bcc6088a1bd51d70066d67d6dad
Signed-off-by: Mark Zhuang <mark.zhuang@spacemit.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8367
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-11-02 21:03:37 +00:00
Mark Zhuang b95633b30c flash: convert 'unsigned' to 'unsigned int'
Change-Id: I8e8da78385eed714524891b580e19a79cfb459d3
Signed-off-by: Mark Zhuang <mark.zhuang@spacemit.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8370
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-11-02 21:03:19 +00:00
Mark Zhuang 114ad468ca server: convert 'unsigned' to 'unsigned int'
Conversion done with
        checkpatch --fix-inplace -types UNSPECIFIED_INT

Ignore the cast as they could be better addressed.

Change-Id: Ib0cbd9388d61659f8d47c8f57c09baa6df123487
Signed-off-by: Mark Zhuang <mark.zhuang@spacemit.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8369
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-11-02 21:03:04 +00:00
Mark Zhuang 134e56338d target: riscv: convert 'unsigned' to 'unsigned int'
Change-Id: I10b9abf9e42389eb91b210b8c2f01219ca9068cd
Signed-off-by: Mark Zhuang <mark.zhuang@spacemit.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8366
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-11-02 21:02:42 +00:00
Antonio Borneo 34ec5536c0 stlink: deprecate HLA support
The STLink API that supports dap-direct is available from STLink
firmware v2j24, published in early 2015.
We can reasonably expect that any old STLink still in use today
has got at least one firmware update during the last 10 years.

Most of the board files in upstream OpenOCD still use the STLink
in HLA mode. This limits the test coverage of the dap-direct code,
which was introduced in OpenOCD v0.11.0.

- Rename interface/stlink.cfg as interface/stlink-hla.cfg to still
  provide support for HLA, adding a deprecated message.

- Rename interface/stlink-dap.cfg as interface/stlink.cfg to make
  dap-direct the default trasport.

- Add a redirect file interface/stlink-dap.cfg for users that have
  out-of-tree custom board files.

- Update all the board files to the new setup.

- Remove STLink HLA mentions from the documentation, while adding
  a reference to interface/stlink-hla.cfg

Checkpatch-ignore: LONG_LINE
Change-Id: I99366bb03cd3b83f8f408514e657f30e59813063
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8523
Tested-by: jenkins
Reviewed-by: Andrzej Sierżęga <asier70@gmail.com>
2024-11-02 21:01:07 +00:00
Antonio Borneo 3ce0962f2c target: cortex_m: fix polling for target kept under reset
In multi-target SoC not all the targets are running simultaneously
and some target could be powered off or kept under reset.
Commit 4892e32294 ("target/cortex_m: allow poll quickly get out
of TARGET_RESET state") does not considers the case of a target
that is kept in reset and expects the target to change state from
TARGET_RESET immediately.
This causes OpenOCD to log continuously:
	Info : [stm32mp15x.cm4] external reset detected
	Info : [stm32mp15x.cm4] external reset detected
	Info : [stm32mp15x.cm4] external reset detected

Read again dhcsr to detect the 'stable' reset status and quit,
waiting for next poll to re-check the target's status.

Change-Id: Ic66029b988404a1599bb99bc66d4a8845b8b02c6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 4892e32294 ("target/cortex_m: allow poll quickly get out of TARGET_RESET state")
Reviewed-on: https://review.openocd.org/c/openocd/+/8399
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2024-11-02 20:59:48 +00:00
R. Diez 7214c8be46 configure: show adapter Xilinx XVC/PCIe in the configuration summary
Adapter Xilinx XVC/PCIe was not appearing in the configuration summary
because of the wrong variable name: build_xlnx_pcie_xvc
instead of enable_xlnx_pcie_xvc.

Also build this adapter automatically on Linux.

Change-Id: I69ea92f550052b9ce55ce32597ac446a15a87388
Signed-off-by: R. Diez <rdiezmail-openocd@yahoo.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8312
Tested-by: jenkins
Reviewed-by: R. Diez <rdiez-2006@rd10.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-11-02 20:59:15 +00:00
Evgeniy Naydanov f9a1292716
Merge pull request #1154 from en-sc/en-sc/dcsr-ebreak-halt-on-reset
target/riscv: avoid unnecessary `dcsr.ebreak*` update on reset
2024-10-30 17:52:56 +03:00
Evgeniy Naydanov e3a47cae3e
Merge pull request #1156 from zqb-all/max-macro
[NFC] target/riscv: simplify code with MAX macros
2024-10-30 17:51:35 +03:00
Mark Zhuang b7708c84e6 [NFC] target/riscv: simplify code with MAX macros
slightly improves readability
2024-10-28 22:57:07 +08:00
Evgeniy Naydanov 9ff272e34b
Merge pull request #1149 from zqb-all/read-write-cross-page
riscv: fix read/write virtual memory across page boundaries
2024-10-28 14:40:13 +03:00
Evgeniy Naydanov 3fe20e7aa4 target/riscv: avoid unnecessary `dcsr.ebreak*` update on reset
There is no need to change if `dcsr.ebreak*` fields after a reset if a
user requested a configuration that will result `dcsr.ebreak*` field
values equal to reset values.

Change-Id: I2844d30aef8f735c7b37394ee422e9b3f04a2e3b
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2024-10-25 17:27:19 +03:00
Mark Zhuang 92d7a5798d [NFC] target/riscv: refactor riscv_read_memory,riscv_write_memory
Reduce duplicate code
2024-10-24 23:47:58 +08:00
Mark Zhuang 4a1bd80842 target/riscv: fix cross-page misaligned access when mmu not enabled
When mmu is disabled, simply call the physical read/write function
2024-10-24 23:47:48 +08:00
Mark Zhuang 593b377073 target/riscv: fix read/write virtual memory across page boundaries
When read/write virtual addresses cross page boundaries,
the physical addresses are not necessarily contiguous and
need to call virt2phys again.
2024-10-24 23:39:10 +08:00
Evgeniy Naydanov 7b4ad6f173
Merge pull request #1152 from fk-sc/translation-drivers
target/riscv: added translation drivers
2024-10-24 15:06:27 +03:00
Farid Khaydari 6a27d9fbc0 target/riscv: added translation drivers
Existing flags: 'enable_virtual' and 'enable_virt2phys' were
replaced with explicit translation drivers. Motivation:

(1) Having 'enable_virtual' and 'enable_virt2phys' flags set simultaneously
may cause double address translation which is unacceptable

(2) Flags were global for all targets which is wrong too

Signed-off-by: Farid Khaydari <f.khaydari@syntacore.com>
2024-10-23 12:36:29 +03:00
Jan Matyas d09ff47644 gdb_server: Improve const correctness
On several packet-handling functions, add "const" to arguments
that represent read-only packet buffers.

For instance on GCC 13.2.0, this code:

const char *some_packet = "...";
gdb_put_packet(conn, some_packet, strlen(some_packet));

would prior to the fix produce warning:

passing argument 2 of ‘gdb_put_packet’ discards ‘const’
qualifier from pointer target type [-Wdiscarded-qualifiers]

Change-Id: Idb62f57d37ed323c39de38982e57afdd3882e280
Signed-off-by: Jan Matyas <jan.matyas@codasip.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8517
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2024-10-20 09:25:25 +00:00
Jan Matyas 114ca19f64 gitignore: Start ignoring ".vscode"
To help the developers who use Visual Studio Code IDE,
ignore the ".vscode" folder in Git. This folder contains
local configuration of the VSCode workspace.

Change-Id: I1d54d8ce2bd0680f2fa1fb773bb33c786bdcc608
Signed-off-by: Jan Matyas <jan.matyas@codasip.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8518
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2024-10-20 09:24:43 +00:00
Florian Fainelli 21a211d547 arm_adi_v5: Added Cortex-A55 debug unit identifier
Add identifier of the Cortex-A55 debug unit.

Change-Id: I67336094a5153a3187cccc32c0e38d78ae4af542
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8430
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-10-20 09:24:15 +00:00
Antonio Borneo fec3b22421 target: riscv: remove non-trivial 'unsigned' cast
Change the prototype of riscv_batch_get_dmi_read_op().
Now that 'target->smp' is unsigned, drop the cast.

Change-Id: I2a54268ed1e4bf0ea884b62cceb73f5c7451da78
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8484
Tested-by: jenkins
2024-10-20 09:23:09 +00:00
Antonio Borneo 957eb741a0 target: riscv: convert 'unsigned' to 'unsigned int'
Conversion done with
	checkpatch --fix-inplace -types UNSPECIFIED_INT

Ignore the cast as they could be better addressed.
Fix only minor additional checkpatch issue (spacing and line
length).

Change-Id: I11f10eddadc21e051c96eb3d4d4c0554a2cddd15
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8483
Tested-by: jenkins
2024-10-20 09:22:52 +00:00
Antonio Borneo bcf63ac562 checkpatch: check SPDX in Makefile
The firmware in contrib folder use Makefile for the build.
Force checkpatch to check these Makefile for the SPDX.

Change-Id: I815bf6df636c96a15f82c3d8a9de0c4f219303d2
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8520
Tested-by: jenkins
2024-10-20 09:21:11 +00:00
Evgeniy Naydanov bc68bd71a3
Merge pull request #1146 from en-sc/en-sc/select-dmi-bypass
target/riscv: check other TAPs in `select_dmi()`
2024-10-18 12:37:31 +03:00
Evgeniy Naydanov 417ff401f8
Merge pull request #1150 from borneoa/riscv
target: riscv: convert 'unsigned' to 'unsigned int'
2024-10-17 11:10:42 +03:00
Evgeniy Naydanov f3ed0ab608 target/riscv: check other TAPs in `select_dmi()`
If some other TAP is not in BYPASS, an IR scan is needed to select
BYPASS on that TAP.

Change-Id: Iae425a415109b1a853db3718762661877eea56e8
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2024-10-16 13:42:48 +03:00
Antonio Borneo 89fb9211ec target: riscv: convert 'unsigned' to 'unsigned int'
Conversion done with
	checkpatch --fix-inplace -types UNSPECIFIED_INT

Change-Id: I62fad88dd33716c24154d44c5a23ae2c0f7c4a4c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-10-12 17:01:36 +02:00
Evgeniy Naydanov a4020f1a02
Merge pull request #1142 from en-sc/en-sc/from_upstream
Merge up to 1173473f66 from upstream
2024-10-08 14:17:57 +03:00
Jan Matyas edf2c82cf6 helper/align.h: Fix macro IS_PWR_OF_2
Zero is not a power of two.

All functions that use IS_PWR_OF_2 were checked and the edge case
of IS_PWR_OF_2(0) does not occur anywhere at the moment. Therefore
the fix is safe.

Change-Id: I84d9f9c64c9a7df452ca6e99c2ee4169ccb2b0be
Signed-off-by: Jan Matyas <jan.matyas@codasip.com>
Fixes: 9544cd653d ("helper: add align.h")
Reviewed-on: https://review.openocd.org/c/openocd/+/8511
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2024-10-05 15:53:43 +00:00
Antonio Borneo 30c3d077f2 jimtcl: update to version 0.83
New version tagged on 2024-08-28.

Change-Id: Id0cf82a692469ccf794c9680c5d5ac09ea26e6da
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8513
Tested-by: jenkins
2024-10-05 15:53:02 +00:00
Antonio Borneo 73390332d2 openocd: fix build with jimtcl 0.83
In jimtcl 0.82, the include file jim.h included in turn stdio.h
This made redundant to include the former in openocd source files.
Since jimtcl 0.83, jim.h drops the include of stdio.h, causing
openocd build to fail.

Include stdio.h in the files that need it.

Change-Id: Ic81c9b273d7520f4d2d8c32bc3e0a6bcfffb67ed
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8512
Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li>
Tested-by: jenkins
2024-10-05 15:52:26 +00:00
Antonio Borneo 116e9553d1 openocd: build: allow more socket connections on Windows
Cross compiling OpenOCD for Windows forces the maximum number of
open files (including sockets) to 64. See in include file
psdk_inc/_fd_types.h:
	#ifndef FD_SETSIZE
	#define FD_SETSIZE 64
	#endif

This limit is far lower than the default value 1024 used by Linux.

In pull request #644 [1] in risc-v fork it's reported that:
- each socket server of OpenOCD (GDB, telnet, ...) uses one FD;
- each active connection to a socket server uses another FD;
- multi-core devices with 32 or more cores, each having a GDB
  connection, already saturates the 64 available FD at the 26th
  GDB connection.

The patch [2] proposed and merged in risc-v fork adds the compile
flag
	-DFD_SETSIZE=128
to all the host types. While this looks fine for Windows, it
reduces the default value for Linux and other OS.

Add the compile flag FD_SETSIZE only to cross compile for Windows.

Link: [1] https://github.com/riscv-collab/riscv-openocd/pull/644
Link: [2] https://github.com/riscv-collab/riscv-openocd/pull/644/commits/1bab4cfbc4f4
Change-Id: Ie43a792ac11a5e63e0407b68e3f270efea0c87be
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8503
Tested-by: jenkins
2024-10-05 15:51:58 +00:00