You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(57) |
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(14) |
Nov
(36) |
Dec
(7) |
2007 |
Jan
(48) |
Feb
(10) |
Mar
(17) |
Apr
(8) |
May
(35) |
Jun
(28) |
Jul
(50) |
Aug
(71) |
Sep
(40) |
Oct
(19) |
Nov
(22) |
Dec
(143) |
2008 |
Jan
(184) |
Feb
(549) |
Mar
(381) |
Apr
(388) |
May
(148) |
Jun
(128) |
Jul
(502) |
Aug
(243) |
Sep
(136) |
Oct
(327) |
Nov
(252) |
Dec
(475) |
2009 |
Jan
(344) |
Feb
(185) |
Mar
(338) |
Apr
(826) |
May
(1559) |
Jun
(1429) |
Jul
(817) |
Aug
(451) |
Sep
(639) |
Oct
(935) |
Nov
(1222) |
Dec
(826) |
2010 |
Jan
(552) |
Feb
(532) |
Mar
(355) |
Apr
(206) |
May
(162) |
Jun
(203) |
Jul
(168) |
Aug
(232) |
Sep
(270) |
Oct
(259) |
Nov
(439) |
Dec
(468) |
2011 |
Jan
(224) |
Feb
(249) |
Mar
(278) |
Apr
(381) |
May
(316) |
Jun
(637) |
Jul
(544) |
Aug
(465) |
Sep
(159) |
Oct
(440) |
Nov
(139) |
Dec
|
2012 |
Jan
(204) |
Feb
(383) |
Mar
(295) |
Apr
(196) |
May
(590) |
Jun
(158) |
Jul
(167) |
Aug
(177) |
Sep
(179) |
Oct
(301) |
Nov
(144) |
Dec
(173) |
2013 |
Jan
(299) |
Feb
(120) |
Mar
(238) |
Apr
(140) |
May
(69) |
Jun
(133) |
Jul
(160) |
Aug
(107) |
Sep
(164) |
Oct
(196) |
Nov
(105) |
Dec
(74) |
2014 |
Jan
(205) |
Feb
(156) |
Mar
(175) |
Apr
(181) |
May
(162) |
Jun
(158) |
Jul
(117) |
Aug
(109) |
Sep
(148) |
Oct
(106) |
Nov
(82) |
Dec
(72) |
2015 |
Jan
(191) |
Feb
(205) |
Mar
(197) |
Apr
(163) |
May
(136) |
Jun
(36) |
Jul
(79) |
Aug
(55) |
Sep
(64) |
Oct
(146) |
Nov
(142) |
Dec
(78) |
2016 |
Jan
(65) |
Feb
(190) |
Mar
(53) |
Apr
(38) |
May
(95) |
Jun
(53) |
Jul
(58) |
Aug
(113) |
Sep
(96) |
Oct
(59) |
Nov
(136) |
Dec
(124) |
2017 |
Jan
(80) |
Feb
(109) |
Mar
(163) |
Apr
(78) |
May
(61) |
Jun
(73) |
Jul
(29) |
Aug
(47) |
Sep
(60) |
Oct
(76) |
Nov
(48) |
Dec
(35) |
2018 |
Jan
(138) |
Feb
(84) |
Mar
(109) |
Apr
(49) |
May
(24) |
Jun
(62) |
Jul
(96) |
Aug
(116) |
Sep
(53) |
Oct
(99) |
Nov
(80) |
Dec
(88) |
2019 |
Jan
(100) |
Feb
(141) |
Mar
(72) |
Apr
(174) |
May
(129) |
Jun
(102) |
Jul
(52) |
Aug
(45) |
Sep
(28) |
Oct
(43) |
Nov
(78) |
Dec
(47) |
2020 |
Jan
(113) |
Feb
(72) |
Mar
(94) |
Apr
(141) |
May
(82) |
Jun
(68) |
Jul
(125) |
Aug
(76) |
Sep
(33) |
Oct
(184) |
Nov
(61) |
Dec
(95) |
2021 |
Jan
(109) |
Feb
(77) |
Mar
(145) |
Apr
(116) |
May
(134) |
Jun
(113) |
Jul
(71) |
Aug
(118) |
Sep
(116) |
Oct
(92) |
Nov
(124) |
Dec
(68) |
2022 |
Jan
(57) |
Feb
(61) |
Mar
(57) |
Apr
(74) |
May
(86) |
Jun
(80) |
Jul
(43) |
Aug
(85) |
Sep
(120) |
Oct
(88) |
Nov
(100) |
Dec
(108) |
2023 |
Jan
(39) |
Feb
(56) |
Mar
(92) |
Apr
(81) |
May
(84) |
Jun
(72) |
Jul
(182) |
Aug
(82) |
Sep
(54) |
Oct
(68) |
Nov
(67) |
Dec
(75) |
2024 |
Jan
(79) |
Feb
(65) |
Mar
(42) |
Apr
(47) |
May
(68) |
Jun
(111) |
Jul
(43) |
Aug
(73) |
Sep
(100) |
Oct
(35) |
Nov
(100) |
Dec
(99) |
2025 |
Jan
(71) |
Feb
(68) |
Mar
(44) |
Apr
(40) |
May
(92) |
Jun
(45) |
Jul
(86) |
Aug
(31) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Michael F. <mf...@mf...> - 2025-08-15 21:29:08
|
Hi, I'm using OpenOCD with an ARM7TDMI core and noticed some issues when trying to use gdb to call various functions manually (e.g. with the gdb command `call foo()`). One issue is that gdb tries to change SP and LR, but those registers are banked and the ones that gdb tries to change are the the generic versions: /* These are only used for GDB target description, banked registers are accessed instead */ [37] = { .name = "sp", .cookie = 13, .mode = ARM_MODE_ANY, .gdb_index = 13, }, [38] = { .name = "lr", .cookie = 14, .mode = ARM_MODE_ANY, .gdb_index = 14, }, When these registers are read, it reads r13 and r14 in the current processor mode. When they written, the value is saved in the struct reg and it is marked as dirty. However, in arm7_9_restore_context, it loops through the armv4_5_core_reg_map for each mode, but registers 37 and 38 don't appear anywhere in this map. So they are never actually updated. My first thought to fix this was to change arm_get_gdb_reg_list, which does map registers 0-16 to the current mode with arm_reg_current, but then replaces r13 and r14 with registers 37 and 38 shown above (due to their gdb_index). However, if I leave these with the mapped versions, it seems to break the XML target description. I did manage to find another approach to fix this by changing armv4_5_set_core_reg to resolve the register according to the processor mode before changing it: diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 597dc8990..74f2d6f0e 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -618,6 +618,9 @@ static int armv4_5_set_core_reg(struct reg *reg, uint8_t *buf) return ERROR_TARGET_NOT_HALTED; } + if (reg->number < 16) + reg = arm_reg_current(armv4_5_target, reg->number); + /* Except for CPSR, the "reg" command exposes a writeback model * for the register cache. */ This worked, but I think it might be better to map the register when the gdb register list is generated rather than redirecting it here. The other problem I encountered is that ARMv4/5 registers are marked as non-caller save: /* This really depends on the calling convention in use */ reg_list[i].caller_save = false; This flag controls the save-restore attribute in the gdb target description, which is documented as follows: > save-restore > > Whether the register should be preserved across inferior function > calls; this must be either yes or no. The default is yes, which > is appropriate for most registers except for some system control > registers; this is not related to the target’s ABI. So I think the comment about calling convention is not correct. After gdb clobbers some registers for the function call, they are not restored. I looked at other targets and they all set caller_save = true for all registers (except RISCV vector registers). I think ARMv4/5 should have caller_save = true as well, which fixed the issue for me: diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 597dc8990..74f2d6f0e 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -707,7 +710,7 @@ struct reg_cache *arm_build_reg_cache(struct target *target, struct arm *arm) reg_list[i].exist = true; /* This really depends on the calling convention in use */ - reg_list[i].caller_save = false; + reg_list[i].caller_save = true; /* Registers data type, as used by GDB target description */ reg_list[i].reg_data_type = malloc(sizeof(struct reg_data_type)); Do these changes seem like the correct way to solve these problems? If so, I can send a proper patch. If not, does anyone have any suggestions? |
From: <ge...@op...> - 2025-08-15 14:21:15
|
This is an automated email from Gerrit. "Antonio Borneo <bor...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9083 -- gerrit commit af4eef2668dee259ce3a0ca89ca78e0af38078a5 Author: Antonio Borneo <bor...@gm...> Date: Thu Aug 14 22:18:56 2025 +0200 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 <bor...@gm...> diff --git a/src/helper/command.c b/src/helper/command.c index 04f4f9a54c..d6993ab76f 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -63,15 +63,6 @@ void *jimcmd_privdata(Jim_Cmd *cmd) return jimcmd_is_proc(cmd) ? 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; -} - extern struct command_context *global_cmd_ctx; /* dump a single line to the log for the command. @@ -475,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); + + int *return_retval = Jim_GetAssocData(interp, "retval"); + if (return_retval) + *return_retval = retval; + + if (retval == ERROR_OK) + return JIM_OK; + + return retval; } int command_run_line(struct command_context *context, char *line) -- |
From: <ge...@op...> - 2025-08-15 14:21:15
|
This is an automated email from Gerrit. "Antonio Borneo <bor...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9084 -- gerrit commit c23043752bd92b24a8d6434dc50d604826f70e15 Author: Antonio Borneo <bor...@gm...> Date: Fri Aug 15 14:53:34 2025 +0200 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. 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 <bor...@gm...> Reported-by: Andrzej Sierżęga <as...@gm...> diff --git a/src/helper/command.c b/src/helper/command.c index d6993ab76f..742eea1b16 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -417,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 */ @@ -467,14 +467,14 @@ static int exec_command(Jim_Interp *interp, struct command_context *context, free(words); - int *return_retval = Jim_GetAssocData(interp, "retval"); - if (return_retval) - *return_retval = retval; - if (retval == ERROR_OK) return JIM_OK; - return retval; + // 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) @@ -484,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 @@ -499,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; @@ -522,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)); + return ERROR_OK; + } - if (retval == ERROR_OK) { - /* It wasn't a low level OpenOCD command that failed */ - return ERROR_FAIL; - } - return retval; + if (retcode == JIM_EXIT) { + // used by telnet server to close one connection + return ERROR_COMMAND_CLOSE_CONNECTION; } - return retval; + 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, ...) @@ -867,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; -- |
From: <ge...@op...> - 2025-08-14 13:14:01
|
This is an automated email from Gerrit. "zapb <de...@za...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9082 -- gerrit commit 5606f5982107cf30b5016ecc46835cb39829a4c1 Author: Marc Schink <de...@za...> Date: Thu Aug 14 15:01:27 2025 +0200 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 <de...@za...> diff --git a/tcl/board/sifive-e31arty.cfg b/tcl/board/sifive/e31-arty.cfg similarity index 94% rename from tcl/board/sifive-e31arty.cfg rename to tcl/board/sifive/e31-arty.cfg index b3e980f408..bdf79dae61 100644 --- a/tcl/board/sifive-e31arty.cfg +++ b/tcl/board/sifive/e31-arty.cfg @@ -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 diff --git a/tcl/board/sifive-e51arty.cfg b/tcl/board/sifive/e51-arty.cfg similarity index 94% rename from tcl/board/sifive-e51arty.cfg rename to tcl/board/sifive/e51-arty.cfg index 3133c39023..1476d503e2 100644 --- a/tcl/board/sifive-e51arty.cfg +++ b/tcl/board/sifive/e51-arty.cfg @@ -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 diff --git a/tcl/board/sifive-hifive1-revb.cfg b/tcl/board/sifive/hifive1-rev-b.cfg similarity index 100% rename from tcl/board/sifive-hifive1-revb.cfg rename to tcl/board/sifive/hifive1-rev-b.cfg diff --git a/tcl/board/sifive-hifive1.cfg b/tcl/board/sifive/hifive1.cfg similarity index 100% rename from tcl/board/sifive-hifive1.cfg rename to tcl/board/sifive/hifive1.cfg diff --git a/tcl/file_renaming.cfg b/tcl/file_renaming.cfg index 20679b6abc..fac625eb59 100644 --- a/tcl/file_renaming.cfg +++ b/tcl/file_renaming.cfg @@ -19,6 +19,10 @@ 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 + board/sifive-e31arty.cfg board/sifive/e31-arty.cfg + board/sifive-e51arty.cfg board/sifive/e51-arty.cfg + board/sifive-hifive1.cfg board/sifive/hifive1.cfg + board/sifive-hifive1-revb.cfg board/sifive/hifive1-rev-b.cfg target/nrf51.cfg target/nordic/nrf51.cfg target/nrf52.cfg target/nordic/nrf52.cfg target/nrf53.cfg target/nordic/nrf53.cfg -- |
From: <ge...@op...> - 2025-08-14 08:07:15
|
This is an automated email from Gerrit. "Marek Vrbka <mar...@co...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9081 -- gerrit commit cf72ef7496164318fabc612d107b71395f4706e9 Author: Marek Vrbka <mar...@co...> Date: Wed Aug 13 15:36:21 2025 +0200 replacements: return 0 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 Windows crash if no services are enabled. Change-Id: I601878671caf4ae44e105d6a819251d2d96c607c Signed-off-by: Marek Vrbka <mar...@co...> diff --git a/src/helper/replacements.c b/src/helper/replacements.c index 782d975184..c082ae228a 100644 --- a/src/helper/replacements.c +++ b/src/helper/replacements.c @@ -19,6 +19,7 @@ #define IN_REPLACEMENTS_C #include "replacements.h" +#include <stdbool.h> #include <stdlib.h> #include <string.h> @@ -152,9 +153,26 @@ 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)) { + any_fd_set = true; intptr_t handle = (intptr_t) _get_osfhandle(i); handles[n_handles] = (HANDLE)handle; if (handles[n_handles] == INVALID_HANDLE_VALUE) { -- |
From: <ge...@op...> - 2025-08-13 12:48:01
|
This is an automated email from Gerrit. "zapb <de...@za...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9080 -- gerrit commit ded7aa695c3e3366641abd43a8279599d9362e1e Author: Marc Schink <de...@za...> Date: Wed Aug 13 10:08:41 2025 +0000 flash/nor/stm32lx: Make use of BIT() macro Use the BIT() macro instead of the << operator. Change-Id: I771f3b669c38529cb707885004548a9c321753b0 Signed-off-by: Marc Schink <de...@za...> diff --git a/src/flash/nor/stm32lx.c b/src/flash/nor/stm32lx.c index abdaf71bbf..c7bd1c9b7f 100644 --- a/src/flash/nor/stm32lx.c +++ b/src/flash/nor/stm32lx.c @@ -17,6 +17,7 @@ #include "imp.h" #include <helper/binarybuffer.h> +#include <helper/bits.h> #include <helper/align.h> #include <target/algorithm.h> #include <target/armv7m.h> @@ -35,34 +36,34 @@ #define FLASH_WRPR 0x20 /* FLASH_ACR bites */ -#define FLASH_ACR__LATENCY (1<<0) -#define FLASH_ACR__PRFTEN (1<<1) -#define FLASH_ACR__ACC64 (1<<2) -#define FLASH_ACR__SLEEP_PD (1<<3) -#define FLASH_ACR__RUN_PD (1<<4) +#define FLASH_ACR__LATENCY BIT(0) +#define FLASH_ACR__PRFTEN BIT(1) +#define FLASH_ACR__ACC64 BIT(2) +#define FLASH_ACR__SLEEP_PD BIT(3) +#define FLASH_ACR__RUN_PD BIT(4) /* FLASH_PECR bits */ -#define FLASH_PECR__PELOCK (1<<0) -#define FLASH_PECR__PRGLOCK (1<<1) -#define FLASH_PECR__OPTLOCK (1<<2) -#define FLASH_PECR__PROG (1<<3) -#define FLASH_PECR__DATA (1<<4) -#define FLASH_PECR__FTDW (1<<8) -#define FLASH_PECR__ERASE (1<<9) -#define FLASH_PECR__FPRG (1<<10) -#define FLASH_PECR__EOPIE (1<<16) -#define FLASH_PECR__ERRIE (1<<17) -#define FLASH_PECR__OBL_LAUNCH (1<<18) +#define FLASH_PECR__PELOCK BIT(0) +#define FLASH_PECR__PRGLOCK BIT(1) +#define FLASH_PECR__OPTLOCK BIT(2) +#define FLASH_PECR__PROG BIT(3) +#define FLASH_PECR__DATA BIT(4) +#define FLASH_PECR__FTDW BIT(8) +#define FLASH_PECR__ERASE BIT(9) +#define FLASH_PECR__FPRG BIT(10) +#define FLASH_PECR__EOPIE BIT(16) +#define FLASH_PECR__ERRIE BIT(17) +#define FLASH_PECR__OBL_LAUNCH BIT(18) /* FLASH_SR bits */ -#define FLASH_SR__BSY (1<<0) -#define FLASH_SR__EOP (1<<1) -#define FLASH_SR__ENDHV (1<<2) -#define FLASH_SR__READY (1<<3) -#define FLASH_SR__WRPERR (1<<8) -#define FLASH_SR__PGAERR (1<<9) -#define FLASH_SR__SIZERR (1<<10) -#define FLASH_SR__OPTVERR (1<<11) +#define FLASH_SR__BSY BIT(0) +#define FLASH_SR__EOP BIT(1) +#define FLASH_SR__ENDHV BIT(2) +#define FLASH_SR__READY BIT(3) +#define FLASH_SR__WRPERR BIT(8) +#define FLASH_SR__PGAERR BIT(9) +#define FLASH_SR__SIZERR BIT(10) +#define FLASH_SR__OPTVERR BIT(11) /* Unlock keys */ #define PEKEY1 0x89ABCDEF -- |
From: Bill H. <bil...@um...> - 2025-08-12 21:30:30
|
Hello OpenOCD Devs, Thank you for your contributions to this great project! A couple years ago I found STMicro implemented PowerPC support in their OpenOCD Windows binary shipped with their SDK. Knowing it was GPLv2, I asked them for their source code. Eventually they released it on GitHub here: https://github.com/STMicroelectronics/OpenOCD/tree/openocd-automotive-mcu-r2 (branch: openocd-automotive-mcu-r1/r2). It looks like it was developed independently from existing PowerPC support on the OpenOCD Gerrit that I found here: https://review.openocd.org/c/openocd/+/4337/11. A few months ago, a colleague, Bhargab, compiled and tested this branch against an SPC58XX, and it more-or-less worked for register dumps & flash dumps. So, we wanted to gauge interest in bringing PPC support into upstream OpenOCD and look for guidance on an approach: 1) gently massage the existing patchsets found in Gerrit based on the STMicro openocd-automotive-mcu-r2 branch or 2) abandoning existing patchsets in favor of STMicro's branch. We would prefer the latter since this is the second release (first was r1) that STMicro has done which indicates some willingness for continued development there. Ideally, STMicro could bring these changes to upstream, but we would be willing to help by taking a stab at it. Currently no real idea about how much effort it will be either way. In any-case, this message serves as a notification that PPC support in OpenOCD was added by STMicro over on their GitHub page. Best Regards, Bill & Bhargab |
From: Antonio B. <bor...@gm...> - 2025-08-12 17:57:51
|
On Tue, Aug 12, 2025, 18:38 R. Diez <rdi...@rd...> wrote: > > [...] > > But for all the new stuff, I would keep them at the same level while > > using different macros for easier code split in future. > > LOG_LVL_DEBUG_USB= 5, // new > > LOG_LVL_DEBUG_MALLOC= 5, // new > > LOG_LVL_DEBUG_...= 5, // new > > OK, that means that setting the debug level to 5 will add to the log > output both the USB and malloc messages from the old > --enable-verbose-usb-comms and --enable-malloc-logging configuration > options, right? > > That will make the log output even more annoyingly verbose until the > future selective log filtering you mentioned is in place. > > Is that right? > Yes, right ! At least we keep them separate and we can always re-assign different values later, if we need. Antonio > |
From: R. D. <rdi...@rd...> - 2025-08-12 16:55:29
|
> [...] > But for all the new stuff, I would keep them at the same level while > using different macros for easier code split in future. > LOG_LVL_DEBUG_USB= 5, // new > LOG_LVL_DEBUG_MALLOC= 5, // new > LOG_LVL_DEBUG_...= 5, // new OK, that means that setting the debug level to 5 will add to the log output both the USB and malloc messages from the old --enable-verbose-usb-comms and --enable-malloc-logging configuration options, right? That will make the log output even more annoyingly verbose until the future selective log filtering you mentioned is in place. Is that right? Best regards, rdiez |
From: Antonio B. <bor...@gm...> - 2025-08-12 15:09:52
|
On Mon, Aug 11, 2025 at 6:07 PM R. Diez <rdi...@rd...> wrote: > > > > Today we have in OpenOCD > > enum log_levels { > > LOG_LVL_SILENT = -3, > > LOG_LVL_OUTPUT = -2, > > LOG_LVL_USER = -1, > > LOG_LVL_ERROR = 0, > > LOG_LVL_WARNING = 1, > > LOG_LVL_INFO = 2, > > LOG_LVL_DEBUG = 3, > > LOG_LVL_DEBUG_IO = 4, > > }; > > [...] > > My proposal is, as a first step, to simply add a new entry in > > "log_level": LOG_LVL_DEBUG_USB. Then convert current _DEBUG_USB_COMMS_ > > code under this new category. > > I think that should be doable. But before I delve into the details, I have another related question: > > After converting --enable-verbose-usb-comms to this method, I wanted to do the same with --enable-malloc-logging / _DEBUG_FREE_SPACE_ . > > Should I add a new LOG_LVL_DEBUG_MALLOC too? Like this: > > [...] > LOG_LVL_DEBUG = 3, > LOG_LVL_DEBUG_IO = 4, > LOG_LVL_DEBUG_USB= 5, // new > LOG_LVL_DEBUG_MALLOC= 6, // new I don't think it would make sense to have more levels. I mean, why enabling MALLOC should enable USB and not the opposite? There is no real hierarchy here. For backward compatibility, I would keep the levels USER, ERROR, WARNING, INFO, DEBUG in the future rework. Not sure about DEBUG_IO. But for all the new stuff, I would keep them at the same level while using different macros for easier code split in future. LOG_LVL_DEBUG_USB= 5, // new LOG_LVL_DEBUG_MALLOC= 5, // new LOG_LVL_DEBUG_...= 5, // new Antonio |
From: <ge...@op...> - 2025-08-12 13:53:10
|
This is an automated email from Gerrit. "Antonio Borneo <bor...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9079 -- gerrit commit dd983a8f8de02b79499e7464f4a5074d3a4d0a4e Author: Antonio Borneo <bor...@gm...> Date: Tue Aug 12 15:32:51 2025 +0200 target: drop hint about using Tcl/Tk events The pre-git commit ef1cfb23947b ("Duane Ellis: "target as an [tcl] object" feature.") adds a FIXME comment about the possibility to reuse Tcl/Tk events in OpenOCD. The Tcl/Tk events are useful for User Interfaces (UI) as they are triggered by window system events, e.g. by X11. See [1] and [2]. The events in OpenOCD have no link with any UI and are triggered by the same OpenOCD code, which is quite far from Tcl/Tk events. Probably, to avoid confusion with Tcl, we should even rename the OpenOCD 'events' as 'callbacks' or similar. Drop the misleading comment. Change-Id: Iccb97db483804765866acdbf7c55adc6c5222674 Signed-off-by: Antonio Borneo <bor...@gm...> Link: http://www.tcl-lang.org/man/tcl8.6/TkCmd/event.htm [1] Link: https://www.tcl-lang.org/man/tcl8.6/TkCmd/bind.htm [2] diff --git a/src/target/target.c b/src/target/target.c index 002fd78864..a6ad202d77 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -4985,16 +4985,6 @@ static COMMAND_HELPER(target_configure, struct target *target, unsigned int inde /* use jim object to keep its reference on tcl file and line */ /* TODO: need duplicate? isn't IncrRefCount enough? */ teap->body = Jim_DuplicateObj(teap->interp, CMD_JIMTCL_ARGV[index++]); - /* - * FIXME: - * Tcl/TK - "tk events" have a nice feature. - * See the "BIND" command. - * We should support that here. - * You can specify %X and %Y in the event code. - * The idea is: %T - target name. - * The idea is: %N - target number - * The idea is: %E - event name. - */ Jim_IncrRefCount(teap->body); if (!replace) { -- |
From: Lupien, J. <jl...@dr...> - 2025-08-11 19:40:15
|
To me the strategy seems good, but you can ripple it right along and it's a lot of stuff to change. I would love to be able to selectively turn on messages from almost every subsystem/category. The current system is "nothing,some status, some_more status,firehose" where to fix the tricky stuff, I have to devise external filters for the firehose mode. Being able to say "looks like it's the target JTAG interface, show me that stuff" and only get those messages added to my default would help a lot when trying to bring up new boards. -John -----Original Message----- From: R. Diez <rdi...@rd...> Sent: Monday, August 11, 2025 12:08 PM To: Antonio Borneo <bor...@gm...> Cc: ope...@li... Subject: [EXTERNAL] Re: Replacing --enable-verbose-usb-comms in configure.ac WARNING: External Email Alert This email has been sent from outside of the Draper network. Please treat the email with caution, especially if you are requested to click on a link, decrypt/open an attachment, or enable macros. For further information on how to spot phishing, access "Phishing Awareness Policy" on the Draper Portal and report phishing by clicking the "Report Suspicious" button on the Outlook toolbar > Today we have in OpenOCD > enum log_levels { > LOG_LVL_SILENT = -3, > LOG_LVL_OUTPUT = -2, > LOG_LVL_USER = -1, > LOG_LVL_ERROR = 0, > LOG_LVL_WARNING = 1, > LOG_LVL_INFO = 2, > LOG_LVL_DEBUG = 3, > LOG_LVL_DEBUG_IO = 4, > }; > [...] > My proposal is, as a first step, to simply add a new entry in > "log_level": LOG_LVL_DEBUG_USB. Then convert current _DEBUG_USB_COMMS_ > code under this new category. I think that should be doable. But before I delve into the details, I have another related question: After converting --enable-verbose-usb-comms to this method, I wanted to do the same with --enable-malloc-logging / _DEBUG_FREE_SPACE_ . Should I add a new LOG_LVL_DEBUG_MALLOC too? Like this: [...] LOG_LVL_DEBUG = 3, LOG_LVL_DEBUG_IO = 4, LOG_LVL_DEBUG_USB= 5, // new LOG_LVL_DEBUG_MALLOC= 6, // new Best regards, rdiez |
From: R. D. <rdi...@rd...> - 2025-08-11 16:24:39
|
> Today we have in OpenOCD > enum log_levels { > LOG_LVL_SILENT = -3, > LOG_LVL_OUTPUT = -2, > LOG_LVL_USER = -1, > LOG_LVL_ERROR = 0, > LOG_LVL_WARNING = 1, > LOG_LVL_INFO = 2, > LOG_LVL_DEBUG = 3, > LOG_LVL_DEBUG_IO = 4, > }; > [...] > My proposal is, as a first step, to simply add a new entry in > "log_level": LOG_LVL_DEBUG_USB. Then convert current _DEBUG_USB_COMMS_ > code under this new category. I think that should be doable. But before I delve into the details, I have another related question: After converting --enable-verbose-usb-comms to this method, I wanted to do the same with --enable-malloc-logging / _DEBUG_FREE_SPACE_ . Should I add a new LOG_LVL_DEBUG_MALLOC too? Like this: [...] LOG_LVL_DEBUG = 3, LOG_LVL_DEBUG_IO = 4, LOG_LVL_DEBUG_USB= 5, // new LOG_LVL_DEBUG_MALLOC= 6, // new Best regards, rdiez |
From: <ge...@op...> - 2025-08-11 11:29:35
|
This is an automated email from Gerrit. "Name of user not set <nik...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9078 -- gerrit commit c11cfcd0293cf12181dd05e152b48f90993e70d2 Author: NikLeberg <nik...@gm...> Date: Mon Aug 11 13:19:08 2025 +0200 jtag/drivers/jtag_dpi: fix wraparound bug in runtest Commit #0847a4d introduced bug when changing loop variable from `int` to `unsigned int`. Instead of getting negative and terminating the loop, the value wraps around to `INT_MAX` and the loop never finishes. Change-Id: I055025a1f8eb4abe50955607b3e89530dfd92af4 Signed-off-by: NikLeberg <nik...@gm...> Fixes: 0847a4d diff --git a/src/jtag/drivers/jtag_dpi.c b/src/jtag/drivers/jtag_dpi.c index d6418d39c7..35dd245072 100644 --- a/src/jtag/drivers/jtag_dpi.c +++ b/src/jtag/drivers/jtag_dpi.c @@ -189,7 +189,7 @@ static int jtag_dpi_runtest(unsigned int num_cycles) return ERROR_FAIL; } snprintf(buf, sizeof(buf), "ib %d\n", num_bits); - while (num_cycles > 0) { + for (unsigned int cycle = 0; cycle < num_cycles; cycle += num_bits + 6) { ret = write_sock(buf, strlen(buf)); if (ret != ERROR_OK) { LOG_ERROR("write_sock() fail, file %s, line %d", @@ -208,8 +208,6 @@ static int jtag_dpi_runtest(unsigned int num_cycles) __FILE__, __LINE__); goto out; } - - num_cycles -= num_bits + 6; } out: -- |
From: <ge...@op...> - 2025-08-11 08:36:44
|
This is an automated email from Gerrit. "Antonio Borneo <bor...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9077 -- gerrit commit 6a6f5dbecbded921a5b42c0cbb4e6b57c3073df4 Author: Antonio Borneo <bor...@gm...> Date: Tue Aug 5 12:06:22 2025 +0200 target: cortex-m: add support for armv8m caches Cores like Cortex-M7, Cortex-M55 and Cortex-M85 can have either D-Cache and/or I-Cache. Using SW breakpoints in RAM requires handling these caches. Detect the presence of cache at examine. Detect cache state (enable/disable) at debug entry. Take care of caches synchronization through the PoC (usually the SRAM) while setting and removing SW breakpoints. Add command 'cache_info' to check cache presence and size. Change-Id: Ice637c215fe3042c8fff57edefbab1b86515ef4b Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/src/target/Makefile.am b/src/target/Makefile.am index 1a76864180..0b5a85704c 100644 --- a/src/target/Makefile.am +++ b/src/target/Makefile.am @@ -75,6 +75,7 @@ ARMV6_SRC = \ ARMV7_SRC = \ %D%/armv7m.c \ + %D%/armv7m_cache.c \ %D%/armv7m_trace.c \ %D%/cortex_m.c \ %D%/armv7a.c \ @@ -183,6 +184,7 @@ ARC_SRC = \ %D%/armv4_5_cache.h \ %D%/armv7a.h \ %D%/armv7m.h \ + %D%/armv7m_cache.h \ %D%/armv7m_trace.h \ %D%/armv8.h \ %D%/armv8_dpm.h \ diff --git a/src/target/armv7m.h b/src/target/armv7m.h index 86c45f7f26..942e22584d 100644 --- a/src/target/armv7m.h +++ b/src/target/armv7m.h @@ -15,6 +15,7 @@ #define OPENOCD_TARGET_ARMV7M_H #include "arm.h" +#include "armv7m_cache.h" #include "armv7m_trace.h" struct adiv5_ap; @@ -239,6 +240,8 @@ struct armv7m_common { /* hla_target uses a high level adapter that does not support all functions */ bool is_hla_target; + struct armv7m_cache_common armv7m_cache; + struct armv7m_trace_config trace_config; /* Direct processor core register read and writes */ diff --git a/src/target/armv7m_cache.c b/src/target/armv7m_cache.c new file mode 100644 index 0000000000..c46211b21a --- /dev/null +++ b/src/target/armv7m_cache.c @@ -0,0 +1,281 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Copyright (C) 2025 by STMicroelectronics + * Copyright (C) 2025 by Antonio Borneo <bor...@gm...> + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdint.h> + +#include <helper/align.h> +#include <helper/bitfield.h> +#include <helper/bits.h> +#include <helper/command.h> +#include <helper/log.h> +#include <helper/types.h> +#include <target/armv7m_cache.h> +#include <target/cortex_m.h> + +static int get_cache_info(struct target *target, unsigned int cl, + unsigned int ind, uint32_t *ccsidr) +{ + uint32_t csselr = FIELD_PREP(CSSELR_LEVEL_MASK, cl) + | FIELD_PREP(CSSELR_IND_MASK, ind); + + target_write_u32(target, CSSELR, csselr); + + return target_read_u32(target, CCSIDR, ccsidr); +} + +static int get_d_ucache_info(struct target *target, unsigned int cl, + uint32_t *ccsidr) +{ + return get_cache_info(target, cl, CSSELR_IND_DATA_OR_UNIFIED_CACHE, ccsidr); +} + +static int get_icache_info(struct target *target, unsigned int cl, + uint32_t *ccsidr) +{ + return get_cache_info(target, cl, CSSELR_IND_INSTRUCTION_CACHE, ccsidr); +} + +static struct armv7m_cachesize decode_ccsidr(uint32_t ccsidr) +{ + struct armv7m_cachesize size; + + size.linelen = 16 << FIELD_GET(CCSIDR_LINESIZE_MASK, ccsidr); + size.associativity = FIELD_GET(CCSIDR_ASSOCIATIVITY_MASK, ccsidr) + 1; + size.nsets = FIELD_GET(CCSIDR_NUMSETS_MASK, ccsidr) + 1; + size.cachesize = size.linelen * size.associativity * size.nsets / 1024; + + /* compute info for set way operation on cache */ + size.index_shift = FIELD_GET(CCSIDR_LINESIZE_MASK, ccsidr) + 2; + size.index = FIELD_GET(CCSIDR_NUMSETS_MASK, ccsidr); + size.way = FIELD_GET(CCSIDR_ASSOCIATIVITY_MASK, ccsidr); + + unsigned int i = 0; + while (((size.way << i) & 0x80000000) == 0) + i++; + size.way_shift = i; + + return size; +} + +int armv7m_identify_cache(struct target *target) +{ + struct armv7m_common *armv7m = target_to_armv7m(target); + struct armv7m_cache_common *cache = &armv7m->armv7m_cache; + + uint32_t clidr; + int retval = target_read_u32(target, CLIDR, &clidr); + if (retval != ERROR_OK) + return retval; + + uint32_t ctr; + retval = target_read_u32(target, CTR, &ctr); + if (retval != ERROR_OK) + return retval; + + if (clidr == 0) { + LOG_TARGET_DEBUG(target, "No cache detected"); + return ERROR_OK; + } + + if (FIELD_GET(CTR_FORMAT_MASK, ctr) != CTR_FORMAT_PROVIDED) { + LOG_ERROR("Wrong value in CTR register"); + return ERROR_FAIL; + } + + cache->iminline = 4UL << FIELD_GET(CTR_IMINLINE_MASK, ctr); + cache->dminline = 4UL << FIELD_GET(CTR_DMINLINE_MASK, ctr); + LOG_TARGET_DEBUG(target, + "ctr=0x%" PRIx32 " ctr.iminline=%" PRIu32 " ctr.dminline=%" PRIu32, + ctr, cache->iminline, cache->dminline); + + cache->loc = FIELD_GET(CLIDR_LOC_MASK, clidr); + LOG_TARGET_DEBUG(target, + "clidr=0x%" PRIx32 " Number of cache levels to PoC=%" PRIu32, + clidr, cache->loc); + + /* retrieve selected cache for later restore */ + uint32_t csselr; + retval = target_read_u32(target, CSSELR, &csselr); + if (retval != ERROR_OK) + return retval; + + /* retrieve all available inner caches */ + for (unsigned int cl = 0; cl < cache->loc; cl++) { + unsigned int ctype = FIELD_GET(CLIDR_CTYPE_MASK(cl + 1), clidr); + + /* skip reserved values */ + if (ctype > CLIDR_CTYPE_UNIFIED_CACHE) + continue; + + /* separate d or unified d/i cache at this level ? */ + if (ctype & (CLIDR_CTYPE_UNIFIED_CACHE | CLIDR_CTYPE_D_CACHE)) { + /* retrieve d-cache info */ + uint32_t ccsidr; + retval = get_d_ucache_info(target, cl, &ccsidr); + if (retval != ERROR_OK) + goto restore_csselr; + + cache->arch[cl].d_u_size = decode_ccsidr(ccsidr); + + LOG_TARGET_DEBUG(target, + "data/unified cache index %" PRIu32 " << %" PRIu32 ", way %" PRIu32 " << %" PRIu32, + cache->arch[cl].d_u_size.index, + cache->arch[cl].d_u_size.index_shift, + cache->arch[cl].d_u_size.way, + cache->arch[cl].d_u_size.way_shift); + + LOG_TARGET_DEBUG(target, + "cacheline %" PRIu32 " bytes %" PRIu32 " KBytes asso %" PRIu32 " ways", + cache->arch[cl].d_u_size.linelen, + cache->arch[cl].d_u_size.cachesize, + cache->arch[cl].d_u_size.associativity); + } + + if (ctype & CLIDR_CTYPE_I_CACHE) { + /* retrieve i-cache info */ + uint32_t ccsidr; + retval = get_icache_info(target, cl, &ccsidr); + if (retval != ERROR_OK) + goto restore_csselr; + + cache->arch[cl].i_size = decode_ccsidr(ccsidr); + + LOG_TARGET_DEBUG(target, + "instruction cache index %" PRIu32 " << %" PRIu32 ", way %" PRIu32 " << %" PRIu32, + cache->arch[cl].i_size.index, + cache->arch[cl].i_size.index_shift, + cache->arch[cl].i_size.way, + cache->arch[cl].i_size.way_shift); + + LOG_TARGET_DEBUG(target, + "cacheline %" PRIu32 " bytes %" PRIu32 " KBytes asso %" PRIu32 " ways", + cache->arch[cl].i_size.linelen, + cache->arch[cl].i_size.cachesize, + cache->arch[cl].i_size.associativity); + } + + cache->arch[cl].ctype = ctype; + } + +restore_csselr: + /* restore selected cache */ + target_write_u32(target, CSSELR, csselr); + + if (retval == ERROR_OK) + cache->info_valid = true; + + return retval; +} + +int armv7m_d_cache_flush(struct target *target, uint32_t address, + unsigned int length) +{ + struct armv7m_common *armv7m = target_to_armv7m(target); + struct armv7m_cache_common *cache = &armv7m->armv7m_cache; + + if (!cache->info_valid) + return ERROR_OK; + + if (target->state != TARGET_HALTED) { + LOG_TARGET_ERROR(target, "not halted"); + return ERROR_TARGET_NOT_HALTED; + } + + if (!armv7m->armv7m_cache.d_u_cache_enabled) + return ERROR_OK; + + uint32_t linelen = cache->dminline; + uint32_t addr_line = ALIGN_DOWN(address, linelen); + uint32_t addr_end = address + length; + + while (addr_line < addr_end) { + target_write_u32(target, DCCIMVAC, addr_line); + addr_line += linelen; + keep_alive(); + } + + return ERROR_OK; +} + +int armv7m_i_cache_inval(struct target *target, uint32_t address, + unsigned int length) +{ + struct armv7m_common *armv7m = target_to_armv7m(target); + struct armv7m_cache_common *cache = &armv7m->armv7m_cache; + + if (!cache->info_valid) + return ERROR_OK; + + if (target->state != TARGET_HALTED) { + LOG_TARGET_ERROR(target, "not halted"); + return ERROR_TARGET_NOT_HALTED; + } + + if (!armv7m->armv7m_cache.i_cache_enabled) + return ERROR_OK; + + uint32_t linelen = cache->iminline; + uint32_t addr_line = ALIGN_DOWN(address, linelen); + uint32_t addr_end = address + length; + + while (addr_line < addr_end) { + target_write_u32(target, ICIMVAU, addr_line); + addr_line += linelen; + keep_alive(); + } + + return ERROR_OK; +} + + +int armv7m_handle_cache_info_command(struct command_invocation *cmd, + struct target *target) +{ + struct armv7m_common *armv7m = target_to_armv7m(target); + struct armv7m_cache_common *cache = &armv7m->armv7m_cache; + + if (!target_was_examined(target)) { + command_print(cmd, "Target not examined yet"); + return ERROR_FAIL; + } + + if (!cache->info_valid) { + command_print(cmd, "No cache detected"); + return ERROR_OK; + } + + for (unsigned int cl = 0; cl < cache->loc; cl++) { + struct armv7m_arch_cache *arch = &cache->arch[cl]; + + if (arch->ctype & CLIDR_CTYPE_I_CACHE) + command_print(cmd, + "L%d I-Cache: linelen %" PRIu32 ", associativity %" PRIu32 + ", nsets %" PRIu32 ", cachesize %" PRIu32 " KBytes", + cl + 1, + arch->i_size.linelen, + arch->i_size.associativity, + arch->i_size.nsets, + arch->i_size.cachesize); + + if (arch->ctype & (CLIDR_CTYPE_UNIFIED_CACHE | CLIDR_CTYPE_D_CACHE)) + command_print(cmd, + "L%d %c-Cache: linelen %" PRIu32 ", associativity %" PRIu32 + ", nsets %" PRIu32 ", cachesize %" PRIu32 " KBytes", + cl + 1, + (arch->ctype & CLIDR_CTYPE_D_CACHE) ? 'D' : 'U', + arch->d_u_size.linelen, + arch->d_u_size.associativity, + arch->d_u_size.nsets, + arch->d_u_size.cachesize); + } + + return ERROR_OK; +} diff --git a/src/target/armv7m_cache.h b/src/target/armv7m_cache.h new file mode 100644 index 0000000000..19cb7c82c4 --- /dev/null +++ b/src/target/armv7m_cache.h @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/* + * Copyright (C) 2025 by STMicroelectronics + * Copyright (C) 2025 by Antonio Borneo <bor...@gm...> + */ + +#ifndef OPENOCD_TARGET_ARMV7M_CACHE_H +#define OPENOCD_TARGET_ARMV7M_CACHE_H + +#include <stdbool.h> +#include <stdint.h> + +#include <helper/types.h> + +struct target; + +struct armv7m_cachesize { + /* cache dimensioning */ + uint32_t linelen; + uint32_t associativity; + uint32_t nsets; + uint32_t cachesize; + /* info for set way operation on cache */ + uint32_t index; + uint32_t index_shift; + uint32_t way; + uint32_t way_shift; +}; + +/* information about one architecture cache at any level */ +struct armv7m_arch_cache { + unsigned int ctype; /* cache type, CLIDR encoding */ + struct armv7m_cachesize d_u_size; /* data cache */ + struct armv7m_cachesize i_size; /* instruction cache */ +}; + +/* common cache information */ +struct armv7m_cache_common { + bool info_valid; + unsigned int loc; /* level of coherency */ + uint32_t dminline; /* minimum d-cache linelen */ + uint32_t iminline; /* minimum i-cache linelen */ + struct armv7m_arch_cache arch[6]; /* cache info, L1 - L7 */ + bool i_cache_enabled; + bool d_u_cache_enabled; +}; + +int armv7m_identify_cache(struct target *target); + +int armv7m_d_cache_flush(struct target *target, uint32_t address, + unsigned int length); +int armv7m_i_cache_inval(struct target *target, uint32_t address, + unsigned int length); +int armv7m_handle_cache_info_command(struct command_invocation *cmd, + struct target *target); + +#endif /* OPENOCD_TARGET_ARMV7M_CACHE_H */ diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index a90610b088..b635072942 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -21,6 +21,7 @@ #include "jtag/interface.h" #include "breakpoints.h" #include "cortex_m.h" +#include "armv7m_cache.h" #include "target_request.h" #include "target_type.h" #include "arm_adi_v5.h" @@ -30,6 +31,7 @@ #include "arm_semihosting.h" #include "smp.h" #include <helper/nvp.h> +#include <helper/string_choices.h> #include <helper/time_support.h> #include <rtt/rtt.h> @@ -926,6 +928,20 @@ static int cortex_m_debug_entry(struct target *target) secure_state ? "Secure" : "Non-Secure", target_state_name(target)); + if (armv7m->armv7m_cache.info_valid) { + uint32_t ccr; + retval = target_read_u32(target, CCR, &ccr); + if (retval != ERROR_OK) + return retval; + + armv7m->armv7m_cache.d_u_cache_enabled = ccr & CCR_DC_MASK; + armv7m->armv7m_cache.i_cache_enabled = ccr & CCR_IC_MASK; + + LOG_TARGET_DEBUG(target, "D-Cache %s, I-Cache %s", + str_enabled_disabled(armv7m->armv7m_cache.d_u_cache_enabled), + str_enabled_disabled(armv7m->armv7m_cache.i_cache_enabled)); + } + /* Errata 3092511 workaround * Cortex-M7 can halt in an incorrect address when breakpoint * and exception occurs simultaneously */ @@ -1938,12 +1954,25 @@ int cortex_m_set_breakpoint(struct target *target, struct breakpoint *breakpoint breakpoint->orig_instr); if (retval != ERROR_OK) return retval; + /* make sure data cache is cleaned & invalidated down to PoC */ + retval = armv7m_d_cache_flush(target, breakpoint->address, breakpoint->length); + if (retval != ERROR_OK) + return retval; + retval = target_write_memory(target, breakpoint->address & 0xFFFFFFFE, breakpoint->length, 1, code); if (retval != ERROR_OK) return retval; + /* update i-cache at breakpoint location */ + retval = armv7m_d_cache_flush(target, breakpoint->address, breakpoint->length); + if (retval != ERROR_OK) + return retval; + retval = armv7m_i_cache_inval(target, breakpoint->address, breakpoint->length); + if (retval != ERROR_OK) + return retval; + breakpoint->is_set = true; } @@ -1986,12 +2015,25 @@ int cortex_m_unset_breakpoint(struct target *target, struct breakpoint *breakpoi target_write_u32(target, comparator_list[fp_num].fpcr_address, comparator_list[fp_num].fpcr_value); } else { + /* make sure data cache is cleaned & invalidated down to PoC */ + retval = armv7m_d_cache_flush(target, breakpoint->address, breakpoint->length); + if (retval != ERROR_OK) + return retval; + /* restore original instruction (kept in target endianness) */ retval = target_write_memory(target, breakpoint->address & 0xFFFFFFFE, breakpoint->length, 1, breakpoint->orig_instr); if (retval != ERROR_OK) return retval; + + /* update i-cache at breakpoint location */ + retval = armv7m_d_cache_flush(target, breakpoint->address, breakpoint->length); + if (retval != ERROR_OK) + return retval; + retval = armv7m_i_cache_inval(target, breakpoint->address, breakpoint->length); + if (retval != ERROR_OK) + return retval; } breakpoint->is_set = false; @@ -2906,6 +2948,12 @@ int cortex_m_examine(struct target *target) LOG_TARGET_INFO(target, "target has %d breakpoints, %d watchpoints", cortex_m->fp_num_code, cortex_m->dwt_num_comp); + + retval = armv7m_identify_cache(target); + if (retval != ERROR_OK) { + LOG_ERROR("Cannot detect cache"); + return retval; + } } return ERROR_OK; @@ -3235,6 +3283,13 @@ COMMAND_HANDLER(handle_cortex_m_reset_config_command) return ERROR_OK; } +COMMAND_HANDLER(handle_cortex_m_cache_info_command) +{ + struct target *target = get_current_target(CMD_CTX); + + return armv7m_handle_cache_info_command(CMD, target); +} + static const struct command_registration cortex_m_exec_command_handlers[] = { { .name = "maskisr", @@ -3257,6 +3312,13 @@ static const struct command_registration cortex_m_exec_command_handlers[] = { .help = "configure software reset handling", .usage = "['sysresetreq'|'vectreset']", }, + { + .name = "cache_info", + .handler = handle_cortex_m_cache_info_command, + .mode = COMMAND_EXEC, + .help = "display information about target caches", + .usage = "", + }, { .chain = smp_command_handlers, }, diff --git a/src/target/cortex_m.h b/src/target/cortex_m.h index 82b2c1ecde..6b8b410a16 100644 --- a/src/target/cortex_m.h +++ b/src/target/cortex_m.h @@ -15,6 +15,7 @@ #define OPENOCD_TARGET_CORTEX_M_H #include "armv7m.h" +#include "helper/bitfield.h" #include "helper/bits.h" #define CORTEX_M_COMMON_MAGIC 0x1A451A45U @@ -114,6 +115,45 @@ struct cortex_m_part_info { #define FPU_FPCAR 0xE000EF38 #define FPU_FPDSCR 0xE000EF3C +/* Cache */ +#define CCR 0xE000ED14 +#define CLIDR 0xE000ED78 +#define CTR 0xE000ED7C +#define CCSIDR 0xE000ED80 +#define CSSELR 0xE000ED84 +#define ICIMVAU 0xE000EF58 +#define DCCIMVAC 0xE000EF70 + +#define CCR_IC_MASK BIT(17) +#define CCR_DC_MASK BIT(16) + +#define CLIDR_ICB_MASK GENMASK(31, 30) +#define CLIDR_LOUU_MASK GENMASK(29, 27) +#define CLIDR_LOC_MASK GENMASK(26, 24) +#define CLIDR_LOUIS_MASK GENMASK(23, 21) +#define CLIDR_CTYPE_MASK(i) (GENMASK(2, 0) << (3 * (i) - 3)) + +#define CLIDR_CTYPE_I_CACHE BIT(0) +#define CLIDR_CTYPE_D_CACHE BIT(1) +#define CLIDR_CTYPE_UNIFIED_CACHE BIT(2) + +#define CTR_FORMAT_MASK GENMASK(31, 29) +#define CTR_CWG_MASK GENMASK(27, 24) +#define CTR_ERG_MASK GENMASK(23, 20) +#define CTR_DMINLINE_MASK GENMASK(19, 16) +#define CTR_IMINLINE_MASK GENMASK(3, 0) + +#define CTR_FORMAT_PROVIDED 0x04 + +#define CCSIDR_NUMSETS_MASK GENMASK(27, 13) +#define CCSIDR_ASSOCIATIVITY_MASK GENMASK(12, 3) +#define CCSIDR_LINESIZE_MASK GENMASK(2, 0) + +#define CSSELR_LEVEL_MASK GENMASK(3, 1) +#define CSSELR_IND_MASK BIT(0) +#define CSSELR_IND_DATA_OR_UNIFIED_CACHE 0 +#define CSSELR_IND_INSTRUCTION_CACHE 1 + #define TPIU_SSPSR 0xE0040000 #define TPIU_CSPSR 0xE0040004 #define TPIU_ACPR 0xE0040010 -- |
From: <ge...@op...> - 2025-08-10 14:48:33
|
This is an automated email from Gerrit. "Antonio Borneo <bor...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9076 -- gerrit commit 4c4af22066e97617fab6e53648bee4fc9a81c9f2 Author: Antonio Borneo <bor...@gm...> Date: Sat May 17 18:28:47 2025 +0200 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 <bor...@gm...> diff --git a/src/helper/command.c b/src/helper/command.c index b70081a4dd..a3ceed0e2e 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -358,14 +358,12 @@ void command_print_sameline(struct command_invocation *cmd, const char *format, string = alloc_vprintf(format, ap); if (string && cmd) { - /* we want this collected in the log + we also want to pick it up as a tcl return - * value. - * - * The latter bit isn't precisely neat, but will do for now. - */ - Jim_AppendString(cmd->ctx->interp, cmd->output, string, -1); - /* We already printed it above - * command_output_text(context, string); */ + char *output = cmd->output ? cmd->output : ""; + output = alloc_printf("%s%s", output, string); + if (output) { + free(cmd->output); + cmd->output = output; + } free(string); } @@ -381,16 +379,12 @@ void command_print(struct command_invocation *cmd, const char *format, ...) string = alloc_vprintf(format, ap); if (string && cmd) { - strcat(string, "\n"); /* alloc_vprintf guaranteed the buffer to be at least one - *char longer */ - /* we want this collected in the log + we also want to pick it up as a tcl return - * value. - * - * The latter bit isn't precisely neat, but will do for now. - */ - Jim_AppendString(cmd->ctx->interp, cmd->output, string, -1); - /* We already printed it above - * command_output_text(context, string); */ + char *output = cmd->output ? cmd->output : ""; + output = alloc_printf("%s%s\n", output, string); + if (output) { + free(cmd->output); + cmd->output = output; + } free(string); } @@ -441,11 +435,9 @@ static int exec_command(Jim_Interp *interp, struct command_context *context, .argc = argc - 1, .argv = words + 1, .jimtcl_argv = argv + 1, + .output = NULL, }; - cmd.output = Jim_NewEmptyStringObj(context->interp); - Jim_IncrRefCount(cmd.output); - int retval = c->handler(&cmd); if (retval == ERROR_COMMAND_SYNTAX_ERROR) { /* Print help for command */ @@ -456,20 +448,23 @@ static int exec_command(Jim_Interp *interp, struct command_context *context, if (retval != ERROR_OK) LOG_DEBUG("Command '%s' failed with error code %d", words[0], retval); - /* - * Use the command output as the Tcl result. - * Drop last '\n' to allow command output concatenation - * while keep using command_print() everywhere. - */ - const char *output_txt = Jim_String(cmd.output); - int len = strlen(output_txt); - if (len && output_txt[len - 1] == '\n') - --len; - Jim_SetResultString(context->interp, output_txt, len); + if (cmd.output) { + /* + * Use the command output as the Tcl result. + * Drop last '\n' to allow command output concatenation + * while keep using command_print() everywhere. + */ + int len = strlen(cmd.output); + if (len && cmd.output[len - 1] == '\n') + --len; + Jim_SetResultString(context->interp, cmd.output, len); + } else { + Jim_SetEmptyResult(context->interp); + } } - Jim_DecrRefCount(context->interp, cmd.output); - + free(cmd.output); free(words); + return command_retval_set(interp, retval); } diff --git a/src/helper/command.h b/src/helper/command.h index 8bd2430e0b..8ce45473f2 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -80,7 +80,7 @@ struct command_invocation { unsigned int argc; const char **argv; Jim_Obj * const *jimtcl_argv; - Jim_Obj *output; + char *output; }; /** -- |
From: Agnelo D. (QUIC) <qui...@qu...> - 2025-08-08 12:13:35
|
Hello, Request to please review the following gerritt https://review.openocd.org/c/openocd/+/8615 Adding a new config file to enable debug support for the Qualcomm QCS6490 chipset based dev kit https://www.qualcomm.com/developer/hardware/rb3-gen-2-development-kit Thanks, Agnelo |
From: <ge...@op...> - 2025-08-05 09:58:09
|
This is an automated email from Gerrit. "Antonio Borneo <bor...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9073 -- gerrit commit 291cc101353b759b0b1c0aa806f44a2b3bb24f2a Author: Thomas Huth <th...@re...> Date: Mon Jul 21 12:15:37 2025 +0200 LICENSES: Replace the obsolete address of the FSF in the GFDL-1.2 The FSF does not reside in the Franklin street anymore. Let's update the address with the link to their website, as suggested in the latest revisions of their GFDL-1.2 license: https://www.gnu.org/licenses/old-licenses/fdl-1.2.txt Change-Id: I7492b596729deb2837de9529975e4d61b6a582f8 Signed-off-by: Thomas Huth <th...@re...> Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/LICENSES/preferred/GFDL-1.2 b/LICENSES/preferred/GFDL-1.2 index 9217d9c8ec..ded6f4d453 100644 --- a/LICENSES/preferred/GFDL-1.2 +++ b/LICENSES/preferred/GFDL-1.2 @@ -18,7 +18,7 @@ License-Text: Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. diff --git a/doc/fdl.texi b/doc/fdl.texi index 2189f80a66..72916a9fb7 100644 --- a/doc/fdl.texi +++ b/doc/fdl.texi @@ -7,7 +7,7 @@ @display Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc. -51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +<https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. -- |
From: <ge...@op...> - 2025-08-05 09:58:09
|
This is an automated email from Gerrit. "Antonio Borneo <bor...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9074 -- gerrit commit d85c168c4def93f2819f365da3fb187e5a938bd8 Author: Thomas Huth <th...@re...> Date: Mon Jul 21 12:15:33 2025 +0200 LICENSES: Replace the obsolete address of the FSF in the GPL-2.0 The FSF does not reside in the Franklin street anymore. Let's update the address with the link to their website, as suggested in the latest revisions of their GPL-2.0 license: https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt Change-Id: Iaa45bc1e65383ee960055d0013d03bea54a7a91f Signed-off-by: Thomas Huth <th...@re...> Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/LICENSES/preferred/GPL-2.0 b/LICENSES/preferred/GPL-2.0 index 687bdddb11..25d8343cd0 100644 --- a/LICENSES/preferred/GPL-2.0 +++ b/LICENSES/preferred/GPL-2.0 @@ -15,7 +15,7 @@ License-Text: Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -317,8 +317,7 @@ the "copyright" line and a pointer to where the full notice is found. GNU General Public License for more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + with this program; if not, see <https://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. -- |
From: <ge...@op...> - 2025-08-05 09:58:04
|
This is an automated email from Gerrit. "Antonio Borneo <bor...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9075 -- gerrit commit d7cd53e4dbb429316a1ebf7c29ff662c59218b57 Author: Thomas Huth <th...@re...> Date: Mon Jul 21 12:15:35 2025 +0200 LICENSES: Replace the obsolete address of the FSF in the LGPL-2.1 The FSF does not reside in the Franklin street anymore. Let's update the address with the link to their website, as suggested in the latest revisions of their LGPL-2.1 license: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt Change-Id: If3c272c8e942a59b532c7c2a89ff3a450f34530b Signed-off-by: Thomas Huth <th...@re...> Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/LICENSES/preferred/LGPL-2.1 b/LICENSES/preferred/LGPL-2.1 index 8738a8d578..b19c23d17c 100644 --- a/LICENSES/preferred/LGPL-2.1 +++ b/LICENSES/preferred/LGPL-2.1 @@ -16,7 +16,7 @@ GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +<https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -486,9 +486,9 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License -along with this library; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add -information on how to contact you by electronic and paper mail. +along with this library; if not, see <https://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if -- |
From: <ge...@op...> - 2025-08-04 16:10:02
|
This is an automated email from Gerrit. "Antonio Borneo <bor...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9072 -- gerrit commit a4d317714fc0e86d67a6696b75ab3a00434fa843 Author: Antonio Borneo <bor...@gm...> Date: Mon Aug 4 17:45:53 2025 +0200 target: riscv-011: don't change 'debug_level' during target polling In the riscv fork, [1] has disable the debug log during target polling, with message: Improve low-level logging. Now logging is consistent and more readable. I did remove most logging during riscv_poll() since it clutters up the log/screen and is not generally helpful. This is questionable, because if the user enables the debug log, the messages should all be logged. Drop the code that overwrites the 'debug_level'. Link: https://github.com/riscv-collab/riscv-openocd/commit/54c65a9a4b71 [1] Change-Id: Ia86b998cf654760f36c2f217d44bcb9ffd9c3a94 Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/src/target/riscv/riscv-011.c b/src/target/riscv/riscv-011.c index 15c1c307d7..26189bdc86 100644 --- a/src/target/riscv/riscv-011.c +++ b/src/target/riscv/riscv-011.c @@ -1931,11 +1931,6 @@ static int poll_target(struct target *target, bool announce) { jtag_add_ir_scan(target->tap, &select_dbus, TAP_IDLE); - /* Inhibit debug logging during poll(), which isn't usually interesting and - * just fills up the screen/logs with clutter. */ - int old_debug_level = debug_level; - if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) - debug_level = LOG_LVL_INFO; bits_t bits = { .haltnot = 0, .interrupt = 0 @@ -1943,8 +1938,6 @@ static int poll_target(struct target *target, bool announce) if (read_bits(target, &bits) != ERROR_OK) return ERROR_FAIL; - debug_level = old_debug_level; - if (bits.haltnot && bits.interrupt) { target->state = TARGET_DEBUG_RUNNING; LOG_DEBUG("debug running"); -- |
From: <ge...@op...> - 2025-08-04 16:09:57
|
This is an automated email from Gerrit. "Antonio Borneo <bor...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9071 -- gerrit commit 5933039469b5605478ff294dd3697adeef9a776e Author: Antonio Borneo <bor...@gm...> Date: Mon Aug 4 17:40:39 2025 +0200 target: riscv: don't test 'debug_level' directly Use the macro 'LOG_LEVEL_IS()' to test 'debug_level'. Change-Id: Ic931fd2eff0fa97a7a315b4b276f85dfc5fc8d5f Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/src/target/riscv/batch.c b/src/target/riscv/batch.c index 56143808f0..5acbddaf37 100644 --- a/src/target/riscv/batch.c +++ b/src/target/riscv/batch.c @@ -204,7 +204,7 @@ static void log_batch(const struct riscv_batch *batch, size_t start_idx, const struct riscv_scan_delays *delays, bool resets_delays, size_t reset_delays_after) { - if (debug_level < LOG_LVL_DEBUG) + if (!LOG_LEVEL_IS(LOG_LVL_DEBUG)) return; const unsigned int abits = riscv_get_dmi_address_bits(batch->target); diff --git a/src/target/riscv/riscv-011.c b/src/target/riscv/riscv-011.c index a84beb2a97..15c1c307d7 100644 --- a/src/target/riscv/riscv-011.c +++ b/src/target/riscv/riscv-011.c @@ -391,7 +391,7 @@ static void dump_field(const struct scan_field *field) static const char * const op_string[] = {"nop", "r", "w", "?"}; static const char * const status_string[] = {"+", "?", "F", "b"}; - if (debug_level < LOG_LVL_DEBUG) + if (!LOG_LEVEL_IS(LOG_LVL_DEBUG)) return; uint64_t out = buf_get_u64(field->out_value, 0, field->num_bits); @@ -1934,7 +1934,7 @@ static int poll_target(struct target *target, bool announce) /* Inhibit debug logging during poll(), which isn't usually interesting and * just fills up the screen/logs with clutter. */ int old_debug_level = debug_level; - if (debug_level >= LOG_LVL_DEBUG) + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) debug_level = LOG_LVL_INFO; bits_t bits = { .haltnot = 0, diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index abb339aca5..b472e08ebc 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -368,7 +368,7 @@ static struct riscv_debug_reg_ctx get_riscv_debug_reg_ctx(const struct target *t static void log_debug_reg(struct target *target, enum riscv_debug_reg_ordinal reg, riscv_reg_t value, const char *file, unsigned int line, const char *func) { - if (debug_level < LOG_LVL_DEBUG) + if (!LOG_LEVEL_IS(LOG_LVL_DEBUG)) return; const struct riscv_debug_reg_ctx context = get_riscv_debug_reg_ctx(target); char * const buf = malloc(riscv_debug_reg_to_s(NULL, reg, context, value, RISCV_DEBUG_REG_HIDE_UNNAMED_0) + 1); @@ -735,7 +735,7 @@ int riscv013_execute_abstract_command(struct target *target, uint32_t command, { assert(cmderr); *cmderr = CMDERR_NONE; - if (debug_level >= LOG_LVL_DEBUG) { + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) { switch (get_field(command, DM_COMMAND_CMDTYPE)) { case 0: LOG_DEBUG_REG(target, AC_ACCESS_REGISTER, command); @@ -3094,7 +3094,7 @@ static int execute_autofence(struct target *target) static void log_memory_access128(target_addr_t address, uint64_t value_h, uint64_t value_l, bool is_read) { - if (debug_level < LOG_LVL_DEBUG) + if (!LOG_LEVEL_IS(LOG_LVL_DEBUG)) return; char fmt[80]; @@ -3106,7 +3106,7 @@ static void log_memory_access128(target_addr_t address, uint64_t value_h, static void log_memory_access64(target_addr_t address, uint64_t value, unsigned int size_bytes, bool is_read) { - if (debug_level < LOG_LVL_DEBUG) + if (!LOG_LEVEL_IS(LOG_LVL_DEBUG)) return; char fmt[80]; -- |
From: <ge...@op...> - 2025-08-04 16:09:33
|
This is an automated email from Gerrit. "Antonio Borneo <bor...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9070 -- gerrit commit 3304d3074bbacd4d8fcf2886ef0a0e28f92687f5 Author: Antonio Borneo <bor...@gm...> Date: Mon Aug 4 17:42:22 2025 +0200 openocd: don't test 'debug_level' directly Use the macro 'LOG_LEVEL_IS()' to test 'debug_level'. While there, use the macro 'LOG_LVL_*' in place of the numeric value. Skip all riscv code, as it is going to be updated soon from the external fork. Change-Id: Icad7e879e040d3b9cf1cc004c433f28725017493 Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/src/helper/command.c b/src/helper/command.c index b70081a4dd..f785e79b07 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -73,7 +73,7 @@ extern struct command_context *global_cmd_ctx; * Do nothing in case we are not at debug level 3 */ static void script_debug(Jim_Interp *interp, unsigned int argc, Jim_Obj * const *argv) { - if (debug_level < LOG_LVL_DEBUG) + if (!LOG_LEVEL_IS(LOG_LVL_DEBUG)) return; char *dbg = alloc_printf("command -"); diff --git a/src/helper/log.c b/src/helper/log.c index d8c4e09ac7..2dada3540e 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -113,7 +113,7 @@ static void log_puts(enum log_levels level, if (f) file = f + 1; - if (debug_level >= LOG_LVL_DEBUG) { + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) { /* print with count and time information */ int64_t t = timeval_ms() - start; #ifdef _DEBUG_FREE_SPACE_ diff --git a/src/helper/log.h b/src/helper/log.h index ac24f8e833..474d082ede 100644 --- a/src/helper/log.h +++ b/src/helper/log.h @@ -101,7 +101,7 @@ extern int debug_level; #define LOG_DEBUG_IO(expr ...) \ do { \ - if (debug_level >= LOG_LVL_DEBUG_IO) \ + if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO)) \ log_printf_lf(LOG_LVL_DEBUG, \ __FILE__, __LINE__, __func__, \ expr); \ @@ -109,7 +109,7 @@ extern int debug_level; #define LOG_DEBUG(expr ...) \ do { \ - if (debug_level >= LOG_LVL_DEBUG) \ + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) \ log_printf_lf(LOG_LVL_DEBUG, \ __FILE__, __LINE__, __func__, \ expr); \ @@ -118,7 +118,7 @@ extern int debug_level; #define LOG_CUSTOM_LEVEL(level, expr ...) \ do { \ enum log_levels _level = level; \ - if (debug_level >= _level) \ + if (LOG_LEVEL_IS(_level)) \ log_printf_lf(_level, \ __FILE__, __LINE__, __func__, \ expr); \ diff --git a/src/jtag/core.c b/src/jtag/core.c index 6dd2144c63..4a5e096758 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -967,7 +967,7 @@ int default_interface_jtag_execute_queue(void) struct jtag_command *cmd = jtag_command_queue_get(); int result = adapter_driver->jtag_ops->execute_queue(cmd); - while (debug_level >= LOG_LVL_DEBUG_IO && cmd) { + while (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO) && cmd) { switch (cmd->type) { case JTAG_SCAN: LOG_DEBUG_IO("JTAG %s SCAN to %s", diff --git a/src/rtos/ecos.c b/src/rtos/ecos.c index a70084b4fb..9539852992 100644 --- a/src/rtos/ecos.c +++ b/src/rtos/ecos.c @@ -539,7 +539,7 @@ static int ecos_check_app_info(struct rtos *rtos, struct ecos_params *param) return -1; if (param->flush_common) { - if (debug_level >= LOG_LVL_DEBUG) { + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) { for (unsigned int idx = 0; idx < ARRAY_SIZE(ecos_symbol_list); idx++) { LOG_DEBUG("eCos: %s 0x%016" PRIX64 " %s", rtos->symbols[idx].optional ? "OPTIONAL" : " ", diff --git a/src/svf/svf.c b/src/svf/svf.c index ce994686f1..bcebcbe399 100644 --- a/src/svf/svf.c +++ b/src/svf/svf.c @@ -1604,7 +1604,7 @@ xxr_common: LOG_USER("(Above Padding command skipped, as per -tap argument)"); } - if (debug_level >= LOG_LVL_DEBUG) { + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) { /* for convenient debugging, execute tap if possible */ if ((svf_buffer_index > 0) && (((command != STATE) && (command != RUNTEST)) || diff --git a/src/target/arc.c b/src/target/arc.c index f2482c25ef..4a6303fbeb 100644 --- a/src/target/arc.c +++ b/src/target/arc.c @@ -769,7 +769,7 @@ static int arc_exit_debug(struct target *target) target->state = TARGET_HALTED; CHECK_RETVAL(target_call_event_callbacks(target, TARGET_EVENT_HALTED)); - if (debug_level >= LOG_LVL_DEBUG) { + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) { LOG_TARGET_DEBUG(target, "core stopped (halted) debug-reg: 0x%08" PRIx32, value); CHECK_RETVAL(arc_jtag_read_aux_reg_one(&arc->jtag_info, AUX_STATUS32_REG, &value)); LOG_TARGET_DEBUG(target, "core STATUS32: 0x%08" PRIx32, value); @@ -824,7 +824,7 @@ static int arc_halt(struct target *target) CHECK_RETVAL(target_call_event_callbacks(target, TARGET_EVENT_HALTED)); /* some more debug information */ - if (debug_level >= LOG_LVL_DEBUG) { + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) { LOG_TARGET_DEBUG(target, "core stopped (halted) DEGUB-REG: 0x%08" PRIx32, value); CHECK_RETVAL(arc_get_register_value(target, "status32", &value)); LOG_TARGET_DEBUG(target, "core STATUS32: 0x%08" PRIx32, value); @@ -1148,7 +1148,7 @@ static int arc_arch_state(struct target *target) { uint32_t pc_value; - if (debug_level < LOG_LVL_DEBUG) + if (!LOG_LEVEL_IS(LOG_LVL_DEBUG)) return ERROR_OK; CHECK_RETVAL(arc_get_register_value(target, "pc", &pc_value)); diff --git a/src/target/arm720t.c b/src/target/arm720t.c index 702d6cfb10..ddb91ff39f 100644 --- a/src/target/arm720t.c +++ b/src/target/arm720t.c @@ -323,7 +323,7 @@ static int arm720t_soft_reset_halt(struct target *target) return retval; } else break; - if (debug_level >= 3) + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) alive_sleep(100); else keep_alive(); diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index 5550fb1e24..60a9155176 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -637,7 +637,7 @@ int arm7_9_execute_sys_speed(struct target *target) if ((buf_get_u32(dbg_stat->value, EICE_DBG_STATUS_DBGACK, 1)) && (buf_get_u32(dbg_stat->value, EICE_DBG_STATUS_SYSCOMP, 1))) break; - if (debug_level >= 3) + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) alive_sleep(100); else keep_alive(); @@ -1088,7 +1088,7 @@ int arm7_9_soft_reset_halt(struct target *target) retval = jtag_execute_queue(); if (retval != ERROR_OK) return retval; - if (debug_level >= 3) + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) alive_sleep(100); else keep_alive(); diff --git a/src/target/arm920t.c b/src/target/arm920t.c index 67c212e0bf..441e423054 100644 --- a/src/target/arm920t.c +++ b/src/target/arm920t.c @@ -746,7 +746,7 @@ int arm920t_soft_reset_halt(struct target *target) return retval; } else break; - if (debug_level >= 3) { + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) { /* do not eat all CPU, time out after 1 se*/ alive_sleep(100); } else diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c index a3fff2ae5e..560109228b 100644 --- a/src/target/arm926ejs.c +++ b/src/target/arm926ejs.c @@ -544,7 +544,7 @@ int arm926ejs_soft_reset_halt(struct target *target) return retval; } else break; - if (debug_level >= 1) { + if (LOG_LEVEL_IS(LOG_LVL_WARNING)) { /* do not eat all CPU, time out after 1 se*/ alive_sleep(100); } else diff --git a/src/target/xscale.c b/src/target/xscale.c index 50e03f202e..ccaaceb763 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -400,7 +400,7 @@ static int xscale_read_tx(struct target *target, int consume) } if (!((!(field0_in & 1)) && consume)) goto done; - if (debug_level >= 3) { + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) { LOG_DEBUG("waiting 100ms"); alive_sleep(100); /* avoid flooding the logs */ } else @@ -471,7 +471,7 @@ static int xscale_write_rx(struct target *target) } if (!(field0_in & 1)) goto done; - if (debug_level >= 3) { + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) { LOG_DEBUG("waiting 100ms"); alive_sleep(100); /* avoid flooding the logs */ } else -- |
From: Antonio B. <bor...@gm...> - 2025-08-04 10:22:18
|
Hello! Today we have in OpenOCD enum log_levels { LOG_LVL_SILENT = -3, LOG_LVL_OUTPUT = -2, LOG_LVL_USER = -1, LOG_LVL_ERROR = 0, LOG_LVL_WARNING = 1, LOG_LVL_INFO = 2, LOG_LVL_DEBUG = 3, LOG_LVL_DEBUG_IO = 4, }; If we enable log level "debug", or even worse with "debug_io", we get everything printed out. Too much, not very informative. In my wishlist there I see the possibility to better filter the debug messages, similar to what is done in Linux kernel. Beside the current option of a number for the log levels, I would like to use a list of strings corresponding to subsets in the common log level "debug", while making "debug_io" obsolete. The subsets can be, e.g.: "target", "flash", transport", "io", "usb", "gdb", "socket", ..., and the special string "all" that enables all of them that will work as the full level 3. I mean: "debug_level 3" and "debug_level all" to be equivalent. Then, having the possibility to use "debug level {flash gdb socket}" to enable the level "debug" only for the specified parts of the code. I was considering this for a future activity after v1.0.0 because it could be too invasive for this end of dev cycle. My proposal is, as a first step, to simply add a new entry in "log_level": LOG_LVL_DEBUG_USB. Then convert current _DEBUG_USB_COMMS_ code under this new category. So using separate LOG_DEBUG(), LOG_DEBUG_IO() and the new LOG_DEBUG_USB() in the meantime. This will at least isolate the USB messages from the others, making further work easier. Then, trying to use the new log level for all the USB transfers. And for a longer term and independently from this, we could see the split by subsets. Would it make sense for you? Do you see anything that could prevent using LOG_DEBUG_USB() ? Regards, Antonio On Sun, Aug 3, 2025 at 10:07 PM R. Diez <rdi...@rd...> wrote: > > Hallo Antonio Borneo: > > I wanted to remove configuration option --enable-verbose-usb-comms from configure.ac and replace it with a new run-time option --verbose-usb-comms in the openocd executable. > > My first thought for options.c was (see HAVE_LIBUSB1 below): > > static const struct option long_options[] = { > {"help", no_argument, &help_flag, 1}, > {"version", no_argument, &version_flag, 1}, > {"debug", optional_argument, NULL, 'd'}, > {"file", required_argument, NULL, 'f'}, > {"search", required_argument, NULL, 's'}, > {"log_output", required_argument, NULL, 'l'}, > {"command", required_argument, NULL, 'c'}, > #ifdef HAVE_LIBUSB1 > {"verbose-usb-comms", no_argument, &enable_verbose_usb_comms, 1}, > #endif > {NULL, 0, NULL, 0} > }; > > Where should I place variable 'enable_verbose_usb_comms'? It should be accessible from options.c and from these modules: > > opendous.c > arm-jtag-ew.c > openjtag.c > ti_icdi_usb.c > ulink.c > > My first though was to place it in libusb_helper.h, but that header file is not easily accessible from options.c . > > I was only planning to convert code as follows: > > From: > #ifdef _DEBUG_USB_COMMS_ > opendous_debug_buffer(buffer, (scan_size + 7) / 8); > #endif > > To: > if ( enable_verbose_usb_comms ) > { > opendous_debug_buffer(buffer, (scan_size + 7) / 8); > } > > The refactoring into libusb_helper.h & .c you mentioned is too extensive for a first step. > > Best regards, > rdiez > |
From: R. D. <rdi...@rd...> - 2025-08-03 20:33:04
|
Hallo Antonio Borneo: I wanted to remove configuration option --enable-verbose-usb-comms from configure.ac and replace it with a new run-time option --verbose-usb-comms in the openocd executable. My first thought for options.c was (see HAVE_LIBUSB1 below): static const struct option long_options[] = { {"help", no_argument, &help_flag, 1}, {"version", no_argument, &version_flag, 1}, {"debug", optional_argument, NULL, 'd'}, {"file", required_argument, NULL, 'f'}, {"search", required_argument, NULL, 's'}, {"log_output", required_argument, NULL, 'l'}, {"command", required_argument, NULL, 'c'}, #ifdef HAVE_LIBUSB1 {"verbose-usb-comms", no_argument, &enable_verbose_usb_comms, 1}, #endif {NULL, 0, NULL, 0} }; Where should I place variable 'enable_verbose_usb_comms'? It should be accessible from options.c and from these modules: opendous.c arm-jtag-ew.c openjtag.c ti_icdi_usb.c ulink.c My first though was to place it in libusb_helper.h, but that header file is not easily accessible from options.c . I was only planning to convert code as follows: From: #ifdef _DEBUG_USB_COMMS_ opendous_debug_buffer(buffer, (scan_size + 7) / 8); #endif To: if ( enable_verbose_usb_comms ) { opendous_debug_buffer(buffer, (scan_size + 7) / 8); } The refactoring into libusb_helper.h & .c you mentioned is too extensive for a first step. Best regards, rdiez |