Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDC epout_buf and epin_buf sizes should be different #1924

Open
1 task done
bremenpl opened this issue Feb 24, 2023 · 0 comments
Open
1 task done

CDC epout_buf and epin_buf sizes should be different #1924

bremenpl opened this issue Feb 24, 2023 · 0 comments
Labels

Comments

@bremenpl
Copy link

bremenpl commented Feb 24, 2023

Operating System

Others

Board

KA-NUCLEO-F411CE

Firmware

src\class\cdc\cdc_device.c

What happened ?

I have described the issue in this post exactly: #1923 (comment)

The problem in a nutshell, is that the 'epout_buf' and 'epin_buf" members of the 'cdcd_interface_t' struct should be allowed to have different sizes, that correspond to the rx_ff_buf and tx_ff_buf sizes consequently.

How to reproduce ?

  1. Power up a CDC device example,
  2. In the config file, change the 'CFG_TUD_CDC_RX_BUFSIZE value to 1 lower than 'CFG_TUD_CDC_EP_BUFSIZE is set to.
  3. Observe how the stack starts to work unstable and the tud_cdc_rx_cb function is not called.

To solve the issue, set 'epout_buf' size to not higher than the rx_ff_buf size. So currently for everything to work as expected, the CFG_TUD_CDC_RX_BUFSIZE has to be >= CFG_TUD_CDC_EP_BUFSIZE. IMO that should not be the case. For example, in my application I wanted to set the CFG_TUD_CDC_RX_BUFSIZE to 0, so I don't use reception at all, as it is not needed.

If I do this:

// CDC FIFO size of TX and RX
#define CFG_TUD_CDC_RX_BUFSIZE   	(0) // <- no RX buffer
#define CFG_TUD_CDC_TX_BUFSIZE   	(128)

// CDC Endpoint transfer buffer size, more is faster
#define CFG_TUD_CDC_EP_BUFSIZE   	(128)

and this:

  uint8_t rx_ff_buf[CFG_TUD_CDC_RX_BUFSIZE];
  uint8_t tx_ff_buf[CFG_TUD_CDC_TX_BUFSIZE];

  OSAL_MUTEX_DEF(rx_ff_mutex);
  OSAL_MUTEX_DEF(tx_ff_mutex);

  // Endpoint Transfer buffer
  CFG_TUSB_MEM_ALIGN uint8_t epout_buf[CFG_TUD_CDC_RX_BUFSIZE]; // <-- replaced the size to the give 0
  CFG_TUSB_MEM_ALIGN uint8_t epin_buf[CFG_TUD_CDC_EP_BUFSIZE];

}cdcd_interface_t;

I can then runy the CDC with only transmission working and nothing crashing when I try to send data from the host to the device/

Debug Log as txt file

No response

Screenshots

No response

I have checked existing issues, dicussion and documentation

  • I confirm I have checked existing issues, dicussion and documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🆕 New
Development

No branches or pull requests

1 participant