kondzio9224 Posted July 9, 2017 Share Posted July 9, 2017 Hi All, I have bought ZYBO board. I create simple block design and now I am trying to write 1MB (and more) of data on sd-card. My simple bare-metal apllication code: #include <stdio.h> #include <stdlib.h> #include "platform.h" #include "xil_printf.h" #include "ff.h" #include "xsdps.h" #include "stdio.h" #include "ps7_init.h" int main() { static FATFS FS_Instance; static FIL file1; static char FileName[32] = "F1.txt"; static char *Log_File; FRESULT result; TCHAR *Path = "0:/"; unsigned int BytesWr; init_platform(); ps7_post_config(); u32 transfer_size = 1024*1024; u8 *wr_buff; wr_buff = malloc(transfer_size); xil_printf("Mount device...\n\r"); result = f_mount(&FS_Instance, Path, 1); if (result != 0) { xil_printf("Error! f_mount %d\n\r", result); return XST_FAILURE; } Log_File = (char *)FileName; xil_printf("Create file Frame.txt...\n\r"); result = f_open(&file1, Log_File, FA_CREATE_ALWAYS | FA_WRITE); if (result != 0) { xil_printf("Error! f_open %d\n\r", result); return XST_FAILURE; } xil_printf("Write some data on sd card...\n\r"); result = f_write(&file1, (const void*)wr_buff, transfer_size, &BytesWr); if (result != 0) { xil_printf("Error! f_write %d\n\r", result); return XST_FAILURE; } result = f_close(&file1); xil_printf("Close file...\n\r"); if (result != 0) { xil_printf("Error! f_close %d\n\r", result); return XST_FAILURE; } cleanup_platform(); return 0; } Terminal outputs: Mount device... Create file Frame.txt... Write some data on sd card... Error! f_write 1 So problem is in f_write function. This code works fine for 1KB data size. I dont't know what am I doing wrong. Can You help me? Link to comment Share on other sites More sharing options...
jpeyron Posted July 10, 2017 Share Posted July 10, 2017 Hi @kondzio9224, Unfortunately, I have not worked with the sd card with a simple bare-metal application. In general I would suggest to add xil_printf's in the f_write function to see where the error is. Here is a thread that might be useful. cheers, Jon Link to comment Share on other sites More sharing options...
Question
kondzio9224
Hi All,
I have bought ZYBO board. I create simple block design and now I am trying to write 1MB (and more) of data on sd-card. My simple bare-metal apllication code:
#include <stdio.h>
#include <stdlib.h>
#include "platform.h"
#include "xil_printf.h"
#include "ff.h"
#include "xsdps.h"
#include "stdio.h"
#include "ps7_init.h"
int main()
{
static FATFS FS_Instance;
static FIL file1;
static char FileName[32] = "F1.txt";
static char *Log_File;
FRESULT result;
TCHAR *Path = "0:/";
unsigned int BytesWr;
init_platform();
ps7_post_config();
u32 transfer_size = 1024*1024;
u8 *wr_buff;
wr_buff = malloc(transfer_size);
xil_printf("Mount device...\n\r");
result = f_mount(&FS_Instance, Path, 1);
if (result != 0) {
xil_printf("Error! f_mount %d\n\r", result);
return XST_FAILURE;
}
Log_File = (char *)FileName;
xil_printf("Create file Frame.txt...\n\r");
result = f_open(&file1, Log_File, FA_CREATE_ALWAYS | FA_WRITE);
if (result != 0) {
xil_printf("Error! f_open %d\n\r", result);
return XST_FAILURE;
}
xil_printf("Write some data on sd card...\n\r");
result = f_write(&file1, (const void*)wr_buff, transfer_size, &BytesWr);
if (result != 0) {
xil_printf("Error! f_write %d\n\r", result);
return XST_FAILURE;
}
result = f_close(&file1);
xil_printf("Close file...\n\r");
if (result != 0) {
xil_printf("Error! f_close %d\n\r", result);
return XST_FAILURE;
}
cleanup_platform();
return 0;
}
Terminal outputs:
Mount device...
Create file Frame.txt...
Write some data on sd card...
Error! f_write 1
So problem is in f_write function.
This code works fine for 1KB data size. I dont't know what am I doing wrong. Can You help me?
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.