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.

osal_snv_write has different results on same CC2540 chip

Other Parts Discussed in Thread: CC2540

I tried to use "osal_snv_write" to write a few bytes to the NV memory starting at the offset of 0x80.

I can successfully write to NV with CC2540EM+SmartRF05. However, when I download the same firmware to the Blue Giga BLE112A module, the write operation cannot be completed (the return value is not SUCCESS).

Anyone has suggestion on this issue?

  • First I suggest you read the code, its the best way to improve your skills!   You can find the source in Components/osal/mcu/cc2540/osal_snv.c

    Looking at the code, some possible causes:

    * flash erase failure...maybe its a problem with the specific chip in your module?

    * flash write failure...

    Finally there seems to be an error condition which handling has been disabled and the problem will persist indefinitely.  In the code for static void compactPage( uint8 srcPg )  there is an error case which should be handled by an erase page but there is long comment that says:

             // invalid length. Source page must be a corrupt page.
              // This is possible only if the NV initialization failed upon erasing
              // what is selected as active page.
              // This is supposed to be a very rare case, as power should be
              // shutdown exactly during erase and then the page header is
              // still retained as either the Xfer or the Active state.

              // For production code, it might be useful to attempt to erase the page
              // so that at next power cycle at least the device is runnable
              // (with all entries removed).
              // However, it might be still better not to attempt erasing the page
              // just to see if this very rare case actually happened.
              //erasePage(srcPg);

    If you get this error it will remain unfixed for every osal_snv_write.  The only solution is to clear the entire flash and then reload the image.  OR make a new image with erasePage uncommented so it will fix the error.