element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum USB data loss and ALSA problems
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 14 replies
  • Subscribers 677 subscribers
  • Views 1657 views
  • Users 0 members are here
Related

USB data loss and ALSA problems

morgaine
morgaine over 13 years ago

The USB data loss on my Pi is worrying me so I'm starting a new thread for it.

 

I started reporting on this issue over in post #7 of this other thread which was about graphics -- http://www.element14.com/community/message/55209#55209 .  The graphics issue is fixed, but problems of USB data loss started appearing after I connected up the Pi to my NFS servers which are core infrastructure here, used by several machines over a mostly gigabit LAN.

 

Although I hadn't noticed any glitches in audio playback on the Pi yesterday while playing music from the NFS servers (and I still haven't), after stopping playback overnight, this morning I found the MOC player hung in kernel, non-interruptible, with one mocp process hung on a futex() call and the other hung in a recv() call.  The NFS servers were still accessible from other processes on the board (only the player was hung).


Given that Pi's networking is implemented over USB by the LAN9512, it's clear that USB errors could interact with networking on this board.

 

Although networking seemed to be working fine, I've since tested NFS robustness on Pi by pulling out the Ethernet cable during audio playback of an ogg file held on an NFS server, waiting for the player's buffering to drain and playback to freeze waiting for network data, then replugging the Ethernet --- all is fine, playback continues perfectly after reconnection from where it left off, despite Debian taking the interface down and back up.  Networking looks good and solid.

 

What's much worse is that the hung mocp wasn't hung on networking but on audio playback, as I discovered by killing it and starting a fresh player.  Restarting the ALSA system through "/etc/init.d/alsa-utils restart" didn't fix it either, although that may not have reloaded the snd_bcm2835 module --- I'll have to check and/or reload it manually if it hangs again.  So, that's another potential problem for future resolution, there might be hiccups in ALSA on Pi.

 

So, back to my main worry, which is loss of USB device events, mostly mouse clicks.  (I have noticed key presses going astray too, but I haven't quantified this yet, and it's not as frequent as lost mouse clicks).  As I mentioned in the other thread, this is happening regularly while networking is active.  My networking is all wired, fortunately, which eliminates one potential source of problems.

 

I've eliminated a few variables to try to understand the problem better:

 

  • The mouse and keyboard are fine (a Logitech Wireless Combo MK320) --- I moved them over to another Linux machine and they worked perfectly, no lost mouse clicks.  Admittedly, it was an Intel machine, and the problem could be at ARM driver level.
  • I borrowed a different RF mouse (Sandstrom Laser Mouse SMWLL11) which is working perfectly on my laptop and plugged it into the Pi --- same problem of lost mouse clicks as before.
  • Stopping the music playback and hence the Pi's NFS traffic doesn't make the problem go away, so it's not simply a USB bandwidth issue,

 

I still have a few ideas to test, documenting the results here as I go.  Any input would be welcome. image

 

Morgaine.

  • Sign in to reply
  • Cancel
  • morgaine
    morgaine over 13 years ago

    Bringing in some text from the other thread to make this one self-contained ...

     

    The way I'm testing the loss of mouse clicks is simply by putting two xterm windows side by side and left-clicking them alternately while the music is playing, and counting the clicks.  If a click is missed then the window doesn't gain focus and that's immediately visible.  So far I always get a missed click before reaching a count of 30.  The average interval between lost clicks is much less though, maybe around 12-15 clicks, and sometimes two clicks are lost in succession.

     

    Also, the keyboard sometimes goes into autorepeat on pressing a character, which suggests that the key release event is being lost and hence autorepeat gets activated.

     

    And I'm not sure if this is related or not, but sometimes I type a whole commandline in without looking, hit return, and see nothing typed on the xterm at all ... then a few seconds later it appears, along with the command output.  That's pretty bizarre, becaused the characters typed should be displayed by interrupt routines and have nothing to do with user process scheduling, on normal machines at least.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • johnbeetem
    johnbeetem over 13 years ago

    So you're seeing loss of mouse clicks.  What about mouse movement?  There's a lot more mouse data from movement than from clicks.

     

    Usually, X11 programs combine queued up mouse movement events to reduce mouse lag if X11 gets slow.  They don't usually combine queued up button clicks since every one of those matters.

     

    I haven't seen any mouse or keyboard misbehavior personally, but I haven't spent that much time with my RasPi.  I have the joy of a young kitten on the physical desktop and she loves playing with cables.  For me, repeated keystrokes are generally kitten-related.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • morgaine
    morgaine over 13 years ago in reply to johnbeetem

    I haven't noticed the pointer freezing at all.  I assume that this is because pointer movement events occur at such a fast rate with these modern high-resolution mice that even if one or a few motion events are lost, it's just not noticeable because subsequent ones make up for it.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 13 years ago

    I have encountered issues too..

     

    When playing MP3s with MPG321 using "amixer" to control the volume will  sometimes cause the ALSA to hang. using either Ctrl+C or running amixer again can start the music playing again.

     

    It seems to me to be flakeyness in the driver - maybe a lost interrupt or something. It is a pretty reliable test to cause a hang - maybe one in 5 times when running amixer....

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 13 years ago

    Not wanting to try to teach you how to suck eggs, but... image

     

    You have tried:

    power through gpio header from a decent bench psu ?

    all usb stuff on an externally powered USB hub ?

    bridging polyfuses and/or running a pi-pass ?

    larger cap across usb power ?

    wired, not wireless keyboard/mouse ?

    different kernels ?

    cut-down install - something that doesn't have 101 unnecessary daemons running ?  (my feeling here is that the Pi likely isn't suited to a full-blown desktop distro that was designed with a quad core 3Ghz x86_64 and 16Gb of Ram in mind)

     

    I have occasionally seen the repeating key problem, but it's not been something I can reliably reproduce and as such impossible to get a handle on what's causing it.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • morgaine
    morgaine over 13 years ago in reply to Former Member

    selsinork:  I haven't tried most of those because I don't see a causal path that would connect them with the problem.  Pi power is a bit ropey, sure, but my TP1 is at 4.89V and the only USB port that is being used is for the Logitech receiver which is taking less than 3mA and hence running totally cold.  That doesn't make me suspect power issues in the first instance, although noise on the power line still needs to be eliminated.

     

    I haven't tried wired keyboard and mouse yet because mine are mostly old and power-hungry (which is why I bought the modern Logitech with the combined receiver).  It's a good thing to try though, because EMC problems might be the culprit.  I have one similar test lined up, which is to put the Logitech receiver on a long USB lead so that its RF near-field can't affect the Pi nor vice versa.

     

    I haven't tried any new drivers or kernels or blobs yet, and I'll have to migrate to a bigger SD card before I can rebuild the kernel as I'm right up against the ceiling currently.  Is there anything that isn't in the recommended Debian image which might improve matters?

     

    The 300Hz mod sounds like a disaster, but I guess I should try it just in case.

     

    Morgaine.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 13 years ago in reply to morgaine

    Power issues are a tricky one. Too many reports of problems that go away with a better PSU or micro usb cable to rule them out without trying it. Also TP1 voltage isn't necessarily the whole story, have seen several reports of the polyfuses between TP1 and the usb ports having oddly high resistances, so test voltage on the usb port itself rather than TP1.  No way 3mA should be a problem, but for the sake of a couple of minutes what do you have to lose ?

    Others have had luck with either replacing the polyfuses with a wire link or bypassing the whole thing with a heavy wire direct from micro usb to the usb ports - although this seems to leave the bottom usb port unuseable..

     

    Obviously YMMV with any of the power mods as it'll depend a lot on your Pi and whatever devices you plug into it.. In my case it was the micro-usb power cables that were the biggest problem 0.5v+ drop across the cable regardless of the actual power source.

     

    I don't believe there's anything missing from the Debian image, newer kernel/blob just rules out an existing bug that may have been fixed.

     

    Compiling the kernel on the Pi is slow, around 3-4 hours for me with the kernel source on NFS and that's with most of the junk stripped out.  If you have another linux machine available I'd recommend using crosstool-ng to build a cross compiler and reduce the time.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • morgaine
    morgaine over 13 years ago in reply to Former Member

    selsinork wrote:

     

    No way 3mA should be a problem, but for the sake of a couple of minutes what do you have to lose ?

     

    Agreed. image

     

    I did  test F1 and F2 even before I had USB power available --- http://www.element14.com/community/message/54970#54970 --- but wierd things do happen, and you can't measure too often. image

     

    Others have had luck with either replacing the polyfuses with a wire link or bypassing the whole thing with a heavy wire direct from micro usb to the usb ports - although this seems to leave the bottom usb port unuseable.

     

    I won't be doing any hardware hacking until Pi boards are ex-stock.  This ordering and waiting process isn't for me, and I only put up with it once. image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • jamodio
    jamodio over 13 years ago

    Morgaine what image are you working with ?

     

    I experienced some network issues with Debian (not the beta), and running a quick test sending a ping flood test from another unix machine, the R-pi gives a kernel panic after few minutes, sometimes even less than a minute.

     

    I didn't track it down in the kernel, but it looked like there is some issue with the USB driver and interrrupt management.

     

    I was not able to replicate the problem with the Debian Wheezy beta or with Arch Linux

     

    My .02

    -J

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • morgaine
    morgaine over 13 years ago in reply to jamodio

    Just standard Squeeze debian6-19-04-2012.zip that's on their download page here, augmented with a few tools for testing, no major changes as I don't want to introduce new variables at this stage.

     

    I also installed IceWM to check it works on ARM because I'll be using it later by preference.  Interestingly, I see it has signficantly less overhead than OpenBox, so players start up cleaner than with the standard desktop (no ALSA grating during buffer preload).  But during tests I'm still using OpenBox, because that's the reference.

     

    Another interesting observation:  the MOC player's CPU usage of around 30% when playing my Oggs drops to 7% when playing mp3 files, so a tentative guess is that MP3 is decoded by the SoC and Ogg is not.  mpg123 has the same CPU usage as MOC on MP3 files, but of course can't handle Ogg.

     

    Using the Pi over ssh from various boxes overcomes the mouse click loss, and is significantly more responsive as the Pi's sluggish CPU doesn't matter then.

     

    I also installed Synergy on Pi, which gives me yet another way of avoiding the USB mouse problems.  I use Synergy quite a lot at home anyway to avoid keyboard/mouse proliferation, and it'll be the preferred way of using Model A without needing a powered hub, just dedicating the single USB to a wifi dongle.

     

    Morgaine.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube