Skip to content

USB-to-UART converter dropping data #2197

Closed

Description

@iurly

Original post here: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=192987
TL;DR:

  • I'm seeing sporadic data loss from a Full-Speed USB-to-UART bridge from Silabs (CP2104x) running at 2.000.000 bps (actual data traffic around 1.200.000bps)
  • Current settings (tweaking them does not make any difference though):
    dwc_otg.nak_holdoff=2 dwc_otg.fiq_enable=1 dwc_otg.fiq_fsm_enable=1 dwc_otg.fiq_fsm_mask=0x7 dwc_otg.speed=1
  • First drops occur after about 10-30 minutes
  • Identified as a regression between 4.4 and 4.9
  • Tested as working with:
    • 4.4.38, 4.4.50 (from pre-compiled release)
    • 4.8.16 (from source commit 061dccc)
  • Tested as broken with:
    • 4.9.11 (from source commit ef6bc39)
    • 4.9.37 (from pre-compiled release)
    • 4.9.48 (from pre-compiled release)
    • 4.12.11 (from source commit 8f82f55)
    • 4.13.1 (from source commit 93058c5)

I'm willing to investigate this further and provide any required input, but I can't really bisect the whole tree.
Please give me some guidance as to where to look and how I could reproduce the issue quicker.
Thank you!

Activity

  1. iurly commented on Sep 18, 2017

    @iurly
    Author

    @P33M Any idea? Please...

  2. P33M commented on Sep 18, 2017

    @P33M
    Contributor

    Something falling over after 10 minutes would seem to be a reproducible test.

    Without the device at the other end of the UART I won't be able to replicate it, however.

    Is there any way of using a PC to emulate the device? You say you send 1.2mbit/s of data across a 2Mbaud link - can you create an equivalent mini test program that feeds the correct amount of data into the UART?

  3. iurly commented on Sep 18, 2017

    @iurly
    Author

    Yes, I could do that, though you'd probably need a couple of those CP2104 converters.
    Any chance you already have those? Or perhaps I can try to reproduce this issue in some other way?

  4. P33M commented on Sep 18, 2017

    @P33M
    Contributor

    CP2104 is commodity hardware, I'm sure it won't be too hard to find a converter that has one embedded.

  5. iurly commented on Sep 19, 2017

    @iurly
    Author

    I create a test program:
    https://gist.github.com/iurly/64a98566384f6f3fbd59d57f475db702
    The hardware setup involves two cross-connected CP2104's.
    I'm using a PC at the sender's side and a Raspberry Pi at the receiver's side:

    • On a 4.9.11 I was able to reproduce the issue within a few minutes
    • On a 4.4.50 it's been running without any issue for about a half hour and I'm going to leave it running the whole day.
      Please let me know if you can get a hold of such devices.
      Thank you!
  6. iurly commented on Sep 20, 2017

    @iurly
    Author

    Since it's definitely a regression and I could automate the whole testing process, it should not be that hard to find the offending commit.
    If you could help me understand how the rpi kernel evolves (compared to the vanilla kernel) I could probably find it myself.
    Thank you!

  7. thomasrudin commented on Sep 20, 2017

    @thomasrudin

    I have the same issue, but with a pl2303 (gps dongle) and an Arduino (cdc_acm) but it only occurs if the pl2303 is talking, otherwise everything works fine...

  8. thomasrudin commented on Sep 20, 2017

    @thomasrudin

    Additionally: if i set dwc_otg.speed=1 the problem goes away too

  9. iurly commented on Sep 20, 2017

    @iurly
    Author

    @thomasrudin did you try with a previous kernel version, before 4.9?
    Btw, I was also using a pl2303 at the beginning and then moved to CP2104 because it seemed much more reliable. IIRC the pl2303 did not even work reliably on a PC at 921.600 bps.

  10. thomasrudin commented on Sep 20, 2017

    @thomasrudin

    i have my test setup ready, which branch/commit should i test?

  11. iurly commented on Sep 20, 2017

    @iurly
    Author

    See the original post

  12. thomasrudin commented on Sep 20, 2017

    @thomasrudin

    Bad news, i think i have another problem:

    4.9.50-v7 bad
    4.8.16-v7 bad (commit: 061dccce6cf6705bbb5da29a643f4b0ad1d11630)
    
  13. iurly commented on Sep 20, 2017

    @iurly
    Author

    Do you have the following settings in your /boot/cmdline.txt?
    dwc_otg.nak_holdoff=2 dwc_otg.fiq_enable=1 dwc_otg.fiq_fsm_enable=1 dwc_otg.fiq_fsm_mask=0x7

  14. thomasrudin commented on Sep 20, 2017

    @thomasrudin

    tested the settings in cmdline.txt but i have the same problem as before, maybe pl2303 related.

  15. thomasrudin commented on Sep 20, 2017

    @thomasrudin

    I solved my problems with the workaround described in #2140:
    dwc_otg.fiq_fsm_mask=0x2

    I have now a stable communication with the cdc and pl2303 drivers (@115.2kbaud) in kernel 4.9.50-v7
    Sorry for not contributing to this issue...

  16. 3 remaining items

  17. chrisspen commented on Jan 20, 2018

    @chrisspen

    I'm also experiencing a similar problem communicating between a RPi3 and an Arduino Uno over a USB serrial connection. This might be related to a bug reported in the firmware project.

  18. JamesH65 commented on Jun 27, 2018

    @JamesH65
    Contributor

    @iurly Did you or anyone else have any luck finding the commit that caused this issue?

    It might be worth trying the latest 4.14 kernel, just to see if that works.

  19. added
    Waiting for external input
    on Jun 27, 2018
  20. iurly commented on Jun 27, 2018

    @iurly
    Author

    No, I never managed to find it. So far I'v been circumventing the problem by sticking to a 4.8.
    I'll give the 4.14 a shot in the next few days.

  21. iurly commented on Jun 28, 2018

    @iurly
    Author

    I tested the following:

    Linux rpi3-can1 4.14.52-v7+ #1123 SMP Wed Jun 27 17:35:49 BST 2018 armv7l GNU/Linux
    

    and it works!
    I can reproduce the issue relatively quickly, I'm willing to try different binary kernels if anyone could provide some procedure to bisect over them, so we can at least identify a range of broken release.

  22. pelwell commented on Jun 28, 2018

    @pelwell
    Contributor

    Thanks for the feedback. You can download intermediate kernel builds using rpi-update (all releases are listed here), but if the current kernel builds work then there we are unlikely to want to cherry-pick the fixing patch - the recommended solution will be to upgrade.

  23. iurly commented on Jul 17, 2018

    @iurly
    Author

    Even with a known-to-work kernel, I'm still experiencing occasional data loss.
    I reckon it might have to do with the priority of the kernel threads involved:
    kworker/u8:2, kworker/u8:3. I would change their scheduling policy to e.g. RT_FIFO, but they keep getting killed and recreated once an hour or so (which is the frequency at which I experience the data loss).
    Any thoughts?

  24. JamesH65 commented on Jul 30, 2019

    @JamesH65
    Contributor

    Can anyone still seeing a problem make sure they are running the latest kernel. There have been a lot of changes in the last year that might help with this.

    This issue will be closed within 30 days unless further interactions are posted. If you wish this issue to remain open, please add a comment. A closed issue may be reopened if requested.

  25. added
    Close within 30 days
    on Jul 30, 2019
  26. JamesH65 commented on Sep 18, 2019

    @JamesH65
    Contributor

    Closing due to lack of activity. Please request to be reopened if you feel this issue is still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Close within 30 daysWaiting for external input

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions