Commit Graph

8867 Commits

Author SHA1 Message Date
Tomas Vanek
2b986178cf flash: read only alias
Similar as virtual flash but has write/erase suppressed.

'virtual' flash driver name check in flash_free_all_banks()
was replaced by a customized free_driver_priv()

Change-Id: I528760aad0ba55ebc57fc1fabfdfdf07c92cac94
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/5107
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2026-02-15 18:15:33 +00:00
Tomas Vanek
8ee7cb12cf flash: ROM support
The only reason to define a read-only region is that gdb needs
a complete memory map to choose hard or soft breakpoints properly.

Change-Id: I9d05cb6b91f054ad5cc9333af6b14eb433dbdc99
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/5106
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2026-02-15 18:15:20 +00:00
Antonio Borneo
3c1bd50217 target: clean up return value of target_type::blank_check_memory()
The functions in struct target_type::blank_check_memory() return
either an OpenOCD error or a positive value that indicates the
number of blocks checked.

To prevent the mix of error codes and returned values, return the
value through an additional parameter 'checked' and then return
ERROR_OK.

While there:
- change to unsigned int the parameter 'num_blocks';
- in armv7m_blank_check_memory() verify that the working area can
  contain at least two 'algo_block'.

Change-Id: Ie22f5816819bc77ec611c3f251373d026ed9f784
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9386
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2026-02-15 18:14:12 +00:00
Antonio Borneo
5151c98455 flash: virtual: simplify error checking
Return directly the error code returned by last called function
instead of handling it.

Change-Id: I967deb348db535de1972056021484f0e7f32df1c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9385
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
2026-02-15 18:13:48 +00:00
Mikhail Iakhiaev
6eaf951b20 flash/nor/mspm0.c: support new parts
Added support for the following parts:
* MSPM0Gx51x, datasheet:
Link: https://www.ti.com/lit/ds/symlink/mspm0g3518.pdf#page=101

* MSPM0G351x-Q1, datasheet:
Link: https://www.ti.com/lit/ds/symlink/mspm0g3518-q1.pdf#page=99

* MSPM0G3529-Q1, datasheet:
Link: https://www.ti.com/lit/ds/symlink/mspm0g3529-q1.pdf#page=92

* MSPM0G5187, datasheet:
Link: https://www.ti.com/lit/ds/symlink/mspm0g5187.pdf#page=87

Note, these parts have different "part_num" values than
the pre-existing MSPM0G parts listed in this file.

Tested by successfully programming (and verifying) an image
onto LP-MSPM0G3519 development board.

Change-Id: I15f3b368f5307661a32953074768ba810412cf0a
Signed-off-by: Mikhail Iakhiaev <iakhiaev@google.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9418
Tested-by: jenkins
Reviewed-by: Nishanth Menon <nm@ti.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2026-02-15 08:10:45 +00:00
Mikhail Iakhiaev
1967f85548 flash/nor/mspm0.c: add parts.
1. Added some missing variants for MSPM0G110x and MSPM0G150x parts.

2. Corrected the variant number for "MSPM0G1106TRHBR", according to
   datasheet:
Link: https://www.ti.com/lit/ds/symlink/mspm0g1106.pdf#page=68

3. Added MSPM0G350x-Q1 devices. Datasheet:
Link: https://www.ti.com/lit/ds/symlink/mspm0g3507-q1.pdf#page=77

Change-Id: Id4a14b284a5d032d140d695674d1912cbe87d7f6
Signed-off-by: Mikhail Iakhiaev <iakhiaev@google.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9417
Tested-by: jenkins
Reviewed-by: Nishanth Menon <nm@ti.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2026-02-15 08:10:36 +00:00
Mikhail Iakhiaev
0f67341e15 flash/nor/mspm0.c: remove MSPM0G3505TDGS28R
Neither "MSPM0G3505TDGS28R" nor its variant number 0xdf is
listed in the MSPM0G3505 datasheet (likely removed):
Link: https://www.ti.com/lit/ds/symlink/mspm0g3505.pdf#page=75

Change-Id: I3828744a91477b3e3fd164055aa0fe068483f87d
Signed-off-by: Mikhail Iakhiaev <iakhiaev@google.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9420
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Nishanth Menon <nm@ti.com>
2026-02-15 08:10:24 +00:00
Mikhail Iakhiaev
eaa04836dc flash/nor/mspm0.c: organize parts
1. Added comments like /* MSPM0G310x-Q1 */ to the parts table
based on the datasheet the parts came from.

2. Sorted the MSPM0G310x-Q1 device lines alphabetically: this is
how all other MSPM0G parts are organized.

Change-Id: I90d0f44289a538667c4ad0f23d44581f3c65d0c8
Signed-off-by: Mikhail Iakhiaev <iakhiaev@google.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9419
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Nishanth Menon <nm@ti.com>
2026-02-15 08:10:07 +00:00
Gennaro Tortone
b4518ab78b flash/nor/spi: Add Boya-Micro BY25Q128AS and Byte-Semi BY25Q16ES flash
- Boya-Micro BY25Q128AS: 16 MB
- Byte-Semi BY25Q16ES: 2MB

Change-Id: Ib3caee62abc34f92321425d9427054b6a9b6ec66
Signed-off-by: Gennaro Tortone <gtortone@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9412
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2026-02-06 15:34:55 +00:00
Grant Ramsay
db34f6f0a7 target: arm_dap: Fix crash in 'dap info' command
The 'dap info' command was not checking that the target was
an ARM before dereferencing the `arm` pointer. This would
cause a crash if the current target was (say) a mem_ap.

Add 'target_to_dap' function to safely get the dap

Change-Id: I0c765f915f2ef7b9a7d20c934e144559ca4e5f1c
Signed-off-by: Grant Ramsay <grant.ramsay@hotmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8415
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2026-02-01 15:00:24 +00:00
Antonio Borneo
92b482af50 log: change line counter to unsigned
The incremental counter of logged lines is a signed int.

Change it to unsigned, since negative values has no sense in this
context.

Change-Id: Ia75f9ca038bba385c5f88fb9fa368faaf055f9a3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9401
Reviewed-by: R. Diez <rdiez-2006@rd10.de>
Tested-by: jenkins
2026-02-01 14:59:59 +00:00
Antonio Borneo
95bd9093b1 target: cortex-m: defer cache identification on Cortex-M85 under reset
Like for Cortex-M7, also Cortex-M85 prevents detecting the cache
properties when the CPU is kept under reset.

Extend to Cortex-M85 the same deferred mechanism already in place
for Cortex-M7.

Change-Id: Id274bb6c0b46c568554eed9671ef690c34cf7cfa
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9397
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Marc Schink <dev@zapb.de>
2026-02-01 14:59:15 +00:00
R. Diez
294538f0d4 configure.ac: Detect mallinfo automatically
Previously, configure.ac only checked whether glibc was available,
but other C runtime libraries like Newlib have mallinfo too.

This is a first step to remove configuration option --enable-malloc-logging
and replace it with a debug level configurable at runtime.

Change-Id: If30fc98a84158459e222fddf08043f46d6fa4112
Signed-off-by: R. Diez <rdiez-2006@rd10.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9394
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2026-02-01 14:58:57 +00:00
Antonio Borneo
5e7182368e server: close the TCP socket while stopping a service
The function free_service() does not close the TCL socket when the
service is shutdown.

Add the necessarily code.

Change-Id: I58c5c4fee3111949fcc143c6226522c29d976493
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9376
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2026-02-01 14:51:20 +00:00
Antonio Borneo
00e4fb653d target: openrisc: jsp_server: check for out of memory, fix memory leak
During JSP service start, check that memory is properly allocated
and if add_service() fails release the allocated memory.

Change-Id: I7eb2ea8a10dbeccd27fd39485080552c5d0736d3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9375
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2026-02-01 14:51:09 +00:00
Antonio Borneo
b10372f0d2 server: gdb_server: check for out of memory and fix a memory leak
During GDB service start, check that memory is properly allocated
and if add_service() fails release the allocated memory.

While there, modify the code following the coding style.

Change-Id: Iebd1481a82f7391c110c5f6ad9878ba4abf052b3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9374
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2026-02-01 14:50:58 +00:00
Antonio Borneo
70d4ac0395 target: arm_tpiu_swo: fix memory leak on add_service() failure
When add_service() fails, the caller has to free() the private
data.

Add the missing free().

Change-Id: I998782ad3a2612dd289e269e889a3c6912fd8461
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9373
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2026-02-01 14:50:38 +00:00
Antonio Borneo
f275432b27 server: fix double free() on add_service() early return
The function add_service() can return on error when cannot create
the new service. In this case the caller cannot assume that the
parameter 'priv' has been taken in consideration and it should
take care of free() it.
To avoid a double free(), add_service() should not free() the
parameter 'priv' if it exits with error.

Replace the call to free_service() with a dedicated exit path on
error.

Change-Id: I340ec3ee46f471f31170c6717ed74fb632f0da20
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Karl Palsson <karlp@tweak.au>
Fixes: 171454fffa ("server: fix a new double free()")
Fixes: 5ff384be08 ("semihosting: fix memory leak and double free")
Reviewed-on: https://review.openocd.org/c/openocd/+/9372
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2026-02-01 14:50:13 +00:00
HAOUES Ahmed
b9e4016161 flash/stm32l4x: Fix flash size address for STM32WBA5
Update fsize_addr parameter to reference non-secure memory address

Change-Id: I5098f478169bfaac726b96b071b99ca63d25d531
Signed-off-by: HAOUES Ahmed <ahmed.haoues@st.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9357
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-01-25 09:29:05 +00:00
HAOUES Ahmed
eea1bb4d30 flash: nor: keep Windows backslashes in flash list output
Wrap the name field in braces when formatting the flash list Tcl structure
so that Tcl does not interpret backslash escape sequences.
This ensures Windows paths are preserved verbatim in the output and
can be reliably matched in Tcl scripts.

Fixes: 80fc9fabc6 ("flash: nor: rewrite command 'flash list' as COMMAND_HANDLER")
Change-Id: Ibd0a4b292828f084122e4a02732dc69ac0885f3c
Signed-off-by: HAOUES Ahmed <ahmed.haoues@st.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9360
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-01-25 09:28:21 +00:00
R. Diez
c60bb56bb6 log: avoid incrementing 'count' for discarded log lines
This matches the behaviour of code which calls LOG_DEBUG_IO etc. instead.

Change-Id: I7679f0fc67222f947a4d0f1d53aa627a186ebcd3
Signed-off-by: R. Diez <rdiez-2006@rd10.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9318
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-01-25 09:27:30 +00:00
Marc Schink
f36ab02a80 tcl/target: Move GigaDevice configs into vendor directory
Move the configuration files into a dedicated vendor folder as required
by the developer guidelines.

Change-Id: I9ed39e32b6281a9cb8510914690f3f7751b795c8
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9271
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-01-25 09:26:39 +00:00
Marc Schink
60d11a881f adapter/jlink: Use new log level for adapter I/O
Use the new adapter I/O log level to more easily distinguish
adapter I/O messages from other debug messages.

Change-Id: Ib3aa2bf84871c038aef937452cfeb28de232d821
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9387
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2026-01-18 22:46:20 +00:00
R. Diez
ea9afa9e3e configure.ac: Replace --enable-verbose-usb-comms with a new runtime log level.
--enable-verbose actually did the same as --enable-verbose-usb-comms,
so the new code replaces it too.

Change-Id: I1d1ddd5d681009663e0c52a75ad76fe71dbc172a
Signed-off-by: R. Diez <rdiez-2006@rd10.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9281
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
2026-01-18 22:46:06 +00:00
Antonio Borneo
50fdce21a0 jep106: update to revision JEP106BN Jan 2026
Update to latest available document.

Change-Id: Iff4a3bc21394d72a5bb4754c62a0f5fdc4e5e78c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9383
Tested-by: jenkins
2026-01-18 22:45:40 +00:00
Guillaume Faussard
df14f58662 flash/stm32l4x: support STM32WBA6xx devices
STM32WBA6xx support, based on ST Reference Manual RM0515 Rev 4.

Change-Id: I0ddeadd5008a9f81ec638c9ad230b2f6f0349b5a
Signed-off-by: Guillaume Faussard <guillaume.faussard@withings.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9329
Reviewed-by: Ahmed Haoues <ahmed.haoues@st.com>
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-01-18 22:36:21 +00:00
Guillaume Faussard
b074fea079 tcl/target/stm32wba5x: Fix wrong addresses
According to ST Reference Manual RM093	Rev 7:
- OTP is 0x0BF90000
  2.3.2 Memory map and register boundary addresses, page 84
- DBGMCU registers starts at 0xE0044000
  43.5.1 System debug ROM table, page 1736

Change-Id: I735c6184d9f3fd767d9d776b238e88fcfbe8cc8d
Signed-off-by: Guillaume Faussard <guillaume.faussard@withings.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9328
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Ahmed Haoues <ahmed.haoues@st.com>
2026-01-18 22:36:07 +00:00
HAOUES Ahmed
89ded3d2f0 flash/bluenrg-x: Support STM32WL33 AKA Spirit3
This device has a flash size up to 256 Kb with page size equal to 2 Kb

Change-Id: I2e284e9cd1d5be7df491a2fe2c9d11ce99c81d73
Signed-off-by: HAOUES Ahmed <ahmed.haoues@st.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9354
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-01-18 22:29:47 +00:00
HAOUES Ahmed
2389c28ea8 flash/bluenrg-x: implement flash bank deallocation with simple alloc
All drivers which simply allocate one driver_priv memory block
per each bank now use default_flash_free_driver_priv()

Change-Id: Id998013332fe29d6882004a0ff897464dd4dccbc
Signed-off-by: HAOUES Ahmed <ahmed.haoues@st.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9353
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-01-18 22:29:41 +00:00
Samuel Obuch
28eb4c37b9 target/xtensa: fix memory leaks in reg_cache
There are two allocated fields that are never freed,
contiguous_regs_desc and contiguous_regs_list.
Additionally, prevent memory leaks and invalid accesses
when xtregs command is called repeatedly.

Change-Id: Id6ab4a2565ddb19e1e9d3f1c3b822182b3a6fb9d
Signed-off-by: Samuel Obuch <samuel.obuch@espressif.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9113
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Ian Thompson <ianst+cdns@cadence.com>
2026-01-18 22:29:06 +00:00
Igor Cudnik
74d0cff2fe flash: nor: stm32f2x: add NULL check for stm32x_info
This commit prevents NULL dereference during malloc
failure on stm32x bank command.

Change-Id: Ib348a1863aee5f8ed9d1699d203cdc4c83557628
Signed-off-by: Igor Cudnik <igor@its.rel.pl>
Reviewed-on: https://review.openocd.org/c/openocd/+/9379
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2026-01-13 08:27:15 +00:00
Tomas Vanek
8bd25e0329 flash/nor: do not report error as unknown
The command "flash erase_check" reported any error code from
flash driver erase_check method as "unknown" despite the error
is usually described in a log message from the flash driver layer.
E.g.:

Error: Target not halted
unknown error when checking erase state of flash bank #0 at 0x00000000

Reword the message not to mislead user.

Change-Id: Ica768fa2924c107fa36d0f654d2c3149aa608dc4
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9331
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-01-11 18:20:18 +00:00
Lucien Dufour
daaf48b96f target/armv4_5: drop goto and label
Drop the jumps to the label and the label.

Change-Id: I4e20684b06af09dcd749ae520e299c79ce67b467
Signed-off-by: Lucien Dufour <lucien.buchmann@dufour.aero>
Reviewed-on: https://review.openocd.org/c/openocd/+/9292
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2026-01-11 18:18:53 +00:00
Antonio Borneo
58eb7e31a6 helper: log: document the last user of hack in alloc_vprintf()
Apparently the last user of the hack in alloc_vprintf() is the
code in log_vprintf_lf().

Document it for future rework.

Change-Id: I6b69f8b7f3feb93e5daa9649c4122ec12e22d84f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9317
Tested-by: jenkins
2026-01-11 18:15:28 +00:00
Antonio Borneo
cb6b803947 helper: command: assert on command_print() with no command_invocation
Commit 7f260f5009 ("helper/command: Handle Tcl return values
consistently") allows calling command_print with the first
parameter set to NULL.
This should not be allowed.
I cannot identify any part of OpenOCD that calls a command that in
turn calls command_print() with NULL command_invocation.
Adding
	__attribute__((nonnull (1, 2)))
to the prototype of the functions does not trigger any positive
with GCC and scan-build.

Add an assert to detect such corner cases.
This change is kept small and self contained to allow reverting it
easily if a real use case is identified.

Change-Id: I8aa6e5c0c341e818c0327eaa0d2bd5b6304c93b8
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9091
Tested-by: jenkins
2026-01-11 18:15:20 +00:00
Antonio Borneo
1dedd6918b helper: command: rewrite common command_print()
Avoid code duplication by merging command_print() and
command_print_sameline().

Detect the allocation error, keep track of it and let the command
return error.

Add a FIXME as the functions should always have 'cmd' properly
set. Should this be an assert()?

Change-Id: Iff704c42969a7ca9ea884520942adecd40bebbd6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9090
Tested-by: jenkins
2026-01-11 18:14:54 +00:00
Antonio Borneo
6420e83aff helper: command: rewrite command_print() dropping jimtcl strings
Rewrite the function command_print() without using any specific
API from jimtcl for string manipulation.

Change-Id: I1adddd493b43e30ead26e96da09a4ee8c0a41307
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9076
Reviewed-by: Evgeniy Naydanov <eugnay@gmail.com>
Tested-by: jenkins
2026-01-11 18:14:06 +00:00
Antonio Borneo
e39ae004b0 target: cortex_a: support read and write watchpoints
The current code for cortex_a watchpoint sets the field DBGWCR:LSC
to '3', that corresponds to 'access' watchpoint.
Thus, any 'r' or 'w' watchpoint is considered to 'a'.

Convert the enum watchpoint_rw to the corresponding values for the
field DBGWCR:LSC.

Change-Id: Iccfddb3e34f3f26927983f3b00d9d5f81b06eb21
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9291
Tested-by: jenkins
2026-01-11 18:13:54 +00:00
Tomas Vanek
0eecf4d21d target/aarch64: fix last_run_control_op on SMP
aarch64_resume() set the last_run_control_op on the current core
only and left last_run_control_op as is on the rest of the SMP group.
It caused semihosting call on other cores to stop because
last_run_control_op sticked on ARMV8_RUNCONTROL_STEP

Set last_run_control_op to ARMV8_RUNCONTROL_RESUME on all cores
in the SMP group.

Change-Id: I55a97bb1f7ea25bfc5937c3cc846532cdf390064
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9247
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2026-01-11 18:09:10 +00:00
Tomas Vanek
c2fdc38d32 target/aarch64: fix semihosting on SMP
Semihosting worked only on the first/gdb assigned core of a SMP group.
If a semihosting call was issued on another core, aarch64_update_halt_gdb()
emitted 'halted' event on core0 before semihosting decoding started.

Use target's smp_halt_event_postponed flag to keep events from emitting
until semihosting is decoded. If a semihosting call is confirmed,
clear flags and do not send 'halted' event for any core of SMP group.

Change-Id: Ie7eff7e493c2a4df3039f49fce1744d996050a59
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9246
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2026-01-11 18:09:00 +00:00
Tomas Vanek
1ca34e23c0 target/aarch64: improve handling recursion in SMP halt
update_halt_gdb() called aarch64_poll() recursively with temporary
switching target's smp flag off to prevent deeper recursion.
This was not possible for gdb assigned target or hwthread failed
with "SMP node change, disconnect GDB from core/thread".
Therefore the aarch64_poll(gdb_target) resulted in the useless
recursion back to update_halt_gdb().

Introduce aarch64_poll_smp() with smp parameter to avoid
update_halt_gdb() recursion properly and without fiddling
with target's smp flags.

While on it, add 'aarch64_' prefix to update_halt_gdb() function.

Change-Id: I645166f50c106f4a6d4d35dc70ad49041d2442aa
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9245
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2026-01-11 18:08:48 +00:00
Tomas Vanek
5dad8a59d8 target/cortex_m: fix segfault on setting HW BP on not examined target
Check cortex_m->fp_comparator_list and if NULL log and return error.

Change-Id: Icf53f1bbc60de3486a285ef1f16bb98a5596913b
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9182
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-01-11 16:35:39 +00:00
Tomas Vanek
7f8eec108b target/cortex_m, hla_target: implement memory_ready() test
Allow memory access as soon as debug_ap is initiated.
This resolves chicken - egg problem in cortex_m_examine():
examined flag had to be set at the start of examination
to allow memory access during examination.

hla_target has memory ready to access as soon as the adapter
is initialized so we can simply return true.

Change-Id: I30b8bcb8c43775ebbd8e677da09189781bebb4ab
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9179
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2026-01-11 16:35:19 +00:00
Tomas Vanek
ba12fb9b95 target: introduce target_memory_ready() test
Use the new test in target memory access functions
instead of target_was_examined()

Drop the test from target_read/write_u8/16/32/64() helpers
as they directly call a memory access function which does
the test again.

Change-Id: Ic1753e461d2a4b91ce3a3e1bf3e86eb2be743d46
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9178
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-01-11 16:35:06 +00:00
Tomas Vanek
7025e3fe3d target/armv8: do not mark ELx banked regs as save-restore
GDB uses this mark when creating a dummy frame for
manual call of a function by GDB command.

With the original setting of all registers as caller_save = true
GDB inferior call fails in EL2H mode with the message
Could not fetch register "ELR_EL3"; remote failure reply '0E'

It also fails similarly in EL0 and EL1 modes.

A standard function should not change EL banked registers anyway.
Avoid marking ELx banked registers as save-restore.

Treat pauth_dmask and pauth_cmask registers similarly.
They are not typically changed in a function.

Change-Id: Ibaf32210f3fcfa9dfb15e924b888243460e85fb4
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9243
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-01-06 08:00:10 +00:00
Samuel Obuch
ad0ed194f5 target/riscv: fix riscv exec_progbuf for SMP targets
Currently, 'riscv exec_progbuf' command does not select active target.
So with multiple harts with a common debug module, program buffer may
be executed on an incorrect target.

Change-Id: Ic345b09b039c2b1e37e5b99a8534833ac2723277
Signed-off-by: Samuel Obuch <samuel.obuch@espressif.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9312
Tested-by: jenkins
Reviewed-by: Evgeniy Naydanov <eugnay@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2026-01-06 07:59:34 +00:00
HAOUES Ahmed
67153cf3d5 flash/stm32l4x: Fix permanent write protection on STM32WBA5
STM32WBA5 has an UNLOCK bit in FLASH_WRPAR and FLASH_WRPBR registers

Change-Id: I4b8fe4aaa9cd336f07aaf5bad0c44834ead70499
Signed-off-by: HAOUES Ahmed <ahmed.haoues@st.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9358
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2026-01-02 14:35:54 +00:00
Tomas Vanek
4593222e85 target: rework target_checksum_memory()
Commit d7142a5727 ("target/target: Check checksum_memory
before call") added the error return if target's checksum_memory()
method is not implemented however the slow path with read buffer and
image_calculate_checksum() should be used instead.

Also the code fragment commented as /* convert to target endianness */
is a pure nonsense - it does not convert anything. Drop the conversion
loop.

Change-Id: I804605d31310698445b3ffb5e3fcad1fc43a5579
Suggested-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9242
Reviewed-by: Evgeniy Naydanov <eugnay@gmail.com>
Tested-by: jenkins
2025-12-29 11:55:17 +00:00
Marek Kraus
df2eb07086 flash/nor/bl602: add bl602 flash driver
Initial release of Flash bank driver for Bouffalo chips.
The driver currently supports BL602, BL702, BL702L series of chips.
Similar SFlash core is inside of BL808, BL606P and BL616 series,
so those might be supported in future as well.

With adapter speed set to 8000, it can reach speed 140 KiB/s.

Since chips have eXecute In Place support, and they also require
boot config in Flash at offset 0x0, it's required to have properly
crafted linker script, so OpenOCD knows where to write firmware
through gdb.

There is required flash bank parameter, which specifies the chip type.
This is required because BL702 and BL702L have same TAP ID CODE, and
there are no usable indicators to use for automatic chip type
recognition in the chip.

Change-Id: Id57336d447be3c608b39ba3ed143527bfdc0af98
Signed-off-by: Marek Kraus <gamelaster@outlook.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8527
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2025-12-29 11:55:01 +00:00
Evgeniy Naydanov
21e345a2f7 target/riscv: tcl/target: move the WA for GD32VF103 to Tcl
The GD32VF103 has a perculiar reset procedure that does not fully comply
with the RISC-V Debug Specification.
Move the workaroung to the `deassert-reset-post` handler.

Change-Id: I153c866a5b7e2dff2552cc92772ce6ed77ad606b
Signed-off-by: Evgeniy Naydanov <eugnay@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9314
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2025-12-29 11:54:03 +00:00