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.

TMDSEMU110-U: DMA mode UART latency fix

Part Number: TMDSEMU110-U
Other Parts Discussed in Thread: UNIFLASH

As previously discussed in https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1087696/tmdsemu110-u-xds110-usb-uart-is-bursty-at-high-baud-rates/4035123#4035123 there is an awkward behaviour in the XDS110 USB UART handling in DMA mode, where frequency small bursts of data cause the firmware to wait for the entire DMA buffer to fill up before data gets sent over USB. At high baud rates, this can result in delays of hundreds of milliseconds (or even over a second in extreme cases) for the short UART message bursts to come across. I debugged the XDS110 firmware to identify the exact cause of this issue, and described the cause in detail in the earlier thread I linked. However, this wasn't fixed at the time as it would take some engineering time to devise a fix, and it wasn't a priority for TI.

This high latency made the XDS110 USB UART unusable for my application, so I previously switched to using an external USB-UART adapter, however that was inconvenient. I later patched the XDS110 firmware to change the baud rate where the switchover to DMA-based UART operation takes place, from 230400 to 0x200000 (2097152) baud. The XDS110 CPU was more than fast enough to handle non-DMA UART at 2M baud. Back in 2022 with XDS110 firmware 3.0.0.19 (shipped with Uniflash 7.1.0) had a separate/unrelated intermittent data loss bug at high baud rates with UART write sizes not a multiple of 4, though this seems to have been fixed as of the latest XDS110 firwmare 3.0.0.28 (shipped with Uniflash 8.6.0).

I patched the XDS110 firmware 3.0.0.28 to raise the DMA-mode UART switchover baud rate by changing the bytes at offset 0x0A14 in firmware_3.0.0.28.bin from 61 3F to 00 1F. With this change, I have reliable low latency USB UART with the XDS110 at 2M baud, which is perfect for me. However, it would be better if I didn't have to re-patch the XDS110 firmware (and figure out the correct patch offset for the version) every time a new firmware version was released. If you just made this simple low-effort change of raising the switchover baud rate for UART to DMA operation to something above 2M baud, this would solve my problem and make the XDS110 UART experience better for all your other customers too. Alternatively, you could try to fix the DMA-based operation's latency issue with frequent small data bursts, though that would take more engineering time/effort.

  • Hello,

    If you just made this simple low-effort change of raising the switchover baud rate for UART to DMA operation to something above 2M baud, this would solve my problem and make the XDS110 UART experience better for all your other customers too.

    I will need to discuss this with engineering. Thank you for the detailed analysis and suggestion.

    ki

  • I will need to discuss this with engineering. Thank you for the detailed analysis and suggestion.

    They are investigating. A ticket has been filed for this. Tracking link: https://sir.ext.ti.com/jira/browse/EXT_EP-11735

    Thanks

    ki

  • Thank you Ki.

    For reference to the engineers, the root cause of the latency issue is that in DMA-based UART mode, the XDS110 firmware waits for the DMA buffer to fill up with data before sending it over. There is a timer firing every 5 ms (IIRC) that checks if the amount of data in the DMA buffer has not changed over the last 15 ms, and in that case, it flushes the buffer even when it isn't full. However, this DMA buffer does not get flushed if even a small amount of data trickled in over the last 15 ms. Consequently, this flushing logic never gets activated when UART data burts are coming in more frequently than every 15 ms, and this results in the problematic high latency filling up the DMA buffer.

    In the interrupt-driven UART mode (currently used by the XDS110 firmware below 230400 baud), there is no waiting for a buffer to fill up, and latency is minimal. In my testing (modifying the XDS110 firmware binary), interrupt-based UART/USB bridging on the XDS110 also works fine at high baud rates like 2M baud (used by my application). I have not tried any baud rates higher than that. Given the much lower latency, my suggestion is to change the firmware to use the interrupt-driven UART even at high baud rates (like 2M baud).

    There may still be value in keeping the DMA-based UART for even higher baud rates than what I'm using. To avoid this undesirable latency with frequent small data bursts in DMA-based UART, the XDS110 firmware's logic would need to be changed to periodically flush the UART DMA buffer even if more data has come in recently.