maxikrie opened a new pull request, #20926:
URL: https://github.com/apache/nuttx/pull/20926

   ## Summary
   
   The ESP32-S3 OTG device driver lays out its FIFOs in more RAM than the
   hardware has. Its IN TxFIFOs then overlap the RxFIFO, so OUT packets from the
   host overwrite data queued for pending IN transfers.
   
   - The driver partitions `ESP32S3_FIFO_SIZE = 1280` bytes, the STM32F4 OTG_FS
     figure. On the ESP32-S3, `GHWCFG3` reports a data FIFO depth of 200 words
     (800 bytes): the 1 KiB FIFO RAM less the words the core reserves for
     endpoint information.
   - With the default split (half to the RxFIFO, half shared by the TxFIFOs),
     the TxFIFOs start at or past the end of that RAM.
   
   This PR:
   
   - sets `ESP32S3_FIFO_SIZE` to 800 bytes; the RxFIFO/TxFIFO split logic is
     unchanged;
   - in a separate commit, fixes the existing nxstyle errors in
     `esp32s3_otg_device.c` (missing blank lines after declarations), so the
     file passes checkpatch.
   
   ## Impact
   
   - ESP32-S3 boards with `CONFIG_ESP32S3_OTG_DEVICE` (CDC-ACM, USB NSH, ADB,
     fastboot, UVC, ...): every FIFO now lies inside the FIFO RAM, so received
     OUT packets no longer corrupt pending IN data.
   - Each FIFO is smaller. With the default `CONFIG_ESP32S3_OTG_ENDPOINT_NUM=3`,
     each TxFIFO is 100 bytes and the RxFIFO 400 bytes; in-tree configs use at
     most 2 extra endpoints. At the maximum of 6 extra endpoints, the default
     TxFIFOs come to 60 bytes, below a 64-byte max packet; such a configuration
     needs `CONFIG_USBDEV_EPn_TXFIFO_SIZE` overrides. (Before this change, that
     layout ran past the FIFO RAM entirely.)
   - No Kconfig, API or build changes.
   
   ## Testing
   
   Host: Debian Linux (kernel 6.1), x86_64.
   Toolchain: `xtensa-esp-elf-gcc (crosstool-NG esp-14.2.0_20241119) 14.2.0`
   
   - `esp32s3-devkit:usbnsh` builds on current `master` with
     `EXTRAFLAGS=-Werror`; `tools/checkpatch.sh` passes on both commits.
   - Hardware: a custom ESP32-S3 board running CDC-ACM (default 3 extra
     endpoints) on NuttX 12.13 with the same FIFO size change. The board streams
     data to the host continuously over bulk IN while accepting commands over
     bulk OUT. Before the fix, host commands arriving during the stream 
corrupted
     pending bulk-IN transfers and wedged the link until a stall recovery 
rebound
     the class driver. With the fix, the corruption is gone.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to