|
From: openocd-gerrit <ope...@us...> - 2026-10-16 07:31:12
|
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 930a525e7c18146e96586aff017119ba702d9018 (commit)
from 30efa3e11f10b5eff0d2449c9fe0223c8f1e49ed (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 930a525e7c18146e96586aff017119ba702d9018
Author: Marc Schink <de...@za...>
Date: Sun Dec 7 15:35:37 2025 +0000
flash/nor: Support erase operation on banks without sectors
This enables erasing flash banks that have no sectors, such as
configuration areas. Currently, these banks use a single sector as a
workaround.
This change is also required for a follow-up patch that adds support for
non-flash NVM, such as RRAM, which has no concept of sectors at all.
Although erase operations are not needed, GDB still issues them because
all NVM is advertised as flash memory. Internally, we treat the erase
operation as a no-op.
Note that this change is a pragmatic workaround given the current
codebase constraints, not the ideal implementation. In the future, a
model of NVM banks that better reflects their different properties
should be implemented.
Tested with nRF54L15-DK, tested for regression with AT32F421C8T7.
Change-Id: I0ff4ecd36332aa8e0d73bf7cf81fcda4381d6532
Signed-off-by: Marc Schink <de...@za...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9288
Reviewed-by: Tomas Vanek <tom...@gm...>
Tested-by: jenkins
diff --git a/src/flash/nor/core.c b/src/flash/nor/core.c
index 6a9d58ee2..e71546348 100644
--- a/src/flash/nor/core.c
+++ b/src/flash/nor/core.c
@@ -468,19 +468,22 @@ static int flash_iterate_address_range_inner(struct target *target,
if (retval != ERROR_OK)
return retval;
- if (c->size == 0 || c->num_sectors == 0) {
+ if (c->size == 0) {
LOG_ERROR("Bank is invalid");
return ERROR_FLASH_BANK_INVALID;
}
- if (length == 0) {
- /* special case, erase whole bank when length is zero */
+ if (length == 0 || c->sectors == 0) {
+ /*
+ * Special case, erase whole bank when length is zero or the
+ * bank has no sectors.
+ */
if (addr != c->base) {
LOG_ERROR("Whole bank access must start at beginning of bank.");
return ERROR_FLASH_DST_BREAKS_ALIGNMENT;
}
- return callback(c, 0, c->num_sectors - 1);
+ return callback(c, 0, (c->num_sectors == 0) ? 0 : c->num_sectors - 1);
}
/* check whether it all fits in this bank */
diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c
index 5b8bda884..9cf7fdfef 100644
--- a/src/flash/nor/tcl.c
+++ b/src/flash/nor/tcl.c
@@ -302,23 +302,29 @@ COMMAND_HANDLER(handle_flash_erase_command)
if (retval != ERROR_OK)
return retval;
- COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], first);
- if (strcmp(CMD_ARGV[2], "last") == 0)
- last = p->num_sectors - 1;
- else
- COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], last);
+ if (p->num_sectors == 0) {
+ LOG_INFO("bank has no sectors, ignoring specified sectors");
+ first = 0;
+ last = 0;
+ } else {
+ COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], first);
+ if (strcmp(CMD_ARGV[2], "last") == 0)
+ last = p->num_sectors - 1;
+ else
+ COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], last);
- if (!(first <= last)) {
- command_print(CMD, "ERROR: "
- "first sector must be <= last");
- return ERROR_FAIL;
- }
+ if (!(first <= last)) {
+ command_print(CMD, "ERROR: "
+ "first sector must be <= last");
+ return ERROR_FAIL;
+ }
- if (!(last <= (p->num_sectors - 1))) {
- command_print(CMD, "ERROR: "
- "last sector must be <= %u",
- p->num_sectors - 1);
- return ERROR_FAIL;
+ if (!(last <= (p->num_sectors - 1))) {
+ command_print(CMD, "ERROR: "
+ "last sector must be <= %u",
+ p->num_sectors - 1);
+ return ERROR_FAIL;
+ }
}
struct duration bench;
-----------------------------------------------------------------------
Summary of changes:
src/flash/nor/core.c | 11 +++++++----
src/flash/nor/tcl.c | 36 +++++++++++++++++++++---------------
2 files changed, 28 insertions(+), 19 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|