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.git
The following commit(s) were added to refs/heads/master by this push:
new 82f3a18861c drivers/note: add NOTERAM_TEXT_DUMP to optionally exclude
text dump.
82f3a18861c is described below
commit 82f3a18861caa180754cae797a577c03475385f5
Author: yukangzhi <[email protected]>
AuthorDate: Fri Mar 27 09:42:14 2026 +0800
drivers/note: add NOTERAM_TEXT_DUMP to optionally exclude text dump.
Add the CONFIG_DRIVERS_NOTERAM_TEXT_DUMP Kconfig option (default y) to
allow disabling the human-readable text read mode of the noteram
driver.
When disabled, only the binary read mode (NOTERAM_MODE_READ_BINARY) is
available, which reduces code size by compiling out:
- noteram_dump_init_context(), noteram_dump_one() and their helpers
when neither TEXT_DUMP nor CRASH_DUMP is enabled
- the text format branch in noteram_read()
The default keeps the current behavior.
Assisted-by: Kiro
Signed-off-by: yukangzhi <[email protected]>
---
Documentation/debugging/tasktraceuser.rst | 8 ++++++++
drivers/note/Kconfig | 8 ++++++++
drivers/note/noteram_driver.c | 20 +++++++++++++++++++-
3 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/Documentation/debugging/tasktraceuser.rst
b/Documentation/debugging/tasktraceuser.rst
index 6756366fc59..45bb44b5c18 100644
--- a/Documentation/debugging/tasktraceuser.rst
+++ b/Documentation/debugging/tasktraceuser.rst
@@ -64,6 +64,14 @@ The following configurations are configurable parameters for
trace.
- If enabled, it will dump the data in the noteram buffer after a system
crash.
This function can help to view the behavior of the system before the crash
+- ``CONFIG_DRIVERS_NOTERAM_TEXT_DUMP``
+
+ - If enabled (default), reading the noteram device in the default read mode
+ returns the notes as human-readable text. If disabled, only the binary
+ read mode (``NOTERAM_MODE_READ_BINARY``) is available, which saves code
+ size. The text formatting code is still built when
+ ``CONFIG_DRIVERS_NOTERAM_CRASH_DUMP`` is enabled.
+
After the configuration, rebuild the NuttX kernel and application.
If the trace function is enabled, "``trace``"
:doc:`../applications/nsh/builtin` will be available.
diff --git a/drivers/note/Kconfig b/drivers/note/Kconfig
index cd1f312ff87..904ad6b9cf3 100644
--- a/drivers/note/Kconfig
+++ b/drivers/note/Kconfig
@@ -112,6 +112,14 @@ config DRIVERS_NOTERAM_CRASH_DUMP
---help---
If this option is enabled, dump all contents when a crash
occurs.
+config DRIVERS_NOTERAM_TEXT_DUMP
+ bool "Enable text format read mode"
+ default y
+ ---help---
+ Enable human-readable text dump via read(). When disabled, only
+ binary mode (NOTERAM_MODE_READ_BINARY) is available, saving code
+ size.
+
endif # DRIVERS_NOTERAM
config DRIVERS_NOTE_STRIP_FORMAT
diff --git a/drivers/note/noteram_driver.c b/drivers/note/noteram_driver.c
index f391fccfd39..ed12808508a 100644
--- a/drivers/note/noteram_driver.c
+++ b/drivers/note/noteram_driver.c
@@ -130,10 +130,13 @@ static int noteram_poll(FAR struct file *filep, FAR
struct pollfd_s *fds,
bool setup);
static void noteram_add(FAR struct note_driver_s *drv,
FAR const void *note, size_t len);
+#if defined(CONFIG_DRIVERS_NOTERAM_TEXT_DUMP) || \
+ defined(CONFIG_DRIVERS_NOTERAM_CRASH_DUMP)
static void
noteram_dump_init_context(FAR struct noteram_dump_context_s *ctx);
static int noteram_dump_one(FAR uint8_t *p, FAR struct lib_outstream_s *s,
FAR struct noteram_dump_context_s *ctx);
+#endif
/****************************************************************************
* Private Data
@@ -459,7 +462,10 @@ static int noteram_open(FAR struct file *filep)
drv->threshold = sizeof(struct note_common_s);
filep->f_priv = ctx;
+#if defined(CONFIG_DRIVERS_NOTERAM_TEXT_DUMP) || \
+ defined(CONFIG_DRIVERS_NOTERAM_CRASH_DUMP)
noteram_dump_init_context(ctx);
+#endif
return OK;
}
@@ -479,20 +485,26 @@ int noteram_close(FAR struct file *filep)
static ssize_t noteram_read(FAR struct file *filep, FAR char *buffer,
size_t buflen)
{
+#ifdef CONFIG_DRIVERS_NOTERAM_TEXT_DUMP
FAR struct noteram_dump_context_s *ctx = filep->f_priv;
+#endif
FAR struct noteram_driver_s *drv = filep->f_inode->i_private;
- FAR struct lib_memoutstream_s stream;
ssize_t ret;
irqstate_t flags;
+#ifdef CONFIG_DRIVERS_NOTERAM_TEXT_DUMP
if (ctx->mode == NOTERAM_MODE_READ_BINARY)
+#endif
{
flags = spin_lock_irqsave_notrace(&drv->lock);
ret = noteram_get(drv, (FAR uint8_t *)buffer, buflen);
spin_unlock_irqrestore_notrace(&drv->lock, flags);
}
+#ifdef CONFIG_DRIVERS_NOTERAM_TEXT_DUMP
else
{
+ struct lib_memoutstream_s stream;
+
lib_memoutstream(&stream, buffer, buflen);
do
@@ -516,6 +528,7 @@ static ssize_t noteram_read(FAR struct file *filep, FAR
char *buffer,
}
while (ret == 0);
}
+#endif
return ret;
}
@@ -782,6 +795,9 @@ static void noteram_add(FAR struct note_driver_s *driver,
}
}
+#if defined(CONFIG_DRIVERS_NOTERAM_TEXT_DUMP) || \
+ defined(CONFIG_DRIVERS_NOTERAM_CRASH_DUMP)
+
/****************************************************************************
* Name: noteram_dump_init_context
****************************************************************************/
@@ -1293,6 +1309,8 @@ static int noteram_dump_one(FAR uint8_t *p, FAR struct
lib_outstream_s *s,
return ret;
}
+#endif /* NOTERAM_TEXT_DUMP || NOTERAM_CRASH_DUMP */
+
#ifdef CONFIG_DRIVERS_NOTERAM_CRASH_DUMP
/****************************************************************************