|
From: openocd-gerrit <ope...@us...> - 2026-09-16 19:49:04
|
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 339f088acdd706b3c6389755e677a47c1f15aa5b (commit)
from a6df9b87d55b1c1641259a97693f3da0f230f151 (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 339f088acdd706b3c6389755e677a47c1f15aa5b
Author: Tomas Vanek <va...@fb...>
Date: Thu Sep 3 21:01:07 2026 +0200
flash/nor: make flash driver read method optional
Currently more than 60 flash drivers define
.read = default_flash_read
Moreover two drivers (fm3 and dsp5680xx_flash) erroneously do not
define .read at all and therefore flash read commands will
cause OpenOCD segfault.
Fall back to default_flash_read() if the .read method is NULL
Change-Id: If115a0a4325c738a5db0b383c7037a20a10f5f54
Signed-off-by: Tomas Vanek <va...@fb...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9959
Reviewed-by: Antonio Borneo <bor...@gm...>
Tested-by: jenkins
diff --git a/src/flash/nor/core.c b/src/flash/nor/core.c
index 34698299b..6a9d58ee2 100644
--- a/src/flash/nor/core.c
+++ b/src/flash/nor/core.c
@@ -106,7 +106,10 @@ int flash_driver_read(struct flash_bank *bank,
LOG_DEBUG("call flash_driver_read()");
- retval = bank->driver->read(bank, buffer, offset, count);
+ if (bank->driver->read)
+ retval = bank->driver->read(bank, buffer, offset, count);
+ else
+ retval = default_flash_read(bank, buffer, offset, count);
if (retval != ERROR_OK) {
LOG_ERROR(
"error reading to flash at address " TARGET_ADDR_FMT
diff --git a/src/flash/nor/driver.h b/src/flash/nor/driver.h
index 0d55824e2..1d878c591 100644
--- a/src/flash/nor/driver.h
+++ b/src/flash/nor/driver.h
@@ -135,6 +135,9 @@ struct flash_driver {
* "bank->base + offset", while the physical address is
* dependent upon current target MMU mappings.
*
+ * If the flash does not need device specific read processing,
+ * set method to NULL and default_flash_read() will be used.
+ *
* @param bank The bank to read.
* @param buffer The data bytes read.
* @param offset The offset into the chip to read.
diff --git a/src/flash/nor/virtual.c b/src/flash/nor/virtual.c
index 5b8a3c5b7..2c2be0520 100644
--- a/src/flash/nor/virtual.c
+++ b/src/flash/nor/virtual.c
@@ -187,8 +187,11 @@ static int virtual_flash_read(struct flash_bank *bank,
if (!master_bank)
return ERROR_FLASH_OPERATION_FAILED;
- /* call master handler */
- return master_bank->driver->read(master_bank, buffer, offset, count);
+ /* call master handler or default */
+ if (master_bank->driver->read)
+ return master_bank->driver->read(master_bank, buffer, offset, count);
+
+ return default_flash_read(master_bank, buffer, offset, count);
}
void virtual_flash_free_driver_priv(struct flash_bank *bank)
-----------------------------------------------------------------------
Summary of changes:
src/flash/nor/core.c | 5 ++++-
src/flash/nor/driver.h | 3 +++
src/flash/nor/virtual.c | 7 +++++--
3 files changed, 12 insertions(+), 3 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|