2013年1月20日 星期日

[CC253x][Z-Stack] OSAL NV System - Item/data Length Limitation

    For some reasons, I have to store bulky data (slightly > 5kB, from ZigBee's aspect), receving from  remote, to NVRAM. In order to minimize the effort, I tried to leverage OSAL_NV API to speedup the work. The related API information can be found at "OS Abstraction Layer Application Programming Interface", SWRA194.pdf.

    By referencing other application using OSAL NV memory API, I added osal_nv_item_init() in my application initialization function. However, it returned NV_OPER_FAILED all the time. I traced the code and found that the error is due to written length limitation of OSAL NV system.


    CC2530 flash memory uses 2k page. Apparently OSAL NV doesn't manipulate data item cross page, i.e. item cannot be stored partially at page 1 and the rest at page 2. Thus, the maximum item size can be stored is 2048(byte) - 8(page header) - 8(item header) = 2032 bytes

Page header @ OSAL_nv.c

typedef struct
{
  uint16 active;
  uint16 inUse;
  uint16 xfer;
  uint16 spare;
} osalNvPgHdr_t;

Item header @ OSAL_nv.c

typedef struct
{
  uint16 id;
  uint16 len;   // Enforce Flash-WORD size on len.
  uint16 chk;   // Byte-wise checksum of the 'len' data bytes of the item.
  uint16 stat;  // Item status.
} osalNvHdr_t;



I am still thinking whether it's better to use OSAL NV API or writing customized helper functions to store my data > 2kB.






沒有留言:

張貼留言