|
From: openocd-gerrit <ope...@us...> - 2026-07-11 09:04:51
|
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 eff5f00e518438fdb767fd3edc0b9be1fda8723d (commit)
from 16b9eae804f394e72a1ba6eccba9bcb461a0230a (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 eff5f00e518438fdb767fd3edc0b9be1fda8723d
Author: HAOUES Ahmed <ahm...@st...>
Date: Thu Jul 17 09:00:26 2025 +0100
flash/bluenrg-x: fix working area buffer size calculation
Adjust buffer_size to use available working area minus 128 bytes
reserved for write_algorithm_stack and 8 bytes reserved for read
and write pointers.
Ensure buffer_size is aligned to FLASH_DATA_WIDTH boundary.
Add checks to handle insufficient working area (<256 bytes) with
a warning and resource cleanup.
Cap buffer_size at 16384 + 8 bytes to avoid diminishing returns on
larger buffers.
Change-Id: I428a5de1bb6b1c3af0cba41e9a50278c45a1c54c
Signed-off-by: HAOUES Ahmed <ahm...@st...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9530
Reviewed-by: Tomas Vanek <va...@fb...>
Tested-by: jenkins
Reviewed-by: Antonio Borneo <bor...@gm...>
diff --git a/src/flash/nor/bluenrg-x.c b/src/flash/nor/bluenrg-x.c
index caf659eff..651daa98d 100644
--- a/src/flash/nor/bluenrg-x.c
+++ b/src/flash/nor/bluenrg-x.c
@@ -11,6 +11,7 @@
#include <helper/binarybuffer.h>
#include "helper/types.h"
+#include "helper/align.h"
#include <target/algorithm.h>
#include <target/armv7m.h>
#include <target/cortex_m.h>
@@ -273,7 +274,7 @@ static int bluenrgx_write_with_loader(struct flash_bank *bank, const uint8_t *bu
{
struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
struct target *target = bank->target;
- uint32_t buffer_size = 16384 + 8;
+ uint32_t max_buffer_size = 16384 + 8;
struct working_area *write_algorithm;
struct working_area *write_algorithm_stack;
struct working_area *source;
@@ -302,6 +303,23 @@ static int bluenrgx_write_with_loader(struct flash_bank *bank, const uint8_t *bu
if (retval != ERROR_OK)
return retval;
+ /* Compute usable buffer size by excluding 128 bytes for write_algorithm_stack
+ * and 8 bytes for read and write pointers.
+ */
+ uint32_t buffer_size = target_get_working_area_avail(target) - 128 - 8;
+ /* buffer size should be multiple of FLASH_DATA_WIDTH*/
+ buffer_size = ALIGN_DOWN(buffer_size, FLASH_DATA_WIDTH);
+ buffer_size += 8;
+
+ if (buffer_size < 256) {
+ LOG_WARNING("large enough working area not available, can't do block memory writes");
+ target_free_working_area(target, write_algorithm);
+ return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
+ } else if (buffer_size > max_buffer_size) {
+ /* probably won't benefit from more than 16k ... */
+ buffer_size = max_buffer_size;
+ }
+
/* memory buffer */
if (target_alloc_working_area(target, buffer_size, &source)) {
LOG_WARNING("no large enough working area available");
-----------------------------------------------------------------------
Summary of changes:
src/flash/nor/bluenrg-x.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
hooks/post-receive
--
Main OpenOCD repository
|