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.

Compiler/CC2642R: FatFs FR_Not_Ready error

Part Number: CC2642R

Tool/software: TI C/C++ Compiler

Hello TI Experts,

We are working on implementing FatFs on the cc2642r1 launchpad with a Adafruit SPI MicroSD breakout board. We are currently getting an FR_NOT_READY error following a call to f_open.

#include "settings.h"
#include "Board.h"
#include <xdc/std.h>
#include <xdc/runtime/System.h>

 #include <file.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>

#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/BIOS.h>
#include "ti/drivers/SDFatFS.h"
#include "third_party/fatfs/ff.h"
#include <third_party/fatfs/diskio.h>

#include<stdio.h>

FATFS *fs;
FILE *src;
FRESULT fr;

#define DRIVE_NUM 0
char fileName[100] = "1";




/* Set this to the current UNIX time in seconds */
const struct timespec ts = {
    .tv_sec = 1469647026,
    .tv_nsec = 0
};


/*
* ======== fatfs_getFatTime ========
*/
int32_t fatfs_getFatTime(void)
{
    time_t seconds;
    uint32_t fatTime;
    struct tm *pTime;

    seconds = time(NULL);

    pTime = localtime(&seconds);

    fatTime = ((uint32_t)(pTime->tm_year - 80) << 25) |
    ((uint32_t)(pTime->tm_mon) << 21) |
    ((uint32_t)(pTime->tm_mday) << 16) |
    ((uint32_t)(pTime->tm_hour) << 11) |
    ((uint32_t)(pTime->tm_min) << 5) |
    ((uint32_t)(pTime->tm_sec) >> 1);

    return ((int32_t)fatTime);
}

/*
 *
 *  The SDFatFS_Config structure contains a single pointer used to characterize
 *  the SDFatFS driver implementation.
 *
 *  This structure needs to be defined before calling SDFatFS_init() and it must
 *  not be changed thereafter.
 *
 *  @sa SDFatFS_init()
 */
SDFatFS_Object myObj;
SDFatFS_Config SDFatFS_config[] =
     {
         { &myObj },
         NULL
     };
uint_least8_t SDFatFS_count = sizeof(SDFatFS_config) / sizeof(SDFatFS_config[0]) - 1;



void sdCardInit(){



    /* SDFAT_FS_OPEN()
     * Function to open a SDFatFS instance on the specified drive.
     * Function to mount the FatFs filesystem and register the SDFatFS disk
     * I/O functions with the FatFS module.
     *
     * @ param idx Logical peripheral number indexed into the HWAttrs
     * @ param drive Drive Number
     */
    SDFatFS_Handle _sd_handle;
    _sd_handle = SDFatFS_open(Board_SD0, DRIVE_NUM);
    if (_sd_handle == NULL) {
        //Error opening SDFatFS driver
        while (1);
     }


    /* Open the source file */
    fr = f_open(&src, fileName, FA_WRITE|FA_CREATE_ALWAYS);

 //   System_printf("fr following f_open %d\n", fr); System_flush();

}



Is there something we're missing in this code, or do you have any idea why we would be getting this error?

  • Hey TI Experts,

    I am also working on this project and just wanted to add that we are making the call to SDFATfs_init().  

    From the task a call is made to a void function sdCardInit() which is shown in Travis' code located in the post above.
    I would also like to add that our wire setup and pinouts appear to be correct, as were able to get the sdraw example working. Hope this provides a little extra context.

    int main()
    {
        /* Call driver init functions */
        Board_initGeneral();
        I2C_init();
        SPI_init();
        UART_init();
    
        // Function to initialize a SDFatFS instance
        SDFatFS_init();
    
        // Declare task param structure and task handle
        Task_Params taskParams;
        Task_Handle sampleSensors;
    
        Error_Block eb;
        Error_init(&eb);
    
        /* Create 1 task with priority 1 */
        Task_Params_init(&taskParams);
        taskParams.stackSize = 2048;
        taskParams.priority = 1;
        sampleSensors = Task_create((Task_FuncPtr)mainThread, &taskParams, &eb);
        if (sampleSensors == NULL) {
            System_abort("Task create failed");
        }
    
        //call BIOS_start() enables interrupts and starts the scheduler with BIOS
        BIOS_start();
    
        return (0);
    }

  • Hey everyone,

    I figured out what was going on here. Dumb mistake on my part. I had updated the board file to match my circuit so the pins did not match. I was able to a FR_OK response and write a blank file to the SD card. 

    However, when I attempt to write data to the file using the string functions (i.e. f_printf, f_putc, f_gets, ect), I am unable to compile due to unresolved symbol errors despite having FF_USE_STRFUNC =1 in ffconf.h.

    I find this somewhat surprising considering that the f_open call which functioning properly is located within the same file as the string functions that are generating the unresolved symbol error (ff.h).

    Any idea on how to resolve this issue?

    Thanks 

  • A simple include of ff.c  did the trick.  All string functions are now working.

    #include "C:\ti\simplelink_cc2640r2_sdk_2_30_00_28\source\third_party\fatfs\ff.c"