|
From: openocd-gerrit <ope...@us...> - 2026-10-16 07:32:55
|
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 66188cd58e767ec3e23efc31ec207c0e5ed4a84a (commit)
from fb58d764b4caabdece22d729bcce2daab9e4b370 (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 66188cd58e767ec3e23efc31ec207c0e5ed4a84a
Author: Marc Schink <de...@za...>
Date: Wed Dec 17 11:07:45 2025 +0000
flash/nor: Support erase check on banks without sectors
The current implementation of the deletion check is closely tied to the
concept of sectors. Implement a workaround to support sectorless banks
without having to make many changes to the code base.
Tested with nRF54L15-DK, tested for regression with AT32F421C8T7.
Change-Id: I88fd5d56f2edbd8337663bea8d25cd499c09add6
Signed-off-by: Marc Schink <de...@za...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9319
Reviewed-by: Antonio Borneo <bor...@gm...>
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tar...@gm...>
Reviewed-by: Tomas Vanek <tom...@gm...>
diff --git a/src/flash/nor/core.c b/src/flash/nor/core.c
index 336283ae2..c6de2f66a 100644
--- a/src/flash/nor/core.c
+++ b/src/flash/nor/core.c
@@ -373,6 +373,68 @@ done:
return retval;
}
+static int flash_blank_check_no_sectors_fast(struct flash_bank *bank)
+{
+ struct target_memory_check_block check_block;
+
+ check_block.address = bank->base;
+ check_block.size = bank->size;
+ // Erase state unknown.
+ check_block.result = UINT32_MAX;
+
+ unsigned int checked;
+ int retval = target_blank_check_memory(bank->target, &check_block, 1,
+ bank->erased_value, &checked);
+
+ if (retval != ERROR_OK)
+ return retval;
+
+ bank->is_erased = check_block.result;
+
+ return ERROR_OK;
+}
+
+static int flash_blank_check_no_sectors(struct flash_bank *bank)
+{
+ struct target *target = bank->target;
+ const uint32_t buffer_size = 1024;
+ uint8_t buffer[buffer_size];
+
+ if (bank->target->state != TARGET_HALTED) {
+ LOG_ERROR("Target not halted");
+ return ERROR_TARGET_NOT_HALTED;
+ }
+
+ int retval = flash_blank_check_no_sectors_fast(bank);
+ if (retval == ERROR_OK)
+ return retval;
+
+ LOG_WARNING("Fast erase check failed, running slow fallback");
+
+ bank->is_erased = -1;
+
+ for (uint32_t offset = 0; offset < bank->size; offset += buffer_size) {
+ uint32_t chunk_size = MIN(buffer_size, bank->size - offset);
+
+ retval = target_read_buffer(target, bank->base + offset,
+ chunk_size, buffer);
+
+ if (retval != ERROR_OK)
+ return retval;
+
+ for (uint32_t i = 0; i < chunk_size; i++) {
+ if (buffer[i] != bank->erased_value) {
+ bank->is_erased = 0;
+ return ERROR_OK;
+ }
+ }
+ }
+
+ bank->is_erased = 1;
+
+ return ERROR_OK;
+}
+
int default_flash_blank_check(struct flash_bank *bank)
{
struct target *target = bank->target;
@@ -383,6 +445,9 @@ int default_flash_blank_check(struct flash_bank *bank)
return ERROR_TARGET_NOT_HALTED;
}
+ if (bank->num_sectors == 0)
+ return flash_blank_check_no_sectors(bank);
+
struct target_memory_check_block *block_array;
block_array = malloc(bank->num_sectors * sizeof(struct target_memory_check_block));
if (!block_array) {
diff --git a/src/flash/nor/core.h b/src/flash/nor/core.h
index 55ea3c7e5..b1bb8ebba 100644
--- a/src/flash/nor/core.h
+++ b/src/flash/nor/core.h
@@ -116,6 +116,17 @@ struct flash_bank {
unsigned int num_sectors;
/** Array of sectors, allocated and initialized by the flash driver */
struct flash_sector *sectors;
+ /**
+ * Indication of erasure status: 0 = not erased, 1 = erased,
+ * other = unknown. Set by @c flash_driver::erase_check only.
+ *
+ * Use this only if the flash bank has no sectors.
+ *
+ * This information must be considered stale immediately.
+ * Don't set it in flash_driver::erase or a device mass_erase
+ * Don't clear it in flash_driver::write
+ */
+ int is_erased;
/**
* The number of protection blocks in this bank. This value
diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c
index c80b09c29..cf2494bda 100644
--- a/src/flash/nor/tcl.c
+++ b/src/flash/nor/tcl.c
@@ -221,6 +221,9 @@ COMMAND_HANDLER(handle_flash_erase_check_command)
erase_state);
}
+ if (p->num_sectors == 0)
+ blank = (p->is_erased == 1);
+
if (blank)
command_print(CMD, "\tBank is erased");
return retval;
-----------------------------------------------------------------------
Summary of changes:
src/flash/nor/core.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/flash/nor/core.h | 11 +++++++++
src/flash/nor/tcl.c | 3 +++
3 files changed, 79 insertions(+)
hooks/post-receive
--
Main OpenOCD repository
|