Antonio Borneo [Sat, 21 Jun 2025 10:11:24 +0000 (12:11 +0200)]
helper: types: fix proper return type in example of ARRAY_SIZE()
The example in the comment above the declaration of the macro
ARRAY_SIZE() assigns the value to a variable of type 'unsigned'
that is not allowed by the coding style (should be 'unsigned int')
and is not correct since the macro uses 'sizeof()' and the type
returned is 'size_t'.
Henrik Brix Andersen [Wed, 11 Dec 2024 08:34:57 +0000 (09:34 +0100)]
jtag: drivers: xlnx-pcie-xvc: use correct TMS polarity during pathmove
The xlnx_pcie_xvc_execute_pathmove() function checks whether TMS
should be high or low for transitioning from the current state to the
next state, but then calls xlnx_pcie_xvc_transact() with the opposite
level, leading to invalid state transitions.
Fix the polarity of TMS in the calls to xlnx_pcie_xvc_transact() to
match the required TMS level.
Change-Id: I2383e41fb70063e26aa69fabcf728df597607934 Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8613 Reviewed-by: Moritz Fischer <moritzf@google.com> Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Nicolas Derumigny <nicolas.derumigny@inria.fr>
Jan Matyas [Tue, 17 Jun 2025 11:17:23 +0000 (13:17 +0200)]
openocd.c: 'init' should fail if GDB service cannot be created
If it is not possible to create a GDB service for a certain target
(for example the given TCP port is already occupied), the "init"
command should fail, but it currently does not.
Fix this by checking the return code of gdb_target_add_all().
Steps to reproduce:
1) Make the port 3333/tcp occupied. For example by:
nc -l 3333
2) In another terminal, launch OpenOCD. Use the gdb_port
3333 (which is the default). For example:
Antonio Borneo [Sat, 14 Jun 2025 12:39:37 +0000 (14:39 +0200)]
jtag: interfaces: sort the drivers by alphabetic order
Add comments to require the list of drivers to be kept sorted.
While there:
- align the check on BUILD_PRESTO and BUILD_USB_BLASTER;
- fix indentation of the closing parenthesis.
Change-Id: Ic78281b1cdfb5bf72ea41427233e76516001b429 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8950 Tested-by: jenkins
kryvosheiaivan [Wed, 28 May 2025 13:52:42 +0000 (16:52 +0300)]
cmsis-dap: Fix freeing pending transfers on close
Freeing pending transfers on shutdown is done in openOCD
and on libusb side. This created concurrency in freeing
memory and segmentation faults:
https://github.com/libusb/libusb/issues/1627
Bug is reproduced better if many targets are laucnhed.
Bug was reproduced with CMSIS-DAP on targets:
cyw20829, psoc4, stm32l5 if launching multiple times.
Proposed working fix: if some transfers pending/in-flight
on 'shutdown' then apply libusb_handle_events_timeout_completed()
to make transfer complete. In all cases transfer completed
due to tests.
Change-Id: I44621ac6096791714910220d04614d0a19ce47bd Signed-off-by: kryvosheiaivan <Ivan.Kryvosheia@infineon.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8876 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Marc Schink [Wed, 9 Oct 2024 09:14:21 +0000 (11:14 +0200)]
adapter: Deprecate Gateworks GW16012 driver
The adapter is not available for years now. There is also no information
about this device from Gateworks. The poor hardware availability and the
lack of users prevents testing, maintenance and adaptations to future
changes.
Mark the adapter as deprecated as a first step to give potential users
the opportunity to upgrade the hardware until the next OpenOCD release.
Change-Id: I037325a6b018b26608733a36bef30db2785858f8 Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8651 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
The adapter is not available for years now and Amontec is not even a
company anymore. The poor hardware availability and the lack of users
prevents testing, maintenance and adaptations to future changes.
Mark the adapter as deprecated as a first step to give potential users
the opportunity to upgrade the hardware until the next OpenOCD release.
Change-Id: Idd9fb75588246bc39e12ea17a71435ed77f0f50b Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8349 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
Antonio Borneo [Tue, 3 Jun 2025 09:52:59 +0000 (11:52 +0200)]
HACKING: describe keeping the 'Change-Id' on new patch versions
We often get on Gerrit a new version of an old patch with a new
'Change-Id' value. This breaks the history of the review, adding
more work to the review process.
Describe in HACKING why the hook 'commit-msg' is required and how
to handle the 'Change-Id' on new patch versions.
Change-Id: I5c060b19f966add7422704912b38e1ab2f788e5f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8940 Tested-by: jenkins
Electric Worry [Thu, 29 May 2025 10:31:59 +0000 (11:31 +0100)]
tcl/board/orange_pi_zero_3: Add Orange Pi Zero 3 board
The Orange Pi Zero 3 is an SBC that uses an Allwinner H618
SoC. As such, JTAG support is fully available, however the
SoC multiplexes JTAG function with UART1 and microSD.
Unfortunately Xunlong has used UART1 for the Wifi-BT
chip, leaving JTAG accessible only via the microSD using
a microSD breakout board (for example).
Change-Id: I0dc078cd2f3176815271917eb5e948cc8ef94525 Signed-off-by: Electric Worry <me@electricworry.net>
Reviewed-on: https://review.openocd.org/c/openocd/+/8938 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Antonio Borneo [Tue, 3 Jun 2025 08:34:29 +0000 (10:34 +0200)]
configure: hide build issue of amt_jtagaccel driver by disabling it
With commit d8a2f6dbcf5f ("configure.ac: show the Amontec
JTAG-Accelerator driver in the config summary") the driver
amt_jtagaccel is now build by default on Linux.
This highlights the dependency of some include files, dependency
that is not properly managed and that can cause build failure.
The driver is queued to be dropped soon, so there is no real
interest to fix the dependencies.
Change the default so the driver is not built if the user does not
require it at configure time.
Change-Id: Ifb74e2c802abda290efbf59ca4ce02048c94e6f8 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8939 Reviewed-by: R. Diez <rdiez-2006@rd10.de> Tested-by: jenkins
Antonio Borneo [Wed, 28 May 2025 14:58:44 +0000 (16:58 +0200)]
configure: fix for missing include files on Linux
By merging [1] and [2], the drivers 'xlnx-pcie-xvc' and 'linuxspidev'
are now build by default on Linux.
This highlights the dependency of some include files under subfolder
'linux' that are not installed by default in all Linux boxes.
Add the check in 'configure' for the presence of the include file
and conditionally enable the build of the driver.
Change-Id: Ie88645c3455ab07622f069a0cc7bf09d1a5a2c75 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Link: [1] 7214c8be46f7 ("configure: show adapter Xilinx XVC/PCIe in the configuration summary")
Link: [2] 83e0293f7ba3 ("Add Linux SPI device SWD adapter support")
Reviewed-on: https://review.openocd.org/c/openocd/+/8935 Tested-by: jenkins
Kevin Yang [Mon, 12 Oct 2020 20:22:47 +0000 (13:22 -0700)]
target/armv8: Handle modeswitch for aarch32 secure EL3
For aarch32 secure EL3
- Change target_el to 3 for SVC/ABT/IRQ/FIQ/UND/SYS for aarch32 secure
EL3
- Do not update SPSR for SYS, behavior is UNPREDICTABLE (ARMv8-A F5.1.121)
- Do not execute DRPS for SYS, behavior is UNPREDICTABLE (ARMv8-A
F5.1.51)
Change-Id: Ic1484665cd53afcccb5c20b152993a3f0407f8a2 Signed-off-by: Kevin Yang <kangyang@google.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/5854 Tested-by: jenkins Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de> Reviewed-by: Plamena Marinova <pmarinova@hilscher.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Jonathan Bell [Wed, 21 May 2025 14:37:25 +0000 (15:37 +0100)]
tcl: fix broken Raspberry Pi website links
raspberrypi.com is the home for technical information, raspberrypi.org
is the Foundation's site (though there are intelligent redirects).
Several pages have moved around, fix these.
Also tweak a few comments for style and correctness.
Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
Change-Id: I7f52bcc362fb213b50987e3a42866fe4a6fec883
Reviewed-on: https://review.openocd.org/c/openocd/+/8885 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Jonathan Bell [Wed, 21 May 2025 14:26:20 +0000 (15:26 +0100)]
doc: bcm2835gpio: remove broken link and clarify usage
The peripheral address details have been removed from the documentation
part of the website (instead presented in the SoC datasheets).
Pi 5 GPIOs are provided by the RP1 southbridge, which requires the use
of libgpiod. The associated Linux driver for the GPIO interface must be
used when bitbashing on Pi 5, as the timing of pin state changes is not
guaranteed across the PCIe link without special treatment.
Using libgpiod, the typical maximum swclk speed is 1MHz.
Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
Change-Id: I8b2c44ec5edd71abaa0a763ba4d4f4603a211348
Reviewed-on: https://review.openocd.org/c/openocd/+/8884 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Jacek Wuwer [Wed, 24 Apr 2024 08:15:38 +0000 (10:15 +0200)]
jtag/vdebug: implement a polling mechanism
This change adds a polling mechanism to the driver. When not busy
the driver issues a wait, allowing the target to advance time.
The wait period gets adjusted to match the polling setting.
Change-Id: I67f481d05d7c5ce5352b5cb97de78dbaa97d82ae Signed-off-by: Jacek Wuwer <jacekmw8@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8221 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
Marc Schink [Mon, 12 May 2025 04:47:22 +0000 (06:47 +0200)]
tcl/target: Move nordic configuration files
Move target configuration files into a dedicated vendor directory as
required by the new guideline for configuration files.
Note that the moved files are still accessible via the old path to ensure
backwards compatibility. This works because of the extended file search in
vendor folders.
Change-Id: If3935985769dc543e8c7d72cda590c9d79303abb Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8905 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
Antonio Borneo [Wed, 21 May 2025 13:19:28 +0000 (15:19 +0200)]
startup.tcl: extend the file search in vendor folders
The TCL configuration files are going to be dispatched in vendor
specific folders.
Old user configuration files will fail to find the new files to
include, so a set of fallback files reporting the deprecation
should replace the renamed files.
To prevent such enormous proliferation of fallback files, extend
the search of files in the vendor folders too.
For non-trivial renames, a dedicated table is added in the file
tcl/file_renaming.cfg to track old --> new file names.
The deprecated message is then part of the extended search.
and
- path/to/a/certain/config_file
trigger search of:
- path/to/a/certain/${vendor}/config_file
among a possible vendors list.
This is a temporarily feature that should be removed as soon as
possible to prevent clashing on files with the same name.
The names in tcl/file_renaming.cfg are for demonstration purpose
only and should be dropped when the first real entries are added.
Change-Id: If4793fef27dc570d5df4ff4d77a5e36004f394f6 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8929 Tested-by: jenkins
Lucien Dufour [Thu, 15 May 2025 12:31:25 +0000 (14:31 +0200)]
cortex_a: Use endianness for soft breakpoints
Fix endianness for cortex_r4 and cortex_r5 when inserting software
breakpoints. Because the cortex_a target is used by the cortex_r
architecture and some chips start in BE by default (e.g. TMS570)
Tim Newsome [Thu, 27 Oct 2022 21:42:23 +0000 (14:42 -0700)]
gdb_server: Operate on available targets.
When SMP is enabled, gdb will always use the first target in the SMP
group. That doesn't work when that first target is unavailable, but
others in the SMP group are still available.
For cases where gdb expects an operation to affect the entire group (run
control, memory access), find the first available target in an SMP group
and use that.
Imported from
https://github.com/riscv-collab/riscv-openocd/pull/767
Change-Id: I4bed600da3ac0fdfe4287d8fdd090a58452db501 Signed-off-by: Tim Newsome <tim@sifive.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8912 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tim Newsome [Thu, 27 Oct 2022 22:21:31 +0000 (15:21 -0700)]
target: Add TARGET_UNAVAILABLE state
This is added for future RISC-V changes. The RISC-V debug interface can
explicitly tell a debugger when a hart is unavailable. This is used for
instance when that hart is powered down (or yet to be powered up out of
reset).
Imported from
https://github.com/riscv-collab/riscv-openocd/pull/752
Change-Id: I8a062d59eea1e5b3c788281a75159592db024683 Signed-off-by: Tim Newsome <tim@sifive.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8911 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Bernhard Rosenkränzer <bero@baylibre.com>
Tomas Vanek [Sun, 18 May 2025 19:25:35 +0000 (21:25 +0200)]
server/gdb_server: do not discard Ctrl-C if _DEBUG_GDB_IO_
GDB server debug logging eat Ctrl-C when gdb user issues interrupt
in time of communication between OpenOCD and gdb.
E.g. Ctrl-C after `next` gdb command taking many
gdb remote protocol $vCont;s (steps)
Change-Id: I4a65446a9bb25a28e50566607b3dec116fa7d2cd Suggested-by: Tim Newsome <tim@sifive.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/8920 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Antonio Borneo [Sat, 16 Dec 2023 16:39:12 +0000 (17:39 +0100)]
command: drop Jim Command handler, at last
With all OpenOCD commands converted to COMMAND_HANDLER, we can
drop the management of jim_handler commands.
Drop also from documentation the subsection on Jim Command
Registration.
Change-Id: I4d13abc7e384e64ecb155cb40bbbd52bb79ec672 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8901 Tested-by: jenkins
Antonio Borneo [Fri, 2 May 2025 14:10:39 +0000 (16:10 +0200)]
cortex-a: fix single-step on infinite loop
On ARMv7a/r the single-step is implemented through a HW breakpoint
that hits instructions at any address except the address of the
current instruction.
The method above fails in case of an infinite loop coded by a
single instruction that jumps on itself; in such case, the same
instruction (at the same address) is executed over and over and
the breakpoint never hits. In current code this case is wrongly
considered as an error.
Reduce the timeout while waiting for the HW breakpoint being hit,
then halt.
The jump on itself would be executed several times before the
timeout and the halt, but this is not an issue. There are few
"pathological" instructions in ARMv7a/r that jumps on itself and
that can have side effects if executed more than once. They are
listed in the code. We do not consider these as real use cases
generated by a compiler.
Document the method in the code.
Report that the single-step function is not properly managing the
HW breakpoints if it exits on error. To be fixed in the future.
Change-Id: I9641a4a3e2f68b83897ccf3a12d3c34e98a7805c Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8871 Tested-by: jenkins
Walter Ji [Mon, 4 Mar 2024 09:29:15 +0000 (17:29 +0800)]
helper: add bitfield helper macros
This patch ports FIELD_{GET,PREP,FIT} macros and related macro
from FreeBSD, referenced file:
- `src/tree/sys/compat/linuxkpi/common/include/linux/bitfield.h`
Checkpatch-ignore: MACRO_ARG_REUSE
Change-Id: I6fdf4514d3f95d62fadf7654409a4878d470a600 Signed-off-by: Walter Ji <walter.ji@oss.cipunited.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8171 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
target: improve error messaging in `target create`
There are a couple of issues with the usage string for `target create`,
namely:
* `-chain-position` is allowed to be not the first option.
* `-chain-position` should be ommited alltogether on ARM targets when
DAP is specified.
Before the patch:
```
> openocd -c 'target create name testee'
...
target create name type '-chain-position' name [options ...]
```
After the patch:
```
> openocd -c 'target create name testee'
...
-chain-position ?name? required when creating target
> openocd -c 'target create'
...
target create name type [options ...]
```
Change-Id: Ia21a99ce6a4086e2e0676f5ef4685da3514a4f69 Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8860 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
Daniel Goehring [Thu, 1 May 2025 02:38:15 +0000 (22:38 -0400)]
target: cget command fix for result output
Function target_configure() when processing a "cget" command needs
to print the result to the console. Currently the result is only printed
when an error occurs. To fix this, move the command print statement from
the error handling section to the common code section.
The code was tested by executing a "$target_name cget -dap" command
and reviewing the result.
Change-Id: Iff1999de8c8e9a837055ba95714137aa03e68d4b Signed-off-by: Daniel Goehring <dgoehrin@os.amperecomputing.com> Fixes: 61890e3dc320 ("target: rewrite function target_configure() as COMMAND_HELPER")
Reviewed-on: https://review.openocd.org/c/openocd/+/8870 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Antonio Borneo [Thu, 1 May 2025 17:38:42 +0000 (19:38 +0200)]
transport: fix incorrect statement
Commit 236208a5ff2d ("transport: use a bitmask for the transport")
has an incorrect C statement in place of a return.
The code is working thanks to the previous condition never true.
The issue has been detected by clang scan-build in OpenOCD ACI
since the missing return can make the following statement
dereferencing a NULL pointer.
Fix it!
Change-Id: I3bbe04d99ad9b1288f55ba3c45e2e487aef9ae40 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Fixes: 236208a5ff2d ("transport: use a bitmask for the transport")
Reviewed-on: https://review.openocd.org/c/openocd/+/8868 Tested-by: jenkins
Antonio Borneo [Sat, 19 Apr 2025 14:28:50 +0000 (16:28 +0200)]
target: armv7a: drop command 'cache_config l2x'
The command was already tagged as deprecated in 2015 with commit 0df557728216 ("armv7a: remove l1 flush all data handler") but has
never been removed.
An equivalent command 'cache l2x conf' was introduced at the same
time in commit cd440bd32a12 ("add armv7a_cache handlers").
Drop it and deprecate it.
Replace the old command in the Tcl script.
Change-Id: Ie24eccc99a78786903704d10ee1d9f6c924529b5 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8857 Tested-by: jenkins
Chien Wong [Tue, 8 Apr 2025 12:33:56 +0000 (20:33 +0800)]
rtos/FreeRTOS: fix next pointer member offset in FreeRTOS lists
Currently, we are using offset of xListEnd.pxPrevious in List_t for
list_next_offset and offset of pxPrevious in ListItem_t for
list_elem_next_offset. This is confusing. Fix this.
As the related lists are doubly linked lists, only iteration order is
changed without breaking functionality.
Also document those offsets.
Change-Id: I8beacc235ee781ab4e3b415fccad7b72ec55b098 Signed-off-by: Chien Wong <m@xv97.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8833 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
Marc Schink [Sat, 17 Aug 2024 10:35:30 +0000 (12:35 +0200)]
doc/manual: Add guideline for configuration files
The goal of this guideline is to have consistent and well-structured
configurations files. The focus of this patch is on filenames and
directory structure. A guideline for the content of the files should be
included in a subsequent patch.
This patch addresses a long outstanding task listed in 'Pending and Open
Tasks'.
Change-Id: Ib32dd8b9ed15c3f647cd8d74cfc79edf0e79a3df Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8854 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Antonio Borneo [Mon, 23 Dec 2024 19:20:08 +0000 (20:20 +0100)]
stlink: simplify the use of deprecated HLA transport
Commit 34ec5536c0ba ("stlink: deprecate HLA support") makes hard
to use the still functional HLA transport with the stlink listed
in board config files.
Now that the prefixes 'hla_' and 'dapdirect_' has been dropped
from the transport name, allow overriding the transport by using
the 'stlink-hla' script in front of the board file, e.g.:
Revert the documentation changes of the change above.
Improve the documentation to explain how to use the compatibility
HLA mode.
Improve the error message in stlink driver to guide the user to
update the stlink firmware and to use the compatibility HLA mode.
Change-Id: I5d0bc7954511692cebe024bda2aaa72767b97681 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8679 Tested-by: jenkins