Digital Finds

joseph dot reeves at thehumanjourney dot net

USB host mode: The button

Nov 11, 2008 by Joseph Reeves

[EDIT]: Updated

USB host mode is a funny thing on the FreeRunner; it's one of the killer features of this phone, yet the means and ways of getting it working are never really as clear as they could be. The Openmoko wiki, for example, used to say that you needed new kernel modules to get host mode to work; when I asked about these modules I was told that they had been included for some time, and all you actually needed was to run a quick command or two. These I added to the wiki straight away...

The command line is a bit of a pain, however, especially if you want to enable USB host mode to use a keyboard. Keyboards are fun; and I'd previously said that we'd come up with a button to swap between modes. This is easily doable:

[EDIT]: By popular request I've packaged this all into an ipk file: Here

From the (now much improved) USB host Wiki page we get a helpful script that determines the current state of your USB mode and switches to the other:

grep -q 'host' /sys/devices/platform/s3c2410-ohci/usb_mode
if [ $? -eq 0 ]
echo "0" > /sys/devices/platform/neo1973-pm-host.0/hostmode
echo "device" > /sys/devices/platform/s3c2410-ohci/usb_mode
echo USB-Port is in device-mode now.
ifconfig usb0 down
echo "host" > /sys/devices/platform/s3c2410-ohci/usb_mode
echo "1" > /sys/devices/platform/neo1973-pm-host.0/hostmode
echo USB-Port is in host-mode now.

Create a file in an appropriate place named and containing the above. This could be your home folder, or along with the rest of your applications. Chmod +x it.

Find a suitable icon for your button; I Googled up this one, although anything up to 64x64 pixels will do. Remember that png supports transparency and that the background on the FreeRunner is, by default, black. So pick something you'll be able to see! Save the file to /usr/share/pixmaps/usb.png

Create the file /usr/share/applications/usb.desktop

[Desktop Entry]
Name=USB Mode
Comment=Switch between USB modes
Exec= /path/to/

Once that file is created and saved, you'll have a new icon menu on your main screen.


I noticed that I needed to do an lsusb after switching to USB host mode. Then things started working auto-magically. I was thinking of adding a module to Exposure that would control USB host mode, but I am still learning my way around Python and EFL.

Posted by Bryan DeLuca on November 11, 2008 at 04:44 PM GMT #

Thanks Bryan, I'll look into that. It works pretty automagically as it is, but a little more never hurt; I'll give it some testing and may release a version 0.2

Cheers, Joseph

Posted by Joseph Reeves on November 11, 2008 at 05:13 PM GMT #

I write simillar project:

Posted by Thomas Vesely on November 12, 2008 at 08:34 AM GMT #

Hey Joseph, Really good to see this, but... I'm not sure it's working for me. I installed the button, and ran the script (both from the button and from the terminal) but when I plug the keyboard in nothing happens. Even if I run the lsusb command as someone suggested below. Now, what numpty thing have I missed?


Posted by Jo on November 12, 2008 at 01:53 PM GMT #

I wrote a little pygtk app a month ago to switch USB modes (including charge mode) since I as well was tired of running scripts to do it all.

Posted by Mark D. Montgomery II on November 12, 2008 at 03:20 PM GMT #

Thomas & Mark; thanks for your comments. I've added your applications to the wiki page.

Jo; sorry, I don't have much of an idea at the moment. I'll get in touch about it, but at the moment I'm going to have to dose myself up on more coffee before I can do anything too useful...

Posted by Joseph Reeves on November 13, 2008 at 01:13 PM GMT #

Post a Comment:
Comments are closed for this entry.