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.

LAUNCHXL-CC26X2R1: writing mx25r memory in launchpad via NVS driver

Guru 18605 points
Part Number: LAUNCHXL-CC26X2R1
Other Parts Discussed in Thread: SYSCONFIG

Hi buddies,

Just curious about something today I lost some time with.

I configured sysconfig to access and use the MX25R on the cc26x2r launchpad via SPI, the one which CS is DIO_20.

I have my small test program consisting of:

flash_open();

eraseFlashPg(0);
Task_sleep(100000);

uint8_t * s = "1234567";
writeFlash(0, s, 10);
Task_sleep(100000);

uint8_t r[10] = {0};
readFlash(0, r, 10);

flash_close();

At the end of it I just compare "r" to "s".

My writeFlash() function is as easy as:

uint8_t writeFlash(uint_least32_t addr, uint8_t *pBuf, size_t len)
{
    uint8_t flashStat = FLASH_FAILURE;
    uint16_t flags = 0;

    if (is_open)
    {
        if (NVS_write(
                _h,
                addr,
                pBuf,
                len,
                flags) == NVS_STATUS_SUCCESS)
        {
            flashStat = FLASH_SUCCESS;
        }
    }
    return (flashStat);
}

This works if within writeFlash(), the NVS flags are 0.

If I set the flags as 

uint16_t flags = NVS_WRITE_PRE_VERIFY | NVS_WRITE_POST_VERIFY;

it fails with FLASH_FAILURE and nothing is read in "r" variable.

If instead I set the flags as:

uint16_t flags = NVS_WRITE_POST_VERIFY;

it also fails, but the "r" variable content at least is fine.

So my question is simple, why are the flags making this fail? Is because the length content is not 256 for example?

Ok, please let me know and have the nicest Friday!

  • Hi kel,

    I assume you are referencing flash_interface_ext_rtos_NVS.c for your APIs?  The simple peripheral off-chip OAD project shows that NVS_WRITE_PRE_VERIFY can be used while returning successfully when writing flash.  Make sure that flash_open calls NVS_open and NVS_getAttrs, and that your code also uses NVS_init.  You can also evaluate the nvsexternal example although it does not use pre-verification by default.  You could try to first write all contents to zero, and further evaluate the return code if it does not return NVS_STATUS_SUCCESS.

    Regards,
    Ryan