Flash operations do not work in the hard fault handler (HardFault_c_handler function).

Hi,

I want to log the error type and program counter when a hard fault occurred. I implemented some algorithm for that, I am using fds library for saving this information to flash. I do not get an error when saving hard fault information on the flash. 

How can i save hard fault information to the flash?

Parents Reply
  • I see the same value every time.

    I erased flash using nrfjprog. then I run this code. I see the same value (it was 0 )every reset.

    #define ADDRESS_OFF_TEST                    0x45000
    
    void flash_set_data(const uint8_t * src){
        nrf_nvmc_write_bytes(ADDRESS_OFF_TEST, src, sizeof(uint8_t));
    }
    
    void flash_get_data(uint8_t * dst){
        memcpy(dst, (uint8_t*)ADDRESS_OFF_TEST, sizeof(uint8_t));
    }
    int main(void)
    {
        nrf_delay_ms(10000);
    
        uint8_t  buffer[1];
        flash_get_data(buffer);
    
        BB_printf(LOG_FATAL, "Counter : %u", buffer[0]);
    
        buffer[0] = buffer[0] + 1;
        flash_set_data(buffer);
    
        nrf_delay_ms(10000);
    
        NVIC_SystemReset();
    }

    I think my problem is not about enabling or disabling the soft device.

    FDS_BACKEND 1 in sdk_config.
Children
Related