Skip to content

Conversation

HiFiPhile
Copy link
Collaborator

@HiFiPhile HiFiPhile commented Oct 10, 2025

Describe the PR
There was an issue in edpt_schedule_packets, as ep0_pending = xfer->max_size is set in dcd_edpt_xfer, ep0_pending will become 0.

if (epnum == 0) {
    total_bytes = tu_min16(_dcd_data.ep0_pending[dir], xfer->max_size);
    _dcd_data.ep0_pending[dir] -= total_bytes;
    num_packets = 1;
  } 

The issue didn't broken since we schedule only one control transfer each time.

I've add an option CFG_TUD_EP0_BUFSIZE to allow setting EP0 buffer size individually, tested with DFU examples withCFG_TUD_EP0_BUFSIZE=512

@Copilot Copilot AI review requested due to automatic review settings October 10, 2025 11:53
Copy link
Contributor

@Copilot 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 PR fixes EP0 multi-packet transfer logic in the DWC2 driver and adds configurable EP0 buffer size support. The issue was in the edpt_schedule_packets function where ep0_pending was incorrectly being set to xfer->max_size instead of the proper endpoint size, causing transfer size calculation errors.

Key changes:

  • Added CFG_TUD_EP0_BUFSIZE configuration option for EP0 buffer size
  • Fixed EP0 packet scheduling logic to use correct endpoint size
  • Enhanced packet transmission handling for single vs multi-packet transfers
  • Updated DFU examples with BOS descriptors and Microsoft OS 2.0 compatibility

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/tusb_option.h Added CFG_TUD_EP0_BUFSIZE configuration option
src/portable/synopsys/dwc2/dcd_dwc2.c Fixed EP0 transfer logic and improved packet handling
src/device/usbd_control.c Updated to use new CFG_TUD_EP0_BUFSIZE configuration
examples/device/dfu_runtime/src/usb_descriptors.c Added BOS descriptor and Microsoft OS 2.0 support
examples/device/dfu/src/usb_descriptors.c Added BOS descriptor and Microsoft OS 2.0 support

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.

1 participant