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.

CC3220SF-LAUNCHXL: How to use NVS driver for MX25 family flash

Part Number: CC3220SF-LAUNCHXL
Other Parts Discussed in Thread: CC3220SF, CC3220S

This is my previous thread https://e2e.ti.com/support/wireless-connectivity/wifi/f/968/t/783164

We using MX25L6433F 8MB external flash for storing our data this is not a cc3220sf network processor flash.

How to add NVS library for MX25 family flash.

  • CC3220SF_LAUNCHXL.c 
  • CC3220SF_LAUNCHXL.h
  • Board.h

I modified previously mentioned file but fault ISR triggered.

/*
 *  =============================== SPI ===============================
 */
#include <ti/drivers/SPI.h>
#include <ti/drivers/spi/SPICC32XXDMA.h>

SPICC32XXDMA_Object spiCC3220SDMAObjects[CC3220SF_LAUNCHXL_SPICOUNT];

uint32_t spiCC3220SDMAscratchBuf[CC3220SF_LAUNCHXL_SPICOUNT];

const SPICC32XXDMA_HWAttrsV1 spiCC3220SDMAHWAttrs[CC3220SF_LAUNCHXL_SPICOUNT] = {
    /* index 0 is reserved for LSPI that links to the NWP */
    {
        .baseAddr = LSPI_BASE,
        .intNum = INT_LSPI,
        .intPriority = (~0),
        .spiPRCM = PRCM_LSPI,
        .csControl = SPI_SW_CTRL_CS,
        .csPolarity = SPI_CS_ACTIVEHIGH,
        .pinMode = SPI_4PIN_MODE,
        .turboMode = SPI_TURBO_OFF,
        .scratchBufPtr = &spiCC3220SDMAscratchBuf[CC3220SF_LAUNCHXL_SPI0],
        .defaultTxBufValue = 0,
        .rxChannelIndex = UDMA_CH12_LSPI_RX,
        .txChannelIndex = UDMA_CH13_LSPI_TX,
        .minDmaTransferSize = 100,
        .mosiPin = SPICC32XXDMA_PIN_NO_CONFIG,
        .misoPin = SPICC32XXDMA_PIN_NO_CONFIG,
        .clkPin = SPICC32XXDMA_PIN_NO_CONFIG,
        .csPin = SPICC32XXDMA_PIN_NO_CONFIG
    },
    {
        .baseAddr = GSPI_BASE,
        .intNum = INT_GSPI,
        .intPriority = (~0),
        .spiPRCM = PRCM_GSPI,
        .csControl = SPI_SW_CTRL_CS,
        .csPolarity = SPI_CS_ACTIVELOW,
        .pinMode = SPI_3PIN_MODE,
        .turboMode = SPI_TURBO_OFF,
        .scratchBufPtr = &spiCC3220SDMAscratchBuf[CC3220SF_LAUNCHXL_SPI1],
        .defaultTxBufValue = 0,
        .rxChannelIndex = UDMA_CH6_GSPI_RX,
        .txChannelIndex = UDMA_CH7_GSPI_TX,
        .minDmaTransferSize = 10,
        .mosiPin = SPICC32XXDMA_PIN_07_MOSI,
        .misoPin = SPICC32XXDMA_PIN_06_MISO,
        .clkPin = SPICC32XXDMA_PIN_05_CLK,
    }
};

const SPI_Config SPI_config[CC3220SF_LAUNCHXL_SPICOUNT] = {
    {
        .fxnTablePtr = &SPICC32XXDMA_fxnTable,
        .object = &spiCC3220SDMAObjects[CC3220SF_LAUNCHXL_SPI0],
        .hwAttrs = &spiCC3220SDMAHWAttrs[CC3220SF_LAUNCHXL_SPI0]
    },
    {
        .fxnTablePtr = &SPICC32XXDMA_fxnTable,
        .object = &spiCC3220SDMAObjects[CC3220SF_LAUNCHXL_SPI1],
        .hwAttrs = &spiCC3220SDMAHWAttrs[CC3220SF_LAUNCHXL_SPI1]
    }
};


/*
 * =============================== NVS ===============================
 */

#include <ti/drivers/NVS.h>
#include <ti/drivers/nvs/NVSSPI25X.h>

uint8_t verifyBuf[256];

NVSSPI25X_HWAttrs nvsSPIHWAttrs[1] = {
    //
    // region 0 is 1 flash sector in length.
    //
    {
        .regionBaseOffset = 0,
        .regionSize = 4096,
        .sectorSize = 4096,
        .verifyBuf = verifyBuf,
        .verifyBufSize = 256,
        .spiHandle = SPI_config,  This is correct ?
        .spiIndex = 1,
        .spiBitRate = 40000000,
        .spiCsnGpioIndex = CC3220SF_Custom_CS,
    }
};


NVSSPI25X_Object nvs_Objects[CC3220SF_NVSCOUNT];  //CC3220SF_NVSCOUNT is 1


const NVS_Config NVS_config[CC3220SF_NVSCOUNT] = {
    {
        .fxnTablePtr = &NVSSPI25X_fxnTable,
        .object = &nvs_Objects,
        .hwAttrs = &nvsSPIHWAttrs[1],
    },
};

const uint_least8_t NVS_count = CC3220SF_NVSCOUNT;

How to modify correct way ?

Why fault is trigger if i call NVS_open() ?

Possible to attach modified file based on my requirement ?

Vasu

  • Hi dhevan,

    What version of the SimpleLink SDK are you using? This driver supports the following SPI flash devices:

    * Winbond W25xx family
    * Macronics MX25Rxx family
    * Micron N25Qxx family

    What is the fault? Have you called NVS_init? How are you calling NVS_open?

    Todd
  • Hi Todd,

    SDK Version = 2.40.2.00

    SPI Flash = MX25L6433F, 3V, 64Mb, v1.6

    Macronics MX25Rxx family flash and MX25L almost instruction same.

    My problem reading working fine.

    Writing is not working properly if i debug step by step write function NVSSPI25X_write in NVSSPI25X.c file flash is writing data.

    Next time debug mode only calling NVS_write function not returning any error if i try to read i am getting some junk data.

            NVS_write(nvsHandle, 0, (void *) signature, sizeof(signature),
                NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY);

    Problem is write is not working.

    Note : NVSSPI25X_write step by step debug is working.

    My SPI Configuration :

    /*
     *  =============================== SPI ===============================
     */
    #include <ti/drivers/SPI.h>
    #include <ti/drivers/spi/SPICC32XXDMA.h>
    
    SPICC32XXDMA_Object spiCC3220SDMAObjects[CC3220SF_LAUNCHXL_SPICOUNT];
    
    uint32_t spiCC3220SDMAscratchBuf[CC3220SF_LAUNCHXL_SPICOUNT];
    
    const SPICC32XXDMA_HWAttrsV1 spiCC3220SDMAHWAttrs[CC3220SF_LAUNCHXL_SPICOUNT] = {
        /* index 0 is reserved for LSPI that links to the NWP */
        {
            .baseAddr = LSPI_BASE,
            .intNum = INT_LSPI,
            .intPriority = (~0),
            .spiPRCM = PRCM_LSPI,
            .csControl = SPI_SW_CTRL_CS,
            .csPolarity = SPI_CS_ACTIVEHIGH,
            .pinMode = SPI_4PIN_MODE,
            .turboMode = SPI_TURBO_OFF,
            .scratchBufPtr = &spiCC3220SDMAscratchBuf[CC3220SF_LAUNCHXL_SPI0],
            .defaultTxBufValue = 0,
            .rxChannelIndex = UDMA_CH12_LSPI_RX,
            .txChannelIndex = UDMA_CH13_LSPI_TX,
            .minDmaTransferSize = 100,
            .mosiPin = SPICC32XXDMA_PIN_NO_CONFIG,
            .misoPin = SPICC32XXDMA_PIN_NO_CONFIG,
            .clkPin = SPICC32XXDMA_PIN_NO_CONFIG,
            .csPin = SPICC32XXDMA_PIN_NO_CONFIG
        },
        {
            .baseAddr = GSPI_BASE,
            .intNum = INT_GSPI,
            .intPriority = (~0),
            .spiPRCM = PRCM_GSPI,
            .csControl = SPI_SW_CTRL_CS,
            .csPolarity = SPI_CS_ACTIVELOW,
            .pinMode = SPI_3PIN_MODE,
            .turboMode = SPI_TURBO_OFF,
            .scratchBufPtr = &spiCC3220SDMAscratchBuf[CC3220SF_LAUNCHXL_SPI1],
            .defaultTxBufValue = 0,
            .rxChannelIndex = UDMA_CH6_GSPI_RX,
            .txChannelIndex = UDMA_CH7_GSPI_TX,
            .minDmaTransferSize = 10,
            .mosiPin = SPICC32XXDMA_PIN_07_MOSI,
            .misoPin = SPICC32XXDMA_PIN_06_MISO,
            .clkPin = SPICC32XXDMA_PIN_05_CLK,
        }
    };
    
    SPI_Config SPI_config[CC3220SF_LAUNCHXL_SPICOUNT] = {
        {
            .fxnTablePtr = &SPICC32XXDMA_fxnTable,
            .object = &spiCC3220SDMAObjects[CC3220SF_LAUNCHXL_SPI0],
            .hwAttrs = &spiCC3220SDMAHWAttrs[CC3220SF_LAUNCHXL_SPI0]
        },
        {
            .fxnTablePtr = &SPICC32XXDMA_fxnTable,
            .object = &spiCC3220SDMAObjects[CC3220SF_LAUNCHXL_SPI1],
            .hwAttrs = &spiCC3220SDMAHWAttrs[CC3220SF_LAUNCHXL_SPI1]
        }
    };
    
    const uint_least8_t SPI_count = CC3220SF_LAUNCHXL_SPICOUNT;
    

    NVS Configuration :

    /*
     * =============================== NVS ===============================
     */
    #include <ti/drivers/NVS.h>
    #include <ti/drivers/nvs/NVSSPI25X.h>
    
    
    uint8_t verifyBuf[256];
    
    NVSSPI25X_HWAttrs nvsSPIHWAttrs[2] = {
           //
           // region 0 is 1 flash sector in length.
           //
           {
               .regionBaseOffset = 0,
               .regionSize = 4096,
               .sectorSize = 4096,
               .verifyBuf = verifyBuf,
               .verifyBufSize = 256,
               .spiHandle = NULL,
               .spiIndex = 1,
               .spiBitRate = 20000000,
               .spiCsnGpioIndex = CC3220SF_Custom_CS,
           },
           //
           // region 1 is 3 flash sectors in length.
           //
           {
               .regionBaseOffset = 4096,
               .regionSize = 4096 * 3,
               .sectorSize = 4096,
               .verifyBuf = verifyBuf,     // use shared verifyBuf
               .verifyBufSize = 256,
               .spiHandle = NULL,
               .spiIndex = 0,
               .spiBitRate = 40000000,
               .spiCsnGpioIndex = 12,
           }
       };
    
    //CC3220SF_NVSCOUNT is 1
    
    NVSSPI25X_Object nvsObjects[CC3220SF_NVSCOUNT]; 
    
    
    const NVS_Config NVS_config[CC3220SF_NVSCOUNT] = {
        {
            .fxnTablePtr = &NVSSPI25X_fxnTable,
            .object = &nvsObjects[0],
            .hwAttrs = &nvsSPIHWAttrs[0],
        },
    };
    
    const uint_least8_t NVS_count = CC3220SF_NVSCOUNT;

    What is the problem why writing is not working ?

    How to solve this issue ?

    Vasu

  • Hi,

    Can you make a sample CCS project that shows the issue, then export it, and attach it to this thread?

    Todd
  • Hi Todd,

    Sorry for delayed response.

    I attached sample project. 

    MX25L6433F_Flash.zip

    Vasu

  • NVS_write return -7
  • Thanks. I have your project. I'll try to reproduce the issue.

    Todd
  • Sorry, the engineer that has MX25 chips is out this week. I'll look into this early next week when he is back in the office.

    Todd
  • Hi Todd,
    Thank you for your response.
    It's ok no problem take your own time .
    one more thing please check cc3220sf spiffs library with nvs MX25 flash.

    Vasu
  • Ok. I have a chip now. How did you wire up the device (e.g. which boosterpack pin did you use for DO, DI, CS, etc.)?

    Todd
  • Hi Todd,

    I am using our own small pcb containing only flash chip.

    flash cs,mosi,miso,clk directly connected to cc3220sf launch pad.

    reading working fine there is no issue but writing having issue only working on debug mode.

    because of this reason i added delay between on api call to another api call working but i got another issue.

    NVS_write i am passing 1024 bytes start address 0 internal MX25xxx library split 256 bytes of data after that writing data to flash then reading i am getting some junk data.

    Why this is not working any thing wrong in my NVS configuration CC3220SSF_LAUNCHXL.c ?

    /*
     *  ======== spimaster.c ========
     */
    #include <stdbool.h>
    #include <stddef.h>
    #include <stdint.h>
    #include <string.h>
    
    /* POSIX Header files */
    #include <pthread.h>
    #include <semaphore.h>
    #include <unistd.h>
    
    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/display/Display.h>
    #include <ti/drivers/NVS.h>
    #include <ti/drivers/NVS.c>
    
    #include <ti/drivers/nvs/NVSSPI25X.h>
    #include <ti/drivers/nvs/NVSSPI25X.c>
    
    /* Example/Board Header files */
    #include "Board.h"
    
    #define THREADSTACKSIZE (4024)
    
    #define SPI_MSG_LENGTH  (21)
    //#define SPI_MSG_LENGTH  (4)
    #define MASTER_MSG      ("Hello from master, msg#: ")
    
    #define MAX_LOOP        (10)
    
    #define FOOTER "=================================================="
    
    /* Buffer placed in RAM to hold bytes read from non-volatile storage. */
    static char buffer[1000];
    
    /*
     * Some devices have a minimum FLASH write size of 4-bytes (1 word). Trying
     * to write a non-multiple of 4 amount of data will fail. This array is
     * rounded up (to next multiple of 4) to meet this requirement. Refer to NVS
     * driver documentation for more details.
     */
    //static const char signature[52] =
    //    {"SimpleLink SDK Non-Volatile Storage (NDK) Example."};
    
    static const char signature[] =
            "-----BEGIN RSA PRIVATE KEY-----\r\n"
            "MIIEowIBAAKCAQEAuqPnrA+qkLMcl9jd4+cedFU2d8Siaq91BQfwWDyuU1sas5+q\r\n"
            "kRAA0y8MFXXMGPmWzRXdEOXZkL3T8CX0aqPkIHeNCrIiPC0kuwh3Wvxoy63pad9X";
    
    
    
    static Display_Handle display;
    
    void *masterThread(void *arg0)
    {
        int_fast16_t ret;
        NVS_Handle nvsHandle;
        NVS_Attrs regionAttrs;
        NVS_Params nvsParams;
    
        Display_init();
        NVS_init();
    
        NVS_Params_init(&nvsParams);
        nvsHandle = NVS_open(Board_NVSINTERNAL, &nvsParams);
    
        if (nvsHandle == NULL) {
            Display_printf(display, 0, 0, "NVS_open() failed.");
    
            return (NULL);
        }
    
        Display_printf(display, 0, 0, "\n");
    
        /*
         * This will populate a NVS_Attrs structure with properties specific
         * to a NVS_Handle such as region base address, region size,
         * and sector size.
         */
        NVS_getAttrs(nvsHandle, &regionAttrs);
    
        /* Display the NVS region attributes */
        Display_printf(display, 0, 0, "Region Base Address: 0x%x",
                regionAttrs.regionBase);
        Display_printf(display, 0, 0, "Sector Size: 0x%x",
                regionAttrs.sectorSize);
        Display_printf(display, 0, 0, "Region Size: 0x%x\n",
                regionAttrs.regionSize);
    
    check:
       /* Erase the entire flash sector. */
        //NVS_lock(nvsHandle, 10000);
        usleep(20000);
        ret = NVS_erase(nvsHandle, 0, regionAttrs.sectorSize);
    
        usleep(20000);
        ret = NVS_read(nvsHandle, 0, (void *) buffer, sizeof(signature));
        Display_printf(display, 0, 0, "Data - %s \r\n", buffer);
        //NVS_unlock(nvsHandle);
        //ret = NVS_control(nvsHandle, 32, 0);
    
       /* The signature was not found in the NVS region. */
       Display_printf(display, 0, 0, "Writing signature to flash...");
    
       /* Write signature to memory. The flash sector is erased prior
       * to performing the write operation. This is specified by
       * NVS_WRITE_ERASE.
       */
       //NVS_lock(nvsHandle, 10000);
       //NVS_unlock(nvsHandle);
       usleep(20000);
       ret = NVS_write(nvsHandle, 0, (void *) signature, sizeof(signature), 0);
       usleep(20000);
       ret = NVS_read(nvsHandle, 0, (void *) buffer, sizeof(signature));
       Display_printf(display, 0, 0, "Data - %s \r\n", buffer);
    
       memset(buffer, 0, sizeof(signature));
    
       usleep(20000);
       ret = NVS_write(nvsHandle, 257, (void *) signature, sizeof(signature), 0);
       usleep(20000);
       ret = NVS_read(nvsHandle, 257, (void *) buffer, sizeof(signature));
       Display_printf(display, 0, 0, "Data - %s \r\n", buffer);
    
    
       if (regionAttrs.regionBase != NVS_REGION_NOT_ADDRESSABLE) {
           Display_printf(display, 0, 0, "%s\n", regionAttrs.regionBase);
       }
    
       goto check;
    
       NVS_close(nvsHandle);
    
       return (NULL);
    }
    
    /*
     *  ======== mainThread ========
     */
    void *mainThread(void *arg0)
    {
        pthread_t           thread0;
        pthread_attr_t      attrs;
        struct sched_param  priParam;
        int                 retc;
        int                 detachState;
    
        /* Call driver init functions. */
        Display_init();
        GPIO_init();
    
        /* Configure the LED pins */
        GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
        GPIO_setConfig(Board_GPIO_LED1, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    
        /* Open the display for output */
        display = Display_open(Display_Type_UART, NULL);
        if (display == NULL) {
            /* Failed to open display driver */
            while (1);
        }
    
        /* Turn on user LED */
        GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
    
        Display_printf(display, 0, 0, "Starting the SPI master example");
        Display_printf(display, 0, 0, "This example requires external wires to be "
            "connected to the header pins. Please see the Board.html for details.\n");
    
        /* Create application threads */
        pthread_attr_init(&attrs);
    
        detachState = PTHREAD_CREATE_DETACHED;
        /* Set priority and stack size attributes */
        retc = pthread_attr_setdetachstate(&attrs, detachState);
        if (retc != 0) {
            /* pthread_attr_setdetachstate() failed */
            while (1);
        }
    
        retc |= pthread_attr_setstacksize(&attrs, THREADSTACKSIZE);
        if (retc != 0) {
            /* pthread_attr_setstacksize() failed */
            while (1);
        }
    
        /* Create master thread */
        priParam.sched_priority = 1;
        pthread_attr_setschedparam(&attrs, &priParam);
    
        retc = pthread_create(&thread0, &attrs, masterThread, NULL);
        if (retc != 0) {
            /* pthread_create() failed */
            while (1);
        }
    
        return (NULL);
    }
    

    Vasu

  • Have you tried this with the Launchpad and off board M25 device? Does that work? I'd really like to have a setup that is the same as yours.
  • Launchpad + external pcb flash.
    previous post attached code working fine after added delay.
    writing more than 256 bytes having issue .
    any issue is there for this flash MX25L6433F ?
    TI supports MX25Rxx flash but i am using MX25Lxx series.
  • Can you please tell me your wiring for the Launchpad + external M25 device? I need an exact system to look into this. By exact wiring I mean, boosterpack pin X on the launchpad is connected to Pin Y on the M25 and I need this for all the pins.

    Todd
  • Hi,

    I believe this is an issue with the spiBitRate in your NVS configuration. The maximum SPI bit Rate supported by the CC3220S/SF is 20Mhz. Please update this configuration to 10Mhz and report back if you are still reading junk data.

    Jas
  • Hi Todd,

    CC3220SF Launch Pad

    P05 - CLK,

    P06 - MISO

    P07 - MOSI,

    P08 - CS (Custom gpio cs passing to nvs driver).

    I attached flash schematic.

    Vasu

  • Hi Jaskaran,

    Previously i used 20MHz now changed to 10MHz now also same issue.

    /*
     * =============================== NVS ===============================
     */
    #include <ti/drivers/NVS.h>
    #include <ti/drivers/nvs/NVSSPI25X.h>
    //.regionSize = 8388608,
    
    uint8_t verifyBuf[256];
    
       NVSSPI25X_HWAttrs nvsSPIHWAttrs[2] = {
           //
           // region 0 is 1 flash sector in length.
           //
           {
               .regionBaseOffset = 0,
               .regionSize = 8388608,
               .sectorSize = 4096,
               .verifyBuf = verifyBuf,
               .verifyBufSize = 256,
               .spiHandle = NULL,
               .spiIndex = 1,
               .spiBitRate = 10000000,
               .spiCsnGpioIndex = CC3220SF_Custom_CS,
               .statusPollDelayUs = 1000,
           },
           //
           // region 1 is 3 flash sectors in length.
           //
           {
               .regionBaseOffset = 4096,
               .regionSize = 8388608,
               .sectorSize = 4096,
               .verifyBuf = verifyBuf,     // use shared verifyBuf
               .verifyBufSize = 256,
               .spiHandle = NULL,
               .spiIndex = 1,
               .spiBitRate = 20000000,
               .spiCsnGpioIndex = CC3220SF_Custom_CS,
           }
       };
    
    
    
    NVSSPI25X_Object nvsMXObjects[CC3220SF_MX25_NVSCOUNT];
    
    
    const NVS_Config NVS_config[CC3220SF_MX25_NVSCOUNT] = {
        {
            .fxnTablePtr = &NVSSPI25X_fxnTable,
            .object = &nvsMXObjects[0],
            .hwAttrs = &nvsSPIHWAttrs[0],
        },
    };
    
    const uint_least8_t NVS_count = CC3220SF_MX25_NVSCOUNT;

    Vasu

  • Hi Vasu,

    I have your project running with the latest spimaster.c file you attached. I am having trouble seeing where you are receiving junk data. You start by erasing the flash sector and reading from the NVS region before anything is written to it and that is the only time you receive junk data. The next two read and writes work as expected. Can you let me know if I am getting different behavior than what you see?

    Jas
  • Hi Jaskaran,

    Writing and reading data size is below 256 bytes working fine.

    If i increase writing data size to more than 256 bytes while reading i am getting only first line and last line data in between only junk data is there.

    I attached spimater.c check this one.

    Here i added signature data size is more than 256 bytes.

    /*
     *  ======== spimaster.c ========
     */
    #include <stdbool.h>
    #include <stddef.h>
    #include <stdint.h>
    #include <string.h>
    
    /* POSIX Header files */
    #include <pthread.h>
    #include <semaphore.h>
    #include <unistd.h>
    
    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/display/Display.h>
    #include <ti/drivers/NVS.h>
    #include <ti/drivers/NVS.c>
    
    #include <ti/drivers/nvs/NVSSPI25X.h>
    #include <ti/drivers/nvs/NVSSPI25X.c>
    
    /* Example/Board Header files */
    #include "Board.h"
    
    #define THREADSTACKSIZE (4024)
    
    #define SPI_MSG_LENGTH  (21)
    //#define SPI_MSG_LENGTH  (4)
    #define MASTER_MSG      ("Hello from master, msg#: ")
    
    #define MAX_LOOP        (10)
    
    #define FOOTER "=================================================="
    
    /* Buffer placed in RAM to hold bytes read from non-volatile storage. */
    static char buffer[1200];
    
    /*
     * Some devices have a minimum FLASH write size of 4-bytes (1 word). Trying
     * to write a non-multiple of 4 amount of data will fail. This array is
     * rounded up (to next multiple of 4) to meet this requirement. Refer to NVS
     * driver documentation for more details.
     */
    //static const char signature[52] =
    //    {"SimpleLink SDK Non-Volatile Storage (NDK) Example."};
    
    static const char signature[] =
            "-----BEGIN CERTIFICATE-----\r\n"
            "MIICizCCAfQCCQC9wRaASarXVzANBgkqhkiG9w0BAQUFADCBiTELMAkGA1UEBhMC\r\n"
            "VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExDzANBgNVBAcMBkdvbGV0YTELMAkGA1UE\r\n"
            "CgwCVEkxEzARBgNVBAsMCmR1bW15X3Jvb3QxEzARBgNVBAMMCmR1bW15X3Jvb3Qx\r\n"
            "HTAbBgkqhkiG9w0BCQEWDnJvb3RAZHVtbXkuY29tMB4XDTE3MTEyNzE4MDcwOFoX\r\n"
            "DTI3MTEyNTE4MDcwOFowgYkxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9y\r\n"
            "bmlhMQ8wDQYDVQQHDAZHb2xldGExCzAJBgNVBAoMAlRJMRMwEQYDVQQLDApkdW1t\r\n"
            "eV9yb290MRMwEQYDVQQDDApkdW1teV9yb290MR0wGwYJKoZIhvcNAQkBFg5yb290\r\n"
            "QGR1bW15LmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAttRn99pMw3no";
    
    
    
    
    static Display_Handle display;
    
    void *masterThread(void *arg0)
    {
        int_fast16_t ret;
        NVS_Handle nvsHandle;
        NVS_Attrs regionAttrs;
        NVS_Params nvsParams;
    
        Display_init();
        NVS_init();
    
        NVS_Params_init(&nvsParams);
        nvsHandle = NVS_open(Board_NVSINTERNAL, &nvsParams);
    
        if (nvsHandle == NULL) {
            Display_printf(display, 0, 0, "NVS_open() failed.");
    
            return (NULL);
        }
    
        Display_printf(display, 0, 0, "\n");
    
        /*
         * This will populate a NVS_Attrs structure with properties specific
         * to a NVS_Handle such as region base address, region size,
         * and sector size.
         */
        NVS_getAttrs(nvsHandle, &regionAttrs);
    
        /* Display the NVS region attributes */
        Display_printf(display, 0, 0, "Region Base Address: 0x%x",
                regionAttrs.regionBase);
        Display_printf(display, 0, 0, "Sector Size: 0x%x",
                regionAttrs.sectorSize);
        Display_printf(display, 0, 0, "Region Size: 0x%x\n",
                regionAttrs.regionSize);
    
    check:
       /* Erase the entire flash sector. */
        //NVS_lock(nvsHandle, 10000);
        usleep(20000);
        ret = NVS_erase(nvsHandle, 0, regionAttrs.sectorSize);
        //NVS_unlock(nvsHandle);
        //ret = NVS_control(nvsHandle, 32, 0);
    
       /* The signature was not found in the NVS region. */
       Display_printf(display, 0, 0, "Writing signature to flash...");
    
       /* Write signature to memory. The flash sector is erased prior
       * to performing the write operation. This is specified by
       * NVS_WRITE_ERASE.
       */
       //NVS_lock(nvsHandle, 10000);
       //NVS_unlock(nvsHandle);
       usleep(20000);
       ret = NVS_write(nvsHandle, 0, (void *) signature, sizeof(signature), 0);
       usleep(20000);
       ret = NVS_read(nvsHandle, 0, (void *) buffer, sizeof(signature));
       Display_printf(display, 0, 0, "Data - %s \r\n", buffer);
    
       if (regionAttrs.regionBase != NVS_REGION_NOT_ADDRESSABLE) {
           Display_printf(display, 0, 0, "%s\n", regionAttrs.regionBase);
       }
    
       goto check;
    
       NVS_close(nvsHandle);
    
       return (NULL);
    }
    
    /*
     *  ======== mainThread ========
     */
    void *mainThread(void *arg0)
    {
        pthread_t           thread0;
        pthread_attr_t      attrs;
        struct sched_param  priParam;
        int                 retc;
        int                 detachState;
    
        /* Call driver init functions. */
        Display_init();
        GPIO_init();
    
        /* Configure the LED pins */
        GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
        GPIO_setConfig(Board_GPIO_LED1, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    
        /* Open the display for output */
        display = Display_open(Display_Type_UART, NULL);
        if (display == NULL) {
            /* Failed to open display driver */
            while (1);
        }
    
        /* Turn on user LED */
        GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
    
        Display_printf(display, 0, 0, "Starting the SPI master example");
        Display_printf(display, 0, 0, "This example requires external wires to be "
            "connected to the header pins. Please see the Board.html for details.\n");
    
        /* Create application threads */
        pthread_attr_init(&attrs);
    
        detachState = PTHREAD_CREATE_DETACHED;
        /* Set priority and stack size attributes */
        retc = pthread_attr_setdetachstate(&attrs, detachState);
        if (retc != 0) {
            /* pthread_attr_setdetachstate() failed */
            while (1);
        }
    
        retc |= pthread_attr_setstacksize(&attrs, THREADSTACKSIZE);
        if (retc != 0) {
            /* pthread_attr_setstacksize() failed */
            while (1);
        }
    
        /* Create master thread */
        priParam.sched_priority = 1;
        pthread_attr_setschedparam(&attrs, &priParam);
    
        retc = pthread_create(&thread0, &attrs, masterThread, NULL);
        if (retc != 0) {
            /* pthread_create() failed */
            while (1);
        }
    
        return (NULL);
    }
    

    Vasu

  • Hi Vasu,

    I tested with the new spimaster.c file you sent with the larger signature size and I am still able to read back the correct signature as seen in the screenshot below. Please check with a logic analyzer if you are actually writing and reading the correct signature from the external flash. 

    Thanks,

    Jas

  • Hi Jaskaran,

    We don't have logic analyzer. I check with CRO.

    I used MX25L6433F flash.

    What flash you used (part number) ? 

    Same code but i am not able to receive full data.

    May be this model issue but all instruction same why i am not able to receive data ?

    Vasu

  • Hi Vasu,

    I am using the W25Q64 flash module. I am sorry but It is difficult to debug further what the problem could be Without waveforms from a logic analyzer on your specific setup.

    Jas
  • Vasu,

    I'm not sure what else we can do on our side since we cannot reproduce your issue and you cannot get us the additional information (via logic analyzer). Therefore, I'm going to mark this as TI Thinks Resolved.

    Todd