This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Getting RAM and Flash data corruption in runtime.

Hi Team,

we are using the Nrf52840 board for our development. We are facing one issue with RAM Structure Corruption.

We have one Global structure in our code, in that one of the variable is corrupting which is linking with other RAM Variable , it is not part of structure.

Eg:

typedef struct
{ 

uint8_t BLE_MAC_ID[6];
uint8_t sbSysFlags[4]; // 32 bit variable system wide flags
uint16_t FLA_Reserve9;

uint16_t Sb_Err_Value;
uint16_t Reserve;

uint16_t kpda_kpin_crc[2];
uint16_t ksys_kbox_kold_crc[3];
uint16_t FLA_Reserve10;

}FLA_FS_sysStruct_t;

FLA_FS_sysStruct_t m_Sb_Secure_data ={0};

bool Crc_check_flag = 0;

when ever the "Crc_check_flag" got updated in runtime  "m_Sb_Secure_data.Sb_Err_Value" also updating automatically. but there is link between these two variables, both are indepnedent each other, but both are declared and updated in same .c file, but no linkage between these two. How to detect what is the root cause for this detection.Is there any way to identify the stack and RAM overflows. 

1. Suppose if want to put the one specific structure in Specific RAM location and no other parts of the code should not disturb this location or data.

2. Similar way for flash as well, if we block one flash sector(0x5e000)  for application usage, how to avoid this one by other code parts to overwrite.

It is very urgent for me, if any one having some solution it is very helpful to us.

Regards,

Srinivas.V

Parents
  • there is link between these two variables

    Did you mean no link ?

    What IDE are you using?

    You should be able to use data breakpoints to catch writes ... ?

  • Hi Awneil,

    Thanks for your reply. We are using the IAR ide for our development.

    Can you give more insight on how to use the data breakpoints and catch the writes to particular data variables.

    I have added the code snippet for the same. 

    " when ever the "Crc_check_flag" got updated in runtime  "m_Sb_Secure_data.Sb_Err_Value" also updating automatically. but there is link between these two variables, both are indepnedent each other, but both are declared and updated in same .c file, but no linkage between these two. How to detect what is the root cause for this detection.Is there any way to identify the stack and RAM overflows. "

    /*---------------------------------------------------------------------------
    ** Data
    */
    bool Crc_check_flag = 0;
    uint8_t Sb_Error_Code = 0x00;
    
    // The following constants are stored in customer configuration flash (CCFG) as default initializers only.
    // Any changes to defaults will be stored in external flash or a different region of internal flash.
    FLA_FS_sysStruct_t m_Sb_Secure_data = 
    {
       .BLE_MAC_ID                      =       { 0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF},
      .sbSysFlags                      =       { 0x00,0x00,0x00,0x00},       // 32 bit variable system wide flags 
      .FLA_Reserve9                    = 0x00,
       
      .Sb_Err_Value = 0x0000,
      .Reserve     = 0x0000,
        
      .kpda_kpin_crc =      {0x6a0a, 0x6a0a},
      .ksys_kbox_kold_crc = {0x6a4b, 0x6a4b, 0x6a4b},
      .FLA_Reserve10  = 0x00
        
    };
    
    

Reply
  • Hi Awneil,

    Thanks for your reply. We are using the IAR ide for our development.

    Can you give more insight on how to use the data breakpoints and catch the writes to particular data variables.

    I have added the code snippet for the same. 

    " when ever the "Crc_check_flag" got updated in runtime  "m_Sb_Secure_data.Sb_Err_Value" also updating automatically. but there is link between these two variables, both are indepnedent each other, but both are declared and updated in same .c file, but no linkage between these two. How to detect what is the root cause for this detection.Is there any way to identify the stack and RAM overflows. "

    /*---------------------------------------------------------------------------
    ** Data
    */
    bool Crc_check_flag = 0;
    uint8_t Sb_Error_Code = 0x00;
    
    // The following constants are stored in customer configuration flash (CCFG) as default initializers only.
    // Any changes to defaults will be stored in external flash or a different region of internal flash.
    FLA_FS_sysStruct_t m_Sb_Secure_data = 
    {
       .BLE_MAC_ID                      =       { 0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF},
      .sbSysFlags                      =       { 0x00,0x00,0x00,0x00},       // 32 bit variable system wide flags 
      .FLA_Reserve9                    = 0x00,
       
      .Sb_Err_Value = 0x0000,
      .Reserve     = 0x0000,
        
      .kpda_kpin_crc =      {0x6a0a, 0x6a0a},
      .ksys_kbox_kold_crc = {0x6a4b, 0x6a4b, 0x6a4b},
      .FLA_Reserve10  = 0x00
        
    };
    
    

Children
Related