maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N900 (https://talk.maemo.org/forumdisplay.php?f=44)
-   -   N900 will not allow USB OTG! (https://talk.maemo.org/showthread.php?t=31921)

javispedro 2010-05-28 08:47

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by blue_led (Post 684310)
so limitaton on real n900 device with not id pin hardwired : any a-state machine can not start, and bme with charger check procedure prevent bus to enter suspend state and my final conclusions are
as nokia deliver n900 ( with glorious bme ) can't perform otg as everybody know that
the only host hope for us is b_host and i am confident it can be reached without a pc

To check this was one of the reasons I had started testing with the N810. All of the previous devices (including non id pin in connector ones) use a_host state.

joerg_rw 2010-05-28 10:32

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by flailingmonkey (Post 684794)
I have started to wonder if Nokia is actually not allowed to assist in these efforts to determine how to manually turn the USB controller to hostmode, due to USB Consortium crap, or if its just due to the bme system being closed-source. Does the partial OTG software implementation in the drivers provide any actual benefits beyond pure peripheral mode? Or is it there because they started work on OTG and realized they couldn't finish it, and reworked that code instead of removing all the OTG-ness.

I have been wondering about literally hacking the bme. basically, the program would not change, and maybe with the magic of LD_PRELOAD and some tracing, we'd fake out the syscalls/library calls it would make (akin to how rootkits hide themselves).

AIUI they simply swapped the USB receptacle (and added a 1k VBUS R to PHY 1707) to get by the OTG cert. The driver isn't exactly from Nokia, but is more like a generic linux driver pushed by maybe mentorgraphics originally.
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.

joerg_rw 2010-05-28 11:28

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by javispedro (Post 685012)
To check this was one of the reasons I had started testing with the N810. All of the previous devices (including non id pin in connector ones) use a_host state.

Yes, but aiui this was accomplished by "echo host >mode" triggering a fake ID_GND signal from "PHY" layer to the above machinery, which our 1707 alas is incapable to do.

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:

bit 7 FORCE_HOST:
Set this bit to forcibly put the USB controller into Host mode when SESSION bit is set,
regardless of whether it is connected to any peripheral. The controller remains in Host mode
until the Session bit is cleared, even if a device is disconnected. And if the FORCE_HOST but
remains set, it will re-enter Host mode next time the SESSION bit is set. The operating speed is
determined using the FORCE_HS and FORCE_FS bits.
alas it seems there will be no automatic speed negotiation, no session-end detection and no HOSTDISCON IRQ generated, so the software statemachine found mainly inside function
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:

23.1.3.4.6 FORCE_HOST
The Force Host test mode enables the user to instruct the core to operate in Host mode, regardless of
whether it is actually connected to any peripheral i.e. the state of the CID input and the LINESTATE and
HOSTDISCON signals are ignored. (While in this mode, the state of the HOSTDISCON signal can be read
from bit 7 of the DevCtl register.)
This mode, which is selected by setting bit 7 within the Testmode register, allows implementation of the
USB TEST_FORCE_ENABLE (7.1.20). It can also be used for debugging PHY problems in hardware.
While the FORCE_HOST bit remains set, the core will enter Host mode when the Session bit is set and
remain in Host mode until the Session bit is cleared even if a connected device is disconnected during the
session. The operating speed while in this mode is determined for the setting of the FORCE_HS and
FORCE_FS bits of the Testmode register in Section 23.1.4.11.
description of IRQ we will not see in FORCE_HOST mode
Quote:

HOSTDISCONNECT_RISE
Generate an interrupt event notification when
Hostdisconnect changes from low to high. Applicable only in
host mode (DpPulldown and DmPulldown both set to 1b).
please hit 'thanks' if you feel this is a useful post

titan 2010-05-28 13:54

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:

Originally Posted by joerg_rw (Post 685367)
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.


joerg_rw 2010-05-28 15:18

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by titan (Post 685697)
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?

host has 2 pulldown R (15k)
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:

The operating speed while in this mode is determined for the setting of the FORCE_HS and
FORCE_FS bits of the Testmode register in Section 23.1.4.11.

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.

sarahn 2010-05-28 15:56

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by joerg_rw (Post 685914)
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 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
Then we set SESSION bit
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 *).

An excerpt from my kernel patches, which I posted:

Code:

                if (testmode & MUSB_TEST_FORCE_HOST) {
                        u8 r,reg;
      void __iomem *mbase = musb->mregs;

                        musb_force_term(musb->mregs,MUSB_TERM_HOST_HIGHSPEED);

                        r = musb_ulpi_readb(mbase, ISP1704_DEBUG);
                        DBG(1,"Linestate %x\n",r);
                        switch(r) {
                        case 2:
                                musb->port1_status |= USB_PORT_STAT_LOW_SPEED;
                                reg = musb_readb(mbase, MUSB_TESTMODE);
                                reg &= ~MUSB_TEST_FORCE_FS;
                                reg &= ~MUSB_TEST_FORCE_HS;
                                musb_writeb(mbase, MUSB_TESTMODE, reg);

                                reg = musb_readb(mbase, MUSB_POWER);
                                reg &= ~MUSB_POWER_HSENAB;
                                musb_writeb(mbase, MUSB_POWER, reg);

                                musb_force_term(musb->mregs,MUSB_TERM_HOST_LOWSPEED);
                                break;
                        case 1:
                                /*High or full speed*/
                                reg = musb_readb(mbase, MUSB_TESTMODE);
                                if(reg &  MUSB_TEST_FORCE_HS) {
                                        /*High speed*/
                                        reg &= ~MUSB_TEST_FORCE_FS;
                                        musb_writeb(mbase, MUSB_TESTMODE, reg);

                                        reg = musb_readb(mbase, MUSB_POWER);
                                        reg |= MUSB_POWER_HSENAB;
                                        musb_writeb(mbase, MUSB_POWER, reg);
                                } else {
                                        /*Full speed*/
                                        reg |= MUSB_TEST_FORCE_FS;
                                        musb_writeb(mbase, MUSB_TESTMODE, reg);

                                        reg = musb_readb(mbase, MUSB_POWER);
                                        reg &= ~MUSB_POWER_HSENAB;
                                        musb_writeb(mbase, MUSB_POWER, reg);
                                }

                                musb_force_term(mbase,MUSB_TERM_HOST_FULLSPEED);

                                break;
                        case 0:
                        case 3:
                                /*invalid*/
                                WARNING("Invalid line state of %d\n",r);
                                break;
                               
                        }
                } else {

                        /* high vs full speed is just a guess until after reset */
                        if (devctl & MUSB_DEVCTL_LSDEV)
                                musb->port1_status |= USB_PORT_STAT_LOW_SPEED;
                }


sarahn 2010-05-28 16:05

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.

joerg_rw 2010-05-28 16:27

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by sarahn (Post 686002)
An excerpt from my kernel patches, which I posted:

I gather you do this speed setting (which is btw exactly what I had in mind) on
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

blue_led 2010-05-28 19:54

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

sarahn 2010-05-28 20:33

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

MohammadAG 2010-05-28 20:38

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.

javispedro 2010-05-28 21:11

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by MohammadAG (Post 686692)
imo using a modified cable/adapter should be avoided.

Don't worry, as doing any id pin work is meaningless, unless ID pin is also connected to isp1707 (which it isn't afaiu), or twl3040 is in some hardcoded way altering the behaviour of the SoC's usb controller (which it isn't either, as it's not connected via ulpi).

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...).

blue_led 2010-05-28 21:16

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

GI jack 2010-05-28 21:16

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by qgil (Post 330513)
You can't connect a camera in host mode, but the N900 comes with a good camera. The use case is still relevant but is not as heavy as in previous Maemo devices.

You can't connect a hard drive in host mode, but the N900 comes with a big internal memory expandable with a MicroSD card. The use case is still relevant but is not as heavy as in previous Maemo devices.

I don't care about this, the camera is good enough, and the camera can afford to gain a few more features in software, like a timer. The flash card is also big enough for everything I'd need it for. If not, I can always SCP and SFTP files to my server. I have but haven't had to use my ext3 formatted microsd card yet.

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.

javispedro 2010-05-28 21:34

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by blue_led (Post 686781)
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

Is your camera a OTG device also? Can reproduce it with a dumb usb stick?

joerg_rw 2010-05-28 22:11

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by javispedro (Post 686829)
Is your camera a OTG device also? Can reproduce it with a dumb usb stick?

http://www.google.de/search?q=07b4+0...UTF-8&oe=UTF-8

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

sarahn 2010-05-28 22:34

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

blue_led 2010-05-28 22:37

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

sarahn 2010-05-30 06:12

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
to see if that stops the constant re-enumeration? By default that value is set to 2 which could relate to a re-enumeration every 3 seconds.

Bec 2010-05-30 07:05

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

ahmadamaj 2010-05-30 08:09

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?

anaskr 2010-05-30 08:48

Re: N900 will not allow USB OTG!
 
well can we have a tutorial on this? step by step? please

tenQ

joerg_rw 2010-05-30 11:31

Re: N900 will not allow USB OTG!
 
Quote:

where exactly have you reached guys in making OTG easy to use for everyone? will a normall cable (mini usb - USB) work?
This isn't OTG. It is NOT easy to use for anybody, as it doesn't exactly work at all yet. If eventually we get to have a plain working hostmode, then a simple adapter A-FtoA-F will suffice, together with your CA-101 cable that came with the phone.

Quote:

well can we have a tutorial on this? step by step? please
As soon as we got something useful to describe in such a step by step HowTo, of course you'll get one and we'll do a BIG announcement on that - we're just not there yet.
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:

install package hostmode-easy-now
klick the h-e-n icon
from the menu select "hostmode, powered" (a red USB icon will show up in systray area)
attach your USB keyboard, memstick, IrDA adapter, or whatever, using your CA-101 cable and a female-to-female adapter
or
from the menu select "hostmode, charging" (a white USB icon will show up in systray area)
attach your USB peripheral and a USB charger capable to deliver at least 1A, using CA-101, F2F-adapter, and a Y-cable

To stop hostmode, or to switch between powered and charging hostmode, click on systray and select the option you like from the pulldown menu

To finetune hostmode behaviour, click h-e-n icon, and select "config" from menu.
You will see a list of all previously attached USB peripherals that have been configured, plus the currently attached peripheral which is highlighted. On the right you can select for the highlighted item whether your N900, when the peripheral is being plugged in, should automatically change from powered to charging mode (for selfpowered drives etc), and if the screen dim should be disabled. There's also a wildcard item with the name "powered mode" in the list, which will have "disable dim" option only, to disable dimming of screen as long as device is in powered hostmode (you might not care about saving screen backlight power, while USB blasts out 5V to a hungry peripheral)
There's also an option to make indicator LED flash red during powered hostmode, to warn you about the power drain.

hostmode-easy-now will power up the USB and enter hostmode as soon as you click the h-e-n icon and the main menu shows up. Depending on your selection, it will switch to hostmode,charging, or revert to whatever was the USB state before on selecting "config".
When hostmode wasn't enabled when you click the h-e-n icon, and the automatic enabling of powered hostmode makes an already attached peripheral become visible for N900, and if this peripheral is a configured item, then the hostmode and other option are set according to the config for that item, and the main menu is closed immediately. Put simply, if you first attach a known and configured device, then clicking h-e-n is all you need to do to make it start.

hcm 2010-05-30 15:55

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.

sarahn 2010-05-31 08:16

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.

joerg_rw 2010-05-31 12:58

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

Nokia7Linux 2010-05-31 13:16

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...

MohammadAG 2010-05-31 13:23

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by Nokia7Linux (Post 691712)
I think you guys should see this:

It is still in beta stages...

Quite ironic to see the pics watermarked since...
http://talk.maemo.org/showthread.php?t=31921&page=91

Chrome 2010-05-31 13:34

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by Nokia7Linux (Post 691712)
I think you guys should see this:

It is still in beta stages...

MohammadAG took these pictures, and i credited him in m4a thread.. No need to post them with the watermark :)

imperiallight 2010-05-31 14:33

Re: N900 will not allow USB OTG!
 
Quote:

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.
Awesome, does the touchpad work properly?

Bec 2010-05-31 17:19

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

blue_led 2010-05-31 22:29

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

javispedro 2010-05-31 22:34

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.

MohammadAG 2010-05-31 22:37

Re: N900 will not allow USB OTG!
 
And as I said before, echo host > ... is redundant (or null() as joerg_rw calls it)

sarahn 2010-05-31 23:57

Re: N900 will not allow USB OTG!
 
1 Attachment(s)
Quote:

Originally Posted by joerg_rw (Post 691671)
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

I agree the ID pin shouldn't be necessary and I'm working on that right now.

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.

sarahn 2010-06-01 00:11

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by blue_led (Post 692609)
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

I'm not able to duplicate. Can you post dmesg + /proc/driver/musb_hdrc step by step?

sarahn 2010-06-01 00:28

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by javispedro (Post 692615)
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.

Grouding the id pin sets the a_idle state, not a_host.

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.

jimx 2010-06-01 00:31

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...

maxximuscool 2010-06-01 03:17

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by jimx (Post 692748)
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...

Wrong, I am here always following this thread too lol. I think everyone is following this thread very closely. If there is a break through in thi OTG USB then it will be a world peace..

Bec 2010-06-01 03:47

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