NUCLEO-U5A5ZJ-Q USB CDC ACM issue with ux_device_class_cdc_acm_write() function
Hi,
I have been working on NUCLEO-U5A5ZJ-Q EVK to setup as a USB VCP device with the support of STM32CubeIDE. I got an example from the ST repository. Its using the Azure RTOS USBX stack instead of STM32 USB Device stack. I am not very much familiar with this RTOS framework.
System details:
NUCLEO-U5A5ZJ-Q
Example: Ux_Device_CDC_ACM
I am trying to have a throughput test from data sending from device to Host PC via VCP. So I have edited the thread function usbx_cdc_acm_write_thread_entry() function to remove the UART-USB bridge setup of the example project and just send a bulk data to the HOST. Here is the code,
#define MAX_PKT_SIZE 128 /* 200 */ /* 512 */ /* 1024 */
VOID usbx_cdc_acm_write_thread_entry(ULONG thread_input)
{
ULONG actual_length;
uint32_t i = 0;
uint32_t total_bytes_to_send = APP_TX_DATA_SIZE*100;
uint32_t bytes_to_send = 0;
uint32_t buf_indx = 0;
UX_PARAMETER_NOT_USED(thread_input);
for (i = 0; i < APP_TX_DATA_SIZE; i++)
{
UserTxBufferFS[i] = i;
}
tx_thread_sleep(MS_TO_TICK(10000));
while (1)
{
while(total_bytes_to_send)
{
if (total_bytes_to_send > MAX_PKT_SIZE)
{
bytes_to_send = MAX_PKT_SIZE;
}
else
{
bytes_to_send = total_bytes_to_send;
}
/* Send data over the class cdc_acm_write */
if (ux_device_class_cdc_acm_write(cdc_acm, (UCHAR *)(&UserTxBufferFS[buf_indx]),
bytes_to_send, &actual_length) == UX_SUCCESS)
{
total_bytes_to_send -= actual_length;
buf_indx += actual_length;
if (buf_indx >= APP_TX_DATA_SIZE)
{
buf_indx = 0;
}
}
}
/* Sleep thread for 10ms */
tx_thread_sleep(MS_TO_TICK(10));
}
}
Total of 204800 bytes is ready for transmit. MAX_PKT_SIZE is the packet size which I have been used to send in each loop. When I have configured it as just below or equal to 128 bytes, the transactions was successful. But above that the API waits for some interrupts internally for infinite time and it just hangs there, even though this API fragments the data buffer with respect to the UX_SLAVE_REQUEST_DATA_MAX_LENGTH configured as 512 bytes internally. Other configurations of this example is not touched. Do anybody has a hint to look somewhere.
When I pause the execution in CubeIDE its usually in USB_ReadInterrupts() or HAL_PCD_IRQHandler().
Also tried with enabling the UX_DEVICE_CLASS_CDC_ACM_WRITE_AUTO_ZLP, but same effect.
My ultimate aim is to test the speed of sending data from device to PC via USB CDC VCP.
Thanks

