This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SD Card examples in C55XCSL_LOWPOWER_2.10.00.00

Other Parts Discussed in Thread: TMS320C5515, TMS320C6416

We made an expansion card for the VC5505 USB Stick with a sd Card interface. Using CCS 4.1.2.0027 we tried the SD card examples in the library. The programs csl_mmcsd_intr_example, csl_mmcsd_SDCardExample (polled) and csl_mmcsd_dma_example are build without problems but do not work. The intr and the dma example have an error when executing the function MMC_setBlockLength, status = 0xfff6. The polled example has an error when executing SD_setBusWidth, also with status 0xfff6.Has anyone successful tried the sd card examples for a VC5505 USB Stick?

The example with the file system was not possible to build because a ATA driver library is missing and there is no project to create the library. Is there elsewhere a project for the library?

Thanks in advance

  • Hi,

     

    Have you tried with the latest CSL version 2.10 found at http://software-dl.ti.com/dsps/dsps_public_sw/dsps_swops_houston/C55X/CSL-c55x-lowpower-versions.htm ?

    Which MMC/SD port are you using? For C5515 EVM uses MMCSD0 and C5515 eZdsp uses MMCSD1. So you should set correct MMCSD  port. It has been done with compile option in CLS.

    Please refer the release note attached. 

    For ccs3.3, example directory included ATAFA project and ccs4 example should include C5515_CSL_REL_2.10_2010826\c55xx_csl\ccs_v4.0_examples\drv\atafs\atafs_bios_drv_lib project.

     

    Regards,

    Hyun

  • Hi,

    I 'm using the 2.10 lib with the Spectrum Digital C5515EVM. Writng to  SD Card works, but if I change the endian mode, the writen data is not affected. If I see at the debugger, I see the handle is changed though.

    How to do this?

     

    Regards,

    Micky

  • Hi,

    I installed C55XCSL_LOWPOWER_2.10.00.00 and run successfully the project CSL_MMCSD_SdCardExample_Out. but this code only write a file from buffer on a SD card.

    Now, I want to create a  code to read from my file in my PC to DSP memory. I've try to use some instruction like: malloc, calloc, ... but unsuccessfully.  Please help me!!

    Please show me how can I use these instructions?

    Thank you so much.

  • Hi,

      

     

    You can use fopen(), fread() functions.

    Example:

    /* fread example: read a complete file */
    #include <stdio.h>
    #include <stdlib.h>
    
    int main () {
      FILE * pFile;
      long lSize;
      char * buffer;
      size_t result;
    
      pFile = fopen ( "myfile.bin" , "rb" );
      if (pFile==NULL) {fputs ("File error",stderr); exit (1);}
    
      // obtain file size:
      fseek (pFile , 0 , SEEK_END);
      lSize = ftell (pFile);
      rewind (pFile);
    
      // allocate memory to contain the whole file:
      buffer = (char*) malloc (sizeof(char)*lSize);
      if (buffer == NULL) {fputs ("Memory error",stderr); exit (2);}
    
      // copy the file into the buffer:
      result = fread (buffer,1,lSize,pFile);
      if (result != lSize) {fputs ("Reading error",stderr); exit (3);}
    
      /* the whole file is now loaded in the memory buffer. */
    
      // terminate
      fclose (pFile);
      free (buffer);
      return 0;
    }

    Regards,

    Hyun

     

  • Thanks Hyun.

    But I have to copy the file "myfile.bin" to the folder contained the project or simply use "Add File to Project" in CCS4?

  • Hi,

    The file can exist anywhere in you PC and you can include directory as in your file name.

    For a simple test, you can put a file in your debug directory or project directory.

    Regards,

    Hyun

  • Got it. Thank you so much

  • pFile = fopen ( "Lenna.raw" , "rb" );
      if (pFile==NULL) {fputs ("File error",stderr); exit (1);}
     
      fseek (pFile , 0 , SEEK_END);
      lSize = ftell (pFile);
      rewind (pFile);
     // allocate memory to contain the whole file:
      buffer = (char*) malloc (sizeof(char)*lSize);
      if (buffer == NULL) {fputs ("Memory error",stderr); exit (2); }

      // copy the file into the buffer:
      result = fread (buffer,1,lSize,pFile);
      if (result != lSize) {fputs ("Reading error",stderr); exit (3);}

    My file is Lenna.raw, I saved it into folder contained project or in a folder that I include it into project by CCS4. But, both of these cases, It does not run.

    It returns:

    MMCSD-ATAFS TESTS!

    MMCSD-ATAFS POLL MODE TEST!

    CONFIG CARDSD Card detected
    SD card is Standard Capacity Card
    Memory Access will use Byte Addressing
    SD card initialization Successful
    CONFIG FILE
    ATA File System Initialization successful

    File Creation on SD card is Successful
    File error

     

    Help me, what can I do with my file so that my program can read file Lenna.raw to buffer?

     

  • pFile = fopen ( "Lenna.raw" , "rb" );
      if (pFile==NULL) {fputs ("File error",stderr); exit (1);}
     
      fseek (pFile , 0 , SEEK_END);
      lSize = ftell (pFile);
      rewind (pFile);
     // allocate memory to contain the whole file:
      buffer = (char*) malloc (sizeof(char)*lSize);
      if (buffer == NULL) {fputs ("Memory error",stderr); exit (2); }

      // copy the file into the buffer:
      result = fread (buffer,1,lSize,pFile);
      if (result != lSize) {fputs ("Reading error",stderr); exit (3);}

    My file is Lenna.raw, I saved it into folder contained project or in a folder that I include it into project by CCS4. But, both of these cases, It does not run.

    It returns:

    MMCSD-ATAFS TESTS!

    MMCSD-ATAFS POLL MODE TEST!

    CONFIG CARDSD Card detected
    SD card is Standard Capacity Card
    Memory Access will use Byte Addressing
    SD card initialization Successful
    CONFIG FILE
    ATA File System Initialization successful

    File Creation on SD card is Successful
    File error

     

    Help me, what can I do with my file so that my program can read file Lenna.raw to buffer?

  • Can you put the Lenna.raw file in your debug or your .out file located?

    Regards,

    Hyun

  • I saved file "Lenna.raw" to folder Debug in my project folder.

    But after I do like in file C55XCSL-LOWPOWER-2.10.00.00_Release_Notes_20100813.pdf , I click "Target" ---> Debug Active Project. After that, my file "Lenna.raw" is deleted and disappear from Debug.

    So please show me how can I compile the project to can be read my file? It mean that my file is not deleted after compiling.

    Thank in advance.

  • Hi,

     

    I guess that I didn't clearly say it. The file locates not in the CCS directory but it should be in the actual windows/dos file system. So you need to copy/move "Lenna.raw" to the Debug directory in your physical storage where your .out file located.

     

    Regards,

    Hyun

  • Hi,

    I do like your instructions and my program read file successfully, but I encounter with another problem :(

    It cannot allocate memory for array "buffer":

      pFile = fopen ( "Lenna.raw" , "rb" );
      if (pFile==NULL) {fputs ("File error",stderr); exit (1);}
     
      fseek (pFile , 0 , SEEK_END);
      lSize = ftell (pFile);
      printf("lSize=%ld", lSize);
      rewind (pFile);
     // allocate memory to contain the whole file:
      buffer = (char*) malloc (sizeof(char)*lSize);
      if (buffer == NULL) {fputs ("Memory error",stderr); exit (2); }

      // copy the file into the buffer:
      result = fread (buffer,1,lSize,pFile);
      if (result != lSize) {fputs ("Reading error",stderr); exit (3);}

      /* the whole file is now loaded in the memory buffer. */

      // terminate
      fclose (pFile);
     

       printf("done\n");

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    CONFIG CARDSD Card detected
    SD card is Standard Capacity Card
    Memory Access will use Byte Addressing
    SD card initialization Successful
    Memory error

    lSize=65536 <------------ my file "Lenna.raw" 's size = 64kB

  • Hiiii,

     

    I have done it, no error. But the problem is lSize must not larger than 16000.

    I read TMS320C55x Optimizing C/C++ Compiler User’s Guide, and It show me that I have to change value after -heap in the command file to enlarge the limit size of iSize.

    But in  my project: CSL_MMCSD_SdCardFSExample_Out (because I have to read file from my PC, then process and write on SD Card, so I use this available project and modify it by adding some code paragraph like you see in my previous post), I cannot see the path to file command: *.cmd in Project Properties in CCS4.

    I add the default command file after I changed the value -heap to 65000, but then, compling error.

    So please help me, show me how can I enlarge the biggest size of allocated memory use malloc?

    Thanks in advance.

  • Hiiii,

    Dear Hyun,

    I have done it, no error. But the problem is lSize must not larger than 16000.

    I read TMS320C55x Optimizing C/C++ Compiler User’s Guide, and It show me that I have to change value after -heap in the command file to enlarge the limit size of iSize.

    But in  my project: CSL_MMCSD_SdCardFSExample_Out (because I have to read file from my PC, then process and write on SD Card, so I use this available project and modify it by adding some code paragraph like you see in my previous post), I cannot see the path to file command: *.cmd in Project Properties in CCS4.

    I add the default command file after I changed the value -heap to 65000, but then, compling error.

    So please help me, show me how can I enlarge the biggest size of allocated memory use malloc?

    Thanks in advance.

  • Hi,

     

    You increase heap size with ***.tcf file. If you double click tcf file in your CCS4 project window, Configuration Tool windows will be open. Then select System-->MEM-->SARAM.

    Find heap size box and increase the size.

    4786.heap_increase.ppt

    Regards,

    Hyun

  • Thanks for your help Hyun,

    I use a "for" loop to write successively to file in csl_mmcsd_atafs_example.c, like that:

    for( i=0;i<256;i++)
    {
        /* Write data to the file */
        for(index = 0; index < CSL_MMCSD_ATA_BUF_SIZE; index++)
        {
            gMmcWriteBuf[index] = i+1; // assign value to Write buffer
           
           
        }
        ata_error = ATA_write(pAtaFile, gMmcWriteBuf, CSL_MMCSD_ATA_BUF_SIZE);
        if(ata_error != ATA_ERROR_NONE)
        {
            printf("ATA_write Failed\n i=%d",i);
            return(ata_error);
        }
        else
        {
            printf("\nWriting Data to the file on SD card successful i= %d\n", i);
        }
    }

    It show "Writing Data to the file on SD card successful" in whole 256 loops.

    But, when I read from this file:

    ATA_seek (pAtaFile, 0);

        /* Read the data from the file in little endian mode */
       
        /* Close the file */
        ata_error = ATA_close(pAtaFile);
        if(ata_error != ATA_ERROR_NONE)
        {
            printf("ATA_close Failed\n");
            return(ata_error);
        }

        /* Compare the data read and data written */
        for(i=0;i<256;i++)
        {
            printf("i=%d\n", i);
            /////////////////////////////
            ata_error = ATA_readLittleEndian(pAtaFile,gMmcReadBuf, CSL_MMCSD_ATA_BUF_SIZE);
        if(ata_error != ATA_ERROR_NONE)
        {
            printf("ATA_readLittleEndian Failed\n");
            return(ata_error);
        }
        else
        {
            printf("\nReading Data from the file on SD card successful\n");
        }
            //////////////////////
        for(index = 0; index < CSL_MMCSD_ATA_BUF_SIZE; index++)
        {
           
            if(gMmcReadBuf[index] != i+1)
            {
                printf("ReadBuf [%d]=%d\n",index, gMmcReadBuf[index]);
                printf("i+1=%d\n",i+1);
               
                ata_error = 1;
                printf("\nMMCSD Read and Write Buffers do not Match\n");
                //break;
            }
        }

        if(ata_error == 0)
        {
            printf("\nMMCSD Read and Write Buffers Match\n");
        }
        }

        return(ata_error);

    i from 0 to 31, it's ok, MMCSD Read and Write Buffers Match. But from 32 to 256, MMCSD Read and Write Buffers do not Match, and all values readed from file equal to zero, like that in Debug window:

    i=32

    Reading Data from the file on SD card successful
    ReadBuf [0]=0
    i+1=33

    MMCSD Read and Write Buffers do not Match
    ReadBuf [1]=0
    i+1=33

    MMCSD Read and Write Buffers do not Match
    ReadBuf [2]=0
    i+1=33

    MMCSD Read and Write Buffers do not Match
    ReadBuf [3]=0
    i+1=33

    MMCSD Read and Write Buffers do not Match
    ReadBuf [4]=0
    i+1=33

    So, what is problem? :( and how can I correct it?

    I wonder that the problem is the instruction: ata_error = ATA_readLittleEndian(pAtaFile,gMmcReadBuf, CSL_MMCSD_ATA_BUF_SIZE);, it limits i<32, right??

    Please help me, if I need write a file with large size (it mean that i>32), what I have to do?

    I am very interested in this kit :D

    Thanks in advance.

  • Hi,

     

    I see that it happens. I'll follow up this.

    Regards,

    Hyun

  • Hi,

     

    Here is a solution:

    You need to include attached files in your project.

    ata_error = ATA_fopen(pAtaFile, fileName, "txt"); // open a file, if there is no file then it creates one.

    for (i=0; i<256; i++) {

    /* Write data to the file */

         ata_error = ATA_write(pAtaFile, gMmcWriteBuf, CSL_MMCSD_ATA_BUF_SIZE);

         if(ata_error != ATA_ERROR_NONE)

         {

    printf("ATA_write Failed\n");

             return(ata_error);

         }

         else

         {

    //printf("\nWriting Data to the file on SD card successful\n");

    }

    /* Close the file */

        ata_error = ATA_close(pAtaFile);

        //ATA_flush(pAtaFile);

    /* Open the file */

        ata_error = ATA_fopen(pAtaFile, fileName, "txt");

     

    ATA_seek (pAtaFile, 0);

     

    for (i=0; i<256; i++) {

    /* Read the data from the file in little endian mode */

         ata_error = ATA_readLittleEndian(pAtaFile,gMmcReadBuf, CSL_MMCSD_ATA_BUF_SIZE);

         if(ata_error != ATA_ERROR_NONE)

         {

    printf("ATA_readLittleEndian Failed\n");

             return(ata_error);

         }

         else

         {

    //printf("\nReading Data from the file on SD card successful\n");

    }

    for(index = 0; index < CSL_MMCSD_ATA_BUF_SIZE; index++)

         {      

             if(gMmcReadBuf[index] != index+1)

             {

                 printf("ReadBuf [%d]=%d\n",index, gMmcReadBuf[index]);

                 printf("i+1=%d\n",i+1);

     

                 ata_error = 1;

                 printf("\nMMCSD Read and Write Buffers do not Match\n");

                //break;

             }

         }

    }

    /* Close the file */

        ata_error = ATA_close(pAtaFile);

     

     

  • Hi Hyun,

    Thank for your help.

    I got it and continue write my code, then I encounter with this error when I compile my project:

    errors encountered during linking; "CSL_MMCSD_SdCardFSExample_Out.out" not built

    placement fails for object ".text", size 0x13cbb (page 0).  Available ranges: SARAM        size: 0x3fc00      unused: 0x19b6c      max hole: 0x10000

     

    maybe in my code, many arrays are declared (like range[128][128]) and allocated (use "malloc" function), Does they make this error? And how can I deal with this?

    Thanks in advance.

  • Phu Thai,

    You .text section (code) is too big (0x13cbb bytes) for the memory space that you are trying to allocate this section to (SARAM: max hole = 0x10000 bytes).  It appears that there are some actions like alignment which is causing unusable holes to be generated leaving your largest continuous space to be only 0x10000 bytes which is smaller than the size of your .text section.  The memory description and allocation is done in the linker command file (.cmd).

    You will need to redo your memory allocation scheme (move sections to different memory blocks or reorder allocation directives), or redo your code to make is smaller.  Are you using optimization in the compilation stage?  Good documents that describe the Code Generation Tools are:
         Assembly Language Tools User's Guide (including Linker): http://www-s.ti.com/sc/techlit/spru280
         Optimizing C/C++ Compiler User's Guide: http://www-s.ti.com/sc/techlit/spru281

    Regards.

  • Hi Hyun,

    I am trying to run some codes C/C++ on a new kit: TMS320C6416 Starter Kit. But I do not know where to find the examples and documents related to it like TMS320C5515 above.

    I have downloaded C6400 chip support library, but after installing, no document to show how to use that lib as well as run example code?

    Please, help me.

    Best regards,

    Thai

  • Hi Hyun,

    I just wonder that where is file .out loaded? SARAM, DARAM, NOR Flash or where else?

    Because of small memory, so my program only can run with 64x64 image. Bigger images will make memory overflow.

    So, in the kit TMS320C5515 USB Sticky Kit, is there any bigger on-board memory for me to process a bigger image having 128x128 or 256x256 size? And how can I use it.

    Thank you so much.

    Best,

    Thái

  • Hi,

    If you can see map file, you know where your code will be loaded.

    Also you can control using .cmd file to any section of code to place wherever you want.

    Please refer http://focus.ti.com/lit/ug/spru281f/spru281f.pdf Example 4−1. Linker Command File.

    Regards,

    Hyun

  • Hi Hyun,

    I saw it, but I cannot understand all of them. how can I change the location that file .out is loaded? My file .out size is about 650k. I want to save this file in another memory space to maximize the memory space for allocate memory ( when using instruction malloc, alloc,...).

    Please help me. My prof. ask me to increase the size of processed image. So I need to expand the memory to allocate.

    Thank you so much, Hyun.

  • Hi,

    You are run out of your memory resources. C5515 on chip memory is 320K so your code it too big.

    You have to reduce your code size. You can not simply increase your allocate memory size. However you can utilize SD card as data storage.

    Regards,

    Hyun