cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong echo from STM32F4 USB device

SteMMo
Associate III

Hi all,

I'm developing a composite USB device on USB OTG port on a board based on STM32F429 chip.

The device has two interfaces: a custom device + a CDC device. I'm using USB_Device_Library code.

Windows host correctly shows 3 items: the composite device, the generic USB device with my custom label/name, a virtual serial port (COM8).

As test when I open the virtual port (by Putty) I see the three-linee welcome message and a prompt.

When I press a key on the terminal, the code is sent to the device by a BulkOut packet and the device, if the code is different from 0x0d, echoes the code by a BulkIn packet.

This is OK til I press the nine-th character on  the keyboard: as echo of this character I see garbage on the terminal.

Dumping the memory of the internal buffers I see that the device received the correct code and replied 1 byte with the correct code!

If I sniff the usb channel with WireShark I see a 7-bytes packet on BulkIn reply (!!).

My debug log shows that the register containing the number of chars to sent to the host (IN_EP_TSIZ) is 1 and the char written in the FIFO (in USB_WritePacket fn) is 0x39 '9':

 

 

RXFLVL OUT DATA_UPD
RXFLVL DATA_UPD EP buff: x200100c1 - count: 1
OEPINT
OEPINT XFRC ep1
[USBD_LL_DataOutStage]
[USBD_LL_DataOutStage] DataOut ep1 - idx=1
[terminal] echo '9'
[transmit] x20010128, len: 1
[USB_EPStartXfer] IN_EP_TSIZ x00080001
IEPINT
IEPINT TXFE
[USB_WritePacket] ep2 - len: 1
[USB_WritePacket] IN_EP_TSIZ x00080001
[USB_WritePacket] x39
IEPINT
IEPINT XFRC ep2
[USBD_LL_DataInStage] ep2
[USBD_CDC_DataIn] ep2 - id=1
[USBD_CDC_DataIn] endTx TxBuf: x20010128 - 39 -

 

 

 How it is possible that Wireshark and Windows terminal reveive a 7-bytes packet ??? (None of them are 0x39)

 

Thanks!

1 REPLY 1
FBL
ST Employee

Hi @SteMMo 

The issue is likely linked to endpoint configuration or the way the USB stack in CDC class driver handles the transmission. Could you share your code to reproduce on my board Nucleo F439?

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.