Mass storage, or what are good alternatives?

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Philipp Burch

Mass storage, or what are good alternatives?

Post by Philipp Burch » Tue Jan 01, 2008 11:37 pm

Hello guys,

I'm developing a device that should present itself just like a mass storage device. Unfortunately, mass storage devices require bulk endpoints which aren't allowed for low-speed implementations.
So I have two questions:
1. How are the chances for getting a low-speed mass storage device (more or less reliably) working?
2. Are there alternatives to mass storage devices which behave similar and don't need special drivers and/or software? I'm trying to make the device as easy-to-use as possible, so a special software including libUSB isn't a good alternative...

Thanks in advance,
Philipp

BTW: Should I post here in English or German (My native language)?

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Wed Jan 02, 2008 8:21 pm

You can post in English or German, but you can expect more answers to English posts since more users speak English. It's also more polite to others who don't speak German.

I have no experience how reliable a mass storage low speed device would be. The latest version of the driver can implement enough endpoints for this type of device. Most operating systems allow bulk endpoints for low speed devices (except one of the two Linux USB drivers). The main problem is AVR CPU load. Having bulk endpoints puts a very high load on the CPU.

A special software is often the best solution. This does not mean that you need to install it on Windows. HID based devices don't require .inf files, they work "out of the box".

I don't know what you want to implement, but it might be possible to implement a keyboard, mouse or other HID.

Philipp Burch

Post by Philipp Burch » Wed Jan 02, 2008 11:07 pm

christian wrote:I have no experience how reliable a mass storage low speed device would be. The latest version of the driver can implement enough endpoints for this type of device. Most operating systems allow bulk endpoints for low speed devices (except one of the two Linux USB drivers). The main problem is AVR CPU load. Having bulk endpoints puts a very high load on the CPU.

Ok, so it /should/ work on Windows. The CPU load could be a problem indeed, however, the CPU doesn't need to do anything else than read from the SD-Card and put the data to the Host (Well, almost nothing else, it has to present some files which aren't really present on the SD-Card, but that can be done when there is time I suppose...).
christian wrote:A special software is often the best solution. This does not mean that you need to install it on Windows. HID based devices don't require .inf files, they work "out of the box".

Yes, a HID-Device would be an alternative, but the (almost) only purpose of the USB-Connection is to transfer text files to (or from) the device. An MSD should be the ideal type for this I think...
christian wrote:I don't know what you want to implement, but it might be possible to implement a keyboard, mouse or other HID.

Not really. The device will be a trainer for morse code, so I need to put text on the SD-Card of the device...

I've posted on www.mikrocontroller.net too (german), if someone wants to have a look there: http://www.mikrocontroller.net/topic/87416

Thanks,
Philipp

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Wed Jan 02, 2008 11:24 pm

Regarding CPU load: The load is always above 90%, not only if data is transferred. That's because USB is a host-driven bus and the host polls the device for data when there is nothing else to transfer.

But I think that it SHOULD work. It's the task of the low level driver to enforce "no bulk endpoints on low speed devices" and Windows does not enforce this. The higher level drivers usually don't care. Since Windows has no general concepts (every driver is developed by a different group of people with different ideas), it's still possible that the MSD driver checks the bus speed.

You may want to look at our Automator project. We also need to send data to the device (or receive data from the device) in Automator. We did this as HID with a host-side application. The host-side application is based on a cross-platform framework (fltk) and can thus be ported to Windows, Mac and Unix. It's even possilbe to cross-compile for Windows and Mac on Linux.

If you succeed with mass storage, this would be a great example, though. As far as I can see on www.mikrocontroller.net, the driver does not like your descriptor(s). Did you check the event log for error messages? Maybe it's possible to enable more verbose loggings.

Philipp Burch

Post by Philipp Burch » Thu Jan 03, 2008 12:14 am

Don't ask me why, but it suddenly works... Windows rulez I suppose...

christian wrote:Regarding CPU load: The load is always above 90%, not only if data is transferred. That's because USB is a host-driven bus and the host polls the device for data when there is nothing else to transfer.

Ok, that's no problem because USB is only enabled to transfer data. In normal operation, the driver is disabled.
But I think that it SHOULD work. It's the task of the low level driver to enforce "no bulk endpoints on low speed devices" and Windows does not enforce this. The higher level drivers usually don't care. Since Windows has no general concepts (every driver is developed by a different group of people with different ideas), it's still possible that the MSD driver checks the bus speed.

Well, maybe. But either this check is somewhat buggy or it isn't really implemented, since it seems to work now, there can't be a serious problem...
You may want to look at our Automator project. We also need to send data to the device (or receive data from the device) in Automator. We did this as HID with a host-side application. The host-side application is based on a cross-platform framework (fltk) and can thus be ported to Windows, Mac and Unix. It's even possilbe to cross-compile for Windows and Mac on Linux.

Yes, I've already checked that program. That would be the alternative if I can't get the whole thing working...
If you succeed with mass storage, this would be a great example, though. As far as I can see on www.mikrocontroller.net, the driver does not like your descriptor(s). Did you check the event log for error messages? Maybe it's possible to enable more verbose loggings.

I'm implementing the USB-Bootloader for this project right now. I'll send you the whole project once it's finished.
I've not checked the event log, no. Would have been a good idea... However, what really confused me is that there weren't any logged packets at all. I've tried USB-Monitor from hhdsoftware, USBSnoop and another Sniffer, but there haven't been any messages, altough the device appeared in the device manager as "USB device" or with my specified name string (But without a driver).


Right now, I can only say thank you very much for this cool USB-Driver! I'll drop a note if there are any news (good or bad). But now, it's time to sleep...

Philipp Burch

Post by Philipp Burch » Sat Jan 05, 2008 8:50 pm

There's something else I'm not able to find in the driver documentation: How can I STALL one of the user defined endpoints (Not endpoint 0)? The specification often requires to STALL an endpoint in case an error occurs...

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Sat Jan 05, 2008 10:03 pm

For endpoints 0, 1 and 3 (this is the default endpoint number, actual numbers may be assigned differently), there are global variables

volatile uchar usbTxLen;
volatile uchar usbTxLen1;
volatile uchar usbTxLen3;

(only usbTxLen1 and usbTxLen3 are declared extern in the header, if you need to stall endpoint 0, declare usbTxLen yourself).

To stall an endpoint, set its txLen to USBPID_STALL. To remove the stall condition, set it to USBPID_NAK.

We may add an abstraction layer to this mechanism later, but this method should continue to work.

Philipp Burch

Post by Philipp Burch » Sun Jan 06, 2008 5:26 pm

Thank you!

mygift001
Posts: 2
Joined: Wed Feb 20, 2008 4:40 am

Post by mygift001 » Wed Feb 20, 2008 5:09 am

Hello Philipp Burch
How is your project going on ?
"1. How are the chances for getting a low-speed mass storage device (more or less reliably) working?"

Thanks,

Philipp Burch

Post by Philipp Burch » Sun Mar 02, 2008 12:44 pm

Well, I'm still on it. The basic functionality seems to work quite well, the device presents itself to the host as a mass storage device. But the command flow causes some trouble, vendor-specific commands are used and although I report an error, the computer still tries the same command. But I think, I'll find ways to get it working when I've time...

mygift001
Posts: 2
Joined: Wed Feb 20, 2008 4:40 am

Post by mygift001 » Wed Apr 16, 2008 11:09 am

Hello Philipp Burch,
Have you already completed it ? Does it need to install extra software on the computer ?

Thanks,

Philipp Burch

Post by Philipp Burch » Wed Apr 16, 2008 8:10 pm

No, I'm sorry. And it looks like the completion goes the longer the farther away, because my time is very limited at the moment...
Maybe I discard the whole thing, some extra software shouldn't be much of a problem and would be much more reliable...

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Thu Apr 17, 2008 9:25 am

If you give up the project, can you please post the code somewhere (e.g. in our wiki) and add a link here in the forum? Maybe others are interested.

Philipp Burch
Posts: 1
Joined: Wed Apr 16, 2008 8:12 pm
Location: Switzerland
Contact:

Post by Philipp Burch » Fri Apr 18, 2008 10:05 pm

Sure. Here you are: http://activevb.de/members/philippburch ... dr_avr.zip
But please note: The code is quite ugly and one single construction site (Just look at the warnings generated by the compiler...), I'm not even sure what "features" are supported and working in this version. My intention was to create a USB bootloader for the bigger AVRs, but mass-storage devices only support direct reads and writes to the filesystem, so I would need to emulate a FAT... Not really suitable for a bootloader.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Mon Apr 21, 2008 10:29 am

Thanks!

So the challenge is open: Can anybody come up with a device (whatever it is) based on the mass storage class?

Post Reply