How do I emulate a USB drive with the P1?
AwesomeCronk
Posts: 1,055
How would I even begin doing this? I have the appropriate resistors to set up a 5v to 3.3v interface (47ohm and 47kohm), from attempting a similar interface (prop to usb keyboard), so that shouldn’t be an issue.
Should I attempt to bit bang the protocol or is there an existing library for this? Following that, is there a chip I can buy that would convert the usb commands to address/read/write commands in a way that the prop will easily pick it up? Or should I not even worry about this?
Sometimes I wonder if reality is big enough for my dreams...
Edit: I am digging through the usb specs for the usb mass storage class and usb 2.0. I must say I am very much in over my head! I will likely be building a usb library, then a mass storage class library, then emulating a usb drive. What fun!
Should I attempt to bit bang the protocol or is there an existing library for this? Following that, is there a chip I can buy that would convert the usb commands to address/read/write commands in a way that the prop will easily pick it up? Or should I not even worry about this?
Sometimes I wonder if reality is big enough for my dreams...
Edit: I am digging through the usb specs for the usb mass storage class and usb 2.0. I must say I am very much in over my head! I will likely be building a usb library, then a mass storage class library, then emulating a usb drive. What fun!
Comments
P1 is at its limit running 12Mbps. USB places strict response time requirements on devices. While it is possible that it could be done on the P1, the work involved in wouldn't be worth it considering the alternative processors available. It's easier for a USB host to cheat the timing requirements.
P2 has hardware for USB in the smartpins. I don't think there is much code for USB devices right now. It would be very useful to have something like LUFA for the P2.
There are some other micros that have USB connections. Many of these have a vendor provided USB stack with mass storage support. Here's one example: http://cdemu.blogspot.com/
There are also SBCs that can act as USB device, like Pi Zero and BeagleBone.
Enjoy!
Mike
USB mass storage reads 512 bytes at a time. The timeout per block depends on the host, but I'd expect it to be on the order of seconds. Maybe you could stall for about a minute.
At this point I think we should step back and ask ourselves "Are we asking the right questions?" Elon Musk is really big on this. So what are you trying to accomplish with this USB drive emulator?
@SaucySoliton I took a few days and thought on that, and here is what I've come up with: I'm not sure I was asking the right question, "How do I emulate a USB Drive?". What I should have asked was this: "How do I interface a propeller device with a PC via USB Mass Storage?" I guess my youth shows in my question-asking skills .
I think I'm going to wait on the USB interface and I am instead going to work on fleshing out the hardware. I think I'll make a middleware piece to move files across until I can get this thing working. I estimate that it'll be a few hundred times too slow, at .125 bytes per second. One way I might be able to fix this while simultaneously expanding the storage capacity is eventually adding more belts in parallel. That'd be where 8 cogs shine! But let's not go there until it all works right!
Thank you for the insight here. I'm glad for the forums in more ways than one because I can say something here, get multiple perspectives, and then really flesh out how something might work. That goes on top of the amazing technical info that gets shared here!
SORRY, posted this reply in your other thread.