PDA

View Full Version : 770 USB Host Mode - Knowledge base


Hedgecore
2006-01-10, 17:17
As a precursor to a Wiki entry, how exactly does USB host mode work on the 770? I'm aware that it has to be enabled via a command line argument under the linux/osx flasher, but then what?

If (assuming I had all the power requirements sorted out) I plugged my 40GB MP3 player into it, which is detected as an external drive by XP/Linux, would the 770 inherently know what to do with it?

Connectivity and power requirements are fine, but what about software/OS requirements.

thoughtfix
2006-01-10, 18:48
I am WAY too lazy to write all this out again so...
http://thoughtfix.blogspot.com/2006/01/no-solder-usb-host-method.html

Hedgecore
2006-01-10, 19:38
Ok, so a KB works. Howabout storage devices? ;)

Simon
2006-01-10, 19:43
There was a post the other day about enabling and disabling host mode via a terminal if you have root access. I tried the command but didn't have anything on me at the time to see if it really was in host mode.

I can't cut and paste the URL (bloody Firefox!) but if you search for:

echo host >

And look for the post from AaronL you'll find it. Has anyone actually tried this method yet and had it working?

Hedgecore
2006-01-10, 20:20
Well that's just it, aside from Thoughtfix's blog posting, nothing has been incredibly clear as to that the 770 actually does. Ok, so it's in hostmode. Thoughtfix has said it will automatically detect a USB keyboard properly, no tweaking required... I've read nothing difinitive about mass storage, etc. If I plugged a USB mouse in, the 770 wouldn't have a clue what it was. (I would imagine).

Simon
2006-01-10, 20:24
Until my keyboard arrives I don't have anything to plug into it to test it out! And like you say there isn't really much we can plug into it. I can try my usb memory card thing I guess. I'll build up my powered usb box tonight and try it.

ReinhardE
2006-01-10, 21:46
Well that's just it, aside from Thoughtfix's blog posting, nothing has been incredibly clear as to that the 770 actually does. Ok, so it's in hostmode. Thoughtfix has said it will automatically detect a USB keyboard properly, no tweaking required... I've read nothing difinitive about mass storage, etc. If I plugged a USB mouse in, the 770 wouldn't have a clue what it was. (I would imagine).
My Archos Jukebox wasn't, whereas my DigiMate II-plus was recognized as /dev/sda. So /dev/sda1 could be mounted just like with any other linux.

bigboote
2006-01-10, 21:53
Actually, there are several threads that discuss USB storage, etc. Unfortunately they are all over the place so you have to dig around to find them. Time to consolidate?

As for mass storage: in my experience the 770 detects FAT formatted drives like USB thumb drives, and you can (manually via xterm) mount them. Also, it seems that you have to boot the 770 with the device attached because it doesn't do hotplugging.

I have tried a USB mouse and it doesn't work. Might be possible if someone were to compile an arm version of the usbmouse drivers.

I have tried a USB sound device, and that doesn't work either. I tried installing the GStreamer drivers according to the Maemo wiki and somehow bricked my 770, forcing a reflash. Haven't tried USB audio since, although this is an important feature for me.

bhima
2006-01-10, 22:07
All USB devices need power from somewhere to work. The 770 will _not_ supply power to the USB port. It's a hardware limitation.

In my experience, every USB device with its own power supply _also_ required power over the USB cable! I think that they use that to detect whether you've plugged them in or not.

In addition, it seems that the 770's USB chipset requires USB power to work as well!

In other words, for the 770 to be either a device _or_ a host, it _must_ get USB power over the cable. Even in host mode, it still needs 5v power.

Virtually every USB device needs power from the USB cable.

I made a magic USB cable that added a power jack in the middle. Hook up 5v to it, and both ends have power. You MUST NOT plug this cable in to anything but a 770! If you plug it into your laptop or desktop's USB port, bad things may happen.

Once you enable USB host mode, and have this magic cable, everything seems to work.

mount /dev/sda /mnt

worked to mount my flash reader.

I did notice that, when it detected USB power, my 770 automatically unmounted the RS-MMC card - even when I was in host mode. This is something that will need to be fixed to make host mode convenient.

AaronL
2006-01-10, 22:11
To learn about what USB peripherals have been shown to work almost out-of-the-box with the 770, go to http://www.internettablettalk.com/forums/showthread.php?t=751.

And, go to http://www.internettablettalk.com/forums/showthread.php?p=6622#post6622 to see my post regarding enabling USB host mode dynamically if you already have root. I haven't tested this, so I don't know if it works yet. Please note that it is relatively easy to get root now using Kreature's patch. Also, if the technique I discuss in this post doesn't work, then consider modifying /mnt/initfs/linuxrc appropriately to force USB host mode (again, as root). Again, not sure if this will work. It's hard to test this without having a working hub, etc.

Also, I said something in my post to the "Shame" thread about dyntick being disabled, according to some information from the maemo wiki. Upon further investigation, I'm not sure if this is the case.

Aaron

Simon
2006-01-10, 22:12
I did notice that, when it detected USB power, my 770 automatically unmounted the RS-MMC card - even when I was in host mode. This is something that will need to be fixed to make host mode convenient.
Doesn't it do that in normal mode anyway? When you plug in the usb cable to the PC you can't access the MMC card from apps on the 770.

Hedgecore
2006-01-10, 22:23
Time to start the Wiki entry? ;)

bhima
2006-01-11, 00:28
Doesn't it do that in normal mode anyway? When you plug in the usb cable to the PC you can't access the MMC card from apps on the 770.

That's correct - but when you're accessing the rs-mmc card over usb using your desktop, it's both useful and necessary to unmount it. In host mode, there's no reason to unmount, so I want to stop that behaviour.

bigboote
2006-01-11, 07:01
I spent a little time playing with the "software" based host vs peripheral mode toggles, which, BTW are:

command to put it into host mode:
echo host > /sys/devices/platform/tahvo-usb/otg_mode

command to put it into peripheral mode:
echo peripheral > /sys/devices/platform/tahvo-usb/otg_mode


First, you need to log in as root to execute these commands.

Next, there are some quirks:

If in flashed host mode (ie "./flasher --enable-usb-host-mode"), this method doesn't work. You can change the otg_mode file to "peripheral", but it's still host, and every time you reboot, otg_mode is changed back to 'host". Also, in flashed USB host mode, the mmc does not unmount if you plug the USB cable into a PC.

If in flashed peripheral mode (ie the vanilla state), the software toggle works as reported, but when otg_mode contents are changed to 'host", the mmc will unmount if USB cable is attached to a PC (but not a peripheral).

Personally, I can live with the flashed peripheral mode quirks. It's really nice to be able to switch modes in software.

John

Simon
2006-01-11, 10:42
Joh Bigboote, great name by the way! Wonderful film. You try to explain it to people and they think you're mad :)

I built my little USB host box tonight. Way over engineered and complicated but fun to make. I'll put some pics up on my site soon. I don't have my USB keyboard yet to test it (and I need to charge the batteries). Can someone please explain the mounting a USB device that Bhima mentioned earlier. I am a Linux newbie so I only have a vague understanding of how that works and how I use it. I basically got as far as enabling host mode via x terminal with root access. When I plugged in my little box it would detect the USB cable was connected but then I didn't try anything with it since the batteries were uncharged. I do have a USB thumb drive and a USB card reader. How can I use them to test if everything is working?

Thanks!

Simon

Simon
2006-01-11, 12:03
OK. I put some pics of my little powered USB box up at http://www.asciimation.co.nz/770

The page is really crappy but hey, it's 1 am here and I should be asleep!

I haven't tested it fully yet since I am am waiting for the batteries to be fully charged first.

I can't really provide full instructions since 1, I made it up as I went along and 2, it doesn't need to be this complicated. I just like an excuse to waste time making gadgets!

Mike Cane
2006-01-11, 14:10
Simon:

Congratulations! Yours is now the itT post that makes me the most jealous!!

D/L your EE skillzz into my head so I can make one of those too!

Bloody excellent work there!

bigboote
2006-01-11, 18:07
John Bigboote, great name by the way! Wonderful film. You try to explain it to people and they think you're mad :)

It's BigbooTE, TE! Monkeyboy!

I agree with Mike, that's some seriously pro looking EE hacking there. Kudos.


For mounting a USB thumbdrive (or card reader), see:
http://www.internettablettalk.com/forums/showthread.php?p=4299&highlight=mount#post4298

A while back, I posted instructions for how to modify a mini-hub to send power back to the 770. For a portable rig, this would require a regulated power supply.
http://www.internettablettalk.com/forums/showthread.php?p=4113&highlight=vakoss#post4113

John

Simon
2006-01-11, 18:44
Ah thanks. I must have missed those links. We need to be more organised. It's easy to lose stuff in the forums.

I think I overcompensated on my EE gadget building to make up for my complete lack of Linux skills! Batteries should be charged now. It didn't burn my house down overnight (or even get warm) so tonight after work I will try mounting my USB drive or card reader and see how that works.

thoughtfix
2006-01-11, 20:16
OK. I put some pics of my little powered USB box up at http://www.asciimation.co.nz/770

Damn. You win the internet. I lose.
;)

Mike Cane
2006-01-11, 21:20
Hey thoughtfix! Need your reply --

http://www.internettablettalk.com/forums/showpost.php?p=6840&postcount=208

Simon
2006-01-11, 22:00
Damn. You win the internet. I lose.
;) Except I don't actually know if mine works yet! It might be a nice looking paperweight :) My little USB keyboard is in the country now according to the tracking number. Hopefully have it tomorrow sometime.

JMills
2006-01-11, 22:28
So... has anyone tried just following the USB 2.0 / USB On-The-Go 1.0 specs and connecting a self-powered USB 2.0 hub (f'rex CyberPower Systems CP-H420MP) to the Nokia 770 with an OTG host-mode cable (f'rex SerialIO.com C-OTG-6I)?

The cable supplied with the Nokia 770 is an OTG peripheral-mode cable, from what I can tell.


Per USB OTG 1.0 spec, the Nokia 770 should happily supply up to 8mA @ 5VDC nominal on VBus+ as long as the appropriate ID pin is shunted in the USB OTG 1.0 Mini-AB connector. The messages logged in `dmesg` support this hypothesis.


Although I've used the "forced" method described earlier in this thread -- plumbing the downstream VBus+ and GND lines on a self-powered USB hub (IOGear GUH-274 and some external wiring) to the upstream side by hand -- and it works (FWIW, the -data- lines should not be plumbed from downstream-to-upstream), doing it via USB OTG 1.0 just strikes me as the more elegant solution, ne?

thoughtfix
2006-01-11, 22:31
Simon: You can always build a second one and ship it to me and I'll test it with my multimeter, keyboard, and iPod nano. ;)

Simon
2006-01-11, 22:43
JMills I must admit I had no idea what you were talking about but I found this link:
http://pd.pennnet.com/Articles/Article_Display.cfm?Section=Articles&Subsection=Display&ARTICLE_ID=218924
that explains it I think.

Is there a way of telling which mode you're actually in via XTerminal? I vaguely understand the echo host, echo peripherial commands you use to set the mode. Can I query what it is though?

If I understand what you're saying correctly with the right USB powered hub and the right cable the 770 should automatically detect and switch itself into the right mode if it supports USB OTG?

Daniel, I'll try testing it out tonight when I am home with a USB pen drive I have. There is that fiddling I have to figure out about mounting the drive and so on. The keyboard should be a lot easier to test when it arrives.

JMills
2006-01-11, 22:53
JMills I must admit I had no idea what you were talking about but I found this link:
http://pd.pennnet.com/Articles/Article_Display.cfm?Section=Articles&Subsection=Display&ARTICLE_ID=218924
that explains it I think.

The article meanders a bit, but yeah, that's what I was referring to. Canonical URL for On-the-Go 1.0 is:

http://www.usb.org/developers/onthego


Is there a way of telling which mode you're actually in via XTerminal? I vaguely understand the echo host, echo peripherial commands you use to set the mode. Can I query what it is though?

The state data is reported in the kernel log ring-buffer (what `dmesg` sources from) so you could theoretically parse the output from `dmesg`.

I don't have the right connector on-hand yet to determine whether the SysFS node used to manually force OTG host-mode will dynamically flip from 'peripheral' to 'host' if using cable-sense.


If I understand what you're saying correctly with the right USB powered hub and the right cable the 770 should automatically detect and switch itself into the right mode if it supports USB OTG?

Precisely.

Mike Cane
2006-01-11, 23:03
How much testing would something like that entail? From what I've seen of hub packaging, there doesn't seem to be any way to determine which would be a "magic" hub. At least one person here has a hub that is supplying power to his 770 w/o any magic cable! Aside from all of us buying the same hub -- which might not even be possible -- what's the way to tell which works?

JMills
2006-01-11, 23:13
How much testing would something like that entail? From what I've seen of hub packaging, there doesn't seem to be any way to determine which would be a "magic" hub.

At least one person here has a hub that is supplying power to his 770 w/o any magic cable!

Yep, and they're doing it by shunting power with a 'Y' cable from the downstream side (USB type A sockets) to the upstream side (USB type A plug or cable-tail).

Aside from all of us buying the same hub -- which might not even be possible -- what's the way to tell which works?

That depends on how you intend to use it. :-)

Any self-powered (i.e., internal batteries or an external power-supply) USB 2.0 hub should work fine using the shunt method, since you're going to manually switch the USB port on the 770 side to host-mode.

I'm mostly wary of this existing method from an electrical perspective... I'd rather not feed power -into- the 770 if I don't have to.

Mike Cane
2006-01-11, 23:19
Yes, of course you're right about that. But there was someone who surprised thoughtfix without apparently needing such a cable -- that's what I meant. Post is in his Comments here:

http://www.blogger.com/comment.g?blogID=20105749&postID=113667386104837654

JMills
2006-01-12, 00:10
Yes, of course you're right about that. But there was someone who surprised thoughtfix without apparently needing such a cable -- that's what I meant. Post is in his Comments here:

http://www.blogger.com/comment.g?blogID=20105749&postID=113667386104837654


Someone wrote...

"So it obviously depends on the hub. Mine seems to feed current. So there is no poblem. It's a cheap 4-port mini hub:"

The URL they posted requires the user's cookie to work. Iasked for the store part # instead.

*****

I'm a bit surprised that either of these (USB Type-A socket to Type-A socket "gender changer" and the hub) work... it suggests that certain USB _peripherals_ (hubs, etc...) are providing power on the upstream side, which IIRC is a violation of the USB spec.

JMills

dreaming
2006-01-12, 02:53
OK. I put some pics of my little powered USB box up at http://www.asciimation.co.nz/770

The page is really crappy but hey, it's 1 am here and I should be asleep!

I haven't tested it fully yet since I am am waiting for the batteries to be fully charged first.

I can't really provide full instructions since 1, I made it up as I went along and 2, it doesn't need to be this complicated. I just like an excuse to waste time making gadgets!

Awsome! Nokia owes you some cash.

Mike Cane
2006-01-12, 04:53
I'm a bit surprised that either of these (USB Type-A socket to Type-A socket "gender changer" and the hub) work... it suggests that certain USB _peripherals_ (hubs, etc...) are providing power on the upstream side, which IIRC is a violation of the USB spec.

This is also why the entire affair is so confusing to non-EEs like me.

I appreciate all the efforts people have made to get things to work with the 770's port. Heroes all.

Simon
2006-01-12, 06:08
Excellent! It's not a paperweight! Using instruction in the forum I just tried mounting my USB pen drive and that worked! It seems to appear as /dev/sda. I was able to link it to /home/user/MyDocs then fire up FileManager and there was the pen drive in the view. I was able to play a random MP3 and some film clips I had sitting on the pen drive even. Can't wait until my keyboard arrives to try. Thanks to everyone for all their tips and hints to get this to work!

One thing I noticed (and I don't recommend doing this!) is I switched off my little box halfway through playing a MP3. It reverted back to being able to read the MMC card which is good and I was then able to switch it back on and the pen drive appeared again automatically. But then when I played that MP3 it stoped halfway! At the same point as when I unplugged it in fact. I also tried unplugging the pen drive then plugged it back in and it said there were no files on it. I turned off the 770 and then restarted it with everything connected and remounted and relinked the drive and it all works again so no permanent damage done.

Like with any computer I don't recommend plugging or unplugging things whilst they are being accessed! The little LED on the pen drive seems to flash the whole time it is connected to the 770.

I will set up some scripts I can run in Xterminal to make all this stuff easier to do. I already have those set up to tun on and off host mode. What I would really love to do is write apps that run from the desktop to do all that. Is that possible? Better start learning how Maemo works I guess.

Simon

meshsmooth
2006-01-12, 12:46
my curent isues are with not being able to mount the drives as user, not because i cant gainroot but the interface operates as user, so if you want save files using the gui you need write acess as a user. the ohter isue is it mounts as dos file system meaning only 8 character names. any ideas on fixing this?

CrossBow
2006-01-12, 14:01
As one of the "inventors" who has made a back-feeding battery powered USB Hub, I would like to report a discovery, and a small note of caution.

Appearently, Low batteries in these devices cause crashes. When I first built mine, I used whatever "AA" batteries I found lying around. It seemed to work fine with several keyboards and several flash drives, but a Dell Multi-media keyboard would crash the 770.

A few days later, I started getting crashes using the Apple keyboard that I had been using for days.

Suspecting the batteries, I changed them with a fresh set. Now even the Dell Keyboard works fine.

Doing some testing, I found that the Dell keyboard reports itself as wanting 100ma (hub) + 50ma (keyboard) = 150ma from the USB bus. The Apple reports 50ma (hub) + 50ma (keyboard) = 100ma total. The Dell keyboard has a bunch of LED's that are lit anytime it is plugged in.

BTW, the LED on my batterypack/hub combination was bright at all times.

So all you USB power hackers may want to save your work often as the batteries get low.

Mike Cane
2006-01-12, 14:06
I will set up some scripts I can run in Xterminal to make all this stuff easier to do. I already have those set up to tun on and off host mode.

Clarify this. Do you mean you can now switch between host/client at will, without reflashing every time?!

bhima
2006-01-12, 15:44
Appearently, Low batteries in these devices cause crashes.

Did you build in any regulation or not? I'm planning to build a battery powered one to complement my current externally powered unit, and would obviously like to avoid the crashing problem. I'm hoping that a regulator which simply cuts out totally rather than slowly drops the voltage will help fix that.

Another issue to be aware of is that you are violating the USB spec if you provide live data to a device without providing power first - USB cables are designed to ensure you get power first. I don't know if this will cause damage, but some semiconductors are unhappy if you do that.

Simon
2006-01-12, 17:06
Did you build in any regulation or not? I'm planning to build a battery powered one to complement my current externally powered unit, and would obviously like to avoid the crashing problem. I'm hoping that a regulator which simply cuts out totally rather than slowly drops the voltage will help fix that.

Another issue to be aware of is that you are violating the USB spec if you provide live data to a device without providing power first - USB cables are designed to ensure you get power first. I don't know if this will cause damage, but some semiconductors are unhappy if you do that.
Given what you say I might remove the power switch from mine. It is unessary anyway. If I can I might put in a low current LED that switches off when my battery voltage drops too low. Maybe using a zener somehow? Tricky with NiMH since when considered flat they are still giving out about 1.1 volts I think? I tbelieve most regulators like 7805s and so on just stop regulating when the input voltage drops too low rather than switch off. They need so many volts above the regulated output to keep regulating. When the input voltage drops below their cut off point you just get out what goes in. I used a low drop out type (2940 from memory) which regulates down to .5 a volt above rated. So my 5 cell NiMH battery will give say 6 volts fully charged (actually more) and 5.5 volts flat which is where the regulator stops regulating anyway. I need my LED to turn off then so I know to recharge it.

Be aware I an not an EE! I am just a tinkerer :) Things I say or do probably make real EEs cringe! I am actually a low drop out EE. I did the first year of the EE degree then changed to computer science. Much less maths!

Mike, there are instructions on how to enable and disable host mode from within a terminal with a Linux command but you need to have root access to do so. I am a little rushed now or I would post the links for you but if you search the forum for the text 'echo host >' you should find the relevent posts.

Simon
2006-01-12, 17:34
Oh, can't take the switch out to put in an LED because I would still need a switch since otherwise the LED will be the thing draining the battery!

Mike, that enabling host mode on the fly was posted by Aaron here: http://www.internettablettalk.com/f...p=6622#post6622

bhima
2006-01-12, 19:57
If I can I might put in a low current LED that switches off when my battery voltage drops too low. Maybe using a zener somehow? Tricky with NiMH since when considered flat they are still giving out about 1.1 volts I think?


I don't remember the exact numbers, but that's about right. The voltage of a battery is constantly lowering as you draw power from it.

When it's "dead" is not really an absolute, precise number. However, if you lower the voltage beyond a certain point, you will damage the battery...

I think your circuit ideas may be reasonable, but I'm not sure what is normally done. I'm planning to use a fancier DC/DC switched mode converter.


I did the first year of the EE degree then changed to computer science. Much less maths!


When I started at Carnegie Mellon, the degree they offered was "Math/Computer Science." From what I've seen, CS at Carnegie Mellon actually involves more math than EE. It's a lot more symbolic, with a lot more discrete math and combinatorics. You see less numbers, but more math. :)

Simon
2006-01-12, 22:09
Ah, the numbers weren't the problem it was the proofs I didn't like. Given a formula and data I do fine.

I got my USB stowaway keyboard and hooked it up quickly and enabled host mode and it detected it and it almost works. I have the problem where any key I press just keeps auto repeating though. It's not the keyboard itself as it works fine in XP.

At work so I can't play with it now unfortunately.

Simon
2006-01-12, 22:49
OK, I am being bad and was trying it again when no one was looking. Definietely repeats each key press forever.

Now this is Linux right which is supposed to be infinitely configurable. Is there some command to turn off keyboard repeating? Anyone else got any suggestions.

meshsmooth
2006-01-12, 23:32
after having isues with my low tek battery pack i have decided to not use it. what i am using is a usb plug with the power extracted to supply my 5.1V, the power adapter for the powered hub, the last power suply i may go for is my old nokia car charger that puts out 5V.
Somebody may find or make a compact regulated 5V battery and i will be fuly mobile but untill then.....

JMills
2006-01-13, 08:55
When I started at Carnegie Mellon, the degree they offered was "Math/Computer Science." From what I've seen, CS at Carnegie Mellon actually involves more math than EE. It's a lot more symbolic, with a lot more discrete math and combinatorics. You see less numbers, but more math. :)

The degree at CMU you'd be after would be the ECE (Electrical Computer Engineering) program, which was/is a hybrid between CS and EE.