Commit Graph

11316 Commits

Author SHA1 Message Date
Mark O'Donovan
0e41ac862d pld/gatemate: move pointer deref after NULL check
Move pointer deref after NULL check.
Found by cppcheck.

Change-Id: Ifdf40046cb1b03dbe7f445660b3349deae788e7b
Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed-on: https://review.openocd.org/c/openocd/+/9499
Reviewed-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2026-04-06 16:22:52 +00:00
Mark O'Donovan
b215fe8621 jtag/drivers/presto: fix potential divide by 0
Found by cppcheck.

Change-Id: I656685eb3b639dc054c3a563203264e03d72d1c7
Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed-on: https://review.openocd.org/c/openocd/+/9498
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-04-06 16:22:40 +00:00
Mark O'Donovan
92dc88978a flash/nor/str7x: fix undefined behaviour
Shifting 32 bit signed variables by 31 bits is undefined behaviour

Change-Id: Iec61a98eecd6657ff6ba1dcad6fff76052c917e3
Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed-on: https://review.openocd.org/c/openocd/+/9497
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-04-06 16:22:28 +00:00
Mark O'Donovan
4e23bf155f flash/nand/core: remove redundant NULL check
The value p can never be NULL here.
Found by cppcheck.

Change-Id: I2947b46e714c365021a945705f71d099168d30f4
Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed-on: https://review.openocd.org/c/openocd/+/9496
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-04-06 16:22:07 +00:00
Marc Schink
e4c49d8605 server/server: Fix build on FreeBSD
On FreeBSD, sig_atomic_t is of type 'long' rather than 'int'. Remove
the assert() instead of replacing it with a more complex, size-agnostic
check that would handle both 'int' and 'long'. Since the signal number
comes from the operating system, an explicit range check is unnecessary.

Checkpatch-ignore: COMMIT_LOG_LONG_LINE

Build error on FreeBSD:

../src/server/server.c:616:39: error: result of comparison of constant 9223372036854775807 with expression of type 'int' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
  616 |                 assert(sig >= SIG_ATOMIC_MIN && sig <= SIG_ATOMIC_MAX);
      |                                                 ~~~ ^  ~~~~~~~~~~~~~~
/usr/include/assert.h:55:21: note: expanded from macro 'assert'
   55 | #define assert(e)       ((e) ? (void)0 : __assert(__func__, __FILE__, \
      |                           ^
../src/server/server.c:616:14: error: result of comparison of constant -9223372036854775808 with expression of type 'int' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
  616 |                 assert(sig >= SIG_ATOMIC_MIN && sig <= SIG_ATOMIC_MAX);
      |                        ~~~ ^  ~~~~~~~~~~~~~~
/usr/include/assert.h:55:21: note: expanded from macro 'assert'
   55 | #define assert(e)       ((e) ? (void)0 : __assert(__func__, __FILE__, \

Change-Id: I6cf9242ab8206184bff9390ef0245843261656bd
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9477
Reviewed-by: Anatoly P <kupokupokupopo@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2026-03-08 10:25:35 +00:00
Cristian Dinca
22e1e1b33e target/smp: reply to unknown packets in gdb_read_smp_packet
Some clients probe or use SMP-related 'j' packets. If OpenOCD
received an unknown 'j' packet, gdb_read_smp_packet previously did
not send any reply. This may result cause the client to hang while
waiting for a response.

Send an empty reply packet for unsupported 'j' packets.

Change-Id: I84c5e8e99f946d41dd5c11163c3eeb8af2b6c90f
Signed-off-by: Cristian Dinca <hello@icmd.tech>
Reviewed-on: https://review.openocd.org/c/openocd/+/9461
Tested-by: jenkins
Reviewed-by: Evgeniy Naydanov <eugnay@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-03-08 10:21:55 +00:00
Marc Schink
092282c7d2 tools/checkpatch: Add Markdown linter support
Use 'pymarkdownlnt' to lint Markdown files and enforce a strict style.
If the linter is not found, a single error message is printed and the
Markdown checks are skipped.

Example checkpatch output (line breaks added for commit message only):

ERROR:MARKDOWN_LINT: ./README.md:1:1: MD041: First line in file should
be a top level heading (first-line-heading,first-line-h1)

ERROR:MARKDOWN_LINT: ./README.md:272:1: MD012: Multiple consecutive
blank lines [Expected: 1, Actual: 4] (no-multiple-blanks)

ERROR:MARKDOWN_LINT: ./README.md:273:35: MD026: Trailing punctuation
present in heading text. (no-trailing-punctuation)

Change-Id: I460ef881b83eb0a2eb46ee62d520b514785ad4e1
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9474
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-03-08 10:21:21 +00:00
Antonio Borneo
c3b4bcc6e6 log: simplify handling of mallinfo()
Simplify the use of C preprocessor conditionals by adding a new
function get_free_memory_space().

Change-Id: I795bd13284d06844f976a5264ca4d54ad887983c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9463
Reviewed-by: R. Diez <rdiez-2006@rd10.de>
Tested-by: jenkins
2026-03-08 10:20:25 +00:00
Antonio Borneo
a5a9121ad6 target: stm32mpxxx: fix return to SWD after reset
A target reset can cause a power cycle, causing the DAP to switch
from SWD to JTAG. The adapter can loose the connection because it
keeps using SWD, triggering error messages.
While some ST-Link FW can automatically reconnect the lost SWD
connection, this is not possible with older FW nor with other
adapters.

Force a DAP initialization after reset to eventually switch it
back to SWD.

Change-Id: I29ea49d2d5ee013ad33371265fd6996353f391d6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9462
Tested-by: jenkins
2026-03-08 10:18:36 +00:00
Antonio Borneo
687dd5c5df flash: nor: improve check on memory allocations
Add check for failed allocation.
Add warning for memory allocation fallback and change existing log
from user to more appropriate warning and debug.
Move allocation and check before changing flash information.

Change-Id: I5b2ab6bc12ea15a5d8f634ed00cf0a0bc7e5a517
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9384
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Marc Schink <dev@zapb.de>
2026-03-08 10:15:08 +00:00
Jan Matyas
0c6fe74351 server: Make "exit" command behave consistently
Before this fix, the "exit" command behaved differently
depending on where it was called from:

- "exit" in a telnet session: Session disconnected.
- "exit" in a Tcl session: Empty response sent but the
  session remained connected.
- "exit" in a script (outside of Telnet or Tcl): OpenOCD
  exited with code 0. Based on the help and documentation
  "exit" was apparently not intended for these cases.
  What's more, if "exit" is allowed in Tcl scripts,
  user may confuse it with the Tcl's native "exit"
  command that is not available in OpenOCD (it is
  shadowed with this OpenOCD's "exit" command).

This fix makes the behavior of "exit" consistent:

- "exit" in a telnet session: Session disconnected
  (no change).
- "exit" in a Tcl session: Session disconnected
  (same as for telnet).
- "exit" in a script: Notify the user that "exit"
  is deprecated outside of telnet/tcl but
  still shut down OpenOCD (to preserve the original
  behavior).

Update the documentation to make it very clear to users
when to use "exit" vs. "shutdown".

Change-Id: I790495330e1fa705b34097a1347fdc57aaa86de1
Signed-off-by: Jan Matyas <jan.matyas@codasip.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9380
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2026-03-08 10:13:45 +00:00
Tomas Vanek
5b3db97c42 tcl/target/nordic/nrf53: fix empty event handler
reset-assert of network CPU should be handled by empty dummy handler
to prevent the Cortex-M target native processing. Unfortunately configuring
the empty string does not define a new handler, it drops the existing one.

Use semicolon to fix configuration and to make the emtpy handler
clearly visible.

Fixes: commit 17be341d38 ("tcl/target: add nRF53 and nRF91 config files")
Reported-by: Lawrence King <lawrencek52@gmail.com>
Change-Id: I3bd229a78860ed05d694e708ab62cb1670a77010
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9492
Tested-by: jenkins
Reviewed-by: Lawrence King <lawrencek52@gmail.com>
2026-03-05 21:31:20 +00:00
Tomas Vanek
84f8814003 target/arm_adi_v5: search for multiple AP types much more effective way
Cortex-M debug AP could be on AHB3 or AHB5.
Finding AHB3 is fast as AP usually has a low address.
On the other hand, finding AP on the AHB5 equipped device is weird
without this patch. cortex_m_find_mem_ap()
first tries to read IDR from all possible 256 ADIv5 APs and checks
for AHB3 ID and if that fails, starts over and search for AHB5.
It takes long time (74 msec on fast USB HS based STLINK V3J15M7)
and logs lot of rubbish:

Debug: 168 117  target_examine_one(): [stm32u3x.cpu] Examination started
Debug: 169 117  target_call_event_callbacks(): event 19 (examine-start)
Debug: 170 117 arm_adi_v5.c:1201 dap_get_ap(): refcount AP#0x0 get 1
Debug: 171 118 arm_adi_v5.c:1226 dap_put_ap(): refcount AP#0x0 put 0
Debug: 172 118 arm_adi_v5.c:1201 dap_get_ap(): refcount AP#0x1 get 1
Debug: 173 118 arm_adi_v5.c:1226 dap_put_ap(): refcount AP#0x1 put 0
Debug: 174 118 arm_adi_v5.c:1201 dap_get_ap(): refcount AP#0x2 get 1
Debug: 175 119 arm_adi_v5.c:1226 dap_put_ap(): refcount AP#0x2 put 0
...
Debug: 188 123 arm_adi_v5.c:1201 dap_get_ap(): refcount AP#0x9 get 1
Debug: 189 123  stlink_usb_error_check(): STLINK_BAD_AP_ERROR
Debug: 190 123 arm_adi_v5.c:1226 dap_put_ap(): refcount AP#0x9 put 0
Debug: 191 123 arm_adi_v5.c:1201 dap_get_ap(): refcount AP#0xa get 1
Debug: 192 123  stlink_usb_error_check(): STLINK_BAD_AP_ERROR
Debug: 193 123 arm_adi_v5.c:1226 dap_put_ap(): refcount AP#0xa put 0
...
Debug: 926 190 arm_adi_v5.c:1201 dap_get_ap(): refcount AP#0xff get 1
Debug: 927 191  stlink_usb_error_check(): STLINK_BAD_AP_ERROR
Debug: 928 191 arm_adi_v5.c:1226 dap_put_ap(): refcount AP#0xff put 0
Debug: 929 191 arm_adi_v5.c:1154 dap_find_get_ap(): No MEM-AP AHB3 found
Debug: 930 191 arm_adi_v5.c:1201 dap_get_ap(): refcount AP#0x0 get 1
Debug: 931 191 arm_adi_v5.c:1144 dap_find_get_ap(): Found MEM-AP AHB5
 at AP index: 0 (IDR=0x14770015)

Introduce dap_find_by_types_get_ap() to search for the array of AP IDs.

With the patch cortex_m_find_mem_ap() succeeds immediately:

Debug: 168 118  target_examine_one(): [stm32u3x.cpu] Examination started
Debug: 169 118  target_call_event_callbacks(): event 19 (examine-start)
Debug: 170 118 arm_adi_v5.c:1222 dap_get_ap(): refcount AP#0x0 get 1
Debug: 171 118 arm_adi_v5.c:1150 dap_find_by_types_get_ap(): Found MEM-AP
 AHB5 at AP index: 0 (IDR=0x14770015)

Change-Id: Iabcfa1fd64a48febb0f759a213f15d69621ea5cf
Fixes: commit 0d47d85ff5 ("target/cortex_m: Add support for AHB5-AP")
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9439
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
2026-03-01 19:42:39 +00:00
Marc Schink
7052573187 server/gdb: Add support for NVM banks without sectors
This is necessary for non-flash NVM which does not have the concept of
sectors, such as RRAM. Also small flash memory regions without sectors,
such as configuration areas, can now be exposed to GDB.

Tested with nRF54L15-DK, tested for regression with AT32F421C8T7.

Change-Id: Ifc96ddca7dcfcd4ab17683c0e59f1be912901941
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9290
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2026-02-27 16:16:25 +00:00
R. Diez
129e9d3005 configure.ac: Replace --enable-malloc-logging with a new runtime log level.
About why the new log level LOG_LVL_DEBUG_USB has the same value a
LOG_LVL_DEBUG_MALLOC, see the mailing list discussion starting here:
Replacing --enable-verbose-usb-comms in configure.ac
https://sourceforge.net/p/openocd/mailman/message/59215751/

Other minor fixes included here which are probably
not worth submmitting in separate patches:
- In error message "level must be between -3 and 4", increase 4 to 5.
- LOG_DEBUG_IO was passing LOG_LVL_DEBUG instead of LOG_LVL_DEBUG_IO.

Change-Id: I71440bbabe4785338c0a27562cc76fa1b7d54bf5
Signed-off-by: R. Diez <rdiez-2006@rd10.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9432
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-02-15 18:24:28 +00:00
Antonio Borneo
aaceff81f0 configure: silent MacOS clang warning gnu-folding-constant
On the specific fork of clang for MacOS, the compiler gets more
strict on the use of GNU folding constants, generating warnings
that halts the build of OpenOCD.
The GNU folding constants are highlighted by upstream clang only
for global variables. E.g.:
	const int len = 10;
	int array[len];
generates the warning on:
	clang -c x.c
	x.c:2:5: warning: variable length array folded to constant
		 array as an extension [-Wgnu-folding-constant]
	int array[len];
	    ^
Apparently only the MacOS fork generates warning for folded
constants inside a function. E.g.:
	int a(int *x);
	int b(void)
	{
		const int len = 10;
		int array[len];
		return a*array);
	}
does not return error even forcing -Wgnu-folding-constant on clang
upstream.

Current code triggers warning on the following lines due to the
size of the array being computed from a const variable:
	jtag/drivers/xds110.c:354         unsigned char data[max_data + 1];
	flash/nor/dw-spi.c:950            uint8_t buffer[buffer_size];
	flash/nor/dw-spi.c:980            uint8_t buffer[buffer_size];
	flash/nor/dw-spi.c:1034           uint8_t buffer[buffer_size];
	flash/nor/dw-spi.c:1065           uint8_t buffer[buffer_size];
	flash/nor/jtagspi.c:364           uint8_t ..., write_buffer[max], ...;
	flash/nor/stmqspi.c:778           char ..., output[(2 + max + 256) * 3 + 8];
	flash/nor/xcf.c:392               uint8_t reference[L];
	target/target.c:3303              char output[line_bytecnt * 4 + 1];
	target/semihosting_common.c:1787  char buf[buf_len];
	target/smp.c:59                   char hex_buffer[len * 2 + 1];
	target/smp.c:60                   uint8_t buffer[len];
	target/cortex_m.c:296             uint32_t r_vals[n_r32];
	target/cortex_m.c:297             uint32_t dhcsr[n_r32];
	target/x86_32_common.c:1337       char output[line_bytecnt * 4 + 1];
	target/riscv/riscv.c:2377         uint8_t buffer[length];
	target/xtensa/xtensa.c:536        uint8_t ops_padded[max_oplen];

While some of the const variable above could be replaced by macros,
for the majority of them I don't see such need, and the use of
const looks to me correct.

Silent the warning adding the clang flag -Wno-gnu-folding-constant.
The flag is not recognized by GCC, but it's silently ignored.

Change-Id: I1d452af115355bc4949b1616648fe6544cc48318
Reported-by: Frank Zeyda <frank.zeyda@gmail.com>
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9431
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
2026-02-15 18:23:30 +00:00
Antonio Borneo
9e1db0e8c7 transport: don't warn when a transport is selected twice
Selecting the same transport is not an issue.
Move the warning message to debug level.

Change-Id: I52a7fffeb08a5aa6ee8a72af6b740f7e0fbe5b27
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9428
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2026-02-15 18:22:34 +00:00
Antonio Borneo
22bad00b9b target: stm32u0x: add transport swd
The STM32U0xx devices support only SWD.

Add swd transport in the target file.
Remove swd transport from the associated board files.

Change-Id: I2d31856951d15fcf2d1986ee5b1b31464e68db1c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9427
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Reviewed-by: Ahmed Haoues <ahmed.haoues@st.com>
2026-02-15 18:22:18 +00:00
Antonio Borneo
0e4d6d202a target: stm32l0x: drop swj on swd only target
The STM32L0xx devices support only SWD.

Drop swj support.
Add swd transport.
Remove swd transport from the associated board files.

Change-Id: I5f8fb4344b33f8bdefd67fd86326f4dccb674d92
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9426
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Ahmed Haoues <ahmed.haoues@st.com>
Tested-by: jenkins
2026-02-15 18:22:04 +00:00
Antonio Borneo
c11a325ed8 target: stm32g0x: drop swj on swd only target
The datasheets for all STM32G0xx devices report that only SWD is
supported. No TDI/TDO pin is present.

Drop swj support.
Add swd transport.
Remove swd transport from the associated board files.

Change-Id: Ib29171dd614eb84346e90cb447bc7292465095ac
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9425
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Reviewed-by: Ahmed Haoues <ahmed.haoues@st.com>
2026-02-15 18:21:48 +00:00
Antonio Borneo
a02550bafa target: stm32f0x: drop swj on swd only target
The datasheets for all STM32F0xx devices report that only SWD is
supported. No TDI/TDO pin is present.

Drop swj support.
Add swd transport.
Remove swd transport from the associated board files.

Change-Id: I65a08b6a441d794aa209cff8583a971d3546f49e
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9424
Reviewed-by: Ahmed Haoues <ahmed.haoues@st.com>
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2026-02-15 18:21:36 +00:00
Antonio Borneo
b164b65b3b target: stm32c0x: drop swj on swd only target
The datasheets for all STM32C0xx devices report that only SWD is
supported. No TDI/TDO pin is present.

Drop swj support.
Add swd transport.
Remove swd transport from the associated board files.

Change-Id: If6e630858aa64fbb3938a520604748f3f0ff7356
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9423
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Ahmed Haoues <ahmed.haoues@st.com>
Tested-by: jenkins
2026-02-15 18:21:21 +00:00
Tomas Vanek
e135ffe205 tcl/target/numicro*: drop swj on swd only target
Historically swj_newdap was necessary to handle HLA properly
Since commit 60f104f450 ("hla_transport: split command
registration per transport") there is no point in using
swj_newdap on SWD only devices.

There are no relevant board files.

Change-Id: I2119e0c0895ca97895ade92a1b1becef6bd6cfdb
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9438
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-02-15 18:19:46 +00:00
Tomas Vanek
86bdd88282 tcl/target/lpc8nxx: drop swj on swd only target
Historically swj_newdap was necessary to handle HLA properly
Since commit 60f104f450 ("hla_transport: split command
registration per transport") there is no point in using
swj_newdap on SWD only devices.

There are no relevant board files.

Change-Id: Id66a808475f061307fc6a0b3e0d2a9840b543e7f
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9437
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2026-02-15 18:19:34 +00:00
Tomas Vanek
0163d9ddba tcl/target/psoc4: drop swj on swd only targets
Historically swj_newdap was necessary to handle HLA properly.
Since commit 60f104f450 ("hla_transport: split command
registration per transport") there is no point in using
swj_newdap on SWD only devices.

There are no relevant board files.

Change-Id: I7ff7b2dee316c10a24e2ab38f8c03f504295d868
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9436
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2026-02-15 18:19:19 +00:00
Tomas Vanek
e85f9b2954 tcl/target/nordic: drop swj on swd only targets
Historically swj_newdap was necessary to handle HLA properly.
Since commit 60f104f450 ("hla_transport: split command
registration per transport") there is no point in using
swj_newdap on SWD only devices.

Drop 'transport select swd' from board files referring to
these targets.

While on it remove useless endianness option handling.

Change-Id: Icb4c04c79998369059044c203edcca61648aa936
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9435
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-02-15 18:19:02 +00:00
Tomas Vanek
a7d31c87e1 tcl/target/klx, ke0x: drop swj on swd only targets
Historically swj_newdap was necessary to handle HLA properly.
Since commit 60f104f450 ("hla_transport: split command
registration per transport") there is no point in using
swj_newdap on SWD only devices.

No board files referring these targets select swd transport.

Change-Id: I002ce7029936f56b1d8b41505bca8dc771c33187
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9434
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2026-02-15 18:18:45 +00:00
Tomas Vanek
2374db956b tcl/target/at91samd, atsame5x: drop swj on swd only targets
Historically swj_newdap was necessary to handle HLA properly.
Since commit 60f104f450 ("hla_transport: split command
registration per transport") there is no point in using
swj_newdap on SWD only devices.

No board files referring these targets select swd transport.

While on it remove useless endianness option handling.

Change-Id: I3b47750cc69fc9009fdd4cfdccfc213792d1b7ee
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9433
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2026-02-15 18:18:32 +00:00
Tomas Vanek
9b21a31eb7 tcl/target/rp2040, rp2350: use swd newdap instead of swj_newdap
Historically swj_newdap was necessary to handle HLA properly.
Since commit 60f104f450 ("hla_transport: split command
registration per transport") there is no point in using
swj_newdap on SWD only devices.

Change-Id: Ib4d7eb5935e0b44087cc8ea73ab187a417413db6
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/9421
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-02-15 18:18:18 +00:00
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
078a6b1f9f tcl/target/ti/mspm0.cfg: drop swj on swd only target
The MSPM0 devices support only SWD.
Drop swj support, add swd support.

This also gets rid of the following warnings:

Warn : DEPRECATED: auto-selecting transport "swd". Use 'transport ...
Warn : Transport "swd" was already selected

Tested by programming/verifying firmware on LP-MSPM0G3519 dev board.

Change-Id: Ieafd9c4691343124b2dfb2daa1c0d3a96b13e485
Signed-off-by: Mikhail Iakhiaev <iakhiaev@google.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9413
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2026-02-15 08:11:53 +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
Jérôme Pouiller
718eb22bfc meta: Add editor configuration
.editorconfig is supported out-of-the box by many editors (vim, vscode,
etc...). This file prevent new comers to do mistake with their editor
configuration.

Change-Id: I60c3dedc20161883f388af6f1cb9b95b90beff2a
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9454
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2026-02-15 08:08:49 +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
Marc Schink
62f49b7fe2 README.md: Fix Markdown linter errors
Adjust Markdown formatting to satisfy the Markdown linter [1], no content
changes are included.

[1] https://github.com/jackdewinter/pymarkdown

Change-Id: I28a2e8d12bfab08017de330ae3e81239082110ff
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9404
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-02-01 14:58:39 +00:00
Marc Schink
8bc12d98e7 README.macOS: Align structure and fix linter errors
Refactor the document structure to align with README.Windows and fix
two line-length issues so that the file is free of Markdown linter [1]
errors.

[1] https://github.com/jackdewinter/pymarkdown

Change-Id: Iab5ca09aeed2225e43934c8c2bd952a3a4b32cd0
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9403
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-02-01 14:57:49 +00:00
Marc Schink
91799d0579 README.Windows: Avoid multiple top-level headings
Refactor the document structure to avoid multiple top-level headings in
the same file.

The document is now free of Markdown linter [1] errors.

[1] https://github.com/jackdewinter/pymarkdown

Change-Id: I70122453c23c6230617c72d45986c88bb646edf5
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9402
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-02-01 14:57:01 +00:00
Marc Schink
7d6f3ede0e README: Rework installation section
Document the OpenOCD installation with specific examples for package
managers and move the installation section to the beginning of the
document to make it more prominent.

Change-Id: I86e175fdd4060b49070a5c8d2b92ec1c6cfe6acf
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9395
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-02-01 14:56:39 +00:00
Marc Schink
c348b9f2d7 README.macOS: Use Markdown syntax
Refurbish the document and use only Markdown syntax according to the
specification in [1].

[1] https://www.markdownguide.org/

Change-Id: I7ef0d4b7359ba12fd6f2fbf2c4ea1d092dcd71bd
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9391
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2026-02-01 14:55:47 +00:00
Marc Schink
3ba83c76a2 README.Windows: Use Markdown syntax
Refurbish the document and use only Markdown syntax according to the
specification in [1].

[1] https://www.markdownguide.org/

Change-Id: I7baa9a25621155ff4acabcfde724f233578c9ee1
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9390
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2026-02-01 14:55:23 +00:00