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

How to use flash_manager.c

In mesh2.1.1\examples\light_switch\proxy_server I find this flash_manager.c file.Its purpose is to store/resorre/remove DSM&access data.

My flash function referred to access.c.But I found a problem.

If node is provisioning or provides completion, calling flash_manager_remove() and mesh_stack_device_reset(), it can reinitialize this flash.

If it's new node.,calling flash_manager_remove() and mesh_stack_device_reset().After waiting for the node to restart,I try to read(flash_manager_add()&flash_manager_entry_get()&flash_manager_entry_next_get()),old data can be get.

This is unreasonable.

Parents
  • Hi,

    The call to flash_manager_remove() schedules removal of the flash manager contents, but it will still take some time to remove. Therefore there is an optional callback for this in the manager (remove_complete_cb) that will be called when the operation is finished. If you reset the device before the operation is finished then contents may still be remaining. See also flash_manager_remove() documentation on Infocenter.

    Regards,
    Terje

  • Hi,

    I know remove_complete_cb will be called when the remove operation is finished.But,if it's new node,calling flash_manager_remove() ,cannot be triggered remove_complete_cb.

    You can try this(proxy_server):

    Button 3 is used to calling flash_manager_remove() reset this node.If remove_complete_cb was already calling,it will be blink all LEDs;If not,blink LED1 Indicates that node are currently busy.

    Download proxy_server demo for nRF52832(in advance Erase the device flash).

    Press the button 3 for the firs,LED1 blink,that means not implemented remove_complete_cb.

    Press the button 3 again,all LEDs will blink,now,that's the real erase&reset success.

    If use APP configured node,once push button 3 will be succeeded.

    Why is this?

  • Hi,

    I am afraid I still do not understand what you mean. Have you found a bug in nRF5 SDK for Mesh v2.1.1, that is not present in nRF5 SDK for Mesh v2.2.0? In that case it has been fixed?

    If it is still present in nRF5 SDK for Mesh v2.2.0, what are the steps to reproduce?

    Regards,
    Terje

  • Hi,

    You can compare between 2.1.1&2.2.0 about "main.c"file,"button_event_handler()" function,"case 3:"handle.Also can between 2.1.1&2.2.0 try to press the button 3 again and again,then I think you can know my mean.

  • Hi,

    Yes, I think I begin to understand now. Yes, it looks like this may have been a bug in previous releases. In 2.2.0 it only clears the configuration and resets the device if it has actually already been provisioned. In previous versions it initiates the clear and reset regardless of the state, which means it can happen at any time including during provisioning. It looks like that could go horribly wrong and lead to strange behavior. Is that the issue that you are seeing?

    Regards,
    Terje

  • yes!But I want to know why in version 2.1.1,if device was not provisioned,when press the button 3:

    press the first is fail.

    press again will success(clear and reset).

    In my understanding,In any event,when press button 3,it must be clear and reset(even if it has not already been provisioned).

  • Hi,

    A short debug session reveals that on the first press, in mesh_stack_device_reset() in mesh_stack.c, flash_manager_is_stable() returns false, which means flash operations are ongoing and the device cannot reset yet. Therefore an event handler is added that should take care of resetting the device once flash operations are finished. But, it looks like this event handler is not called.

    Further debugging may reveal why, but as the issue is fixed by the changes in nRF5 SDK for Mesh v2.2.0 I highly recommend using that version instead. If you really want to get to the bottom of this then I am afraid you will have to do the rest of the debugging yourself.

    Regards,
    Terje

Reply
  • Hi,

    A short debug session reveals that on the first press, in mesh_stack_device_reset() in mesh_stack.c, flash_manager_is_stable() returns false, which means flash operations are ongoing and the device cannot reset yet. Therefore an event handler is added that should take care of resetting the device once flash operations are finished. But, it looks like this event handler is not called.

    Further debugging may reveal why, but as the issue is fixed by the changes in nRF5 SDK for Mesh v2.2.0 I highly recommend using that version instead. If you really want to get to the bottom of this then I am afraid you will have to do the rest of the debugging yourself.

    Regards,
    Terje

Children
Related