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.

TM4C129XNCZAD: write files to two different volumes on the same SDcard

Part Number: TM4C129XNCZAD

I had a tm4c129xnczad microcontroller with SDcard connected to it via SPI3 

and the SDcard with 1 Gb size had 2 volumes with about 500 Mb each

I want to write data to files to each volume I can access the first one but the second volume is not accessible through the code I had so the steps I did was

1. first I started Mounting the 2 volumes such that 

    EIO_vmturnSDCardPowerON();
    UTIL_vNonOSDelayMiliSeconds(200);/* this delay is gurantee the proper rest for the SD card */
    /* Mount and register the FSHELL Card */
    SDSPI_Params_init(&objstrsdspiParameters);
    objsdspiHandle = SDSPI_open(Board_SDSPI0, DRIVE_NUM, &objstrsdspiParameters);
    if(objsdspiHandle == STD_NULL)
    {
        FSHELL_vmLogError0(&objstrFSHELLModuleInfoType, "Can't mount SD card");
    }
    else
    {
        FSHELL_vmLogActivity1(&objstrFSHELLModuleInfoType, "SD card is mounted Drive:%u", DRIVE_NUM);
        bSdMountState = STD_TRUE;
    }
    objsdspiHandle = SDSPI_open(1, 1, &objstrsdspiParameters);
    if(objsdspiHandle == STD_NULL)
    {
        FSHELL_vmLogError0(&objstrFSHELLModuleInfoType, "Can't mount SD card");
    }
    else
    {
        FSHELL_vmLogActivity1(&objstrFSHELLModuleInfoType, "SD card is mounted Drive:%u", 1);
        bSdMountState = STD_TRUE;
    }

2. then I used the standard file APIs from the studio.h (fopen, fclose, fwrite ) functions such that

#include <stdio.h>

function (){
...
INT8S *ps8ProgFilePath = "fat:0:/ProgBlocks/Blocks.txt";
INT8S *ps8ProgFilePath_1 = "fat:1:/ProgBlocks/Blocks.txt";
FRESULT objFRESULT = FR_DISK_ERR;
FILE *pSourceFile;
...

objFRESULT = f_mkdir("/ProgBlocks");
if((objFRESULT == FR_OK)||(objFRESULT == FR_EXIST)) /* if folder is created or alredy existed */
{
pSourceFile = fopen((const INT8S*)ps8ProgFilePath, "a");
if(pSourceFile == STD_NULL)
{
SCFGM_vmLogError1(&objstrSCFGMModuleInfoType, "\"%s\" could not be created", (INT32U)ps8ProgFilePath);
}
else
{
u32NumBytesWritten = fwrite((INT8S*)ps8Data,1,(MAX_BLOCK_ID_STRING+(u32BlockLen*3)),pSourceFile);
if (u32NumBytesWritten != (MAX_BLOCK_ID_STRING+(u32BlockLen*3)))
{
SCFGM_vmLogError1(&objstrSCFGMModuleInfoType, "\"%s\"Err wrt Blk", (INT32U)ps8ProgFilePath);
}
}
if(fclose(pSourceFile) != 0)
{
SCFGM_vmLogError1(&objstrSCFGMModuleInfoType, "\"%s\" could not be Close", (INT32U)ps8ProgFilePath);
}
}
....
}

so I can access the first volume "fat:0:" but can't write or even access the second volume "fat:1:" in the same way

so the question is can I even access 2 volumes within the same SD card and how? 

  • Hello Hazem,

    The SD Card libraries provided with TivaWare are not TI-developed, they are third party libraries. We are not able to support this question as we lack any development knowledge of the FATFS library. You would need to reach out to the developers of that third party library to get insight on if it is possible to access multiple volumes.

    Best Regards,

    Ralph Jacobi