MCUBoot, FOTA with Zephyr and NCS 2.5.0

Hi.

I'm still developing FOTA functionality with nRF52832 QFAA, NCS 2.5.0 and zephyr in VS Code environment.

Everything is going well with the application development process, but there are problems on bootloader for FOTA.

Here is my design of bootloader.

Left image is flash map and right one is boot-up process for my system.

MCUboot should check slot 1 and check its application version to swap applications in slot 0.

 

So, How can I do this in MCUboot?

Application version is define like this in each applications(slot0, slot1 application)

For examples, in slot0 application : 

#define FIRM_VER_MAJOR 1

#define FIRM_VER_MINOR 0

#define FIRM_vER_PATCH 0

In slot1 application : 

#define FIRM_VER_MAJOR 1

#define FIRM_VER_MINOR 1

#define FIRM_vER_PATCH 1

MCUboot have to compare this value.

 

Summary : 

1) MCUboot should check the existance of application in slot1.

2) MCUboot should compare firmware version of each applications.

3) Swap application between slot 0 and slot1 and erase after copy.

Please help me.

Parents
  • Hi,

    I think the Direct XIP mode would be the best fit for your need. You can find the documentation of this mode  here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/mcuboot/design.html#equal-slots-direct-xip . You can find this: 

    At boot time the bootloader first looks for images in the slots and then inspects the version numbers in the image headers. It selects the newest image (with the highest version number) and then checks its validity (integrity check, signature verification etc.). If the image is invalid MCUboot erases its memory slot and starts to validate the other image. After a successful validation of the selected image the bootloader chain-loads it.

    It's a new feature that just got supported in our NCS SDK in v2.5.0. You can find how to test it here: 
    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/device_guides/working_with_nrf/nrf52/developing.html#build-configuration-additions-for-mcuboot-in-the-direct-xip-mode

    When you do "no revert" the MCUBoot will decide which image should it boot and there is no test or confirm needed. After booting it will erase the image that has lower version number (make sure you build the image with no-rever option and in the app you select the no-revert option ). 


    If you don't want to do DirectXIP and prefer the original way of FOTA I'm not so sure how you can make the process automatic. As far as I can see you will need to do Test - Confirm manually to choose the slot/application you want to run. 

  • Thank you for replay.

    I think there is not enough information about MCUboot and tutorials.

    I cannot understand entire schemas about relationships with mcu boot, zephyr, and ncs.

    How can I modify mcuboot(bootloader)? for example, I want to add printk function in bootloader, but I cannot find any source files(c, cpp) that can be modified in my project and SDK folders.

    How can I understand this eco system?

    Should I build firmware seprately? for example, Should I make projects for each(MCUBoot project, Main Application in Slot 0, Test applications for FOTA in Slot 1) like this?

    1) Bootloader : MCUBoot project(with main.c)

    2) Application with main c

    3) Test application with main c

    And what is the purpose of below codes?

    As I know, these formats are c code.

    Where can I use this code?

    Everything is so confused.

    All I want to do is just swap firmware from slot 1 to slot 0 and I think this is not complex concept or works. But I cannot do it for a week.

    Please help me.

    P.S : Should I do it like the picture below?

  • Hi, 

    It's actually quite simple as we has already integrated a lot of what you are uncertain about into the build system so that MCUBoot is build automatically as the child image. MCUBoot hex file will also be merged automatically. 

    My suggestion is to take a look at this guide:  Add DFU support to your application 

    It was made for older version of NCS and there would be some small change needed when you develop for NCS v2.5.0

    However, the fundamental is the same that you can base on the smp_svr example and then include what inside that example into your application. 

    For example when you config: CONFIG_BOOTLOADER_MCUBOOT=y  it will automatically include MCUBoot as the child image. 

    You can follow the above guide, or you can also follow the FOTA guide here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/device_guides/working_with_nrf/nrf52/developing.html

    In the FOTA guide you will find that you need to add CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y. It's basically the same as what you find in SMP_SVR example: 
    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/kconfig/index.html#CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU

    After you have MCUBoot included, the build system will generate the dfu_application.zip file in build\zephyr folder. You can then transfer this file to the phone and then use the nRF Device Manager app on the phone to do the FOTA update. 

    The FOTA update process will take care of swapping Slot 0 and Slot 1. Please try testing with "Confirm only" option in the nRF Device Manager app. 

  • Thank you for your kindness.

    I tried to follow DFU Guides, but I cannot set the configuation in prj.conf file.

    In the guide, 

    # Enable most core commands.
    CONFIG_MCUMGR_CMD_IMG_MGMT=y
    CONFIG_MCUMGR_CMD_OS_MGMT=y

    But, I cannot apply these config.

    How can I do?

Reply Children
Related