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

proxy_enable()/proxy_start() cause an assert when using alongside flash manager module (nRF Mesh SDK).

Hi, I'm having a bit of an issue with the proxy_enable() & proxy_start() functions when they are used in tandem with the flash manager module.

Some info on my setup:

  • Softdevice S140 v6.1.0
  • nRF52840
  • Mesh SDK v3.1.0
  • SDK v15.2.0

Description of the issue:

So I have been using a method of enabling/disabling the mesh for lower power consumption as outlined here:

https://devzone.nordicsemi.com/f/nordic-q-a/43301/nrf_mesh_disable-function-changed-since-sdk-for-mesh-v3-1-0

The method is as follows (as suggested by Nordic):

//Disabling the mesh:
uint32_t err_code = NRF_SUCCESS;

err_code = proxy_stop();
if(err_code != NRF_SUCCESS)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO,"proxy_stop() ERROR: %d\r\n",err_code);
    APP_ERROR_CHECK(err_code);
}
 
err_code = nrf_mesh_disable();
if(err_code != NRF_SUCCESS)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO,"nrf_mesh_disable() ERROR: %d\r\n",err_code);
    APP_ERROR_CHECK(err_code);
}


//Enabling the mesh
uint32_t err_code = NRF_SUCCESS;

err_code = proxy_enable();
if(err_code != NRF_SUCCESS)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO,"proxy_enable() ERROR: %d\r\n",err_code);
    APP_ERROR_CHECK(err_code);                
}

err_code = proxy_start();
if(err_code != NRF_SUCCESS)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO,"proxy_start() ERROR: %d\r\n",err_code);
    APP_ERROR_CHECK(err_code);                
}

err_code = nrf_mesh_enable();
if(err_code != NRF_SUCCESS)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO,"nrf_mesh_enable() ERROR: %d\r\n",err_code);
    APP_ERROR_CHECK(err_code);
}

Calling proxy_stop(); in this manner seems to be fine - the proxy is stopped and then the mesh is disabled. The device is then in its lowest power state.

When I try and re-enable the mesh one of the functions, either proxy_enable() or proxy_start() (not quite sure which as the call stack isn't clear) triggers an assert "Mesh assert at 0x00032DE8". From the call stack:

It seems there is some interference from the flash manager causing this behavior.

After a bit of digging around the forums, I find that this post mentions that the proxy stores some state info in flash:

https://devzone.nordicsemi.com/f/nordic-q-a/38915/mesh-2-2-0-clear-stack-config-data/150424#150424

(see Hung's post below).

I was wondering then what is the correct way to enable/disable the mesh and start/stop the proxy?

Any help or tips would be greatly appreciated.

  • Have you tried using the addr2line tool to double check that 0x00032DE8 is related to flash operations?

  • Hi Bjorn,

    I have just verified that it is related to flash operations:

    Using MinGW, I enter this into cmd prompt:

    addr2line -e my_filename.elf 0x00032DE8 etc...

    And I get:

    mesh_sdk/mesh/core/include/flash_manager_internal.h:133

    which asserts here (marked):

    static inline const fm_entry_t * get_next_entry(const fm_entry_t * p_entry)
    {
        NRF_MESH_ASSERT(p_entry->header.len_words != 0); // Assert here
        if ((p_entry + p_entry->header.len_words) == (const fm_entry_t *) PAGE_START_ALIGN(p_entry + p_entry->header.len_words) ||
            p_entry->header.handle == HANDLE_PADDING)
        {
            /* For padding entries and entries that fill the current page, the next entry is the first
             * entry on the next page. */
            return get_first_entry((const flash_manager_page_t *) (PAGE_START_ALIGN(p_entry) + PAGE_SIZE));
        }
        else
        {
            return p_entry + p_entry->header.len_words;
        }
    }

    Any ideas?

  • Did you remember to make the suggested change to bearer_handler_timer_irq_handler() too, like Hung mentions here?

    I tested your code by adding these lines into the button_event_handler of the light switch server example from mesh sdk v3.1.0:

            case 1:
                //Disabling the mesh, added by BK
                err_code = proxy_stop();
                if(err_code != NRF_SUCCESS)
                {
                    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO,"proxy_stop() ERROR: %d\r\n",err_code);
                    APP_ERROR_CHECK(err_code);
                }
     
                err_code = nrf_mesh_disable();
                if(err_code != NRF_SUCCESS)
                {
                    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO,"nrf_mesh_disable() ERROR: %d\r\n",err_code);
                    APP_ERROR_CHECK(err_code);
                }
                break;
            case 2:
                //Enabling the mesh, added by BK
                err_code = proxy_enable();
                if(err_code != NRF_SUCCESS)
                {
                    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO,"proxy_enable() ERROR: %d\r\n",err_code);
                    APP_ERROR_CHECK(err_code);                
                }
    
                err_code = proxy_start();
                if(err_code != NRF_SUCCESS)
                {
                    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO,"proxy_start() ERROR: %d\r\n",err_code);
                    APP_ERROR_CHECK(err_code);                
                }
    
                err_code = nrf_mesh_enable();
                if(err_code != NRF_SUCCESS)
                {
                    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO,"nrf_mesh_enable() ERROR: %d\r\n",err_code);
                    APP_ERROR_CHECK(err_code);
                }
                break;

    I then provisioned the example via nRF Mesh & then pressed button 2 on the DK (i.e. case 1) to disable the mesh. I could then not reconnect via nRF Mesh. When I pressed, button 3 (i.e. case 2), I was able to enable the proxy & reconnect to the node via nRF Mesh. Unfortunately I could not reproduce this issue. Therefore, I do not believe there is an issue by enabling & disabling the proxy & mesh in this manner.

  • Hi Bjorn,

    I did make the changes that Hung mentioned. I use enable/disable the mesh using this method via a timer interrupt handler. Could this perhaps be the reason it does not work for me? I have not tested the code via button handler just yet. I will try that out and post results here.

  • Sorry for the delayed response. Are you using the app timer module? Have you set the irq priority to be the same as the mesh? This may be related maybe. Have you tested the code via the button handler?

Related