This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 4a3bb802fba18eaa8d8f8458d1745dff50a6199a
Author: Ricard Rosson <[email protected]>
AuthorDate: Fri Nov 27 05:33:41 2026 +0000

    arch/xtensa/esp32s3: Start the transmission of the USB-Serial driver.
    
    The driver sent data only from the "IN empty" interrupt, which is
    raised when the host takes a packet.  esp32s3_txint() enabled the
    interrupt and relied on the flag of an earlier packet still being
    pending.  As far as can be told from the code, when that flag was
    already cleared and no packet was on its way to the host, no interrupt
    came, nothing was sent, and the writers blocked for ever once the
    transmit buffer was full.  Seen after a reset with the port open on
    the host: no output of the application at all.
    
    Send from esp32s3_txint() when the hardware buffer can take data, as
    other serial drivers do.
    
    Assisted-by: Claude Code:claude-fable-5-2
    Signed-off-by: Ricard Rosson <[email protected]>
---
 arch/xtensa/src/esp32s3/esp32s3_usbserial.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/arch/xtensa/src/esp32s3/esp32s3_usbserial.c 
b/arch/xtensa/src/esp32s3/esp32s3_usbserial.c
index dfa5ddb8754..8a9eee282cd 100644
--- a/arch/xtensa/src/esp32s3/esp32s3_usbserial.c
+++ b/arch/xtensa/src/esp32s3/esp32s3_usbserial.c
@@ -82,6 +82,7 @@ static void esp32s3_shutdown(struct uart_dev_s *dev);
 static int  esp32s3_attach(struct uart_dev_s *dev);
 static void esp32s3_detach(struct uart_dev_s *dev);
 static void esp32s3_txint(struct uart_dev_s *dev, bool enable);
+static void esp32s3_txkick(struct uart_dev_s *dev);
 static void esp32s3_rxint(struct uart_dev_s *dev, bool enable);
 static bool esp32s3_rxavailable(struct uart_dev_s *dev);
 static bool esp32s3_txready(struct uart_dev_s *dev);
@@ -211,6 +212,26 @@ static void esp32s3_shutdown(struct uart_dev_s *dev)
 {
 }
 
+/****************************************************************************
+ * Name: esp32s3_txkick
+ *
+ * Description:
+ *   Start the transmission when the hardware buffer can take data.  The
+ *   "IN empty" interrupt is raised when the host takes a packet; when the
+ *   flag of an earlier packet was already cleared and nothing is on its way
+ *   to the host, no interrupt would come to send the first byte.  Called
+ *   with the interrupts disabled.
+ *
+ ****************************************************************************/
+
+static void esp32s3_txkick(struct uart_dev_s *dev)
+{
+  if (dev->xmit.head != dev->xmit.tail && esp32s3_txready(dev))
+    {
+      uart_xmitchars(dev);
+    }
+}
+
 /****************************************************************************
  * Name: esp32s3_txint
  *
@@ -223,8 +244,12 @@ static void esp32s3_txint(struct uart_dev_s *dev, bool 
enable)
 {
   if (enable)
     {
+      irqstate_t flags = enter_critical_section();
+
       modifyreg32(USB_SERIAL_JTAG_INT_ENA_REG, 0,
                   USB_SERIAL_JTAG_SERIAL_IN_EMPTY_INT_ENA);
+      esp32s3_txkick(dev);
+      leave_critical_section(flags);
     }
   else
     {

Reply via email to