Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
806 Views

Configuration from SD card

Hi, 

 

Does anyone know solutions to configure FPGAs from SD card? 

It must be either of the below. I prefer the latter one, but information of any other solutions will be appreciated. 

 

(1) A Nios II in another FPGA read from SD and load the FPGAs. 

(2) A hardware logic in a CPLD read from SD and load the FPGAs. 

 

Regards
0 Kudos
7 Replies
Altera_Forum
Honored Contributor I
38 Views

The first solution is easy. You only need your Nios (or any other processor) drives a spi master which is used to access SD. This for the SD physical layer: depending on how data is stored on your SD, you may need more or less effort in designing the applicaiton (i.e. file system management) 

Clearly this solution involves a greater BOM cost, unless you already have a second processor external to the fpga and you can use it for the configuration task 

 

The second solution would be more correct. I think what you choose depends on how much effort you want to put in the design. The initialization and basic access to SD is not that complicated, especially if you don't need to support all SD device variants. But in the CPLD solution you surely can't use a file system and must load the fpga configuration image as raw data in the SD flash eprom.
Altera_Forum
Honored Contributor I
38 Views

Hi Cris72, 

 

Thank you so much for the quick answer. 

I'd like to use second if I can. May I ask if you would know any ways to write raw data into SD card? 

 

Regards
Altera_Forum
Honored Contributor I
38 Views

I have done this, but I have an external CPU to do that for me. If you use a CPLD, there are a few details (as Cris72 said) you have to take care of since you cannot implement a file system on a CPLD. However, all the file system would let you do is locate the file data. If you know where that data is located, then the rest is relatively easy. You can start by storing your file as raw data starting at address 0. To do this, use the DD command on a linux box. 

 

dd if=<config_file> of=/dev/<sdcard_device>  

 

where <sdcard_device> is something like /dev/sda, /dev/sdb, ... You cannot have a partition in this card, so don't use /dev/sda1, /dev/sdb1, ... 

 

This command will basically store your <config_file> in the card starting at address 0. 

 

Remember that if you are using SDHC cards, they are block-oriented. So address 1 means address 512, while in SD cards, address 1 means address 1. 

 

Hope this helps.
Altera_Forum
Honored Contributor I
38 Views

Hi ironmoose, 

 

I appreciate your answer. It is useful information to me. I will try to use the DD command. 

 

Regards
Altera_Forum
Honored Contributor I
38 Views

I wonder, if it would be reasonable to format the configuration data as a DOS boot record, so it could coexist with a regular file system on the SC card.

Altera_Forum
Honored Contributor I
38 Views

Hi gee, 

Probably you have already done this: a good starting point is download the SD card simplified specification from www.sdcard.org and read it.  

Here you'll easily find the basic commands to detect SD card type, initialize it and write/read data. 

I started this way and in less than two days I built my application from scratch, complete with file system (I used FatFs open source module). My task was easier, since I accessed SD card through Nios and spi port; so it was simply a matter of sending the right command sequences.  

With a CPLD it will be much more challenging. Good luck! 

 

Cris
Altera_Forum
Honored Contributor I
38 Views

Hi Cris, 

 

I'm sorry for delay in my response. It helps a lot. I appreciate it. 

 

Regards
Reply