How Do You Put The Usb Otg Port Into Host Mode?


Loon

Member
Joined
Jul 25, 2006
Messages
357
I bought a USB adapter from deal extreme as per this thread.

It arrived today, it seems to be a good fit in a physical sense, i.e. it slots nicely into the port, all the pins seem to line up.

However when connecting a USB1 mini laptop mouse via the adapter nothing seems to happen. My guess is that I might have to instruct the USB OTG port to operate in host mode. Does anyone know how to do this?

Had a search on the USB page on the Wiki and couldn't find anything there about how to switch on host mode, will update the Wiki page if an answer is forthcoming.
 
Last edited by a moderator:
If it's not one of those adaptors that pull one of the contacts to ground you'll have to enter host mode via terminal, I suppose.

This is how it's done on an N8x0
Code:
echo host > /sys/devices/platform/musb_hdrc/mode
disable
Code:
echo otg > /sys/devices/platform/musb_hdrc/mode

It might be similar on the Pandora. Did you check the menu entry for mass storage mode? Maybe there is a setting for host mode.
 
Maybe either your adaptor is not the correct sort (missing the pin to ground) or your USB host has crashed.
try
Code:
sudo lsusb
Mali's suggestion doesn't seem to do anything (with nothing connected to the USB), no error, but mode does not change. With my adaptor, a mouse worked with no additional intervention.
 
mali said:
If it's not one of those adaptors that pull one of the contacts to ground you'll have to enter host mode via terminal, I suppose.

This is how it's done on an N8x0
Code:
echo host > /sys/devices/platform/musb_hdrc/mode
disable
Code:
echo otg > /sys/devices/platform/musb_hdrc/mode

It might be similar on the Pandora. Did you check the menu entry for mass storage mode? Maybe there is a setting for host mode.

Hi Mali, tried typing exactly what you said (i.e. echo host > /sys/devices/platform/musb_hdrc/mode) into the terminal and I get the response :

bash : /sys/devices/platform/musb_hdrc/mode: permission denied

Then tried typing in : sudo echo host > /sys/devices/platform/musb_hdrc/mode

got the same response.

Browsed the file system to check the mode file was there, it appears to be a text file that only contains the text 'b_idle' does that sound right?

Tried this both with & without the adapter & mouse connected.

As for checking the menu, I could find a setting relating to putting the SD cards into mass storage mode but nothing relating to putting the OTG port into host mode.

tsh said:
Maybe either your adaptor is not the correct sort (missing the pin to ground) or your USB host has crashed.
try
Code:
sudo lsusb
Mali's suggestion doesn't seem to do anything (with nothing connected to the USB), no error, but mode does not change. With my adaptor, a mouse worked with no additional intervention.

Hi TSH, tried typing 'sudo lsusb' and it gives me the response :

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Also tried my memory stick in the USB 2.0 port and it works fine so I'm pretty sure the host has not crashed.

Also of note is that people on the Deal Extreme forums state that this adapter works with the USB OTG port on the Nokia N800, would that require the pin to ground?

Do you have a link to the adapter you are using?

Thanks for your help guys and sorry if I'm missing something obvious, like many here I'm a linux noob.
 
Last edited by a moderator:
Mr Loon said:
Also of note is that people on the Deal Extreme forums state that this adapter works with the USB OTG port on the Nokia N800, would that require the pin to ground?
The N800 works with grounded adaptors and switches automatically or has to be switched in the above described way with a non-grounded adaptor. So when the page says it works with N800 it's true either way.
 
Last edited by a moderator:
Mr Loon said:
Hi Mali, tried typing exactly what you said (i.e. echo host > /sys/devices/platform/musb_hdrc/mode) into the terminal and I get the response :

bash : /sys/devices/platform/musb_hdrc/mode: permission denied

Then tried typing in : sudo echo host > /sys/devices/platform/musb_hdrc/mode

got the same response.

Browsed the file system to check the mode file was there, it appears to be a text file that only contains the text 'b_idle' does that sound right?
Try:
sudo chmod +w /sys/devices/platform/musb_hdrc/mode
sudo echo host > /sys/devices/platform/musb_hdrc/mode
 
Last edited by a moderator:
WizardStan said:
Try:
sudo chmod +w /sys/devices/platform/musb_hdrc/mode
sudo echo host > /sys/devices/platform/musb_hdrc/mode

Hi WizardStan, tried your suggestion, here is what I got :

Code:
jon-openpandora:~$ sudo chmod +w /sys/devices/platform/musb_hdrc/mode

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

Password: 
jon-openpandora:~$ sudo echo host > /sys/devices/platform/musb_hdrc/mode 
bash: /sys/devices/platform/musb_hdrc/mode: Permission denied

Mouse still does nothing.

Tried the same 2 lines again after that with the mouse and adapter plugged in, it did not ask for a password this time after the 1st line but still came back with the permission denied message and the mouse still does not get detected.

Is there a way to get the OTG port to tell you what mode it is in? i.e. is it in host mode or mass storage mode?
 
Last edited by a moderator:
Alerino said:

Hi Alerino, thanks for the suggestions, tried them all and sadly it still does not seem to work. Here is what I got :
Code:
jon-openpandora:~$ sudo cat /sys/devices/platform/musb_hdrc/mode

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

Password: 
b_idle
jon-openpandora:~$ sudo echo "host" > /sys/devices/platform/musb_hdrc/mode
bash: /sys/devices/platform/musb_hdrc/mode: Permission denied
jon-openpandora:~$ sudo sh -c "echo 'host' >> /sys/devices/platform/musb_hdrc/mode"
jon-openpandora:~$ echo host | sudo tee -a /sys/devices/platform/musb_hdrc/mode 
host
jon-openpandora:~$

It could of course be that the adapter is faulty, can anyone think of a way of testing this? FWIW the mouse works fine through a hub in the pandora USB2 port.
 
Last edited by a moderator:
Alerino said:
try
sudo cat /sys/devices/platform/musb_hdrc/mode

edit1
also try
sudo echo "host" > /sys/devices/platform/musb_hdrc/mode

edit2
OR

sudo sh -c "echo 'host' >> /sys/devices/platform/musb_hdrc/mode"

edit3
OR
echo host | sudo tee -a /sys/devices/platform/musb_hdrc/mode
Just tried with a non-wired OTG connector:
sudo su -
Then
echo "host" > /sys/devices/platform/musb_hdrc/mode
The plugging in a USB to PS/2 adaptor was detected.
However unplugging the usb adaptor caused the OTG port to go back in to idle mode.
Also issuing the echo line after plugging the device in seemed to hang the USB subsystem.

Edit:
Just tried a USB mouse and it works ok.
Anybody know what the current (amps) limitation is on the OTG port? Plugging a barcode scanner in to the USB -> PS/2 adaptor seems to cause the port to drop back in to idle. But the mouse didn't.
 
Last edited by a moderator:
mali said:
^ The wiki says 100mA.
That sounds like it could be the issue then - the barcode scanner is an ancient piece of current hungry tech. The mouse is a nice modern high efficiency thing!
 
Last edited by a moderator:
Just to clarify that this variant does work (even if it is not helpful)
Code:
echo host | sudo tee -a /sys/devices/platform/musb_hdrc/mode
 
tsh said:
Just to clarify that this variant does work (even if it is not helpful)
Code:
echo host | sudo tee -a /sys/devices/platform/musb_hdrc/mode

Looks like it's a problem with the adapter then, anyone got any links to working ones?

Edit, should also say thanks for all the help everyone. If someone who has got it working and maybe understands the commands that got it there, wants to write up the Wiki article than that would be great.
 
Last edited by a moderator:
Loon: You should reread the thread mentioned in the 1st post
> Looks like it's a problem with the adapter then, anyone got any links to working ones?
4th in the list took about 1 week, probaly mini A (looks right, not measured)
[edit] Now 14th in the list (of 23)
two months
 
Alerino said:
hdonk said:
Edit:
Just tried a USB mouse and it works ok.
Anybody know what the current (amps) limitation is on the OTG port? Plugging a barcode scanner in to the USB -> PS/2 adaptor seems to cause the port to drop back in to idle. But the mouse didn't.

did you echo host with the mouse plugged?
or afterwards?
I did the echo before plugging the mouse in.
 
Last edited by a moderator:
Wierd... I only see 1 hub listed now after a cold boot from sudo lsusb.

I would be very careful about changing the mode of the USB port using these commands. I managed to get my Pandora into a persistent (through power off) state where the USB-B port was not well behaved. It crashed my phone, and also my desktop (connecting via a powered hub). The desktop only crashed when I tried to enable SD-mass storage mode.

Valid modes for this USB driver seem to be:
a_host, b_idle, b_peripheral

Mode switching is automatic with the 'pin grounded' cable, and only occurs when a slave device is connected - just connecting the cable I see the mode is still b_idle. If I then connect a hub (my mouse seems to take too much current!) it switches to a_host.

If I connect to my desktop, mode becomes b_peripheral.

Connecting this mouse seems to kill the Device002 hub. No messages in dmesg. Invoking the SD-mass storage and disabling reloads the USB drivers, and seems to restore it to working.

Again TAKE CARE - messing with this has the ability to take out any other device you conenct as a host...
 
wdt said:
Loon: You should reread the thread mentioned in the 1st post
> Looks like it's a problem with the adapter then, anyone got any links to working ones?
4th in the list took about 1 week, probaly mini A (looks right, not measured)
[edit] Now 14th in the list (of 23)
two months
Thanks wdt, had a look now.

Thanks for the warning tsh, really must get round to making a bootable SD with the Pandora OS on it for tinkering purposes.
 
Last edited by a moderator:
For me it works without any manual tricks, but the device needs to be plugged twice (plug, unplg, plug) due to some driver breakage. Tested with self made adapter:

otgc0.png
 
notaz said:
For me it works without any manual tricks, but the device needs to be plugged twice (plug, unplg, plug) due to some driver breakage. Tested with self made adapter:

otgc0.png
Confirmed that it works like that as long as the ID pin (4) is connected to ground (5) as it should be in a such adapter. Also confirmed that the adapter i bought from DX doesnt have ID to GND. Did a little soldering iron trick to it and it works (you just need to plug+unplug+plug).
OT:
Also confirmed that the kernel driver is too smart and doesnt allow me to try to use a GPRS modem on the 100mA power :p ("rejected 1 configuration due to insufficient available bus power"). I'll propably add a mod to my pandora to export the raw 5V supply with some "connector" (thinking of a simple single-pin in a hole to which you attach a single-pin female pin header, which I'll mod to my adapter). Then I'll need to mod the kernel to ignore the current ratings...
 
Last edited by a moderator:
connecting, disconnecting, reconnecting, as stated by notaz and urjaman, doesn't work for me.

Instead, running the SD-mass-stage script that can be found in the 'system' menu, enables the small USB OTG: see my detailed post here.

Notaz, Urjaman, could you please look into this?
 
Last edited by a moderator:
Back
Top