Question

i need your help! I want to copy one file from the SD Card to the memory of my ARM Cortex A9 (to transfer it faster to the FPGA). But i dont know the start address of the file and the size. Are there any possibilities to find this information? I have some exp with FPGA, but not with mC and ARM =(

Many thanks in advance! Djrem

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top