EMDS bricking device

Hello,

I am using EMDS to store data to flash under certain conditions. The implementation is pretty basic and follows the specification and example in the SDK (v2.1.2). For the most part it works great, but after the 5th time emds_store is called, the device bricks and must be re-flashed to work again. The device is normally reset after every call to emds_store. emds_store is called in an interrupt context (like the examples). 

I have verified the write/erase etc .. timings are correct for the part. I have tried using 1 or 2 sectors - always the same behaviour.

One clue (maybe) is that I store about 702 bytes of data. A page size is 4096 - which means I can fit about 5 copies of my data in the flash before an erase needs to happen. Could this be the issue? How do  I get around this problem?

Parents
  • Hi, 

    The implementation is pretty basic and follows the specification and example in the SDK (v2.1.2).

    Which example are you referring to? Can you provide the path or example name?

    the device bricks and must be re-flashed to work again.

    What does "bricks" mean? Could you provide any log? Do you prepare EMDS using emds_prepare after reboot?

    Regards,
    Amanda H.

  • I used the bluetooth/mesh/light_ctrl example as a guide to add EMDS to my application.

    To initialize I do the following:

    #define SHARED_DATA_EMDS_ID ((int) 0x100)
    EMDS_STATIC_ENTRY_DEFINE(shared_data_store, SHARED_DATA_EMDS_ID, &m_data_element, sizeof(m_data_element));
    uint32_t shared_data_init(void)
    {
    	int err = emds_init(&app_emds_cb);
    	if (err) {
    		printk("Initializing emds failed (err %d)\n", err);
    		return 1;
    	}
    
    	err = emds_load();
    	if (err) {
    		printk("Restore of emds data failed (err %d)\n", err);
    		return 1;
    	}
    
    	err = emds_prepare();
    	if (err) {
    		printk("Preparation emds failed (err %d)\n", err);
    		return 1;
    	}
    
        LOG_INF("Shared data size = %d %d", sizeof(m_data_records), sizeof(m_data_element));
        return 0;
    }

    Here is my callback ....

    static void app_emds_cb(void)
    {
        NVIC_SystemReset();
    }
    
    

    To trigger the EMDS save-to-flash I call this function:

    uint32_t shared_data_shutdown(void)
    {
        emds_store();
        return 0;
    }

    This triggers the EMDS operation and the emds_store callback triggers the app_emds_cb function which resets the system. Data is successfully recovered for the first 5 times this function is called. 

    The 6th reset (i.e. call to shared_data_shutdown command) 'bricks' the device, meaning that it does not appear that code is running. No RTT logs, resetting the device does not recover this condition, only re-flashing the device does.

    Thanks.

  • Hi, 

    Thanks for the information. It would take time to investigate whether that is a bug. I would be back if we have anything to update. 

    -Amanda H.
  • Hi, 

    Are you testing with NCS v2.1.0? 

    -Amanda H.

  • Hi, 

    The team will need to investigate this in steps. Firstly, could you test this with NCS v2.1.0? This should not take much time and is essential information before investigating further. Also, is it possible to provide the project that triggers this faulty behavior? It would make the debugging process easier for our team.

    If it's necessary, I can set this case private. Then, your project will be only shared with us. 

    -Amanda H.

Reply
  • Hi, 

    The team will need to investigate this in steps. Firstly, could you test this with NCS v2.1.0? This should not take much time and is essential information before investigating further. Also, is it possible to provide the project that triggers this faulty behavior? It would make the debugging process easier for our team.

    If it's necessary, I can set this case private. Then, your project will be only shared with us. 

    -Amanda H.

Children
Related