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);