maemo.org Bugzilla – Bug 3026
USB state hangs at b_idle on N810 (won't allow mode change from sysfs)
Last modified: 2009-01-05 13:17:50 UTC
You need to log in before you can comment on or make changes to this bug.
SOFTWARE VERSION: OS2008- Chinook (n810 only?) STEPS TO REPRODUCE THE PROBLEM: I'm not the only one having this issue, but not everyone is. Could be a hardware problem... 1. Boot the tablet 2. open osso-xterm and do- $sudo gainroot #echo host>/sys/devices/platform/musb_hdrc/mode EXPECTED OUTCOME: Mode should be changed. ACTUAL OUTCOME: Mode is not changed- #tail /sys/devices/platform/musb_hdrc/mode gives- b_idle It seems that the soft ID pullup is getting stuck UP (usb peripheral). It will unstick if external Vbus voltage is applied to the port and allow normal mode change from sysfs... (i.e.- If I plug the tablet into my PC as periperal, then unmount and unplug it, I can change modes once. But if I change mode to otg or peripheral it sticks at b_idle again. REPRODUCIBILITY: always EXTRA SOFTWARE INSTALLED: Have tried this on freshly flashed (51-3) n810 in R&D mode with no additional software... OTHER COMMENTS: I was able to patch the musb_core.c file to make this issue go away by making the driver reinitialize when mode changes. I'm not a kernel developer so my fix may not be 'correct'. but here it is- ## BEGIN PATCH ## --- kernel-source-rx-34-2.6.21.0-orig/drivers/usb/musb/musb_core.c 2008-03-17 21:12:38.000000000 -0600 +++ kernel-source-rx-34-2.6.21.0/drivers/usb/musb/musb_core.c 2008-03-17 22:15:37.000000000 -0600 @@ -1693,16 +1693,30 @@ { struct musb *musb = dev_to_musb(dev); unsigned long flags; + static int last_state; + int new_state = 0; + //reset driver only if we are changing states... seems to fix id pullup sticking + if (!strncmp(buf, "host", 4)) new_state = 3; + if (!strncmp(buf, "peripheral", 10)) new_state = 2; + if (!strncmp(buf, "otg", 3)) new_state = 1; + if (!last_state) last_state = new_state; + + if (!(last_state == new_state)){ + musb_stop(musb); + musb_start(musb); + + spin_lock_irqsave(&musb->lock, flags); + if (!strncmp(buf, "host", 4)) + musb_platform_set_mode(musb, MUSB_HOST); + if (!strncmp(buf, "peripheral", 10)) + musb_platform_set_mode(musb, MUSB_PERIPHERAL); + if (!strncmp(buf, "otg", 3)) + musb_platform_set_mode(musb, MUSB_OTG); - spin_lock_irqsave(&musb->lock, flags); - if (!strncmp(buf, "host", 4)) - musb_platform_set_mode(musb, MUSB_HOST); - if (!strncmp(buf, "peripheral", 10)) - musb_platform_set_mode(musb, MUSB_PERIPHERAL); - if (!strncmp(buf, "otg", 3)) - musb_platform_set_mode(musb, MUSB_OTG); - spin_unlock_irqrestore(&musb->lock, flags); + spin_unlock_irqrestore(&musb->lock, flags); + } + last_state = new_state; return n; } static DEVICE_ATTR(mode, 0644, musb_mode_show, musb_mode_store); ## END PATCH ## User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.12) Gecko/20080129 Iceweasel/2.0.0.12 (Debian-2.0.0.12-0etch1)
Same problem here, description: http://lists.maemo.org/pipermail/maemo-developers/2008-March/017217.html I noted a few OTG discussions on LKML, might be relevant: http://lkml.org/lkml/2008/2/12/112 http://lkml.org/lkml/2008/1/20/112 This is a regression from N800 where host does work.
CC to Quim.
I confirm Charles patch allows me to use USB key and USB keyboard in host mode.
Note: I was using kernel from: ~ $ cat /etc/osso_software_version RX-34+RX-44_2008SE_2.2007.50-2_PR_MR0 Is there an USB change for the latest? RX-34+RX-44_2008SE_2.2007.51-3_PR_MR0~/QR
(In reply to comment #4) > Note: I was using kernel from: > > ~ $ cat /etc/osso_software_version > RX-34+RX-44_2008SE_2.2007.50-2_PR_MR0 > > Is there an USB change for the latest? > RX-34+RX-44_2008SE_2.2007.51-3_PR_MR0~/QR > I'm on 51-3 myself. I think they both use the same kernel(rx-34-2.6.21.0) but I'm not 100% sure on that... Charles Werbick
The more I think about it, the patch should probably have- + if (!last_state) last_state = 1; instead of- + if (!last_state) last_state = new_state; Otherwise the first state change via sysfs is ignored... cheers, Charles Werbick
Created an attachment (id=744) [details] patch in musb_core.c to prevent hang at b_idle on n810 This patch calls usb_stop() then usb_start() on mode change, basically forcing cleanup so that the USB mode can be changed on the n810 via sysfs reliably.
reassigning MDK's bugs to Rodrigo.
OK, this bug bites a lot of people and according to emails and comments the patch works fine. High priority, let me push this for Diablo (or its updates).
another one, copying from today's #maemo irc channel: <zap> Anybody had ever problems with enabling USB host on a N810? I have two things here, one works fine and other doesn't see anything I connect to it (same cable, same USB pen drive) <zap> I have two N810s <zap> flashed them both with the same firmware <zap> I use the usbcontrol python script <zap> when I enable Host mode, the one that works switches from b_idle to a_wait_vrise <zap> the other stays in b_idle <zap> peripherial mode on both works fine <zap> cat /sys/whatever/state shows b_idle as well <andre___> sounds a bit like https://bugs.maemo.org/show_bug.cgi?id=3026 <zap> yes, that's it, thank you very much
Yes, my situation is quite similar to what's described in the first report, with a few differences: - If I plug the N810 into the PC USB port, then unmount the USB drives and plug it off, it won't allow to switch controller mode anyways. - If I plug the N810 into the PC USB port, then unmount the USB drives and then immediately switch the mode to 'host' (without taking the plug out of the PC), it switches to a_wait_vrse, but then if I plug it out of the PC and try to plug into N810 an USB pen drive, it doesn't work. The USB pen drive seems not powered as the LED doesn't light up, and N810 doesn't notice something is inserted. I have access to another N810 and it works just fine with the same cable and the same USB A-A gender converter. I have no problems switching to host mode and connecting the same USB pen drive, keyboard etc. On both units "cat /proc/cpuinfo" says they're a "Nokia RX-44 rev 24202524".
(In reply to comment #11) > Yes, my situation is quite similar to what's described in the first report, > with a few differences: > Andrew, Sounds very similar. Have you tried the patched kernel? It's available here- http://rapidshare.com/files/105578563/zImage.html (It's a stock kernel. The only modification is the usb-host patch. So if you're running any other kernel mods (i.e.- FB rotate support) you'll need to download the patch and compile yourself...) Cheers, Charles Werbick
Forwarding some questions from the internal bugticket, would be great if someone could answer this: Does it work with a correct micro-A cable? The sysfs interface is only there for hacking/testing/development purposes. The correct way to use usb otg is with proper certified cables. Please provide more detailed output from dmesg if you have one of the messy devices: # echo D5 > /proc/drivers/musb_hdrc Will increase the loglevel of the driver giving me more valuable information. A few printk in drivers/usb/musb/tusb6010.c:musb_platform_set_mode() also helps. Try also grounding the id pin in the micro-B cable and see if it automatically switches to host mode. Check if the same bug appears in current linux-omap tree, if it doesn't then it's a bug in our tree if it does then it might be hw issue, although I need more information to state that more certainly.
(In reply to comment #13) > Forwarding some questions from the internal bugticket, would be great if > someone could answer this: > > > Does it work with a correct micro-A cable? > The sysfs interface is only there for hacking/testing/development purposes. The > correct way to use usb otg is with proper certified cables. > Yes, a micro-A host cable still works with the broken kernel. The problem is with the software ID. And while I'm all about using the proper cables, Nokia does not sell one. (Nor have I found one online.) All of the cables I've seen for sale are hacked micro-B motorola phone adapters. Because of this, 95% of n810 users are using sysfs to change modes. Nokia offering host cables for the n810 would be an acceptable fix for this bug though. > Please provide more detailed output from dmesg if you have one of the messy > devices: > > # echo D5 > /proc/drivers/musb_hdrc > > Will increase the loglevel of the driver giving me more valuable information. > > A few printk in drivers/usb/musb/tusb6010.c:musb_platform_set_mode() also > helps. > > Try also grounding the id pin in the micro-B cable and see if it automatically > switches to host mode. > I'm running the patched kernel. So not much help there. However I *did* increase the logging level while looking into the problem. It didn't seem to give me any extra(useful) info. If I have time, I'll flash the stock kernel and post some output... As for trying the generic omap kernel, I'm not quite that brave. (Perhaps if I had more than one n810 ;) cheers, Charles Werbick
According to your description , I try to reproduce the bug,and found the actual outcome is all right;it is changed into "b_wait_bcon" mode waiting for a slave device to plug in, this mode is belong to host mode but just for waiting. when I plug the memory to the N810 and check the mode ,it becomes "b_host" mode. Internet Tablet OS: maemo linux based OS2008 Version :2.2007.51-3
Created an attachment (id=822) [details] Demonstrating the mode can be changed
I didn't modify any source code before reproducing it.So I think this bug has been fixed in my OS version.
(In reply to comment #17) > I didn't modify any source code before reproducing it.So I think this bug has > been fixed in my OS version. Did you ever experience this bug on your device? AFAICT, it is a hardware bug that only affects perhaps one in 50 n810's... If you can't reproduce it, your n810 is likely not one that is affected. Cheers, Charles Werbick
removing invalid target milestone.
Internal ticket was closed as WORKSFORME, see quote below. So maybe it's really a hardware issue as mentioned in comment 18? If we don't get some clarification I'm also going to close this report as WORKSFORME. --quote:-- Can't reproduce it: / # echo host > /sys/devices/platform/musb_hdrc/mode / # [ 48.992187] usb 1-1: new high speed USB device using musb_hdrc and address 2 [ 49.132812] usb 1-1: Product: Cruzer Mini [ 49.140625] usb 1-1: Manufacturer: SanDisk Corporation [ 49.148437] usb 1-1: SerialNumber: SNDK9A73141999307702 [ 49.148437] usb 1-1: device v0781 p5150 is not supported [ 49.171875] usb 1-1: configuration #1 chosen from 1 choice [ 49.203125] scsi0 : SCSI emulation for USB Mass Storage devices [ 54.226562] scsi 0:0:0:0: Direct-Access SanDisk Cruzer Mini 0.2 PQ: 0 ANSI: 2 [ 54.273437] SCSI device sda: 2001888 512-byte hdwr sectors (1025 MB) [ 54.281250] sda: Write Protect is off [ 54.289062] sda: assuming drive cache: write through [ 54.304687] SCSI device sda: 2001888 512-byte hdwr sectors (1025 MB) [ 54.312500] sda: Write Protect is off [ 54.312500] sda: assuming drive cache: write through [ 54.320312] sda:<7>musb_start_urb 214: qh c7d9ad60 urb c7da3540 dev2 ep1out-bulk, hw_ep 1 , ffcfe000/31 [ 54.335937] sda1 [ 54.367187] sd 0:0:0:0: Attached scsi removable disk sda [ 62.156250] usb 1-1: USB disconnect, address 2 / # echo otg > /sys/devices/platform/musb_hdrc/mode / # [ 78.187500] usb0: high speed config #1: 8 mA, Ethernet Gadget, using CDC Ethernet It works with the N810 hardware, marking WORKSFORME.
Closing as per last comment.