9 Replies Latest reply on Oct 29, 2015 4:00 PM by MichaelF_56

    NVRAM data lost after reset

    wewu_1392881

      I define one ID in stacknvram.h, during the application initialize, read this ID(1 byte) with bleprofile_ReadNVRAM(), if the value is not the dedicate value application expect, it will be initialize to the dedicated value and write back with bleprofile_WriteNVRAM(). But when the application reset and check this ID again, it seems the value is lost, any idea about this issue?

        • 1. Re: NVRAM data lost after reset

          Hello.

          Are you checking to see if the read/write to NVRAM are successful after calling the methods?

          bleprofile_ReadNVRAM and bleprofile_WriteNVRAM will return the number of bytes read and written to NVRAM, respectively.

          So if the read/write was successful, you should get 1 since you are only using 1 byte. If you get 0, that means the attempt was a fail.

           

          Also when you say that the application resets, do you mean you are pushing the reset button on the board?

           

          James

          • 2. Re: NVRAM data lost after reset
            wewu_1392881

            i checked the return value and after i write, i use the read function to get the flag value, it's the dedicated value i write into it.

            But after i press the reset butter or trig the WDT, the value is missing.

            • 3. Re: NVRAM data lost after reset

              I'll look into reading/writing to NVRAM after reset.

              If you post your source code, I'd be happy to look into it, see if there are any other variables affecting the problem.

               

              James

              • 4. Re: NVRAM data lost after reset
                wewu_1392881

                here is the code:

                define the ID in stacknvram.h

                #define  VS_BLE_USR_DEV_INFO0x10
                #define  VS_BLE_DEV_INFOR_SERVICE0x11
                #define     VS_BLE_ADV_DATA0x12
                #define     VS_BLE_INIT_FLAG0x13

                 

                //Application data structure initialized

                void app_init(void)

                {

                     UINT8 i;

                     static UINT8 init_flag;


                     // Read configure information

                     bleprofile_ReadNVRAM(VS_BLE_INIT_FLAG, 1, &init_flag);

                     ble_trace1("Init flag is %x. \r\n", init_flag);

                     if(INIT_FLAG != init_flag) {

                          // Default application structure and save to NVRAM

                 

                          //Save initialize flag

                          init_flag = INIT_FLAG;

                          i = bleprofile_WriteNVRAM(VS_BLE_INIT_FLAG, 1, &init_flag);

                          if(!i) {

                               ble_trace0("fail to Save init flag\r\n");

                          }

                          else {

                               ble_trace1("Save init flag, length is %d\r\n", i);

                          }

                          bleprofile_ReadNVRAM(VS_BLE_INIT_FLAG, 1, &init_flag);

                          ble_trace1("Read back init flag, value is %d\r\n", init_flag);

                     }

                     else {

                          // Read application structure from NVRAM

                     }

                }

                • 5. Re: NVRAM data lost after reset

                  Hmm.. I've tested your code and it works perfectly fine.

                  The code that you gave me is bug free.

                  Perhaps something else in your code is overwriting or resetting the init_flag in NVRAM.

                   

                  Can you send me the whole source code file?

                  If you are not comfortable uploading the whole file on the forum, you can email me: jamesle1@broadcom.com

                   

                  James

                  • 6. Re: NVRAM data lost after reset
                    wewu_1392881

                    Thanks a lot, i will check this again and see if i can find something, if not, i will send to and ask for your help.

                    • 7. Re: NVRAM data lost after reset

                      Hello.

                       

                      Did everything work out for you?

                       

                      James

                      • 8. Re: NVRAM data lost after reset
                        wewu_1392881

                        still not, i have sent out a email to you just and attached the application files.

                        • 9. Re: NVRAM data lost after reset
                          MichaelF_56

                          We are really struggling to recreate this one internally wewu_1392881

                           

                          userc_19497 was somewhat able to compile the code you provided by commenting out quite a few things that he felt was unrelated to the issue, but when he runs the app, it resets by itself and calls the app_create function multiple times.

                           

                          It would really help if you could recreate the specific issue using one of the sample applications/TAG3 board with a minimal number of changes (i.e. enough to re-create the issue). The internal apps team can then revisit.