Skip to content

Conversation

@hathach
Copy link
Owner

@hathach hathach commented Nov 22, 2025

for port with dedicated hw fifo i.e writing data to device fifo instead of DMA. We can omit ep buffer for xfer_fifo() and pretty much normal edpt_xfer() TX direction. Currently only enabled this for dwc2 with cdc, midi device. Vendor is updated in the follow-up PR but need to be careful with no-buffer mode (edpt_xfer only)

Sum up

  • add CFG_TUD_EDPT_DEDICATED_HWFIFO for dwc2 when slave is enabled and dma is disabled
  • remove epbuf for device cdc (tx,rx, notify), midi when CFG_TUD_EDPT_DEDICATED_HWFIFO = 1
  • major refactor tusb_fifo, lots of rename and moving. Use LLM to add more unit test for fifo
  • add tud_cdc_n_notify_msg() API
  • fix rhport for vendor device is hard coded to 0
  • fix vendor device read() with non-fifo mode (RX_BUFSIZE = 0)

Copilot AI review requested due to automatic review settings November 22, 2025 04:08
Copilot finished reviewing on behalf of hathach November 22, 2025 04:11
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request removes intermediate endpoint buffers for USB endpoints with dedicated hardware FIFOs, optimizing memory usage and data transfer efficiency for certain USB controllers like DWC2.

  • Introduces CFG_TUD_EDPT_DEDICATED_HWFIFO configuration to enable direct hardware FIFO access without intermediate buffering
  • Refactors FIFO API to use tu_fifo_access_mode_t enum with TU_FIFO_FIXED_ADDR_RW32 mode for hardware FIFO operations
  • Updates CDC device class to conditionally allocate EP buffers only when hardware FIFOs are not available

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test/unit-test/test/test_fifo.c Reformatted code and added comprehensive test coverage for new FIFO access modes and edge cases
test/unit-test/project.yml Added CFG_TUSB_FIFO_ACCESS_FIXED_ADDR_RW32 define for test builds
test/unit-test/CMakeLists.txt New CMake build system for unit tests with Ceedling integration
test/hil/hil_test.py Enhanced CDC tests with variable payload sizes and improved error messages
src/tusb_option.h Added configuration options for dedicated hardware FIFO support and migrated to #pragma once
src/tusb.c Modified stream transfer logic to support NULL ep_buf and use xfer_fifo API when available
src/portable/synopsys/dwc2/dcd_dwc2.c Updated to use new tu_fifo_read_n_access/tu_fifo_write_n_access API with TU_FIFO_FIXED_ADDR_RW32
src/portable/nuvoton/nuc505/dcd_nuc505.c Updated commented-out code to use new FIFO access API
src/portable/microchip/samg/dcd_samg.c Updated commented-out code to use new FIFO access API
src/device/usbd.c Added CFG_TUD_EDPT_DEDICATED_HWFIFO guard for xfer_fifo implementation and formatting cleanup
src/common/tusb_private.h Updated ep_buf comment to clarify NULL usage with dedicated hardware FIFOs
src/common/tusb_mcu.h Migrated to #pragma once and removed TUP_MEM_CONST_ADDR definition
src/common/tusb_fifo.h Refactored API to expose tu_fifo_access_mode_t and reorganized inline helper functions
src/common/tusb_fifo.c Major refactoring: renamed internal functions, moved helpers to header, fixed mutex usage
src/class/cdc/cdc_device.c Conditionally compiled EP buffers and improved wanted char search logic for hardware FIFO compatibility
docs/info/changelog.rst Updated release date (contains error: year changed to 2025 instead of 2024)
.clang-format Added PPIndentWidth configuration and removed ReflowComments option

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sonarqubecloud
Copy link

@hathach hathach merged commit 5ef55bf into master Nov 27, 2025
126 of 127 checks passed
@hathach hathach deleted the xfer-fifo branch November 27, 2025 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants