Compare commits

...

10 Commits

Author SHA1 Message Date
Daniel Anselmi
56d67dac2e flash/nor/max32: fix: call to calloc
With gcc 15.2.1 we get the following error:
'calloc' sizes specified with 'sizeof' in the earlier argument and
not in the later argument.

Change-Id: Ib34d758bc09d34d86d29dd02ea9c7f05b1e83327
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/9014
Reviewed-by: zapb <dev@zapb.de>
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2025-08-24 11:19:52 +00:00
Marc Schink
f381945567 tcl/file_renaming: Remove simple renames
The target configuration entries are simple renames and are handled
automatically.

Change-Id: Icae6b9b0f20b3c31df2900119f9ed2dadb2b768a
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9085
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2025-08-24 11:18:47 +00:00
Marc Schink
65b886812b tcl/board: Move SiFive configs into vendor directory
Move the configuration files into a dedicated vendor folder as required
by the developer guidelines.

Change-Id: I5bf048f2d8d0fccbcfe40e0a0e7b30dfbab192d1
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9082
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2025-08-24 11:18:38 +00:00
Parshintsev Anatoly
23ab2062e7 server: global state updated by signal handlers should have a volatile sig_atomic_t type
Signal handlers currently violate both C language and POSIX requirements:
1. To avoid undefined behavior (UB), variables accessed or modified by
   signal handlers be of atomic lock-free type.
2. The respected variables should be marked as volatile.
3. Signal handlers may only call a very limited subset of standard
   library functions.
4. Additionally, POSIX restricts signal handlers to signal-safe
   functions.

This patch addresses the first two issues by changing the type of global
variables that are accessed inside signal handler to `sig_atomic_t` and
adding `volatile` qualifiers.

Items 3 and 4 must be handled separately but are outside the scope of
this change.

Change-Id: I9c344e87bab9eefe7d99b0aad300a3ef4712df51
Signed-off-by: Parshintsev Anatoly <anatoly.parshintsev@syntacore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8927
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Chris Head <chead@zaber.com>
2025-08-24 11:18:04 +00:00
Ashi Gupta
4e493229c6 tcl/target: Added target configuration for Qualcomm QCS6490 IOT
Processors.

QCS6490 and QCM6490 are 6nm processors designed for enterprise and IOT
applications featuring global 5G and Wi-Fi 6E support with similar
architecture.

This configuration file will allow debugging applications on these
processors.

Verified with Olimex(ARM-USB-OCD-H):
openocd -f tcl/interface/ftdi/olimex-arm-usb-ocd-h.cfg 
-c 'transport select jtag' 
-f <path_to_qcs6490_cfg>

and Jlink:
openocd -f tcl/interface/jlink.cfg 
-c 'transport select jtag' 
-f <path_to_qcs6490_cfg>

Change-Id: I05e923293134eaa9b70d3cf0d18efac9a024b6c7
Signed-off-by: Ashi Gupta <quic_ashig@quicinc.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8615
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2025-08-24 11:17:19 +00:00
Marek Vrbka
160e2343bd replacements: make socket_select() work on Windows if no sockets are provided
On Windows 11, if select() is called with empty sets, it fails and
returns WSAINVAL. On POSIX this works fine.

This patch addresses it by detecting this case in OpenOCD replacements
and returning 0 in these cases.

This fixes OpenOCD crash on Windows if no services are enabled
(gdb server, tcl server and telnet server all disabled).

Change-Id: I601878671caf4ae44e105d6a819251d2d96c607c
Signed-off-by: Marek Vrbka <marek.vrbka@codasip.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9081
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2025-08-24 11:16:42 +00:00
Andreas Dannenberg
7e403d9d3b tcl/target: add Rockchip RK3588 target
The Rockchip RK3588 SoC is used in systems such as the GenBook RK3588
open-hardware laptop and the Coolpi CM5 compute module. This patch adds
support for debugging those. Tested using the ST-LINK/V2 debug adapter
in SWD mode connected to the SDMMC_D2 (SWCLK) and SDMMC_D3 (SWDIO) pins
on the 50-pin J17 connector inside the GenBook RK3588 laptop.

Change-Id: Ia5da403054b6c9aa41184a4e092a74aa882a267d
Signed-off-by: Andreas Dannenberg <andre@miauco.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9013
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2025-08-24 11:16:01 +00:00
Antonio Borneo
93f16eed4d command: fix OpenOCD commands return value for next jimtcl
JimTcl has been so far quite comfortable with new commands that
return error codes not supported by JimTcl itself.
This has been exploited by OpenOCD, allowing the OpenOCD commands
to return OpenOCD error codes mixed with JimTcl error code.

With the change [1] merged in JimTcl branch 'master' for 0.84, any
negative value returned by a command gets interpreted as a syntax
error detected at runtime by the command itself; JimTcl dumps the
correct syntax and returns a valid JimTcl error code that replaces
the negative value.
Since all OpenOCD error codes are negative values, they are all
taken as syntax errors by the new JimTcl. E.g.:
	openocd -c exit
dumps
	wrong # args: should be "exit ..."

Actually OpenOCD does not need the OpenOCD error code from the
commands, with the exception of the codes:
[a] ERROR_COMMAND_SYNTAX_ERROR, used internally by the command
    dispatcher, before returning to JimTcl;
[b] ERROR_COMMAND_CLOSE_CONNECTION, to alert the telnet server
    that the current connection should be closed.

With [a] already used internally, only [b] needs to be propagated
through JimTcl and back to the OpenOCD caller.

Map the OpenOCD error code ERROR_COMMAND_CLOSE_CONNECTION to the
existing JimTcl error code JIM_EXIT, originally used only by
JimTcl 'exit' command.

Detect JIM_EXIT in command_run_line() and return to the caller the
original ERROR_COMMAND_CLOSE_CONNECTION.

Let exec_command(), and also its caller jim_command_dispatch(),
to only return JimTcl error codes. Rename it to report the change.

Modify the test suite as now a syntax error does not returns -601
anymore.

While there, drop the association key "retval" as it's not used.

Note: after this change there is no real need to replace the
JimTcl command 'exit' with the OpenOCD version as both produce the
same result. But I prefer keeping the code as is to mask any
future change in the related JimTcl code.

Link: https://github.com/msteveb/jimtcl/commit/5669e84aad22 [1]
Change-Id: Ibd7aaeccdf4d7c9efe72aa71909aef83be5ecd27
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Andrzej Sierżęga <asier70@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9084
Tested-by: jenkins
2025-08-24 11:15:31 +00:00
Antonio Borneo
7effc6f825 helper: command: inline command_retval_set()
Inline the function command_retval_set(), called only once.
No functional changes.

Change-Id: I4478002adf92c2328e4879019020de5d1dfe89c8
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9083
Tested-by: jenkins
2025-08-24 11:15:21 +00:00
Antonio Borneo
fe0080478b jimtcl: fix build with jimtcl master branch
Current jimtcl release 0.83 has been tagged on 2024-08-28 and the
new 0.84 is on the way.

The change [1] merged in jimtcl branch 'master' for 0.84 breaks
the build of OpenOCD.
OpenOCD releases are not frequent and jimtcl is now by default an
external build dependency. The release of jimtcl 0.84 could force
OpenOCD to deliver a fix release to support it.

Anticipate the change [1] by detecting it at compile time, without
relying on jimtcl version, and providing an alternative code.

Link: https://github.com/msteveb/jimtcl/commit/5669e84aad22 [1]
Change-Id: I61bf100d447083258aea222aaf15608b7cbe2e57
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8956
Tested-by: jenkins
Reviewed-by: Andrzej Sierżęga <asier70@gmail.com>
2025-08-24 11:15:07 +00:00
13 changed files with 192 additions and 51 deletions

View File

@@ -113,7 +113,7 @@ FLASH_BANK_COMMAND_HANDLER(max32xxx_flash_bank_command)
return ERROR_FLASH_BANK_INVALID;
}
info = calloc(sizeof(struct max32xxx_flash_bank), 1);
info = calloc(1, sizeof(struct max32xxx_flash_bank));
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], info->flash_size);
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[6], info->flc_base);
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[7], info->sector_size);

View File

@@ -45,26 +45,22 @@ static enum command_mode get_command_mode(Jim_Interp *interp, const char *cmd_na
/* set of functions to wrap jimtcl internal data */
static inline bool jimcmd_is_proc(Jim_Cmd *cmd)
{
#if defined(JIM_CMD_ISPROC)
// JIM_VERSION >= 84
return cmd->flags & JIM_CMD_ISPROC;
#else
return cmd->isproc;
#endif
}
bool jimcmd_is_oocd_command(Jim_Cmd *cmd)
{
return !cmd->isproc && cmd->u.native.cmdProc == jim_command_dispatch;
return !jimcmd_is_proc(cmd) && cmd->u.native.cmdProc == jim_command_dispatch;
}
void *jimcmd_privdata(Jim_Cmd *cmd)
{
return cmd->isproc ? NULL : cmd->u.native.privData;
}
static int command_retval_set(Jim_Interp *interp, int retval)
{
int *return_retval = Jim_GetAssocData(interp, "retval");
if (return_retval)
*return_retval = retval;
return (retval == ERROR_OK) ? JIM_OK : retval;
return jimcmd_is_proc(cmd) ? NULL : cmd->u.native.privData;
}
extern struct command_context *global_cmd_ctx;
@@ -421,7 +417,7 @@ static bool command_can_run(struct command_context *cmd_ctx, struct command *c,
return false;
}
static int exec_command(Jim_Interp *interp, struct command_context *context,
static int jim_exec_command(Jim_Interp *interp, struct command_context *context,
struct command *c, int argc, Jim_Obj * const *argv)
{
/* use c->handler */
@@ -470,7 +466,15 @@ static int exec_command(Jim_Interp *interp, struct command_context *context,
Jim_DecrRefCount(context->interp, cmd.output);
free(words);
return command_retval_set(interp, retval);
if (retval == ERROR_OK)
return JIM_OK;
// used by telnet server to close one connection
if (retval == ERROR_COMMAND_CLOSE_CONNECTION)
return JIM_EXIT;
return JIM_ERR;
}
int command_run_line(struct command_context *context, char *line)
@@ -480,7 +484,6 @@ int command_run_line(struct command_context *context, char *line)
* results
*/
/* run the line thru a script engine */
int retval = ERROR_FAIL;
int retcode;
/* Beware! This code needs to be reentrant. It is also possible
* for OpenOCD commands to be invoked directly from Tcl. This would
@@ -495,20 +498,17 @@ int command_run_line(struct command_context *context, char *line)
Jim_DeleteAssocData(interp, "context");
retcode = Jim_SetAssocData(interp, "context", NULL, context);
if (retcode == JIM_OK) {
/* associated the return value */
Jim_DeleteAssocData(interp, "retval");
retcode = Jim_SetAssocData(interp, "retval", NULL, &retval);
if (retcode == JIM_OK) {
retcode = Jim_Eval_Named(interp, line, NULL, 0);
Jim_DeleteAssocData(interp, "retval");
}
retcode = Jim_Eval_Named(interp, line, NULL, 0);
Jim_DeleteAssocData(interp, "context");
int inner_retcode = Jim_SetAssocData(interp, "context", NULL, old_context);
if (retcode == JIM_OK)
retcode = inner_retcode;
}
context->current_target_override = saved_target_override;
if (retcode == JIM_RETURN)
retcode = interp->returnCode;
if (retcode == JIM_OK) {
const char *result;
int reslen;
@@ -518,25 +518,19 @@ int command_run_line(struct command_context *context, char *line)
command_output_text(context, result);
command_output_text(context, "\n");
}
retval = ERROR_OK;
} else if (retcode == JIM_EXIT) {
/* ignore.
* exit(Jim_GetExitCode(interp)); */
} else if (retcode == ERROR_COMMAND_CLOSE_CONNECTION) {
return retcode;
} else {
Jim_MakeErrorMessage(interp);
/* error is broadcast */
LOG_USER("%s", Jim_GetString(Jim_GetResult(interp), NULL));
if (retval == ERROR_OK) {
/* It wasn't a low level OpenOCD command that failed */
return ERROR_FAIL;
}
return retval;
return ERROR_OK;
}
return retval;
if (retcode == JIM_EXIT) {
// used by telnet server to close one connection
return ERROR_COMMAND_CLOSE_CONNECTION;
}
Jim_MakeErrorMessage(interp);
/* error is broadcast */
LOG_USER("%s", Jim_GetString(Jim_GetResult(interp), NULL));
return ERROR_FAIL;
}
int command_run_linef(struct command_context *context, const char *format, ...)
@@ -863,7 +857,7 @@ static int jim_command_dispatch(Jim_Interp *interp, int argc, Jim_Obj * const *a
if (c->jim_override_target)
cmd_ctx->current_target_override = c->jim_override_target;
int retval = exec_command(interp, cmd_ctx, c, argc, argv);
int retval = jim_exec_command(interp, cmd_ctx, c, argc, argv);
if (c->jim_override_target)
cmd_ctx->current_target_override = saved_target_override;

View File

@@ -152,6 +152,21 @@ int win_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct time
FD_ZERO(&sock_write);
FD_ZERO(&sock_except);
/* On Windows, if all provided sets are empty/NULL an error code of -1 is returned
* and WSAGetLastError() returns WSAEINVAL instead of delaying.
* We check for this case, delay and return 0 instead of calling select(). */
if (rfds && rfds->fd_count == 0)
rfds = NULL;
if (wfds && wfds->fd_count == 0)
wfds = NULL;
if (efds && efds->fd_count == 0)
efds = NULL;
if (!rfds && !wfds && !efds && tv) {
sleep(tv->tv_sec);
usleep(tv->tv_usec);
return 0;
}
/* build an array of handles for non-sockets */
for (i = 0; i < max_fd; i++) {
if (SAFE_FD_ISSET(i, rfds) || SAFE_FD_ISSET(i, wfds) || SAFE_FD_ISSET(i, efds)) {

View File

@@ -39,7 +39,7 @@ proc find {filename} {
return $t
}
foreach vendor {nordic ti st} {
foreach vendor {nordic ti sifive st} {
# - path/to/a/certain/config_file
# replaced with
# - path/to/a/certain/${vendor}/config_file

View File

@@ -43,10 +43,10 @@ enum shutdown_reason {
SHUTDOWN_WITH_ERROR_CODE, /* set by shutdown command; quit with non-zero return code */
SHUTDOWN_WITH_SIGNAL_CODE /* set by sig_handler; exec shutdown then exit with signal as return code */
};
static enum shutdown_reason shutdown_openocd = CONTINUE_MAIN_LOOP;
static volatile sig_atomic_t shutdown_openocd = CONTINUE_MAIN_LOOP;
/* store received signal to exit application by killing ourselves */
static int last_signal;
static volatile sig_atomic_t last_signal;
/* set the polling period to 100ms */
static int polling_period = 100;
@@ -604,6 +604,7 @@ static void sig_handler(int sig)
/* store only first signal that hits us */
if (shutdown_openocd == CONTINUE_MAIN_LOOP) {
shutdown_openocd = SHUTDOWN_WITH_SIGNAL_CODE;
assert(sig >= SIG_ATOMIC_MIN && sig <= SIG_ATOMIC_MAX);
last_signal = sig;
LOG_DEBUG("Terminating on Signal %d", sig);
} else

View File

@@ -3,7 +3,7 @@
#
# Be sure you include the speed and interface before this file
# Example:
# -c "adapter speed 5000" -f "interface/ftdi/olimex-arm-usb-tiny-h.cfg" -f "board/sifive-e31arty.cfg"
# -c "adapter speed 5000" -f "interface/ftdi/olimex-arm-usb-tiny-h.cfg" -f "board/sifive/e31-arty.cfg"
set _CHIPNAME riscv
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x20000001

View File

@@ -3,7 +3,7 @@
#
# Be sure you include the speed and interface before this file
# Example:
# -c "adapter speed 5000" -f "interface/ftdi/olimex-arm-usb-tiny-h.cfg" -f "board/sifive-e51arty.cfg"
# -c "adapter speed 5000" -f "interface/ftdi/olimex-arm-usb-tiny-h.cfg" -f "board/sifive/e51-arty.cfg"
set _CHIPNAME riscv
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x20000001

View File

@@ -19,8 +19,5 @@ set _file_renaming {
board/nordic_nrf52_dk.cfg board/nordic/nrf52-dk.cfg
board/stm32mp13x_dk.cfg board/st/stm32mp135f-dk.cfg
board/stm32mp15x_dk2.cfg board/st/stm32mp157f-dk2.cfg
target/nrf51.cfg target/nordic/nrf51.cfg
target/nrf52.cfg target/nordic/nrf52.cfg
target/nrf53.cfg target/nordic/nrf53.cfg
target/nrf91.cfg target/nordic/nrf91.cfg
board/sifive-hifive1-revb.cfg board/sifive/hifive1-rev-b.cfg
}

View File

@@ -0,0 +1,48 @@
# SPDX-License-Identifier: GPL-2.0-or-later
#
# The QCS6490/QCM6490 is a 6nm processor designed for enterprise and Internet of Things (IOT) applications,
# featuring global 5G and Wi-Fi 6E support
#
# Product Page:
# https://www.qualcomm.com/products/internet-of-things/industrial/building-enterprise/qcs6490
# https://www.qualcomm.com/products/internet-of-things/industrial/building-enterprise/qcm6490
source [find target/swj-dp.tcl]
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
set _CHIPNAME QCS6490
}
if { [info exists ENDIAN] } {
set _ENDIAN $ENDIAN
} else {
set _ENDIAN little
}
adapter speed 500
reset_config trst_and_srst
# Set CUP TAP ID based on protocol selection
if { [using_jtag] } {
set _CPUTAPID 0x5ba00477
} else {
set _CPUTAPID 0x5ba02477
}
swj_newdap $_CHIPNAME cpu -expected-id $_CPUTAPID -irlen 4
dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu -ignore-syspwrupack
cti create $_CHIPNAME.cti -dap $_CHIPNAME.dap -baseaddr 0x87020000 -ap-num 1
target create $_CHIPNAME.cpu0 aarch64 -endian $_ENDIAN -dap $_CHIPNAME.dap -coreid 0 \
-dbgbase 0x87010000 -cti $_CHIPNAME.cti -event reset-assert-post { dap init }
$_CHIPNAME.cpu0 configure -event examine-end {
eval $_CHIPNAME.cpu0 arp_halt
}
# Default breakpoints to hardware breakpoints
gdb_breakpoint_override hard

86
tcl/target/rk3588.cfg Normal file
View File

@@ -0,0 +1,86 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Rockchip RK3588 Target
# https://www.rock-chips.com/a/en/products/RK35_Series/2022/0926/1660.html
# Andreas Dannenberg <andre@miauco.com>
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
set _CHIPNAME rk3588
}
if { [info exists DAP_TAPID] } {
set _DAP_TAPID $DAP_TAPID
} else {
set _DAP_TAPID 0x2ba01477
}
adapter speed 4000
transport select swd
# Declare the one SWD tap to access the DAP
swd newdap $_CHIPNAME cpu -expected-id $_DAP_TAPID
# Create the DAP
dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
# Create target to allow accessing system memory directly
target create $_CHIPNAME.ahb mem_ap -dap $_CHIPNAME.dap -ap-num 0
# Declare the 8 main application cores (4 little cores + 4 big cores)
# Little cluster (cores 0..3)
set _TARGETNAME $_CHIPNAME.lcore
set $_TARGETNAME.base(0) 0x81004000
set $_TARGETNAME.base(1) 0x81005000
set $_TARGETNAME.base(2) 0x81006000
set $_TARGETNAME.base(3) 0x81007000
set $_TARGETNAME.cti(0) 0x81014000
set $_TARGETNAME.cti(1) 0x81015000
set $_TARGETNAME.cti(2) 0x81016000
set $_TARGETNAME.cti(3) 0x81017000
# Big cluster (cores 4..7)
set _TARGETNAME $_CHIPNAME.bcore
set $_TARGETNAME.base(4) 0x81024000
set $_TARGETNAME.base(5) 0x81025000
set $_TARGETNAME.base(6) 0x81026000
set $_TARGETNAME.base(7) 0x81027000
set $_TARGETNAME.cti(4) 0x81034000
set $_TARGETNAME.cti(5) 0x81035000
set $_TARGETNAME.cti(6) 0x81036000
set $_TARGETNAME.cti(7) 0x81037000
# Build string used to enable SMP mode
set _smp_command "target smp"
set _cores 8
for { set _core 0 } { $_core < $_cores } { incr _core 1 } {
if {$_core < 4} {
set _TARGETNAME $_CHIPNAME.lcore
} else {
set _TARGETNAME $_CHIPNAME.bcore
}
cti create cti$_core -dap $_CHIPNAME.dap -baseaddr [set $_TARGETNAME.cti($_core)] -ap-num 0
target create ${_TARGETNAME}$_core aarch64 \
-dap $_CHIPNAME.dap -coreid $_core -cti cti$_core \
-dbgbase [set $_TARGETNAME.base($_core)]
if { $_core != 0 } {
# non-boot core examination may fail
${_TARGETNAME}$_core configure -defer-examine
} else {
# uncomment to use hardware threads pseudo rtos
# ${_TARGETNAME}$_core configure -rtos hwthread
}
set _smp_command "$_smp_command ${_TARGETNAME}$_core"
}
eval $_smp_command
# Set default target to boot core
targets $_CHIPNAME.lcore0

View File

@@ -32,7 +32,7 @@ namespace eval testing_helpers {
}
proc check_syntax_err script {
tailcall check_for_error -601 {} $script
tailcall check_for_error 1 {} $script
}
proc check_matches {pattern script} {