Page 2 of 2

Re: SD card interface high speed mode

Posted: Wed Oct 03, 2018 2:38 am
by Milad_f1
Hi, I am working with wrover dev kit and use fwrite and fread to write and read a block of data into/from a .DAT file in the SD card. I increased the buffer size to 32kB which is the cluster size of my SD card. The write speed of 6MB and read speed of 1MB was achieved. Does anyone know how I can increase the reading speed from the SD card? Thank!
Here is a part of my code:

Code: Select all

#define FILE_SIZE 1048576 * 2	//2MB
#define BUF_SIZE 512 * 64		//32kB
uint8_t buf[BUF_SIZE];
... 
    FILE* f = fopen("/sdcard/hello.DAT", "w");
    uint32_t n = FILE_SIZE/sizeof(buf);     //= number of clusters
    for (uint32_t i = 0; i < n; i++) {
        fwrite(buf, sizeof(uint8_t), sizeof(buf), f);     
    }
    fclose(f);
    
    f = fopen("/sdcard/hello.DAT", "r");     
    for (uint32_t i = 0; i < n; i++) {
        fread (buf, sizeof(uint8_t), sizeof(buf), f);   
    }    
    fclose(f);

Re: SD card interface high speed mode

Posted: Thu Feb 07, 2019 9:25 pm
by snahmad75
I have same issue. read speed is slow.

Re: SD card interface high speed mode

Posted: Fri Feb 15, 2019 6:47 pm
by snahmad75
Can some one reply and share your experience.

Why big heap memory allocation when read files using SD card interface. Can we avoid it. Can some one point me out line of which allocate this heap. I am hoping to use stack and read file chunk by chunk.