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.

NV Initialization failed

Other Parts Discussed in Thread: CC2540

Hello,

I am experiencing some problems with flashing on my cc2540 128kB custom board running stack 1.3.2. The original idea was to flash 2 bytes into the chip using osal_snv_write function at id 0x80. I modified simpleBLEPeripheral to my uses by adding a flash write event and a flash read event. However, writing fails as when I read it back I only get 0x0000.

I then put break points in my code to pin point where the flash process is failing. This is what I found:

- osal_snv_init() calls initNV()

- initNV() finds that pgHdr does not equal OSAL_NV_XFER_PAGE_STATE or OSAL_NV_ACTIVE_PAGE_STATE

- after erasing (cleanErasedPage) 2 pages, the init function finds activePg is = OSAL_NV_PAGE_NULL and xferPg = OSAL_NV_PAGE_NULL as well

- the whole function returns false and thus !initNV() is returned in osal_snv_init() and the initialization fails.

Could someone please help me find out why and what I have to do to get it working? I have not changed the project settings much (removed Power Saving, CC2540_MINIDK symbols and changed device description to CC2540F128 instead of the default CC2540F256).

Apologies in advance if I have misunderstood something, I am new to this after all.

Thanks. 

  • Hi Osman,
    Are you programming the device through IAR? It could be that you are erasing the NV pages on each programming, which would cause what you are seeing. Please check the project options.
    Using osal_snv_write and osal_snv_read should work well for a 2-byte variable.

    Peder
  • Ensuring IAR isn't erasing unnecessary flash as Peder said is a good step, but even if there were no active flash page, the init shouldn't return a failure. That only happens when and erase or write fails. Both those conditions are checked for every write and erase.

    init() doesn't return FALSE, it returns !failF. What is setting failF to TRUE?

  • Thank you for both responses. Upon Peder's suggestion (since I am using IAR), I went to project options -> Debugger -> Texas Instruments. In the Download tab I unchecked the Erase Flash option and that automatically checked the Retain unchanged pages box. I recompiled and, with the debugger attached to my board and a breakpoint at HAL_ASSERT_FORCED() in osal_snv_init(), chose Download and Debug.

    Warnings came up: Flash page 0 to Flash page 51 are locked and were not written to, then obviously the verification process for these pages was skipped due to lock bits. This was to be expected (I think).

    However, the initialization is still failing as the break point is still being reached. I will try to find out what is setting failF to TRUE as suggested by Peter.

    Thanks for the help.
  • You probably don't want to write to the lower 51 pages. That is where your program code is stored by default (among other things like interrupt vectors).

  • Hi Osman,
    I agree with Peter. It sounds like you're trying to write to some pages that don't exist or shouldn't be used for NV. Please check hal_board_cfg.h, it may look like HAL_BOARD_F128 is not defined in your project. That would lead it to pick the wrong pages for NV.

    Peder
  • Hello Peder and Peter,

    Thanks for pointing that out. I will change project properties to 128 (following the guidelines here: http://processors.wiki.ti.com/index.php/128kproject) and then test it. Once done, I will update this post appropriately.

    Regards,
    Osman