• 0

ZYBO Write data on sd card


Go to solution Solved by jpeyron,

Question

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 post
Share on other sites

1 answer to this question

Recommended Posts

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now