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

BLE CC2540 flash存储问题

大家好!

现在我遇到一个问题:

CC2540 flash存储一般都是用osal_snv_read和osal_snv_write写的吗?

数据手册上说CC2540有2048个字节大小,那么osal 的 NV ID号最大可以定义多大?一条NV ID可以存几个字节?

谢谢!

xie weiping:

The flash controller handles writing and erasing the embedded flash memory. The embedded flashmemory consists of up to 128 pages of 2048 bytes (CC2530/CC2531/CC2540/CC2541) or 1024 bytes(CC2533) each.

以上摘自CC2540数据手册,128页,每个页2K大小,那么NV项占多个pages?

Yue TANG:

回复 xie weiping:

取决于 #define HAL_NV_PAGE_CNT 的定义,EB板是2页。 

Yue TANG:

最长255个字节。

已经使用的ID在bcomdef.h中可以找到,要处理自己的接着下面ID写。

// Device NV Items –    Range 0 – 0x1F#define BLE_NVID_IRK                    0x02  //!< The Device's IRK#define BLE_NVID_CSRK                   0x03  //!< The Device's CSRK#define BLE_NVID_SIGNCOUNTER            0x04  //!< The Device's Sign Counter

// Bonding NV Items –   Range  0x20 – 0x5F    – This allows for 10 bondings#define BLE_NVID_GAP_BOND_START         0x20  //!< Start of the GAP Bond Manager's NV IDs#define BLE_NVID_GAP_BOND_END           0x5f  //!< End of the GAP Bond Manager's NV IDs Range

// GATT Configuration NV Items – Range  0x70 – 0x79 – This must match the number of Bonding entries#define BLE_NVID_GATT_CFG_START         0x70  //!< Start of the GATT Configuration NV IDs#define BLE_NVID_GATT_CFG_END           0x79  //!< End of the GATT Configuration NV IDs/** @} End BLE_NV_IDS */

xie weiping:

回复 Yue TANG:

恩,这个我找到了,这里边定义的每个NV ID 都可以直接写入255个字节吗?

但是之前我从一位代理商技术支持那获知,每个NV ID只能存16个字节的数据。

还有就是假设现在定义了两个NV ID,假如第一个NV ID没写满255个字节,那么第二个NV ID它是另取一行吗?即第一个NV ID 和第二个NV ID之间是不是有空闲的可写入的存储空间?

谢谢!

Yue TANG:

回复 xie weiping:

我没测过,看代码对长度的定义是unsigned char,因此认为可以写255,你可以实测一下,忘了一点需要4字节对齐,所以最大应该是252

Yue TANG:

回复 xie weiping:

注意下面的表述,也就是说2K,1K存数据,另1K是做备份。

The main reason for SNV is that it's only possible to erase a page, and not a small area of flash.  As you re-write a SNV data item, the SNV will create a new space for it and write it. The old space will be marked as invalid, and will become free again when that page is erased.  There is only one active page and then a mirror page where the valid items are copied to when the page gets full. I think the max size for everything in SNV is 1K (minus about 250K for bonding info).

xie weiping:

回复 Yue TANG:

恩,也就是说另外1K是不能被使用的咯。好的,非常感谢!这个信息非常重要!

chengwei wang:

回复 xie weiping:

怎样把存储空间扩大到10k呢,求赐教

赞(0)
未经允许不得转载:TI中文支持网 » BLE CC2540 flash存储问题
分享到: 更多 (0)