This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 91950ed6f system/fastboot: add an optional fixed download buffer
address
91950ed6f is described below
commit 91950ed6fc578494d44716b19fb07c5e76aa353f
Author: wangjianyu3 <[email protected]>
AuthorDate: Mon Oct 26 00:22:19 2026 +0800
system/fastboot: add an optional fixed download buffer address
The download buffer is malloc'ed by default. Boards that would rather
keep a large buffer out of the heap can set
SYSTEM_FASTBOOTD_DOWNLOAD_ADDR to a reserved region of
SYSTEM_FASTBOOTD_DOWNLOAD_MAX bytes, as U-Boot and LK do; fastbootd
then neither allocates nor frees it. The default 0 keeps malloc.
Assisted-by: OpenCode:mimo-v2.6-pro
Signed-off-by: wangjianyu3 <[email protected]>
---
system/fastboot/Kconfig | 4 ++++
system/fastboot/fastboot.c | 9 +++++++++
2 files changed, 13 insertions(+)
diff --git a/system/fastboot/Kconfig b/system/fastboot/Kconfig
index fa551d26f..ff4bc1caa 100644
--- a/system/fastboot/Kconfig
+++ b/system/fastboot/Kconfig
@@ -30,6 +30,10 @@ config SYSTEM_FASTBOOTD_DOWNLOAD_MAX
int "fastboot download buffer size"
default 40960
+config SYSTEM_FASTBOOTD_DOWNLOAD_ADDR
+ hex "fixed download buffer address (0 = malloc)"
+ default 0x0
+
config SYSTEM_FASTBOOTD_USB
bool "Fastboot USB transport"
default y
diff --git a/system/fastboot/fastboot.c b/system/fastboot/fastboot.c
index 7a7635ea3..4364ef4d0 100644
--- a/system/fastboot/fastboot.c
+++ b/system/fastboot/fastboot.c
@@ -1606,7 +1606,12 @@ static int fastboot_context_initialize(FAR struct
fastboot_ctx_s *ctx,
ctx->tran_fd[0] = -1;
ctx->tran_fd[1] = -1;
+#if CONFIG_SYSTEM_FASTBOOTD_DOWNLOAD_ADDR != 0
+ ctx->download_buffer =
+ (FAR void *)(uintptr_t)CONFIG_SYSTEM_FASTBOOTD_DOWNLOAD_ADDR;
+#else
ctx->download_buffer = malloc(CONFIG_SYSTEM_FASTBOOTD_DOWNLOAD_MAX);
+#endif
if (ctx->download_buffer == NULL)
{
fb_err("ERROR: Could not allocate the memory.\n");
@@ -1616,7 +1621,9 @@ static int fastboot_context_initialize(FAR struct
fastboot_ctx_s *ctx,
ret = ctx->ops->init(ctx);
if (ret < 0)
{
+#if CONFIG_SYSTEM_FASTBOOTD_DOWNLOAD_ADDR == 0
free(ctx->download_buffer);
+#endif
ctx->download_buffer = NULL;
ctx->ops->deinit(ctx);
}
@@ -1633,7 +1640,9 @@ static void fastboot_context_deinit(FAR struct
fastboot_ctx_s *ctx,
if (ctx->download_buffer)
{
ctx->ops->deinit(ctx);
+#if CONFIG_SYSTEM_FASTBOOTD_DOWNLOAD_ADDR == 0
free(ctx->download_buffer);
+#endif
}
}
}