|
From: openocd-gerrit <ope...@us...> - 2026-10-16 07:32:45
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via fb58d764b4caabdece22d729bcce2daab9e4b370 (commit)
from 930a525e7c18146e96586aff017119ba702d9018 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit fb58d764b4caabdece22d729bcce2daab9e4b370
Author: Marc Schink <de...@za...>
Date: Sun Dec 7 20:54:57 2025 +0000
flash/nor: Handle banks without erase support
Handle banks that do not support an erase operation. This essentially only
applies to non-flash NVM banks.
Since all NVM is exposed to GDB as flash memory, GDB always issues an erase
before programming. We silently ignore the unsupported erase operation for
GDB requests. For the corresponding Tcl commands, we propagate the error of
missing support to the user.
To avoid confusing messages when programming (and auto-erasing) via GDB,
we remove lower-layer error logging.
While at it, rework the error handling in the respective command
handlers.
Tested with nRF54L15-DK, tested for regression with AT32F421C8T7.
Change-Id: Ic5a84b7af64d5c5dbe4bcd1e78e566771c016ca6
Signed-off-by: Marc Schink <de...@za...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9289
Tested-by: jenkins
Reviewed-by: Tomas Vanek <tom...@gm...>
Reviewed-by: Antonio Borneo <bor...@gm...>
Reviewed-by: Tarek BOCHKATI <tar...@gm...>
diff --git a/src/flash/nor/core.c b/src/flash/nor/core.c
index e71546348..336283ae2 100644
--- a/src/flash/nor/core.c
+++ b/src/flash/nor/core.c
@@ -29,13 +29,7 @@ static struct flash_bank *flash_banks;
int flash_driver_erase(struct flash_bank *bank, unsigned int first,
unsigned int last)
{
- int retval;
-
- retval = bank->driver->erase(bank, first, last);
- if (retval != ERROR_OK)
- LOG_ERROR("failed erasing sectors %u to %u", first, last);
-
- return retval;
+ return bank->driver->erase(bank, first, last);
}
int flash_driver_protect(struct flash_bank *bank, int set, unsigned int first,
diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c
index 9cf7fdfef..c80b09c29 100644
--- a/src/flash/nor/tcl.c
+++ b/src/flash/nor/tcl.c
@@ -278,13 +278,21 @@ COMMAND_HANDLER(handle_flash_erase_address_command)
if (retval == ERROR_OK)
retval = flash_erase_address_range(target, do_pad, address, length);
- if (retval == ERROR_OK && duration_measure(&bench) == ERROR_OK) {
+ if (retval == ERROR_FLASH_OPER_UNSUPPORTED) {
+ command_print(CMD, "erase operation is not supported");
+ return retval;
+ } else if (retval != ERROR_OK) {
+ command_print(CMD, "erase operation failed");
+ return retval;
+ }
+
+ if (duration_measure(&bench) == ERROR_OK) {
command_print(CMD, "erased address " TARGET_ADDR_FMT " (length %" PRIu32 ")"
" in %fs (%0.3f KiB/s)", address, length,
duration_elapsed(&bench), duration_kbps(&bench, length));
}
- return retval;
+ return ERROR_OK;
}
COMMAND_HANDLER(handle_flash_erase_command)
@@ -332,16 +340,21 @@ COMMAND_HANDLER(handle_flash_erase_command)
retval = flash_driver_erase(p, first, last);
- if (retval == ERROR_OK && duration_measure(&bench) == ERROR_OK) {
+ if (retval == ERROR_FLASH_OPER_UNSUPPORTED) {
+ command_print(CMD, "erase operation is not supported");
+ return retval;
+ } else if (retval != ERROR_OK) {
+ command_print(CMD, "failed to erase sectors");
+ return retval;
+ }
+
+ if (duration_measure(&bench) == ERROR_OK) {
command_print(CMD, "erased sectors %" PRIu32 " "
"through %" PRIu32 " on flash bank %u "
"in %fs", first, last, p->bank_number, duration_elapsed(&bench));
}
- if (retval != ERROR_OK)
- command_print(CMD, "failed to erase sectors");
-
- return retval;
+ return ERROR_OK;
}
COMMAND_HANDLER(handle_flash_protect_command)
diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index e9073468a..934ba2265 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -3654,8 +3654,12 @@ static int gdb_v_packet(struct connection *connection,
target_call_event_callbacks(target,
TARGET_EVENT_GDB_FLASH_ERASE_END);
- /* perform erase */
- if (result != ERROR_OK) {
+ /* Perform erase.
+ * If the driver does not support erase, we silently ignore it.
+ * This is expected for non-flash NVM which does not require an erase
+ * operation before programming.
+ */
+ if (result != ERROR_OK && result != ERROR_FLASH_OPER_UNSUPPORTED) {
/* GDB doesn't evaluate the actual error number returned,
* treat a failed erase as an I/O error
*/
-----------------------------------------------------------------------
Summary of changes:
src/flash/nor/core.c | 8 +-------
src/flash/nor/tcl.c | 27 ++++++++++++++++++++-------
src/server/gdb_server.c | 8 ++++++--
3 files changed, 27 insertions(+), 16 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|