UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor s4208198
Visitor
15,904 Views
Registered: ‎11-29-2011

VHDL SD card interface using PmodSD

Hi all,

 

I've been working with the PmodSD, trying to write data to an SD card. 

 

I am currently using the following code to achieve this:

http://stevenmerrifield.com/tools/sd.vhd

 

This seems to be a working interface for FPGA's and SD card's, but I have a few questions:

* Can you specify a txt file already on the SD card to write to? If not, where would the data be written to and how would one access it?

* Do you have to mount the card first?

 

Thanks in advance,

 

Yu.

0 Kudos
7 Replies
Instructor
Instructor
15,851 Views
Registered: ‎07-21-2009

File I/O to SD card

The code you reference is a low-level interface for reading and writing SD card data using SPI protocol.

Accessing files on an SD card is a higher-level function than data access, no different than accessing files on a hard disk.

 

Although you can implement state machines for file I/O, most designs perform file I/O using a processor running an operating system.  File I/O is performed through operating system calls in software.  The operating system includes the bridge between low-level hardware interface and higher-level file I/O.

 

-- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
0 Kudos
Visitor s4208198
Visitor
15,842 Views
Registered: ‎11-29-2011

Re: File I/O to SD card

Hi, 

 

Thanks for your reply.

 

I am happy to use the low-level implementation with SPI, just as long as I can read what is being stored.

 

Could you please tell me how would I then access the data that is being written in this manner? 

 

ie any formatting, setting up partitions etc.

 

Cheers,

 

Yu.

0 Kudos
Instructor
Instructor
15,839 Views
Registered: ‎07-21-2009

Re: File I/O to SD card

Could you please tell me how would I then access the data that is being written in this manner? 

ie any formatting, setting up partitions etc.

 

Suggest you search the web for "how to read and write FAT16 (or FAT32) files".  This is a topic which has no bearing on FPGA design, even though it is interesting, so these forums are not likely to be the best place to look for this information.

 

If you find some interesting and informative links, please post them in this thread.

 

-- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
0 Kudos
Advisor joelby
Advisor
15,832 Views
Registered: ‎10-05-2010

Re: File I/O to SD card

The sanest way to deal with using a filesystem would be to use a soft processor such as MicroBlaze. There's plenty of open source C code for manipulating FAT for both PCs and microcontrollers, which you could port over without much trouble.

 

If you require the highest possible speed and don't want to use a soft processor, you'd probably ditch filesystems and just log data sequentially. It's very straightforward to read the raw data out of a card using dd or whatever the Windows equivalent is.

 

Instructor
Instructor
15,827 Views
Registered: ‎07-21-2009

more: File I/O to SD card

Adding to joelby's comments...

 

If your storage requirements are modest (and you don't need removable storage media), you can use the same SPI flash memory used for configuration data.  Consider replacing the "just big enough" configuration memory in your design with something large enough to accommodate your needs (in addition to the required config data space).

 

Publicly published and distributed SD card interface controller designs rely on using the SPI protocol (actually, it's a slightly twisted version of SPI protocol).  This aspect of SD card interface protocol is not protected by licensing restrictions.  On the other hand, true "native" SD card protocol and controller design information is protected by licensing agreements which are signed as a condition of access to the SD card specifications documents.  In other words, the fastest SD card transfer methods are not available in unrestricted "free" cores.

 

This opencores forum thread might be interesting to you.

 

MMC cards (if you can still find them or remember them) are quite similar to SD cards.  The MMC (or MMC-plus) specifications have been transferred to JEDEC, and are not access-restricted.  MMC cards also support SPI protocol, when I last looked.

 

In the later revisions of the SD card specifications, exceptions were provided for the once-mandatory requirement for SPI protocol support.  For example, SPI protocol support is optional (rather than mandatory) in micro-SDHC cards.  That's about all I can say on the matter short of risking a lawsuit or sniper attack.

 

Don't overlook SATA or CompactFlash interfaces (controllers) for removable media options.  There are FPGA development boards with either CompactFlash sockets, SATA interfaces, or both.

 

-- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
0 Kudos
Highlighted
Newbie ercancosgun
Newbie
15,655 Views
Registered: ‎03-02-2012

Re: VHDL SD card interface using PmodSD

Hi,

 

I've been working SD card İnterface. But, I can't write txt format. Can you do it ?

 

tanks

Tags (1)
0 Kudos
Advisor joelby
Advisor
15,644 Views
Registered: ‎10-05-2010

Re: VHDL SD card interface using PmodSD

ercancosgun, please start a new thread and describe what you've done so far, what isn't working and why you think it's not working, where the data is coming from, and exactly what you're trying to do.

0 Kudos