Shop OBEX P1 Docs P2 Docs Learn Events
How do I emulate a USB drive with the P1? — Parallax Forums

How do I emulate a USB drive with the P1?

AwesomeCronkAwesomeCronk Posts: 1,055
edited 2020-08-02 00:22 in Propeller 1
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!

Comments

  • After further research, I have determined that I will probably have to find a device that can convert the usb signals to a signal the prop can work with. Still not an easy task.
  • After further research, I have determined that I will probably have to find a device that can convert the usb signals to a signal the prop can work with. Still not an easy task.
    You are correct.

    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.
  • @SaucySoliton thanks for chiming in! I have found that Microchip has a USB framework for their devices and I am looking into using a PIC between my Prop and the host. If data transfers are likely to occur at less than one bit per second, will the host throw a fit about that?
  • look for Vinculum FTDI USB Host

    Enjoy!

    Mike

  • @SaucySoliton thanks for chiming in! I have found that Microchip has a USB framework for their devices and I am looking into using a PIC between my Prop and the host. If data transfers are likely to occur at less than one bit per second, will the host throw a fit about that?

    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?
  • For USB memory sticks I just use a Vdrive2, or a FTDI, FT51 is good too.
  • 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 :neutral:.

    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. :grimace: 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!
  • kwinnkwinn Posts: 8,697
    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 :neutral:.........[quote

    Why would you put a USB storage device between the PC and the USB plug. To do that you would have to connect the PC, USB, and Prop to the USB D+ and D- along with some form of bus control code for the PC and Prop. That would not be easy to do. If you want to share storage the PC and and Prop can connect directly and the PC can store date on the local disk drive.
  • AwesomeCronkAwesomeCronk Posts: 1,055
    edited 2020-08-07 12:04
    The idea was to store data on a mechanical device controlled by the Prop. See the thread “Project kiloByte - maybe”. The reason behind my thinking with the title of this thread and the subsequent questions I asked was that the PC would think it has a flash drive when I plug in kiloByte.
  • kwinnkwinn Posts: 8,697
    That is a very ambitious project. I would using a Propeller board with USB on board as the controller/interface between the PC and the disk. I think a machine like that made from furniture grade lumber and good finish would be a thing of beauty but here are a lot of parts to produce so using stock items would help to speed things up. For instance the belt could be cut from wood dowels and the square blocks from 1x2 wood trim. I’m also wondering if the wood belt could be replaced with a paper tape reader/punch. That would save a lot of time and work.

    SORRY, posted this reply in your other thread.
  • AwesomeCronkAwesomeCronk Posts: 1,055
    edited 2020-08-08 03:17
    No prob :smile:
Sign In or Register to comment.