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)

geohsia 2010-06-03 06:56

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by titan (Post 697139)
I have a possible explanation why it fails: my USB stick requests 200mA
which is the limit of the N900. I'll try again with another less power-hungry device.

I have a HDD that has its own internal power. If someone needs to test host mode with no power I am happy to give it a shot.

titan 2010-06-03 07:15

Re: N900 will not allow USB OTG!
 
1 Attachment(s)
this my HOWNOTTO get USB hostmode working.
I hope someone can replicate MohammadAG's success or at least find out what I did wrong.
Warning: This is only for experts! i2cset may damage your device.

0. you need a USB F/F adapter, the N900 USB cable and a USB device with < 200mA power consumption (verify on your PC)
1. install MohammadAG's kernel (with sarahn's patches + power ignore patch + appropriate configuration), i2ctools (i2cset in PATH) and sysklogd
I have PR1.2 installed, wifi on, bluetooth off, 2.5G, autodisconnect on. egoshin's method works (set to host while connected to PC)
2. boot device with USB cable but without USB device connected
3.
Code:

pcsuite-enable.sh
optional:
Code:

echo USB debug start > /var/log/syslog
and
Code:

echo 10 > /sys/module/musb_hdrc/parameters/debug
4. run the attached script ("sh host.txt -d" shows the state after every step)
5. immediately plug in the USB device
6. check dmesg and /proc/driver/musb_hdrc
7. to retry, unplug USB device,
Code:

killall sh; start bme; sleep 2; cat /proc/driver/musb_hdrc
after about 30sec you should see:
Code:

Status: MHDRC, Mode=Peripheral (Power=20, DevCtl=80)
then go to 4.

my results: (with -d flag)
start: Mode=Peripheral (Power=20, DevCtl=80)
echo H: Mode=Peripheral (Power=20, DevCtl=82)
echo e: Mode=Peripheral (Power=20, DevCtl=82)
echo F: Mode=Peripheral (Power=60, DevCtl=83)
bme stopped: Mode=Peripheral (Power=60, DevCtl=83)
slept 3sec: Mode=Peripheral (Power=20, DevCtl=80)
i2cset: Mode=Peripheral (Power=f1, DevCtl=99)
later: Mode=Peripheral (Power=e1, DevCtl=99)

for the description of the power+devctl flags see drivers/usb/musb/musb_regs.h

with egoshin's method:
Status: MHDRC, Mode=Host (Power=f0, DevCtl=dd)
OTG state: b_peripheral:3; active

dmesg:
Code:

[ 1863.465087] musb_restore_ctx_and_resume  435: restoring register context for musb_restore_ctx_and_resume
[ 1863.465087] rx51_xceiv_power 1
[ 1863.465698] rx51_xceiv_reset
[ 1863.850799] musb_interrupt      1948: ** IRQ peripheral usb0001 tx0000 rx0000
[ 1863.850830] musb_stage0_irq      643: <== Power=e5, DevCtl=99, int_usb=0x1
[ 1863.850860] musb_stage0_irq      829: SUSPEND (b_idle) devctl 99 power e5
[ 1863.874389] musb_interrupt      1948: ** IRQ peripheral usb0001 tx0000 rx0000
[ 1863.874420] musb_stage0_irq      643: <== Power=e1, DevCtl=99, int_usb=0x1
[ 1863.874420] musb_stage0_irq      829: SUSPEND (b_idle) devctl 99 power e1
[ 1871.680358] musb_platform_try_idle  160: b_idle inactive, for idle timer for 7 ms

what MohammadAG got with the same commands (his device is in R&D mode, but it didn't make a difference for me):
Status: MHDRC, Mode=Host (Power=f0, DevCtl=dd)
OTG state: a_host:9; active

with flash plugged in (not powered on)
Status: MHDRC, Mode=Host (Power=e0, DevCtl=99)

with bme:
Status: MHDRC, Mode=Host (Power=20, DevCtl=80)
MohammadAG: OTG state: b_idle:1; inactive

If I first apply egoshin's method I get
Status: MHDRC, Mode=Host (Power=e1, DevCtl=99)
OTG state: b_idle:1; inactive
but again no device is detected.

Bec 2010-06-03 07:35

Re: N900 will not allow USB OTG!
 
Thanks a bunch, please keep this post up to date as new info becomes available :)

I'll bookmark it.

Edit: is it possible that different versions of the firmwares may affect this?

MohammadAG 2010-06-03 09:05

Re: N900 will not allow USB OTG!
 
titan, just a note, according to lsusb -v my flash drive also uses 200mA.
Doing some tsts after you left I can see what you experience. I'm afraid at the time being you'll have to time it right after running the script.

Anyways, I can still reproduce it :)

KOJAN 2010-06-03 09:13

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by titan (Post 697172)
...1. install MohammadAG's kernel (with sarahn's patches + power ignore patch + appropriate configuration), i2ctools (i2cset in PATH) and sysklogd...

Where I can download MohammadAG's kernel?

MohammadAG 2010-06-03 09:16

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by KOJAN (Post 697302)
Where I can download MohammadAG's kernel?

Apply the patches and build a kernel.
A binary won't be provided till the app is released :)

Bec 2010-06-03 09:19

Re: N900 will not allow USB OTG!
 
Isn't it possible to stop any event from happening with the stick connected so that we could use two scripts, one to let the device recognize the connection only when we want it and then "host.txt"?
This could solve our synchronization issue.

Can't the 200mA limit be overridden with kernel patching?

MohammadAG 2010-06-03 09:20

Re: N900 will not allow USB OTG!
 
The 200mA limit is a hardware one.

Bec 2010-06-03 09:24

Re: N900 will not allow USB OTG!
 
Also since the sate of an USB device being connected becomes a state defined in the ram memory of the device, would it be possible to simply patch (some of) the code in the ram to skip some of the steps?

clasificado 2010-06-04 09:11

Re: N900 will not allow USB OTG!
 
@Bec no offense, but this has been requested already, please keep this thread for development only.

use this thread instead for petitions and questions. developers comment there too

http://talk.maemo.org/showthread.php...ight=host+mode


All times are GMT. The time now is 15:09.

vBulletin® Version 3.8.8