Yocto - P1010RDB - External Sata Drive

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Yocto - P1010RDB - External Sata Drive

1,564件の閲覧回数
pslavick
Contributor I

I am having trouble figuring out how to write to a solid state drive connected to the eSATA port of the P1010RDB from an applicaion running on Yocto.

Can anyone provide useful information regarding this subject matter?  Examples would be much appreciated...

0 件の賞賛
返信
2 返答(返信)

1,389件の閲覧回数
Pavel
NXP Employee
NXP Employee


Have a great day,
Look at simple program example below for reading/writing using /dev/sda device.

//#include <fcntl.h>

//#include <unistd.h>

#include <stdio.h>

#include <string.h>

#define SIZE 1

#define NUMELEM 5

int main(int argc, char* argv[])

{

FILE* fd = NULL;

    char buff[100];

    memset(buff,0,sizeof(buff));    // write 0 to buff

    fd = fopen("/dev/sda","rw+");    // r - Open text file for reading; ‘w+’ : Open for reading and writing. The file is created if it does not exist, otherwise it is truncated.

    if(NULL == fd)

    {

        printf("\n fopen() Error!!!\n");

        return 1;

    }

    printf("\n File opened successfully through fopen()\n");

// buff - Pointer to a block of memory with a size of at least (size*count) bytes, converted to a void*.

// SIZE- size, in bytes, of each element to be read.

// NUMELM - Number of elements, each one with a size of size bytes.

// fd - Pointer to a FILE object that specifies an input stream.

    if(SIZE*NUMELEM != fread(buff,SIZE,NUMELEM,fd))    //

    {

        printf("\n fread() failed\n");

        return 1;

    }

    printf("\n Some bytes successfully read through fread()\n");

    printf("\n The bytes read are [%s]\n",buff);

    if(0 != fseek(fd,11,SEEK_CUR))

    {

        printf("\n fseek() failed\n");

        return 1;

    }

    printf("\n fseek() successful\n");

    if(SIZE*NUMELEM != fwrite(buff,SIZE,strlen(buff),fd))

    {

        printf("\n fwrite() failed\n");

        return 1;

    }

    printf("\n fwrite() successful, data written to /dev/sda \n");

    fclose(fd);

    printf("\n File stream closed through fclose()\n");

    return 0;

}

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信

1,389件の閲覧回数
Pavel
NXP Employee
NXP Employee


Have a great day,

Look at the following page (http://www.freescale.com/infocenter/index.jsp?topic=%2FQORIQSDK%2F2151449.html).

This page contains description for SATA driver configuration for Freescale SDK and example for the P2020ds board.

Use this command sequence for the P1020RDB testing.

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信