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

Flash data in Hardfault handler

Hello Nordic,

I'm developing app with nrf52840, SDK15.3.0 and s340.

The work almost has done, so we need to test ourdoor.

The problem is that we don't find out the crash location.

We can find out the crash location indoor because of JLink.

So I try to write in flash if it is crashed. But It doesn't make it.

I check invoking fuction, which is called fds_record_write.

Pleas how to do that.

Parents
  • Hello,

    Depending on the fault it may be difficult to reliably write the crash log to flash. I think it's easier to write the information to a non-initialized section of RAM, perform a reset, then on subsequent boot, check the RAM content and write it to flash.

    If you use Segger embedded Studio you can use the ".non_init" section to place the data. 

    e.g., 

    static char error_info[128] __attribute__((section(".non_init")));
    static uint16_t crc __attribute__((section(".non_init")));
    
    /* Call this function on startup to see if there is any new error 
     *  information available
     */
    void check_error_info()
    {
        uint32_t len;
        
        if ( crc == crc16_compute(error_info, sizeof(error_info), NULL))
        {
            crc = 0;
            len = strlen(error_info);
            if (len > sizeof(error_info)) len = sizeof(error_info);
            //store error information to flash
            //TODO: write error info to flash 
            NRF_LOG_INFO("%s", error_info);
        }
    }
    
    /*Read error information from flash */
    void get_error_info(uint32_t * p_data)
    {  
        *p_data = (uint32_t) error_info;
        memset(error_info, 0, sizeof(error_info));
        // flash_read(p_data, p_src)
    }
    

  • Thank for your answer.

    However, I am using eclipse with gcc.

    Would you re-write the way ?

Reply Children
Related