TI中文支持网
TI专业的中文技术问题搜集分享网站

CC1310的NVS异常

您好!

我有两个问题:

1、我以前使用的simplelink_cc13x0_sdk_1_40_00_10调试CC1310(Launchxl)的NVS功能是正常, 但是在5*5的模块上运行却是异常,请问是什么原因呢?

 

2、看到最新的库文件tirtos_cc13xx_cc26xx_2_21_00_06,却发现里面的NVS操作已经发生的变化,同时在示例里面也没有了NVS的演示代码 ,使用simplelink_cc13x0_sdk_1_40_00_10移植后的,发现NVS根本不能工作。我的代码如下:

board.h

/*!  *  @def    CC1310_LAUNCHXL_NVSName  *  @brief  Enum of NVS names  */ typedef enum CC1310_LAUNCHXL_NVSName {     CC1310_LAUNCHXL_NVSCC26XX0 = 0,     CC1310_LAUNCHXL_NVSSPI25X0,

    CC1310_LAUNCHXL_NVSCOUNT } CC1310_LAUNCHXL_NVSName;

board.c

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

#define NVS_REGIONS_BASE 0x1B000 #define SECTORSIZE       0x1000 #define REGIONSIZE       (SECTORSIZE * 4) #define VERIFYBUFSIZE    64

static uint8_t verifyBuf[VERIFYBUFSIZE];

/*  * Reserve flash sectors for NVS driver use by placing an uninitialized byte  * array at the desired flash address.  */ #if defined(__TI_COMPILER_VERSION__)

/*  * Place uninitialized array at NVS_REGIONS_BASE  */ #pragma LOCATION(flashBuf, NVS_REGIONS_BASE); #pragma NOINIT(flashBuf); static char flashBuf[SECTORSIZE * 4];

#elif defined(__IAR_SYSTEMS_ICC__)

/*  * Place uninitialized array at NVS_REGIONS_BASE  */ __no_init static char flashBuf[SECTORSIZE * 4] @ NVS_REGIONS_BASE;

#elif defined(__GNUC__)

/*  * Place the reserved flash buffers in the .nvs section.  * The nvs section will be placed at address NVS_REGIONS_BASE by  * the gcc linker cmd file.  */ __attribute__ ((section (".nvs"))) static char flashBuf[SECTORSIZE * 4];

#endif

/* Allocate objects for NVS and NVS SPI */ NVSCC26XX_Object nvsCC26xxObjects[1]; NVSSPI25X_Object nvsSPI25XObjects[1];

/* Hardware attributes for NVS */ const NVSCC26XX_HWAttrs nvsCC26xxHWAttrs[1] = {     {         .block = (void *)flashBuf,         .blockSize = SECTORSIZE * 4,     }, };

/* Hardware attributes for NVS SPI */ const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = {     {         .regionBaseOffset = 0,         .regionSize = SECTORSIZE * 4,         .sectorSize = SECTORSIZE,         .verifyBuf = verifyBuf,         .verifyBufSize = 64,         .spiHandle = NULL,         .spiIndex = 0,         .spiBitRate = 4000000,        // .*** = CC1310_LAUNCHXL_GPIO_SPI_FLASH_CS,     }, };

/* NVS Region index 0 and 1 refer to NVS and NVS SPI respectively */ const NVS_Config NVS_config[CC1310_LAUNCHXL_NVSCOUNT] = {     {         .fxnTablePtr = &NVSCC26XX_fxnTable,         .object = &nvsCC26xxObjects[0],         .hwAttrs = &nvsCC26xxHWAttrs[0],     },     {         .fxnTablePtr = NULL,         .object = &nvsSPI25XObjects[0],         .hwAttrs = &nvsSPI25XHWAttrs[0],     }, };

const uint_least8_t NVS_count = CC1310_LAUNCHXL_NVSCOUNT;

 

NVS_1310.c

void NvsThread(void) {     NVS_Handle nvsHandle;     NVS_Attrs regionAttrs;     NVS_Params nvsParams;

    NVS_init();

    NVS_Params_init(&nvsParams);     nvsHandle = NVS_open(Board_NVS0, &nvsParams);

    if (nvsHandle == NULL) {     //    Display_printf(displayHandle, 0, 0, "NVS_open() failed.");

        return  ;     }

    NVS_getAttrs(nvsHandle, &regionAttrs);

    /* Print NVS region details */  /*   Display_printf(displayHandle, 0, 0, "Region Base Address: 0x%x",             regionAttrs.regionBase);     Display_printf(displayHandle, 0, 0, "Sector Size: 0x%x",             regionAttrs.sectorSize);     Display_printf(displayHandle, 0, 0, "Region Size: 0x%x\n",             regionAttrs.regionSize); */     NVS_read(nvsHandle, 0, (void *) buf, sizeof(signature));

    /* Determine if flash contains signature string */     if (strcmp((char *) buf, (char *) signature) == 0) {

        /* Erase the entire flash region */         NVS_erase(nvsHandle);//, 0, regionAttrs.blockSize);         NVS_write(nvsHandle, 0, (void *) signature, sizeof(signature),                    NVS_WRITE_ERASE | NVS_WRITE_VALIDATE);// NVS_WRITE_POST_VERIFY);     }     else {       //  Display_printf(displayHandle, 0, 0, "Writing signature to flash…");

        /* Write signature to memory */         NVS_write(nvsHandle, 0, (void *) signature, sizeof(signature),             NVS_WRITE_ERASE | NVS_WRITE_VALIDATE);// NVS_WRITE_POST_VERIFY);     }

    NVS_read(nvsHandle, 0, (void *) buf, sizeof(signature));

    return  ; }

操作以上代码,发现nvsHandle一直为null。

 

另外,我在7*7或者5*5上尝试了都是一样。

谢谢!

Viki Shi:

最新的 CC1310SDK里面有NVS的内容,建议参考。下载地址: www.ti.com.cn/…/simplelink-cc13x0-sdk

赞(0)
未经允许不得转载:TI中文支持网 » CC1310的NVS异常
分享到: 更多 (0)