Shop OBEX P1 Docs P2 Docs Learn Events
Read SD Card over USB — Parallax Forums

Read SD Card over USB

mynet43mynet43 Posts: 644
edited 2012-09-11 11:30 in Propeller 1
I have a customer that wants me to read an SD card through a USB port.

If I use the standard Prop USB interface, and plug a USB card reader into it, will I be able to see it?

Has anyone done this before? And what format will I see the data?

I'm hoping someone has some sample code to make this happen.

I'm familiar with the standard USB Prop interface using the FT232RL.
I also know how to read an SD card from a standard socket using fsrw26.spin.
I'm trying to combine the two.

Any help or sample code will be really appreciated.

Jim

Comments

  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-02-02 20:21
    Not possible through the FTDI chip. Since the FTDI chip and USB card reader are both USB devices, and neither is a host, they can't talk.

    The only way to do this would be with an overclocked prop and the USB stack, but I don't know if that's ever been done.

    Why do you need to read it through the USB port? Why not an SD card socket?
  • Mike GreenMike Green Posts: 23,101
    edited 2012-02-02 20:28
    You could use a Parallax Memory Stick Datalogger. These provide a USB Host interface. You can plug in a USB Memory Stick or a USB SD card reader or any USB mass storage device. The interface is either asynchronous serial or SPI.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-02-02 20:55
    Yes, the Vinculum (Chip on the Memory Stick Datalogger) is an option. It is expensive, though. Looks like the MAX3421E is an option too. http://www.sparkfun.com/products/9947
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-02-02 21:25
    I'm not sure if this answers the question, but if you want to read an SD card over USB, why not an SD card reader? http://www.ebay.com.au/itm/NEW-SD-MMC-MEMORY-CARD-READER-ADAPTOR-USB-2-0-Windows-VISTA-XP-7-/170734927746?pt=AU_Digital_Memory_Card_Readers_Adaptors&hash=item27c0983f82

    $1.00 including shipping. They are available for micro and standard sized SD cards.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-02-02 21:34
    He wants to use the prop as a USB host to read from a USB card reader...
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-02-02 22:14
    I've done what Mike suggests. It was one of those tiny uSD card readers that isn't any bigger than a USB plug. I was able to access the uSD card through the Memory Stick Datalogger. I only used relatively small uSD (1GB) cards though.

    It seems strange to add additional layers between the Prop and SD card since the Prop can read SD cards fine without the reader being in between the two of them.

    As others have pointed out, using the Prop as a USB host is still experimental and will only work with a limited number of USB devices (I think).
  • cavelambcavelamb Posts: 720
    edited 2012-02-02 22:54
    Might he be thinking of something like SanDisk's new SD Flip disk?

    SanDisk has today announced a unique SD card which has a hinged portion, flip this over and the card becomes a USB 2.0 Flash Drive. This neat piece of engineering means that you can flip the card out of your camera and straight into your computer without the need for any card readers or cables. Clever. SanDisk expect to be able to produce this new card in capacities of up to 1.0 GB, they will have more detail and initial samples at the upcoming PMA 2005 show.
    sandiskusbsd.gif

    http://www.dpreview.com/news/2005/1/6/sandisksdflip
    480 x 240 - 14K
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-02-02 23:04
    mynet: My guess is that you want to be able to read files on the SD card without removing the card, and that using the standard FT232RL chip is fine.

    If so, then as far as I am aware, you will require a special app on the pc to achieve this.

    Currently I am working on (but stalled the last week due to other work) on file transfers between VB6 and (to/from) the SD card on the prop. I am using the basics Michael Park did in Sphinx, using a simple checksum. I am also using this prop program to transfer files between the FAT16/32 system on the SD card and the CPM2.2 system we have within contiguous files on the SD card as well.

    Michael Park gave a C example of just the transfer code, not the serial code. This may also help you.

    Overclocking is not required if you are using the FT232 chip.
  • mynet43mynet43 Posts: 644
    edited 2012-02-03 07:00
    Wow! So many answers. I'm overwhelmed :)

    It looks like either Mike's suggestion for the Parallax Memory Stick Datalogger, or the Vinculum chip are possibilities.

    I'm designing a new board, so I can use any chips or software I need.

    I don't have experience with either of these devices. Any suggestions as to which would be easiest and most cost effective?

    As far as SD capacity, the only use for this SD card will be to contain a 32KB update of the Propeller firmware.
    This is used to update the firmware by customers in the field.

    Thank you for your help and support.

    Jim
  • RaymanRayman Posts: 14,826
    edited 2012-02-03 13:09
    I've got some YModem code posted somewhere that will let you transfer files from your SD card over the USB serial connection to a PC running a terminal program...
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-02-03 13:22
    The Vinculum chip is probably the way to go then, but why? Why not a regular SD card socket?

    The Vinculum chip is $5, a USB port is $0.85, an extra 5V regulator is probably $0.50.

    An SD card socket (needs no other supporting hardware) is $3.

    Also, a USB socket probably makes people expect more.
  • mynet43mynet43 Posts: 644
    edited 2012-02-03 14:07
    @ Rayman. Not exactly clear what you said :) It sounds like you have a program that will read from an SD socket on the Prop board and transfer the data to a PC. This isn't what I need. No PC involved. I need a program that let's you attach an SD reader to a USB cable and read the SD card into the Prop.

    @Circuitsoft. The only reason I'm considering this is that it has to fit into an existing product that doesn't have room for an external SD card slot. Right now, I have an internal SD socket on the board, but the customer has to remove the cover to get to it. This doesn't work out too well. This is hooked up to an electron microscope, so it's use will be well defined. I'll take a look at the Vinculum and also Mike's suggestion. Do you have a link to some Vinculum code?

    Thank you all for the great help.

    Jim
  • Mike GreenMike Green Posts: 23,101
    edited 2012-02-03 14:32
    There should be code in the Propeller Object Exchange for working with the Parallax Memory Stick Datalogger which is just a Vinculum chip with some support components. It uses serial I/O for the communications between the two. I strongly suggest designing in a 64K EEPROM into your device rather than the minimum 32K EEPROM. If your program is small enough to leave room for additional code to handle the Vinculum and reading and writing EEPROM, then you'd check for the presence of a USB memory when your program initializes and copy the new firmware to the 2nd 32K, then verify it against the SD card file. If it's ok, then your program copies 32K from the 2nd 32K to the 1st 32K, then reboots. If, for some reason, you can only have a 32K EEPROM, then you'd skip the verify stage and copy the file directly to the 32K EEPROM and reboot.

    If your program is too large to include this update code, then you'd have to have a 64K EEPROM. The first 32K would hold a permanent bootloader / updater that would always read updates into the 2nd 32K of the EEPROM. If no USB memory is present, it would load and execute the code in the 2nd 32K of EEPROM. There's a suitable loader that you can copy in several programs including FemtoBasic (from the Object Exchange).
  • pedwardpedward Posts: 1,642
    edited 2012-02-03 14:34
    This is one of those situations where you are stepping over dollars to pick up pennies. You already know how to talk to an SD card, the problem you should be working out is how to put an SD card socket in the same place you were planning to install a USB socket.

    The flip side is to write a program that runs on a PC to download firmware to the Prop, using the existing USB serial interface. This involves extending the USB from the Prop to the case and writing a program for the PC.

    I think if you step back and consider everything, you will see that the most elegant and reasonable solution is a panel mounted SD card board and a cable to connect it back to the Prop board. Parallax sells a breakout board with mounting holes and a header to connect wires to, that should be a drop-in solution.
  • mynet43mynet43 Posts: 644
    edited 2012-02-03 15:34
    @ Mike. Thanks so much. This is exactly what I was looking for. I really appreciate it!

    @pedward. Thanks for the feedback. I'm well aware of the things you mentioned. We already need the USB connector, and the enclosure case we're using is for a 7" touch screen console that's quite expensive. No room to add more connectors. Right now it's more cost effective to do it this way. I definitely don't want to connect it to a PC. I know how to do this, but it wouldn't work for my customers. I need it completely self-contained. Thanks for the suggestions. Options and critiques are always welcome.

    Jim
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-02-03 17:16
    Couldn't you put a MicroSD slot behind a USB opening in the case?
  • mynet43mynet43 Posts: 644
    edited 2012-02-03 17:38
    @Circuitsoft: Physically no room in the existing case for this. Besides, my customer refuses to use a uSD card. He wants full size :)

    @Mike: I always use a 64K EEPROM. I already update the firmware with no problem. So there's hope. Thanks again.
  • blackprgerblackprger Posts: 2
    edited 2012-09-10 21:34
    Hello, i don't know where to post my question but hopefully this thread is the right place.
    I would like to know if you can read the content of an SD card with an FTDI chip FT2232H, I see that it is possible by using spi mode but then i'm totaly lost and dunno where to start
    Could someone help me out ? I already have a FT2232 spi board with CLK, DO, DI, CS, 3,3v VCC and GND. I got how to wire it up to my card using the cpi outputs.
    sd-card-pinout.png
    But then I don't find any program that can read the content of the sd card, i'm not intrested in reading the files in the sd card, i would like to read the raw data in the card like this
    Sanstitre-1.png
    If anyone could give me a hand, thanks a lot
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-09-11 10:23
    Are you trying to read the SD card on Windows? You can get raw disk access, even through a USB Storage controller, and that will give you what (I think) you're looking for. If you really want to use the MPSSE in SPI mode to connect to the SD card, then you're going to need to initialize the SD card and deal with the access protocol which is far more complex than it probably should be.
  • blackprgerblackprger Posts: 2
    edited 2012-09-11 11:30
    I'm trying to use my current FT2232H SPI board. Both can communicate together but just don't know how to do this
Sign In or Register to comment.