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 access for network processor mode on cc2540/41

Other Parts Discussed in Thread: CC2540

Hi Sir;

       I want to save some data to the CC2540 under network processor  mode, so  i try  UTIL_NVWrite  API  with NVID above 0x80(NV for application usage). It returns failure with  invalid parameter error.  Then i try another NVID(0x20) listed for GAP Bond Manager, still failed. Can you help to explain this?

      Here lists the packets log for test using btool.

[1] : <Tx> - 05:24:33.284
-Type : 0x01 (Command)
-Opcode : 0xFE82 (UTIL_NVWrite)
-Data Length : 0x10 (16) byte(s)
NvID : 0x80 (128)
NvDataLen : 0x0E (14)
NvData : 01:02:03:04:05:06:07:08:09:10:11:12:00:00
Dump(Tx):
01 82 FE 10 80 0E 01 02 03 04 05 06 07 08 09 10
11 12 00 00
------------------------------------------------------------------------------------------------------------------------
[2] : <Rx> - 05:24:33.301
-Type : 0x04 (Event)
-EventCode : 0xFF (HCI_LE_ExtEvent)
-Data Length : 0x06 (6) bytes(s)
Event : 0x067F (GAP_HCI_ExtentionCommandStatus)
Status : 0x02 (Invalid Parameter)
OpCode : 0xFE82 (UTIL_NVWrite)
DataLength : 0x00 (0)
Dump(Rx):
04 FF 06 7F 06 02 82 FE 00
------------------------------------------------------------------------------------------------------------------------

[1] : <Tx> - 05:13:04.384
-Type : 0x01 (Command)
-Opcode : 0xFE82 (UTIL_NVWrite)
-Data Length : 0x10 (16) byte(s)
NvID : 0x20 (32)
NvDataLen : 0x0E (14)
NvData : 01:02:03:04:05:06:07:08:09:10:11:12:00:00
Dump(Tx):
01 82 FE 10 20 0E 01 02 03 04 05 06 07 08 09 10
11 12 00 00
------------------------------------------------------------------------------------------------------------------------
[2] : <Rx> - 05:13:04.400
-Type : 0x04 (Event)
-EventCode : 0xFF (HCI_LE_ExtEvent)
-Data Length : 0x06 (6) bytes(s)
Event : 0x067F (GAP_HCI_ExtentionCommandStatus)
Status : 0x02 (Invalid Parameter)
OpCode : 0xFE82 (UTIL_NVWrite)
DataLength : 0x00 (0)
Dump(Rx):
04 FF 06 7F 06 02 82 FE 00

  • Hello. Firstly, you were correct in using the application NV ID's (i.e. 0x80). The stack ID's should not be used by the customer / application.

    In order to use this, you must modify the embedded software (HostTestRelease) to add length checking for your custom ID's.  Here is an example where for a one-block (4 byte) write:

    static uint8 checkNVLen( osalSnvId_t id, osalSnvLen_t len )
    {
      uint8 stat = SUCCESS;
    
      switch ( id )
      {
    ...
            case BLE_NVID_CUSTOMER1
          if ( len != sizeof ( uint32 ) )
          {
            stat = INVALIDPARAMETER;
          }
          break;
    ...
    }

    You should also define your ID (i.e. BLE_NVID_CUSTOMER1) in bcomdef.h where the other ID's are defined.

  • Hi Tim,

    Thanks for your reply. It works.