![]() |
Re: N900 will not allow USB OTG!
Quote:
|
Re: N900 will not allow USB OTG!
Quote:
The whole bme stuff doesn't interfere right now, as we don't want OTG so we don't need the USB driver controlled VBUS ringing (needed for HNP & SRP), and I so far fail to see evidence a "stop bme" neutered bme would conflict with pure hostmode. |
Re: N900 will not allow USB OTG!
Quote:
I studied 2 versions of SPRUF98 for OTG-USB, and found there are actually 3 'correct' ways to put the musb core to hostmode: * ID pin grounded causing the corresponding flag bit in RXCMD from PHY being asserted, which results in A role for the device and puts musb core into hostmode (for obvious reasons this seems not possible on N900) * HNP to walk the musb core thru the state transitions involved with host role change (the thing egoshin somewhat accidentally exploited by keeping VBUS alive so session end wasn't detected when swapping the cable, and which might be possible to do by blue_led suggested method, without need of a kickstart PC) * FORCE_HOSTMODE bit, which - according to SPRUF98D - October 2009, "§23.1.4.11 Register to Enable the USB 2.0 Test Modes (TESTMODE)" does: Quote:
559 static irqreturn_t musb_stage0_irq() in musb_core.c which is driven entirely by IRQ triggered by the musb core harware, won't play nice. Nevertheless we can probably, even definitely, by some patches force the software statemachine into the correct state when sensing a "echo host >mode" is done. Same time we would config the musb core and PHY correctly (set FORCE_HOST bit, enable the DM_PD and DP_PD resistors in PHY for physical hostmode config, etc), and then poll HOSTDISCON from DevCtl register, to detect attachment/removal of a peripheral and his pullup R. We will need a patch in USB protocol driver (I'm wildly guessing here) to do this poll and start chatting with peripheral when due. description of the FORCE_HOST operation mode Quote:
Quote:
|
Re: N900 will not allow USB OTG!
do you think it would be possible to disable FORCE_HOSTMODE at CONNECT IRQ and enable it again at DISCONNECT IRQ?
or the other way around: temporarily enable FORCE_HOSTMODE upon CONNECT set devctl, and disable it again? Quote:
|
Re: N900 will not allow USB OTG!
Quote:
peripheral has 1 pullup R 1k5 (depending on low speed / full speed either on DP or DM line) host detects attachment of peripheral when one of the D lines is pulled up (= HOSTDISCON) So, to detect attachment of a peripheral, the host MUST have both pulldown R enabled (this is obviously the default idle state of N900) Also host MUST (for the normal procedure) provide 5V VBUS, otherwise the peripheral (unpowered) has no means to pullup any D line N900 switches from default idle PHY config (which is similar to host config, 2 pulldown, see above) to peripheral PHY config (= 1 pullup, no pulldowns), on sensing VBUS. Musb_hdrc driver, musb core, and PHY all do not know about bq24150, so enabling boost mode aka 5V supply mode will make the N900 think it has been attached to a host -> change to peripheral mode -> we lost the game. We need to explicitly switch to hostmode by doing 'echo host >mode', as without that we don't have a means to detect attachment of a peripheral correctly. So on issuing 'echo host >mode': *) We need to FORCE_HOST, make sure the pulldowns stay enabled, do other mandatory configs wrt for example powersaving mode - refer to SPRUF98, and start VBUS supply boost if that is what we want (quite usually it is. Except for externally powered host mode, i.e. host mode while charging, using a Y-cable) Then we set SESSION bit [edited after first tests] Then we can poll for HOSTDISCON flag changing state, which signals us one of the D lines was pulled up. I have to speculate a little what's correct sequence from then, probably we check whether D+ or D- was pulled up (we can read out from PHY's debug register iirc), and set LowSpeed / FullSpeed accordingly Quote:
Now we are ready to pass control to the logical driver talking to the connected peripheral, i.e. start ENUM, aka force software statemachine into hostmode Whenever the logical aka protocol driver detects a disconnect of peripheral, either by timeout, or by HOSTDISCON changing state, it needs to reset SESSION, and we go back to *) When we do a 'echo OTG >mode', the driver needs to stop logic protocol subdriver if there's still a session established, then disable VBUS boost if it was enabled, reset musb core and PHY, and restart the software state machine. Please take the above with a grain of salt, it was written down quickly from memory, without checking back with the datasheets/specs etc, to give you a quick start in the right general direction. I may edit this post if I find inaccuracies on a later more close check, so reread occasionally please. |
Re: N900 will not allow USB OTG!
Quote:
Code:
if (testmode & MUSB_TEST_FORCE_HOST) { |
Re: N900 will not allow USB OTG!
Also, once this is ready, to my knowledge there is no reason you couldn't kick all of this off via the id pin interrupt from the twl4030 and stop it when the cable is disconnected.
|
Re: N900 will not allow USB OTG!
Quote:
801 if (int_usb & MUSB_INTR_CONNECT) {... The problem I see is we never enter the whole 559 static irqreturn_t musb_stage0_irq() function, once we've set FORCE_HOST correctly, as it will disable the IRQ generation from musb core. So we can either postpone FORCE_HOST & setting SESSION until the core threw an IRQ for MUSB_INTR_CONNECT, and do it then same time as the speed settings you have there. My concern is we need VBUS (usually) for a CONNECT to happen (btw MUSB_INTR_CONNECT is the same like the HOSTDISCON IRQ?). This may cause the core to enter peripheral state on PHY 1707 sensing VBUS, if we don't set FORCE_HOST prior to supplying VBUS Or we do a soft-IRQ/simulated IRQ by calling the routine directly. I don't know if that will work though, as for all I understand it's a IRQ callback function which might be a little icky to call directly. cheers jOERG [edit] There is no IRQ from TWL4030 ID pin, for two reasons: 1) we don't use twl4030 at all for USB, so the ID pin IRQ needs to be handled somewhere else and passed in to the USB driver stuff 2) it's unclear if the ID pin really is connected from TWL4030:R11 to the USB receptacle, and it's pretty hard to virtually impossible to find a micro-B plug with ID pin grounded |
Re: N900 will not allow USB OTG!
2 Attachment(s)
the id pin of usb receptacle is very connected to twl chip
i use a modified uB to A adapted during my tests you can see orange a jumper and i can replace it with resistors twl chip have inside comparator sensing 0, 100k 200k 400k resistor between id pin and ground ( old ? charger specs ?! ) tear id to ground switch to a_idle as expected |
Re: N900 will not allow USB OTG!
Yup, we've known about the id pin causing an interrupt and by default switching to a_idle and also setting some sysfs file to read id (I forget which) instead of vbus. That only changes that particular state.
When vcc is applied logically you should go to a_wait_bcon, that may not be useful though. At some point I got an SRP when I started a session under forced host mode. I do not recall the exact sequence to get there. IIRC you'll find within that state machine for irq 0 people already fake out some interrupts. I have always booted with the usb cable attached and in the latest kernel I think I saw some fixes related to that, so I'm hopeful those patches will help. In context save and restore the resistors are set back to peripheral, and somewhere in either plat-omap or mach-omap2 the phy can be put into low power mode(?) also resetting back to peripheral for automatic charger detection. Need to fix that, those changes are on my implemented but untested list as I am getting a kernel panic atm during boot. If this doesn't work I'm going to patch 2.6.29 with beagleboard musb patches and see what the differences are to the maemo 2.6.28, though I am told musb is flaky on the beagleboard too. I think there is a patch to fix not being able to leave suspend under host mode if it happens, and that was a state I saw. I was also trying to prevent suspend outright |
Re: N900 will not allow USB OTG!
imo using a modified cable/adapter should be avoided. Priority should be given to fix the driver, instead of exploiting it.
|
Re: N900 will not allow USB OTG!
Quote:
Patching twl3040-usb to report about id pin always connected is the first thing I did (and I guess the first thing many others did...). |
Re: N900 will not allow USB OTG!
2 Attachment(s)
connection to a pc is not needed
my n900 can talk with my olympus camera using an Y cable powering both n900 and camera. nu external powered hub until now i am happy |
Re: N900 will not allow USB OTG!
Quote:
What I need USB OTG for is something else. odd devices... like a usb to serial cable/converter, a USB ethernet device, and connecting to other phones via usb for programming/address book swap. |
Re: N900 will not allow USB OTG!
Quote:
|
Re: N900 will not allow USB OTG!
Quote:
ID 07b4:0118 Olympus Optical Co., Ltd Mju Mini Digital/Mju Digital 500 Camera Device Name: (OLYMPUS u700,S700 USB Device) PnP Device ID: VID = 07B4 PID = 0118 Serial Number: B25769076 Revision: 1.00 Device Type: Standard USB device - USB2.0 Full-Speed (USB1.1) Chip Vendor: (No match record) Chip Part-Number: (No match record) Product Vendor: OLYMPUS Product Model: u700,S700 It's obviously a Olympus mju 500 or C-700 As as the c-700 is some >6 years old, I wasn't able to find decent datasheets (though wasn't to much into searching) to tell if that one support direct pict bridge. Chances are high for the more probable mju 500 though, which means the cam talks to printers as a host, if it's true. Confirmed: http://www.ciao.de/Olympus_u_MJU_DIG...#productdetail PRINT Image Matching, PictBridge-Unterstützung So now we know we don't need a laptop for kickstart OTG, a cheap mju 500 will do ;-P I support MohammadAG's opinion as of his last post /j |
Re: N900 will not allow USB OTG!
OTG adapter FYI, this is how I ground the id pin
http://www.electronicproductonline.c...oducts_id=2043 |
Re: N900 will not allow USB OTG!
1 Attachment(s)
@ javispedro
yes . usb dumb stick "works" but every 3 seconds n900 run like crazy enumerating this stick @joerg my camera is u1030SW :) when i apply 5v a menu appear on display like n900 ( PC . fast print , ..) so n900 can act as a host without help of any smart device 5v can come from inside or outside |
Re: N900 will not allow USB OTG!
For anyone who has a peripheral at least half working: can you try
Code:
echo -1 >/sys/module/usbcore/parameters/autosuspend |
Re: N900 will not allow USB OTG!
Guys this is great news!
I only wish someone could produce a gizmo that has an USB port and also charges your phone |
Re: N900 will not allow USB OTG!
first i want to thank everyone for their hard work to make this possible. But the talk her is too technical i couldn't understand everything and the wiki didn't help a lot. I have a few questions, where exactly have you reached guys in making OTG easy to use for everyone? will a normall cable (mini usb - USB) work?
|
Re: N900 will not allow USB OTG!
well can we have a tutorial on this? step by step? please
tenQ |
Re: N900 will not allow USB OTG!
Quote:
Quote:
So please stay calm and patient, we're working on it. The previous posts might suggest there's more than we actually got, but we are close [edit] The HowTo will be very simple btw (just the package is still missing ;-D ): Quote:
|
Re: N900 will not allow USB OTG!
1 Attachment(s)
I used some perl magic to grant DocScrutinizers wish of having DBG-statements in every function in usb/.
just call the attached perl-script with a parameter (either a single .c file or a directory => it will recursively process each .c file). the script makes a backup of each .c file and adds DBG-statements in every function and before every return-statement or end of function. ATTENTION: the script uses the program "indent" to generate homogeneous code to avoid parsing errors (the "parser" is not very foolproof). The program must thus be installed, and the line-numbers may not be the same as in the original source-files. |
Re: N900 will not allow USB OTG!
2 Attachment(s)
I am typing this in from a USB keyboard hooked up to an external hub that I got working with just force host. It was not via the HNP trick.
I have tried different hubs connected directly. I can also unplug the keyboard, plug one hub into the other, plug in the keyboard to the cascaded hub, and use it from there. Unfortunately detecting disconnects / connects after initial enumeration is not 100%reliable. Mass storage doesnt seem to be working for reasons I dont know yet. Mass storage devices are detected as shown with lsusb. I have had a keyboard and a keyboard/touchpad plugged in and operating at the same time - this is what I have available right bow other than the mass storage. I tried connecting my keyboard directly without the hub and it showed up in lsusb but did not work, no characters typed showed up on the screen. I am using a power injection cable. It also works with the bq power instead of power injection, but a powered hub still seems to be required. The additional changes to what I did before that seem relevant are disable usbcore autosuspend and then making the musb SUSPEND interrupt a noop when forcing host mode. Also, disabling the usb whitelist appears to causes issues with the gadget driver, grep your syslog for "cut". So for now it seems better to leave whitelist configured but really allow everything. The switch to host is not 100% reliable, probably due to ulpi timeouts. These happen for reasons I don't know. [edit] As it stands host mode only works with connecting the id pin first. The interrupts that happen when applying power first cause a session to be opened as a peripheral, which interferes. Working on it. |
Re: N900 will not allow USB OTG!
sarahn
extremely encouraging results, indeed. :-) You have any idea why we need a hardware ID_GND and can not fake it? would you mind posting a proper diff so we can know what exactly you patched in kernel and also which kernel that is based on, please. A super nice-to-have of course would be if you could apply hcm's pearl script to the whole usb folder (of course after you created the diff), and also supply the result of that, so we finally get an idea what's happening in detail when forcing host mode, function by function - kind like a trace. many thanks jOERG |
Re: N900 will not allow USB OTG!
I think you guys should see this:
http://img14.imageshack.us/img14/5870/40775082.png http://img139.imageshack.us/img139/7259/64147687.png It is still in beta stages... |
Re: N900 will not allow USB OTG!
Quote:
http://talk.maemo.org/showthread.php?t=31921&page=91 |
Re: N900 will not allow USB OTG!
Quote:
|
Re: N900 will not allow USB OTG!
Quote:
|
Re: N900 will not allow USB OTG!
Well at least nokia seems to hear what we want hehe ;) http://www.youtube.com/watch?v=xl4oU...layer_embedded
|
Re: N900 will not allow USB OTG!
stable "almost host" procedure
1 disable bme 2 plug ANY uB with ID grounded 3 echo host > .... 4 echo H > .... 5 apply 5v from extern or intern source 6 attach stick, hub,... enumeration seems to happen once. to restart enumeration unplug uB and go to step 2 |
Re: N900 will not allow USB OTG!
The only thing setting idpin does is changing the initial state of the otg state machine to a_host, and even that is undone when you apply vbus, since for some reason twl4030-usb assumes vbus has prority over id pin connection.
|
Re: N900 will not allow USB OTG!
And as I said before, echo host > ... is redundant (or null() as joerg_rw calls it)
|
Re: N900 will not allow USB OTG!
1 Attachment(s)
Quote:
On the subject of function traces, ftrace would be quite nice. I managed to get zImage to compile and run with ftrace enabled but the modules still had the function __gnu_mcount_nc missing. |
Re: N900 will not allow USB OTG!
Quote:
|
Re: N900 will not allow USB OTG!
Quote:
If I plug in power after I plug in a grounded ID pin, /sys/class/i2c-adapter/i2c-1/1-0048/twl4030_usb/linkstat does not change to read vbus. It still reads idpin. If I do both at once, vbus takes priority. |
Re: N900 will not allow USB OTG!
Extraordinary results. Is there any chance of an 'interim release' just to get us ordinary mortals up-and-running with a USB keyboard in the meantime? It would make such a huge difference.
Apologies if this is an inappropriate request. Very very best of luck with this project - I think I'm not the only one here following this thread with bated breath... |
Re: N900 will not allow USB OTG!
Quote:
|
Re: N900 will not allow USB OTG!
You bet we are, I'm already preparing to order;)
http://cdn1.webvoo.com/cdn/ebay/itri...adx01_3_it.jpg http://cgi.ebay.com/2-USB-2-0-Micro-...item20b1326183 |
| All times are GMT. The time now is 15:09. |
vBulletin® Version 3.8.8