This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LP-AM261: USB CDC Echo is getting stuck

Part Number: LP-AM261

Tool/software:

Hi

I was able to integrate CDC Echo functionality to application running on LP-AM261.

Firmware is sending back echo over usb virtual com

Our application is micrium uC/OS RTOS based.

Scenario 1 : USB_dwcTask, tud_task, cdc_task called in sequence in a single task

Enumeration and data transfer is working properly

Scenario 2:  USB_dwcTask and tud_task called in a task and cdc_task is called in another task

Enumeration and data transfer is working properly initially

But at some point, echo back is stopped working. (this behavior is random in nature)

While debugging we can see that transmit from PC is still reaching the device.

But echo back from the device is not coming to PC anymore.

What i understand is Endpoint 2 IN transactions stopped working

But if try to re-connect serial terminal application that is still happening. But echo back is not working

If we reconnect the USB cable again, then the device is still enumerating, and echo will be working again.

Logs from our testing script is given below:

2025-03-04 17:15:51 - __main__ - INFO - data_send_iteration:1
2025-03-04 17:15:51 - __main__ - INFO - delay_between_send:0.001s
2025-03-04 17:15:51 - __main__ - INFO - data_length_initial:1
2025-03-04 17:15:51 - __main__ - INFO - data_length_increment:1
2025-03-04 17:15:51 - __main__ - INFO - port_open_iteration:1
2025-03-04 17:15:51 - __main__ - INFO - delay_between_data_length:0
2025-03-04 17:15:51 - __main__ - INFO - data_length_final:100
2025-03-04 17:15:51 - __main__ - INFO - 1 1
2025-03-04 17:15:51 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:51 - __main__ - INFO - 1 bytes 1/1 messages received 1 bytes received
2025-03-04 17:15:51 - __main__ - INFO - 2 2
2025-03-04 17:15:51 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:51 - __main__ - INFO - 2 bytes 1/1 messages received 2 bytes received
2025-03-04 17:15:51 - __main__ - INFO - 3 3
2025-03-04 17:15:51 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:51 - __main__ - INFO - 3 bytes 1/1 messages received 3 bytes received
2025-03-04 17:15:51 - __main__ - INFO - 4 4
2025-03-04 17:15:51 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:52 - __main__ - INFO - 4 bytes 1/1 messages received 4 bytes received
2025-03-04 17:15:52 - __main__ - INFO - 5 5
2025-03-04 17:15:52 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:52 - __main__ - INFO - 5 bytes 1/1 messages received 5 bytes received
2025-03-04 17:15:52 - __main__ - INFO - 6 6
2025-03-04 17:15:52 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:52 - __main__ - INFO - 6 bytes 1/1 messages received 6 bytes received
2025-03-04 17:15:52 - __main__ - INFO - 7 7
2025-03-04 17:15:52 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:52 - __main__ - INFO - 7 bytes 1/1 messages received 7 bytes received
2025-03-04 17:15:52 - __main__ - INFO - 8 8
2025-03-04 17:15:52 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:53 - __main__ - INFO - 8 bytes 1/1 messages received 8 bytes received
2025-03-04 17:15:53 - __main__ - INFO - 9 9
2025-03-04 17:15:53 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:53 - __main__ - INFO - 9 bytes 1/1 messages received 9 bytes received
2025-03-04 17:15:53 - __main__ - INFO - 10 10
2025-03-04 17:15:53 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:53 - __main__ - INFO - 10 bytes 1/1 messages received 10 bytes received
2025-03-04 17:15:53 - __main__ - INFO - 11 11
2025-03-04 17:15:53 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:53 - __main__ - INFO - 11 bytes 1/1 messages received 11 bytes received
2025-03-04 17:15:53 - __main__ - INFO - 12 12
2025-03-04 17:15:53 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:54 - __main__ - INFO - 12 bytes 1/1 messages received 12 bytes received
2025-03-04 17:15:54 - __main__ - INFO - 13 13
2025-03-04 17:15:54 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:54 - __main__ - INFO - 13 bytes 1/1 messages received 13 bytes received
2025-03-04 17:15:54 - __main__ - INFO - 14 14
2025-03-04 17:15:54 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:54 - __main__ - INFO - 14 bytes 1/1 messages received 14 bytes received
2025-03-04 17:15:54 - __main__ - INFO - 15 15
2025-03-04 17:15:54 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:54 - __main__ - INFO - 15 bytes 1/1 messages received 15 bytes received
2025-03-04 17:15:54 - __main__ - INFO - 16 16
2025-03-04 17:15:54 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:55 - __main__ - INFO - 16 bytes 1/1 messages received 16 bytes received
2025-03-04 17:15:55 - __main__ - INFO - 17 17
2025-03-04 17:15:55 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:55 - __main__ - INFO - 17 bytes 1/1 messages received 17 bytes received
2025-03-04 17:15:55 - __main__ - INFO - 18 18
2025-03-04 17:15:55 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:55 - __main__ - INFO - 18 bytes 1/1 messages received 18 bytes received
2025-03-04 17:15:55 - __main__ - INFO - 19 19
2025-03-04 17:15:55 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:55 - __main__ - INFO - 19 bytes 1/1 messages received 19 bytes received
2025-03-04 17:15:55 - __main__ - INFO - 20 20
2025-03-04 17:15:55 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:56 - __main__ - INFO - 20 bytes 1/1 messages received 20 bytes received
2025-03-04 17:15:56 - __main__ - INFO - 21 21
2025-03-04 17:15:56 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:56 - __main__ - INFO - 21 bytes 1/1 messages received 21 bytes received
2025-03-04 17:15:56 - __main__ - INFO - 22 22
2025-03-04 17:15:56 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:56 - __main__ - INFO - 22 bytes 1/1 messages received 22 bytes received
2025-03-04 17:15:56 - __main__ - INFO - 23 23
2025-03-04 17:15:56 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:56 - __main__ - INFO - 23 bytes 1/1 messages received 23 bytes received
2025-03-04 17:15:56 - __main__ - INFO - 24 24
2025-03-04 17:15:56 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:57 - __main__ - INFO - 24 bytes 1/1 messages received 24 bytes received
2025-03-04 17:15:57 - __main__ - INFO - 25 25
2025-03-04 17:15:57 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:57 - __main__ - INFO - 25 bytes 1/1 messages received 25 bytes received
2025-03-04 17:15:57 - __main__ - INFO - 26 26
2025-03-04 17:15:57 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:57 - __main__ - INFO - 26 bytes 1/1 messages received 26 bytes received
2025-03-04 17:15:57 - __main__ - INFO - 27 27
2025-03-04 17:15:57 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:57 - __main__ - INFO - 27 bytes 1/1 messages received 27 bytes received
2025-03-04 17:15:57 - __main__ - INFO - 28 28
2025-03-04 17:15:57 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:58 - __main__ - INFO - 28 bytes 1/1 messages received 28 bytes received
2025-03-04 17:15:58 - __main__ - INFO - 29 29
2025-03-04 17:15:58 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:58 - __main__ - INFO - 29 bytes 1/1 messages received 29 bytes received
2025-03-04 17:15:58 - __main__ - INFO - 30 30
2025-03-04 17:15:58 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:58 - __main__ - INFO - 30 bytes 1/1 messages received 30 bytes received
2025-03-04 17:15:58 - __main__ - INFO - 31 31
2025-03-04 17:15:58 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:58 - __main__ - INFO - 31 bytes 1/1 messages received 31 bytes received
2025-03-04 17:15:58 - __main__ - INFO - 32 32
2025-03-04 17:15:58 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:58 - __main__ - INFO - 32 bytes 1/1 messages received 32 bytes received
2025-03-04 17:15:58 - __main__ - INFO - 33 33
2025-03-04 17:15:58 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:59 - __main__ - INFO - 33 bytes 1/1 messages received 33 bytes received
2025-03-04 17:15:59 - __main__ - INFO - 34 34
2025-03-04 17:15:59 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:59 - __main__ - INFO - 34 bytes 1/1 messages received 34 bytes received
2025-03-04 17:15:59 - __main__ - INFO - 35 35
2025-03-04 17:15:59 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:59 - __main__ - INFO - 35 bytes 1/1 messages received 35 bytes received
2025-03-04 17:15:59 - __main__ - INFO - 36 36
2025-03-04 17:15:59 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:15:59 - __main__ - INFO - 36 bytes 1/1 messages received 36 bytes received
2025-03-04 17:15:59 - __main__ - INFO - 37 37
2025-03-04 17:15:59 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:00 - __main__ - INFO - 37 bytes 1/1 messages received 37 bytes received
2025-03-04 17:16:00 - __main__ - INFO - 38 38
2025-03-04 17:16:00 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:00 - __main__ - INFO - 38 bytes 1/1 messages received 38 bytes received
2025-03-04 17:16:00 - __main__ - INFO - 39 39
2025-03-04 17:16:00 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:00 - __main__ - INFO - 39 bytes 1/1 messages received 39 bytes received
2025-03-04 17:16:00 - __main__ - INFO - 40 40
2025-03-04 17:16:00 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:00 - __main__ - INFO - 40 bytes 1/1 messages received 40 bytes received
2025-03-04 17:16:00 - __main__ - INFO - 41 41
2025-03-04 17:16:00 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:01 - __main__ - INFO - 41 bytes 1/1 messages received 41 bytes received
2025-03-04 17:16:01 - __main__ - INFO - 42 42
2025-03-04 17:16:01 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:01 - __main__ - INFO - 42 bytes 1/1 messages received 42 bytes received
2025-03-04 17:16:01 - __main__ - INFO - 43 43
2025-03-04 17:16:01 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:01 - __main__ - INFO - 43 bytes 1/1 messages received 43 bytes received
2025-03-04 17:16:01 - __main__ - INFO - 44 44
2025-03-04 17:16:01 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:01 - __main__ - INFO - 44 bytes 1/1 messages received 44 bytes received
2025-03-04 17:16:01 - __main__ - INFO - 45 45
2025-03-04 17:16:01 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:02 - __main__ - INFO - 45 bytes 1/1 messages received 45 bytes received
2025-03-04 17:16:02 - __main__ - INFO - 46 46
2025-03-04 17:16:02 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:02 - __main__ - INFO - 46 bytes 1/1 messages received 46 bytes received
2025-03-04 17:16:02 - __main__ - INFO - 47 47
2025-03-04 17:16:02 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:02 - __main__ - INFO - 47 bytes 1/1 messages received 47 bytes received
2025-03-04 17:16:02 - __main__ - INFO - 48 48
2025-03-04 17:16:02 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:02 - __main__ - INFO - 48 bytes 1/1 messages received 48 bytes received
2025-03-04 17:16:02 - __main__ - INFO - 49 49
2025-03-04 17:16:02 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:03 - __main__ - INFO - 49 bytes 1/1 messages received 49 bytes received
2025-03-04 17:16:03 - __main__ - INFO - 50 50
2025-03-04 17:16:03 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:03 - __main__ - INFO - 50 bytes 1/1 messages received 50 bytes received
2025-03-04 17:16:03 - __main__ - INFO - 51 51
2025-03-04 17:16:03 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:03 - __main__ - INFO - 51 bytes 1/1 messages received 51 bytes received
2025-03-04 17:16:03 - __main__ - INFO - 52 52
2025-03-04 17:16:03 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:03 - __main__ - INFO - 52 bytes 1/1 messages received 52 bytes received
2025-03-04 17:16:03 - __main__ - INFO - 53 53
2025-03-04 17:16:03 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:04 - __main__ - INFO - 53 bytes 1/1 messages received 53 bytes received
2025-03-04 17:16:04 - __main__ - INFO - 54 54
2025-03-04 17:16:04 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:04 - __main__ - INFO - 54 bytes 1/1 messages received 54 bytes received
2025-03-04 17:16:04 - __main__ - INFO - 55 55
2025-03-04 17:16:04 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:04 - __main__ - INFO - 55 bytes 1/1 messages received 55 bytes received
2025-03-04 17:16:04 - __main__ - INFO - 56 56
2025-03-04 17:16:04 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:04 - __main__ - INFO - 56 bytes 1/1 messages received 56 bytes received
2025-03-04 17:16:04 - __main__ - INFO - 57 57
2025-03-04 17:16:04 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:05 - __main__ - INFO - 57 bytes 1/1 messages received 57 bytes received
2025-03-04 17:16:05 - __main__ - INFO - 58 58
2025-03-04 17:16:05 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:05 - __main__ - INFO - 58 bytes 1/1 messages received 58 bytes received
2025-03-04 17:16:05 - __main__ - INFO - 59 59
2025-03-04 17:16:05 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:05 - __main__ - INFO - 59 bytes 1/1 messages received 59 bytes received
2025-03-04 17:16:05 - __main__ - INFO - 60 60
2025-03-04 17:16:05 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:05 - __main__ - INFO - 60 bytes 1/1 messages received 60 bytes received
2025-03-04 17:16:05 - __main__ - INFO - 61 61
2025-03-04 17:16:05 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:06 - __main__ - INFO - 61 bytes 1/1 messages received 61 bytes received
2025-03-04 17:16:06 - __main__ - INFO - 62 62
2025-03-04 17:16:06 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:06 - __main__ - INFO - 62 bytes 1/1 messages received 62 bytes received
2025-03-04 17:16:06 - __main__ - INFO - 63 63
2025-03-04 17:16:06 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:06 - __main__ - INFO - 63 bytes 1/1 messages received 63 bytes received
2025-03-04 17:16:06 - __main__ - INFO - 64 64
2025-03-04 17:16:06 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:06 - __main__ - INFO - 64 bytes 1/1 messages received 64 bytes received
2025-03-04 17:16:06 - __main__ - INFO - 65 65
2025-03-04 17:16:06 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:07 - __main__ - INFO - 65 bytes 1/1 messages received 65 bytes received
2025-03-04 17:16:07 - __main__ - INFO - 66 66
2025-03-04 17:16:07 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:07 - __main__ - INFO - 66 bytes 1/1 messages received 66 bytes received
2025-03-04 17:16:07 - __main__ - INFO - 67 67
2025-03-04 17:16:07 - __main__ - INFO - ABB COM detected COM9
2025-03-04 17:16:09 - __main__ - INFO - 67 bytes 0/1 messages received 0 bytes received
2025-03-04 17:16:09 - __main__ - INFO - Failed on 1st message :
2025-03-04 17:16:09 - __main__ - INFO - Send :b'hello welcome111111111111111111111hello welcome11111111111111111111'
2025-03-04 17:16:09 - __main__ - INFO - Received:b''

Please help us in resolving this.

Thanks

Nithin

  • Hi Nithin,

    @echo off
    
    set /a count=0
    
    :loop
    set /a count+=1
    echo The test times: %count%
    
    timeout /t 1 /nobreak >nul
    
    python USB_test.py
    
    if %count% lss 1000 goto loop
    import serial
    import serial.tools.list_ports
    
    # list all the ports
    ports = serial.tools.list_ports.comports()
    
    # enumerate all the ports
    for port in sorted(ports):
        #print(f"Port: {port}, Desc: {desc}, HWID: {hwid}")
        if "USB" in port.description:
           print(f"Found USB device on port: {port.device}")
           usb_port = port.device
        
    
    port = usb_port 
    baudrate = 115200  
    timeout = 2  # unit:s
    
    
    data_to_send = [0xF8, 0x03, 0x01, 0x02, 0x00, 0x02, 0x70, 0x5E]
    data_to_send_hex = ' '.join(f'{byte:02X}' for byte in data_to_send)
    print(f"USB Sent data: {data_to_send_hex}, over port: {port}")
    
    try:
        
        # open the port
        ser = serial.Serial(port, baudrate, timeout=timeout)
        
        # send the data
        ser.write(data_to_send)
    
        # receive the data
        received_data = ser.read(20) 
    
        # close the data
        ser.close()
    
        # print the received data
        received_data_hex = ' '.join(f'{byte:02X}' for byte in received_data)
        print(f"USB Received data: {received_data_hex}, over port: {port}")
    
    except serial.SerialException as e:
        print(f"Error: {e}")
    

    As discussed over call, sharing the steps here,

    1. Rebuilding USB libraries without optimizations

    1.1 In the makefile located at "C:\ti\mcu_plus_sdk_am261x_10_00_01_10\source\usb\tinyusb\makefile.cdc_nortos.am261x.r5f.ti-arm-clang", remove the Optimization flag "-Os" from the CFLAGS_release list.

    1.2  In the makefile located at "C:\ti\mcu_plus_sdk_am261x_10_00_01_10\source\usb\synp\makefile.nortos.am261x.r5f.ti-arm-clang", remove the Optimization flag "-Os" from the CFLAGS_release list. 

    1.3 Rebuild both the libraries using the below commands (run from mcu_plus_sdk folder)

    # Tiny USB Stack clean and re-build
    gmake -sj -f makefile.am261x usbd_tusb_cdc_nortos_r5f.ti-arm-clang_clean
    gmake -sj -f makefile.am261x usbd_tusb_cdc_nortos_r5f.ti-arm-clang
    
    ## USB Driver clean and re-build
    gmake -sj -f makefile.am261x usbd_synp_nortos_r5f.ti-arm-clang_clean
    gmake -sj -f makefile.am261x usbd_synp_nortos_r5f.ti-arm-clang


    2. Rebuilding application

    Rebuild your USB CDC application to link these new libs .

    3. Testing application using scripts

    I have attached 2 scripts (1 python script which sends data to COM Port and reads back the data from same port), You can modify this script for two ports if you wish, as well as a bat file to run the python script multiple times (default is 1000). You can run the .bat file after you have the COM Ports enumerated in the application. I guess this is similar to the test script you are using as well. (I tested with 1000 iterations and it worked fine).

    Note: We discovered that the "R355" Resistor was causing some issues on AM261x-LP Boards. It is DNI by default but was causing some interference in USB Signals and enumeration was failing. I request you unmount the "R355" Completely from your board to rule out this issue as well. (https://www.ti.com/lit/ug/sprujf1/sprujf1.pdf?ts=1741330918195&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FAM2612)

    If the above steps don't resolve your issue, please let me know, we can look further at other endpoint related stuff in the driver for debugging.

    Regards,
    Shaunak