简体   繁体   English

将数据从SD卡复制到ARM上的RAM

[英]Copy data from SD card to RAM on ARM

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). 我想将一个文件从SD卡复制到我的ARM Cortex A9的内存中(以便更快地将其传输到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 =( 我有一些带有FPGA的exp,但没有mC和ARM =(

Many thanks in advance! 提前谢谢了! Djrem Djrem

You're going to need some file system layer, that can interpret the contents of the SD card properly. 您将需要一些文件系统层,可以正确解释SD卡的内容。 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. 一旦你有了一个文件系统驱动程序,你就可以基本上打开SD卡上的文件进行读取,然后坐在循环中读取一些合适大小的块。 For every block read in, you simply copy copy it to the desired address in the RAM. 对于读入的每个块,只需将其复制到RAM中所需的地址即可。 Of course, you can read it directly to the proper address too, skipping the copy. 当然,您也可以直接将其读取到正确的地址,跳过副本。

In pseudo-C, it would basically just be: 在伪C中,它基本上只是:

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. 当然,您可能不会使用stdio ,因此fopen()fread()fclose()函数将根据您的文件系统驱动程序而有所不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM