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

commit 5a0b0d5db5c30b31f636463ad057ff663e17865e
Author: chenzihan1 <[email protected]>
AuthorDate: Tue Feb 10 11:34:51 2026 +0800

    drivers/syslog/syslog_rpmsg: initialize the buffer on first use only
    
    syslog_rpmsg_init() runs from drivers_initialize(), which on some
    platforms (qemu) is before board_early_initialize() has set the address
    of a shared log buffer. Initialize the buffer when the endpoint is
    created instead: that is where the first transfer is queued, possibly
    before anything was logged. The first write still initializes it too.
    
    Signed-off-by: chenzihan1 <[email protected]>
    Signed-off-by: Bowen Wang <[email protected]>
---
 drivers/syslog/syslog_rpmsg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/syslog/syslog_rpmsg.c b/drivers/syslog/syslog_rpmsg.c
index 9fcb69a4c1d..e5a246731a9 100644
--- a/drivers/syslog/syslog_rpmsg.c
+++ b/drivers/syslog/syslog_rpmsg.c
@@ -324,6 +324,9 @@ static void syslog_rpmsg_device_created(FAR struct 
rpmsg_device *rdev,
                              syslog_rpmsg_ept_cb, NULL);
       if (ret == 0)
         {
+          /* The first transfer may run before anything was logged */
+
+          syslog_rpmsg_init_buffer(priv);
           work_queue(HPWORK, &priv->work, syslog_rpmsg_work, priv, 0);
         }
     }
@@ -431,7 +434,6 @@ int syslog_rpmsg_init(void)
     }
 #endif
 
-  syslog_rpmsg_init_buffer(&g_syslog_rpmsg);
   return rpmsg_register_callback(&g_syslog_rpmsg,
                                  syslog_rpmsg_device_created,
                                  syslog_rpmsg_device_destroy,

Reply via email to