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

Softdevice fault

Hello,

I am developing product on nrf52 with sd s112_nrf52810_5.1.0_softdevice. My application caused unexpected sd fault at adress 0x000089B2. I expect it to be something related to flash. What I did was call sd flash write function with some data and then I executed power off procedure. I dont know but I might have been interrupted. Then at the start I try to read that data and rewrite it if some checks pass. Can you let me know what causes fault from that address ?

EDIT: I should also mention that if that write wont find enough space in fds then it will execute garbage collector so it is also possible power off will execute in middle of garbage collector, so possibly in eg middle of page erase. 

Regards,

Michal

Parents
  • Hi,

    Michal managed to fix this issue. I would like to share with you our findings. 

    It looks like workaround from MDK for Errata 36 does not cover all corner cases.

    Our hypothesis: Calibration is not terminated by reset.

    We extended system_nrf52.c with this code:

    void SystemInit(void)
    {
     (...)
        /* Workaround for Errata 36 "CLOCK: Some registers are not reset when expected" found at the Errata document
           for your device located at https://infocenter.nordicsemi.com/  */
        if (errata_36()){
            NRF_CLOCK->EVENTS_DONE = 0;
            NRF_CLOCK->EVENTS_CTTO = 0;
            NRF_CLOCK->CTIV = 0;
        }
    
        lfclk_calibrate();
     (...)
    }
     
    
    static void lfclk_calibrate(void)
    {
        // Turn on HFCLK XTAL
        NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_HFCLKSTART = 1;
        while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
        {
        }
    
        // Start LFCLK (32kHz) RC oscillator.
        NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos;
        NRF_CLOCK->EVENTS_LFCLKSTARTED =0;
        NRF_CLOCK->TASKS_LFCLKSTART = 1;
        while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);
        NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
    
        // Calibrate
        NRF_CLOCK->EVENTS_DONE = 0;
        NRF_CLOCK->TASKS_CAL = 1;
        while (NRF_CLOCK->EVENTS_DONE == 0)
        {
        }
        // Turn off HFCLK XTAL
        NRF_CLOCK->TASKS_HFCLKSTOP = 1;
    
        // Turn off LFCLK
        NRF_CLOCK->TASKS_LFCLKSTOP = 1;
    }

    This solved this problem.

Reply
  • Hi,

    Michal managed to fix this issue. I would like to share with you our findings. 

    It looks like workaround from MDK for Errata 36 does not cover all corner cases.

    Our hypothesis: Calibration is not terminated by reset.

    We extended system_nrf52.c with this code:

    void SystemInit(void)
    {
     (...)
        /* Workaround for Errata 36 "CLOCK: Some registers are not reset when expected" found at the Errata document
           for your device located at https://infocenter.nordicsemi.com/  */
        if (errata_36()){
            NRF_CLOCK->EVENTS_DONE = 0;
            NRF_CLOCK->EVENTS_CTTO = 0;
            NRF_CLOCK->CTIV = 0;
        }
    
        lfclk_calibrate();
     (...)
    }
     
    
    static void lfclk_calibrate(void)
    {
        // Turn on HFCLK XTAL
        NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_HFCLKSTART = 1;
        while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
        {
        }
    
        // Start LFCLK (32kHz) RC oscillator.
        NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos;
        NRF_CLOCK->EVENTS_LFCLKSTARTED =0;
        NRF_CLOCK->TASKS_LFCLKSTART = 1;
        while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);
        NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
    
        // Calibrate
        NRF_CLOCK->EVENTS_DONE = 0;
        NRF_CLOCK->TASKS_CAL = 1;
        while (NRF_CLOCK->EVENTS_DONE == 0)
        {
        }
        // Turn off HFCLK XTAL
        NRF_CLOCK->TASKS_HFCLKSTOP = 1;
    
        // Turn off LFCLK
        NRF_CLOCK->TASKS_LFCLKSTOP = 1;
    }

    This solved this problem.

Children
No Data
Related