You're going to need some file system layer, that can interpret the contents of the SD card properly. Such cards are typically never used as raw flash, but instead use a file system layer on top which gives you directories and files. This is of course necessary when moving the card between devices, to make it interoperable.
Once you have a file system driver, you're going to be able to basically open the file on the SD card for reading, and then sit in a loop reading blocks of some suitable size. For every block read in, you simply copy copy it to the desired address in the RAM. Of course, you can read it directly to the proper address too, skipping the copy.
In pseudo-C, it would basically just be:
FILE *in;
if((in = fopen("sd0:\\file.dat", "rb")) != NULL)
{
unsigned char *target = (unsigned char *) 0xec008000; /* totally random */
size_t got;
while((got = fread(target, 1024, 1, in)) > 0)
{
target += got;
}
fclose(in);
}
Of course, you will probably not be using stdio
, so the fopen()
, fread()
and fclose()
functions will be something different depending on your file system driver.