mcuboot/dfu on nRF5280 reverts back to previous install after power cycle

Setup mcuboot and dfu to upgrade firmware on the nRF52840 of our board. Upgrading to new firmware works as expected and the new firmware is running after the install. If I power cycle the board, device come up in pervious version of firmware. Somehow it's not remembering it needs to boot from the partition of the last install. Not sure what I'm missing.

Parents
  • Hi,

    Try calling this in your application:

    boot_write_img_confirmed();

  • boot_write_img_confirmed() returns 0.

    Below is the code that executes when the upgrade completes. After the sys_reboot(0), it will report the correct version number of what was installed. After a power cycle or another sys_reboot(0), it will revert to the previous firmware and report that version number.

    Something is not saving that it needs to keep booting from the newly written to slot partition but yet the first sys_reboot(0) after the upgrade works as expected. Odd.

    case EVENT_FIRMWARE_DONE:
    {
        int err = dfu_target_done(true);
        if(err != 0) 
        {
            LOG_ERR("FW update failed with error: %d. Device will resume operation.\n", err);        
        }
        else
        {
            LOG_INF("FW update was succesfull. System will now reset and reboot.\n");
            k_sleep(K_SECONDS(2));
    
            // Reset the target
            err = dfu_target_reset();
            if(err != 0) 
            {
                LOG_ERR("FW update target reset error: %d. Device will resume operation and not reboot.\n", err);        
            }
            else
            {
                err = boot_write_img_confirmed();
                if(err != 0)
                {
                    LOG_ERR("Failed to confirm: %d", err);
                }
    
                sys_reboot(0);
            }
        }
    
        break;
    }

  • boot_write_img_confirmed() marks the currently running image as confirmed. I guess you are still running the "old image" in the case EVENT_FIRMWARE_DONE ? Try calling boot_write_img_confirmed() in main(), after you have done your application initialization successfully

  • Moved the boot_write_img_confirmed() to main and that seems to have solved the problem. I can power cycle or reboot and it doesn't revert back to the prior firmware version. 

Reply Children
No Data
Related