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 5d6d92fb55882c48752bf57d5bdc6023d5232f7c
Author: Bowen Wang <[email protected]>
AuthorDate: Wed Jul 9 20:39:58 2025 +0800

    drivers/mtd/rpmsgmtd: wait for the server in every operation
    
    The requests that are sent by copy (erase, the geometry query and the
    read requests) went out with rpmsg_send() without waiting for the
    endpoint to be bound to the server, so an operation issued before the
    server appeared failed instead of waiting. Copy them into a buffer from
    rpmsgmtd_get_tx_payload_buffer(), which waits for the binding, and send
    every request with rpmsg_send_nocopy().
    
    Signed-off-by: Bowen Wang <[email protected]>
---
 drivers/mtd/rpmsgmtd.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/rpmsgmtd.c b/drivers/mtd/rpmsgmtd.c
index 2cda3befd31..1710ccf7c7f 100644
--- a/drivers/mtd/rpmsgmtd.c
+++ b/drivers/mtd/rpmsgmtd.c
@@ -740,13 +740,22 @@ static int rpmsgmtd_send_recv(FAR struct rpmsgmtd_s *priv,
 
   if (copy)
     {
-      ret = rpmsg_send(&priv->ept, msg, len);
-    }
-  else
-    {
-      ret = rpmsg_send_nocopy(&priv->ept, msg, len);
+      uint32_t buflen;
+      FAR void *buf;
+
+      buf = rpmsgmtd_get_tx_payload_buffer(priv, &buflen);
+      if (buf == NULL)
+        {
+          ret = -ENOMEM;
+          goto fail;
+        }
+
+      DEBUGASSERT(len <= buflen);
+      memcpy(buf, msg, len);
+      msg = buf;
     }
 
+  ret = rpmsg_send_nocopy(&priv->ept, msg, len);
   if (ret < 0)
     {
       goto fail;

Reply via email to