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.

CC2530 Flash starting address for users

Other Parts Discussed in Thread: CC2530, Z-STACK

Dear all,

    I have been studying using CC2530 to collect data continuously for a long period of time. The total size I'm about to store is around 100KB (I'm using 256KB version). I first checked out the OSAL.c and tried the method of creating nv_item and read/write the item, but I'm not sure about the max item size and item operations seem to be inside one page (2KB). So if the item size is small, I need a lot of items for my 100KB data. Even worse is that every time I create an item, it also creates a header structure, wasting available memory. I checked the memory space and now I'm able to view the content of each flash bank (only content from 0x800~0xFFFF will change accordingly) in the debug mode, after I added below codes during initialization:

for(int i = 0;i<8;i++)
MEMCTR = i;

But I'm not sure where I can start storing my data without overwriting anything crucial for the zstack. Inside f8w2530.xcl, I can see that there are 7 pages reserved:

// Internal flash used for NV address space: reserving 6 pages.
// NV memory segment size must coincide with page declarations in "hal_board_cfg.h" file.
//
-D_ZIGNV_ADDRESS_SPACE_START=(((_NR_OF_BANKS+1)*_FIRST_BANK_ADDR)-0x3800) //My guessing: (8+1)*0x8000-0x3800=0x4 8000 -0x3800 = 0x4 4800, which is in the bank4 ?
-D_ZIGNV_ADDRESS_SPACE_END=(_ZIGNV_ADDRESS_SPACE_START+0x2FFF)
-Z(CODE)ZIGNV_ADDRESS_SPACE=_ZIGNV_ADDRESS_SPACE_START-_ZIGNV_ADDRESS_SPACE_END

//

// The last available page of flash is reserved for special use as follows
// (addressing from the end of the page down):
// 16 bytes Lock bits
// 8 bytes IEEE address space (EUI-64)
...

As for other 121 pages, I didn't find any information and I'm wondering if these pages are free for use.

Another peculiar thing is that when I increased the bank number, I could see only bank 4,5,6,7 are filled with 0xFFFF (bank 0,1,2,3 are filled with other values), while I had already performed 'erase' using flash programmer. And the last page of bank 7 contained 0xFFFF rather than the information page, which I found is actually in the space 0x7800~0x7FFF (not XBANK space).

Does that mean I can use bank 4~7 without any concern of damaging the firmware?

Thank you very much for your time and I'm looking forward to your replies. Have a nice day. 

Best regards, Ray

  • You have 2 options here:

    Option 1: Store it as an NV item, you will need to test if this is possible, all NV items need to fit inside one page. You also need to consider the Stack usage of NV.

    Liu Rui said:
    But I'm not sure where I can start storing my data without overwriting anything crucial for the zstack. Inside f8w2530.xcl, I can see that there are 7 pages reserved:

    Are you trying to increase the number of NV pages? I would recommend this if you are using NV to store large amounts of application data.

    NV is allocated at the end of flash - 1 page. The last page i the info page. This defines the start of NV in flash: 

    -D_ZIGNV_ADDRESS_SPACE_START=(((_NR_OF_BANKS+1)*_FIRST_BANK_ADDR)-0x3800)

    The start of NV is the end of flash - 7 pages (6 NV + 1 info page) - 7 * 2048 = 0x3800.

    -D_ZIGNV_ADDRESS_SPACE_END=(_ZIGNV_ADDRESS_SPACE_START+0x2FFF)

    The end of NV is equal to the start of NV + 6 pages (2048 * 6 = 0x3000).

    To increase the number of pages for NV add more pages to the 0x3800 when calculating _ZIGNV_ADDRESS_SPACE_START. Then add more pages to the 0x2FFF when calculating _ZIGNV_ADDRESS_SPACE_END. You also need to change HAL_NV_PAGE_CNT in hal_board_cfg.h so the NV driver makes use of the extra pages.

    Option 2: Fit an external SPI Flash to store the data in. There is on fitted to the SmartRF05, you can see an example of using this in C:\Users\a0741319\Documents\LPRF\SVN\SVN_IOT_APPS\Z-Stack Home 1.2.0-S\trunk\Components\hal\target\CC2530EB\hal_oad.c

    Regards, TC.