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.

Create a RAM Disk in SYSBIOS

Other Parts Discussed in Thread: SYSBIOS

How do I go about creating a RAM disk in SYSBIOS?  I have run the fatFS example that comes in the the bios install directory:

C:\TI\bios_6_33_04_39\packages\ti\sysbios\fatfs

That includes a  twoFiles_ramdisk.c file, that creates a ram disk with two files in it, but I want to be able to create a blank RAM disk, that I can read and write files to and from?  I see the documentation refers to a script, but I have not been able to locate one...  Any help is appreciated. 

Chad 

  • Chad,

    Have you seen this wiki page?  http://processors.wiki.ti.com/index.php/FatFS_for_SYS/BIOS

    Scott

  • That is where I saw the mention of a script that creates the RAM disk...  I found the 

    C:\TI\bios_6_33_04_39\packages\ti\sysbios\fatfs\utils\bin\mkimage.exe 

    and ran

    mkimage.exe RAMDISK 512000

    It generated a 500Kb file, so now what do I do with that?? the one in the example was a .c file..??

    Thanks again,

    Chad

  • Never mind, I found the following that walks you through generating the .c file:

    C:\TI\bios_6_33_04_39\packages\ti\sysbios\fatfs\utils\examples\addFiles.sh

    Now, when attempting to write a file to the RAM disk:  Here is what I am doing:

    void writeDataToFile(char *data)
    {
    int size;
    FILE *fp;
    const char *filename = "fat:dataFile.txt";
    size = 0;

    /* open the ramdisk file for reading */
    fp = fopen(filename, "w+");
    if (fp == NULL) {
    printf("ERROR: could not open file %s\n", filename);
    System_exit(1);
    }

    do {
    /* write data contents */
    fwrite(data, 1, size, fp);
    } while (size == strlen(data));


    /* clean up */
    fclose(fp);
    }

    I dont see the file when I attempt to read it in..?? 

  • There are a few issues:

    - setting “size = 0;” means nothing will be written by fwrite()

    - “size” is an input parameter to fwrite() and won’t be modified by the call

    - the value *returned* by fwrite() will indicate how much was actually written

    - “strnlen(data)” will not be changed by the fwrite() call