How to reset the nrf52840 dk board using software in zephyr i am using nrf mesh light sample code

I am using nrf 52840dk board i need to know how to reset the devlopment using software reset when we press the Button 1 in the nrf 52840dk board 

1. Give some software reset function example (eg: if i press the Button 1 it need to call this function, inside this reset function all necessary things for reset  that will make to work like a hardware reset 

2. for reset what are the things need to do in software?

3. give simple example code for software reset  

4. this is the sample reset function i am using 

// reboot function

void factory_reset_work_handler(struct k_work *work)

{

    //print_uart("Factory reset started...\n");

    // Reset Bluetooth Mesh provisioning

    bt_mesh_reset();

    // Delete all stored settings (flash/NVS)

    int ret = settings_delete("");

    if (ret) {

        //print_uart("Failed to delete settings: %d\n", ret);

    } else {

        //print_uart("All settings deleted.\n");

    }

    //print_uart("Rebooting device...\n");

    sys_reboot(SYS_REBOOT_COLD);

}      

i am using this function for reset  in main.c in nrf mesh light sdk in this reset function any code modification need or any other files need to change? 

5. I am facing some issues after reset using the above reset function 

I explain the issue facing in above reset function in below

  consider 5 nrf52840 dk all have same code it will transmit and recive ok first time i provisioned all the devices in the same mesh group i am getting 4 reply in master its ok fine if i reset 2 devices like one master and one slave from mesh and again provision in the same group then i got 1 reply in same mesh group i provision , id i power on and off the 2 device one is master and slave  which is resently reset then all the 4 devices is showing  and if i give s v on command the slave is receving and led is turn on but no reply.  can you say what is the root cause and how power disconnect and connect then this issue is fixed , what is the problem and how to solve it ?

i am using nrf mesh app  for provisioning the 5 devices into mesh

can you give example solution and give solution for all the 5 questions 

Thankyou

Parents
  • Te problem might be that you are doing sys_reboot right after mesh reset and settings delete, not giving any time for any flash operations to complete if any. 
    try to make sure that settings is finished with all the activities and add a delay of 100 ms between that and system reset. Something like below

    static void do_factory_reset(void)
    {
        bt_mesh_reset();
        settings_delete("whatever you want to delete");
    
        settings_save();
    
        /* Small delay to allow flash backend to finish erase/write operations */
        k_sleep(K_MSEC(100));
    
        sys_reboot(SYS_REBOOT_COLD);
    }

  • i changed the reset function with delay but stil the issue come after 2nd reset 
    // reboot function
    void factory_reset_work_handler(struct k_work *work)
    {
        print_uart("Factory reset started...\n");


        // Reset Bluetooth Mesh provisioning
        bt_mesh_reset();
        k_sleep(K_MSEC(2000));
        print_uart("Mesh provisioning reset\r\n");
     
        // Delete all stored settings (flash/NVS)
        int ret = settings_delete("");
        k_sleep(K_MSEC(2000));
        if (ret) {
            print_uart("Failed to delete settings: %d\n", ret);
        } else {
            print_uart("All settings deleted.\n");
        }

        k_sleep(K_MSEC(2000));
        print_uart("Rebooting device...\n");
        //sys_reboot(SYS_REBOOT_COLD);
        sys_reboot(SYS_REBOOT_WARM);
    }

    can you give sample code that reset the nrf mesh ?  

Reply
  • i changed the reset function with delay but stil the issue come after 2nd reset 
    // reboot function
    void factory_reset_work_handler(struct k_work *work)
    {
        print_uart("Factory reset started...\n");


        // Reset Bluetooth Mesh provisioning
        bt_mesh_reset();
        k_sleep(K_MSEC(2000));
        print_uart("Mesh provisioning reset\r\n");
     
        // Delete all stored settings (flash/NVS)
        int ret = settings_delete("");
        k_sleep(K_MSEC(2000));
        if (ret) {
            print_uart("Failed to delete settings: %d\n", ret);
        } else {
            print_uart("All settings deleted.\n");
        }

        k_sleep(K_MSEC(2000));
        print_uart("Rebooting device...\n");
        //sys_reboot(SYS_REBOOT_COLD);
        sys_reboot(SYS_REBOOT_WARM);
    }

    can you give sample code that reset the nrf mesh ?  

Children
  • and if i give s v on command the slave is receving and led is turn on but no reply.  can you say what is the root cause and how power disconnect and connect then this issue is fixed , what is the problem and how to solve it ?

    Since this is your main issue, you need to see which state the slave is. Since all the slave devices are also nRF54840 DK, debugging should not be an issue. Enable logs on those devices and add as much logs as you can to understand the state of the slave device. 

    Here it says that doing. a mesh reset will need you to reprovision the device into the network. I hope you are doing that?

Related